Flow123d  JS_before_hm-2137-g84767e588
msh_vtkreader.cc
Go to the documentation of this file.
1 /*!
2  *
3  * Copyright (C) 2015 Technical University of Liberec. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU General Public License version 3 as published by the
7  * Free Software Foundation. (http://www.gnu.org/licenses/gpl-3.0.en.html)
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12  *
13  *
14  * @file msh_vtkreader.cc
15  * @brief
16  * @author dalibor
17  */
18 
19 
20 #include <iostream>
21 #include <vector>
22 #include <pugixml.hpp>
23 #include "boost/lexical_cast.hpp"
24 
25 #include "msh_vtkreader.hh"
26 #include "system/system.hh"
27 #include "system/index_types.hh"
28 #include "mesh/bih_tree.hh"
29 #include "mesh/mesh.h"
30 #include "mesh/accessors.hh"
31 
32 #include "config.h"
33 #include <zlib.h>
34 
35 
36 /*******************************************************************
37  * Helper methods
38  */
39 template<typename T>
40 T read_binary_value(std::istream &data_stream)
41 {
42  T val;
43  data_stream.read(reinterpret_cast<char *>(&val), sizeof(val));
44  return val;
45 }
46 
47 
48 uint64_t read_header_type(DataType data_header_type, std::istream &data_stream)
49 {
50  if (data_header_type == DataType::uint64)
51  return read_binary_value<uint64_t>(data_stream);
52  else if (data_header_type == DataType::uint32)
53  return (uint64_t)read_binary_value<unsigned int>(data_stream);
54  else {
55  ASSERT(false).error("Unsupported header_type!\n"); //should not happen
56  return 0;
57  }
58 }
59 
60 
61 /*******************************************************************
62  * implementation of VtkMeshReader
63  */
64 const double VtkMeshReader::point_tolerance = 1E-10;
65 
66 
68 : BaseMeshReader(file_name),
69  time_step_(0.0)
70 {
71  data_section_name_ = "DataArray";
72  has_compatible_mesh_ = false;
73  can_have_components_ = false;
75 }
76 
77 
78 
79 VtkMeshReader::VtkMeshReader(const FilePath &file_name, std::shared_ptr<ElementDataFieldMap> element_data_values, double time_step)
80 : BaseMeshReader(file_name, element_data_values),
81  time_step_(time_step)
82 {
83  data_section_name_ = "DataArray";
84  has_compatible_mesh_ = false;
85  can_have_components_ = false;
87 }
88 
89 
90 
92 {
93  delete data_stream_;
94 }
95 
96 
97 
98 void VtkMeshReader::read_base_vtk_attributes(pugi::xml_node vtk_node, unsigned int &n_nodes, unsigned int &n_elements)
99 {
100  try {
101  // header type of appended data
102  header_type_ = this->get_data_type( vtk_node.attribute("header_type").as_string() );
103  } catch(ExcWrongType &e) {
104  e << EI_SectionTypeName("base parameter header_type");
105  }
106  // data format
108  data_format_ = DataFormat::ascii;
109  } else {
110  can_have_components_ = true;
112  // Allowable values of header type are only 'UInt64' or 'UInt32'
113  THROW( ExcWrongType() << EI_ErrMessage("Forbidden") << EI_SectionTypeName("base parameter header_type")
114  << EI_VTKFile(tok_.f_name()));
115  }
116  std::string compressor = vtk_node.attribute("compressor").as_string();
117  if (compressor == "vtkZLibDataCompressor")
118  data_format_ = DataFormat::binary_zlib;
119  else
120  data_format_ = DataFormat::binary_uncompressed;
121  }
122  // size of node and element vectors
123  pugi::xml_node piece_node = vtk_node.child("UnstructuredGrid").child("Piece");
124  n_nodes = piece_node.attribute("NumberOfPoints").as_uint();
125  n_elements = piece_node.attribute("NumberOfCells").as_uint();
126 }
127 
128 
129 
131  Tokenizer::Position appended_pos;
132 
133  {
134  // find line by tokenizer
135  tok_.set_position( Tokenizer::Position() );
136  if (! tok_.skip_to("AppendedData"))
137  THROW(ExcMissingTag() << EI_TagType("tag") << EI_TagName("AppendedData") << EI_VTKFile(tok_.f_name()) );
138  else {
139  appended_pos = tok_.get_position();
140  }
141  }
142 
143  // find exact position of appended data (starts with '_')
144  char c;
145  data_stream_->seekg(appended_pos.file_position_);
146  do {
147  data_stream_->get(c);
148  } while (c!='_');
149  appended_pos.file_position_ = data_stream_->tellg();
150  appended_pos.line_counter_++;
151  delete data_stream_; // close stream
152 
153  // reopen stream in binary mode
154  data_stream_ = new std::ifstream( tok_.f_name(), std::ios_base::in | std::ios_base::binary );
155 
156  return appended_pos;
157 }
158 
159 
160 BaseMeshReader::MeshDataHeader VtkMeshReader::create_header(pugi::xml_node node, unsigned int n_entities, Tokenizer::Position pos,
162 {
163  MeshDataHeader header;
164  header.field_name = node.attribute("Name").as_string();
165  header.time = this->time_step_;
166  try {
167  header.type = this->get_data_type( node.attribute("type").as_string() );
168  } catch(ExcWrongType &e) {
169  e << EI_SectionTypeName("DataArray " + header.field_name);
170  }
171  header.discretization = disc;
172  if (disc == OutputTime::DiscreteSpace::NATIVE_DATA) {
173  header.n_components = node.attribute("n_dofs_per_element").as_uint();
174  header.dof_handler_hash = node.attribute("dof_handler_hash").as_uint();
175  } else {
176  header.n_components = node.attribute("NumberOfComponents").as_uint(1);
177  }
178  header.n_entities = n_entities;
179  std::string format = node.attribute("format").as_string();
180  if (format=="appended") {
181  if (data_format_ == DataFormat::ascii)
182  THROW(ExcInvalidFormat() << EI_FieldName(header.field_name) << EI_ExpectedFormat("ascii") << EI_VTKFile(tok_.f_name()) );
183  std::streampos file_pos = pos.file_position_;
184  file_pos += node.attribute("offset").as_uint();
185  header.position = Tokenizer::Position( file_pos, pos.line_counter_, pos.line_position_ );
186  } else if (format=="ascii") {
187  if (data_format_ != DataFormat::ascii)
188  THROW(ExcInvalidFormat() << EI_FieldName(header.field_name) << EI_ExpectedFormat("appended") << EI_VTKFile(tok_.f_name()) );
189 
190  tok_.set_position( Tokenizer::Position() );
191  bool is_point = (header.field_name=="");
192  std::string found_str = (is_point) ? "<Points>" : "Name=\"" + header.field_name + "\"";
193  if (! tok_.skip_to(found_str))
194  THROW(ExcMissingTag() << EI_TagType("DataArray tag") << EI_TagName(header.field_name) << EI_VTKFile(tok_.f_name()) );
195  else {
196  if (is_point) tok_.skip_to("DataArray");
197  header.position = tok_.get_position();
198  }
199  } else {
200  THROW(ExcUnknownFormat() << EI_FieldName(header.field_name) << EI_VTKFile(tok_.f_name()) );
201  }
202 
203  return header;
204 }
205 
206 
208 {
209  pugi::xml_document doc;
210  doc.load_file( tok_.f_name().c_str() );
211  unsigned int n_nodes, n_elements;
212  this->read_base_vtk_attributes( doc.child("VTKFile"), n_nodes, n_elements );
213 
214  // open ifstream for find position
215  data_stream_ = new std::ifstream( tok_.f_name() );
216 
217  // data of appended tag
218  Tokenizer::Position appended_pos;
220  // no AppendedData tag
221  } else {
222  appended_pos = get_appended_position();
223  }
224 
225  pugi::xml_node node = doc.child("VTKFile").child("UnstructuredGrid").child("Piece");
226 
227  header_table_.clear();
228 
229  // create headers of Points and Cells DataArrays
230  auto points_header = create_header( node.child("Points").child("DataArray"), n_nodes, appended_pos,
231  OutputTime::DiscreteSpace::MESH_DEFINITION );
232  points_header.field_name = "Points";
233  header_table_.insert( std::pair<std::string, MeshDataHeader>("Points", points_header) );
234  auto con_header = create_header( node.child("Cells").find_child_by_attribute("DataArray", "Name", "connectivity"),
235  n_elements, appended_pos, OutputTime::DiscreteSpace::MESH_DEFINITION );
236  header_table_.insert( std::pair<std::string, MeshDataHeader>("connectivity", con_header) );
237  auto offsets_header = create_header( node.child("Cells").find_child_by_attribute("DataArray", "Name", "offsets"),
238  n_elements, appended_pos, OutputTime::DiscreteSpace::MESH_DEFINITION );
239  header_table_.insert( std::pair<std::string, MeshDataHeader>("offsets", offsets_header) );
240  auto types_header = create_header( node.child("Cells").find_child_by_attribute("DataArray", "Name", "types"), n_elements,
241  appended_pos, OutputTime::DiscreteSpace::MESH_DEFINITION );
242  header_table_.insert( std::pair<std::string, MeshDataHeader>("types", types_header) );
243 
244  pugi::xml_node point_node = node.child("PointData");
245  for (pugi::xml_node subnode = point_node.child("DataArray"); subnode; subnode = subnode.next_sibling("DataArray")) {
246  auto header = create_header( subnode, n_nodes, appended_pos, OutputTime::DiscreteSpace::NODE_DATA );
247  header_table_.insert( std::pair<std::string, MeshDataHeader>(header.field_name, header) );
248  }
249 
250  pugi::xml_node cell_node = node.child("CellData");
251  for (pugi::xml_node subnode = cell_node.child("DataArray"); subnode; subnode = subnode.next_sibling("DataArray")) {
252  auto header = create_header( subnode, n_elements, appended_pos, OutputTime::DiscreteSpace::ELEM_DATA );
253  header_table_.insert( std::pair<std::string, MeshDataHeader>(header.field_name, header) );
254  }
255 
256  pugi::xml_node native_node = node.child("Flow123dData");
257  for (pugi::xml_node subnode = native_node.child("DataArray"); subnode; subnode = subnode.next_sibling("DataArray")) {
258  auto header = create_header( subnode, n_elements, appended_pos, OutputTime::DiscreteSpace::NATIVE_DATA );
259  header_table_.insert( std::pair<std::string, MeshDataHeader>(header.field_name, header) );
260  }
261 }
262 
263 
265 {
266  unsigned int count = header_table_.count(header_query.field_name);
267 
268  if (count == 0) {
269  // no data found
270  THROW( ExcFieldNameNotFound() << EI_FieldName(header_query.field_name) << EI_MeshFile(tok_.f_name()));
271  } else if (count == 1) {
272  HeaderTable::iterator table_it = header_table_.find(header_query.field_name);
273 
274  // check discretization
275  if (header_query.discretization != table_it->second.discretization) {
276  if (header_query.discretization != OutputTime::DiscreteSpace::UNDEFINED) {
277  WarningOut().fmt(
278  "Invalid value of 'input_discretization' for field '{}', time: {}.\nCorrect discretization type will be used.\n",
279  header_query.field_name, header_query.time);
280  }
281  header_query.discretization = table_it->second.discretization;
282  }
283 
284  if (header_query.discretization == OutputTime::DiscreteSpace::NATIVE_DATA)
285  if (header_query.dof_handler_hash != table_it->second.dof_handler_hash) {
286  THROW(ExcInvalidDofHandler() << EI_FieldName(header_query.field_name) << EI_VTKFile(tok_.f_name()) );
287  }
288  actual_header_ = table_it->second;
289  } else {
290  /*HeaderTable::iterator table_it;
291  for (table_it=header_table_.equal_range(header_query.field_name).first; table_it!=header_table_.equal_range(header_query.field_name).second; ++table_it) {
292  if (header_query.discretization != table_it->second.discretization) {
293  header_query.dof_handler_hash = table_it->second.dof_handler_hash;
294  actual_header_ = table_it->second;
295  }
296  }*/
297  THROW( ExcMissingFieldDiscretization() << EI_FieldName(header_query.field_name) << EI_Time(header_query.time) << EI_MeshFile(tok_.f_name()));
298  }
299 
300  return actual_header_;
301 }
302 
303 
304 
305 DataType VtkMeshReader::get_data_type(std::string type_str) {
306  // names of types in DataArray section
307  static const std::map<std::string, DataType> types = {
308  {"Int8", DataType::int8},
309  {"UInt8", DataType::uint8},
310  {"Int16", DataType::int16},
311  {"UInt16", DataType::uint16},
312  {"Int32", DataType::int32},
313  {"UInt32", DataType::uint32},
314  {"Int64", DataType::int64},
315  {"UInt64", DataType::uint64},
316  {"Float32", DataType::float32},
317  {"Float64", DataType::float64},
318  {"", DataType::undefined}
319  };
320 
322  if (it != types.end()) {
323  return it->second;
324  } else {
325  THROW( ExcWrongType() << EI_ErrMessage("Unknown") << EI_VTKFile(tok_.f_name()));
326  return DataType::uint32;
327  }
328 
329 }
330 
331 
332 
334 {
335  static const std::vector<unsigned int> sizes = { 1, 1, 2, 2, 4, 4, 8, 8, 4, 8, 0 };
336 
337  return sizes[data_type];
338 }
339 
340 
341 
342 void VtkMeshReader::read_element_data(ElementDataCacheBase &data_cache, MeshDataHeader actual_header, unsigned int n_components,
343  bool boundary_domain) {
344 
345  ASSERT(!boundary_domain).error("Reading VTK data of boundary elements is not supported yet!\n");
346 
347  switch (data_format_) {
348  case DataFormat::ascii: {
349  parse_ascii_data( data_cache, n_components, actual_header.n_entities, actual_header.position );
350  break;
351  }
352  case DataFormat::binary_uncompressed: {
353  ASSERT_PTR(data_stream_).error();
354  parse_binary_data( data_cache, n_components, actual_header.n_entities, actual_header.position);
355  break;
356  }
357  case DataFormat::binary_zlib: {
358  ASSERT_PTR(data_stream_).error();
359  parse_compressed_data( data_cache, n_components, actual_header.n_entities, actual_header.position);
360  break;
361  }
362  default: {
363  ASSERT(false).error(); // should not happen
364  break;
365  }
366  }
367 
368  LogOut().fmt("time: {}; {} entities of field {} read.\n",
369  actual_header.time, n_read_, actual_header.field_name);
370 }
371 
372 
373 void VtkMeshReader::parse_ascii_data(ElementDataCacheBase &data_cache, unsigned int n_components, unsigned int n_entities,
374  Tokenizer::Position pos)
375 {
376  n_read_ = 0;
377 
378  tok_.set_position( pos );
379  try {
380  tok_.next_line();
381  for (unsigned int i_row = 0; i_row < n_entities; ++i_row) {
382  data_cache.read_ascii_data(tok_, n_components, i_row);
383  n_read_++;
384  }
385  } catch (boost::bad_lexical_cast &) {
386  THROW(ExcWrongFormat() << EI_Type("DataArray tag") << EI_TokenizerMsg(tok_.position_msg())
387  << EI_MeshFile(tok_.f_name()) );
388  }
389 }
390 
391 
392 void VtkMeshReader::parse_binary_data(ElementDataCacheBase &data_cache, unsigned int n_components, unsigned int n_entities,
393  Tokenizer::Position pos)
394 {
395  n_read_ = 0;
396 
397  data_stream_->seekg(pos.file_position_);
399 
400  for (unsigned int i_row = 0; i_row < n_entities; ++i_row) {
401  data_cache.read_binary_data(*data_stream_, n_components, i_row);
402  n_read_++;
403  }
404 }
405 
406 
407 void VtkMeshReader::parse_compressed_data(ElementDataCacheBase &data_cache, unsigned int n_components, unsigned int n_entities,
408  Tokenizer::Position pos)
409 {
410  data_stream_->seekg(pos.file_position_);
411  uint64_t n_blocks = read_header_type(header_type_, *data_stream_);
412  uint64_t u_size = read_header_type(header_type_, *data_stream_);
413  uint64_t p_size = read_header_type(header_type_, *data_stream_);
414 
415  std::vector<uint64_t> block_sizes;
416  block_sizes.reserve(n_blocks);
417  for (uint64_t i = 0; i < n_blocks; ++i) {
418  block_sizes.push_back( read_header_type(header_type_, *data_stream_) );
419  }
420 
421  stringstream decompressed_data;
422  uint64_t decompressed_data_size = 0;
423  for (uint64_t i = 0; i < n_blocks; ++i) {
424  uint64_t decompressed_block_size = (i==n_blocks-1 && p_size>0) ? p_size : u_size;
425  uint64_t compressed_block_size = block_sizes[i];
426 
427  std::vector<char> data_block(compressed_block_size);
428  data_stream_->read(&data_block[0], compressed_block_size);
429 
430  std::vector<char> buffer(decompressed_block_size);
431 
432  // set zlib object
433  z_stream strm;
434  strm.zalloc = 0;
435  strm.zfree = 0;
436  strm.next_in = (Bytef *)(&data_block[0]);
437  strm.avail_in = compressed_block_size;
438  strm.next_out = (Bytef *)(&buffer[0]);
439  strm.avail_out = decompressed_block_size;
440 
441  // decompression of data
442  inflateInit(&strm);
443  inflate(&strm, Z_NO_FLUSH);
444  inflateEnd(&strm);
445 
446  // store decompressed data to stream
447  decompressed_data << std::string(buffer.begin(), buffer.end());
448  decompressed_data_size += decompressed_block_size;
449  }
450 
451  n_read_ = 0;
452 
453  for (unsigned int i_row = 0; i_row < n_entities; ++i_row) {
454  data_cache.read_binary_data(decompressed_data, n_components, i_row);
455  n_read_++;
456  }
457 }
458 
459 
461  // will be implemented later
462  // ASSERT(0).error("Not implemented!");
463 }
464 
465 
468 
469  ElementDataFieldMap::iterator it=element_data_values_->find("Points");
470  ASSERT(it != element_data_values_->end()).error("Missing cache of Points section. Did you call create_node_element_caches()?\n");
471 
472  // create nodes of mesh
473  std::vector<double> &vect = *( dynamic_cast<ElementDataCache<double> &>(*(it->second)).get_component_data(0).get() );
474  unsigned int n_nodes = vect.size()/3;
475  mesh->init_node_vector( n_nodes );
476  arma::vec3 point;
477  for (unsigned int i=0, ivec=0; i<n_nodes; ++i) {
478  point(0)=vect[ivec]; ++ivec;
479  point(1)=vect[ivec]; ++ivec;
480  point(2)=vect[ivec]; ++ivec;
481  mesh->add_node(i, point);
482  }
483 
484  bulk_elements_id_.clear();
485 }
486 
487 
489  // read offset section in VTK file
490  ElementDataFieldMap::iterator offset_it=element_data_values_->find("offsets");
491  ASSERT(offset_it != element_data_values_->end()).error("Missing cache of offsets section. Did you call create_node_element_caches()?\n");
492  std::vector<unsigned int> &offsets_vec = *( dynamic_cast<ElementDataCache<unsigned int> &>(*(offset_it->second)).get_component_data(0).get() );
493 
494  // read connectivity data section
495  ElementDataFieldMap::iterator conn_it=element_data_values_->find("connectivity");
496  ASSERT(conn_it != element_data_values_->end()).error("Missing cache of offsets section. Did you call create_node_element_caches()?\n");
497  std::vector<unsigned int> &connectivity_vec = *( dynamic_cast<ElementDataCache<unsigned int> &>(*(conn_it->second)).get_component_data(0).get() );
498 
499  // iterate trough connectivity data, create bulk elements
500  // fill bulk_elements_id_ vector
501  bulk_elements_id_.clear();
502  bulk_elements_id_.resize(offsets_vec.size());
503  mesh->init_element_vector(offsets_vec.size());
504  unsigned int i_con = 0, last_offset=0, dim;
505  vector<unsigned int> node_list;
506  for (unsigned int i=0; i<offsets_vec.size(); ++i) { // iterate trough offset - one value for every element
507  dim = offsets_vec[i] - last_offset - 1; // dimension of vtk element
508  for ( ; i_con<offsets_vec[i]; ++i_con ) { // iterate trough all nodes of any element
509  node_list.push_back( connectivity_vec[i_con] );
510  }
511  mesh->add_element(i, dim, dim, 0, node_list); // TODO need to set region_id (3rd parameter, now is created from dim)
512  bulk_elements_id_[i] = (LongIdx)i;
513  node_list.clear();
514  last_offset = offsets_vec[i];
515  }
516 }
517 
518 
520  ElementDataFieldMap::iterator it=element_data_values_->find("Points");
521  if ( it != element_data_values_->end() ) {
522  // prevents repeat call of read_nodes
523  return;
524  }
525 
526  ASSERT( !has_compatible_mesh_ ).error();
527 
528  has_compatible_mesh_ = true;
529 
530  // read Points data section
531  HeaderQuery header_params("Points", 0.0, OutputTime::DiscreteSpace::MESH_DEFINITION);
532  auto point_header = this->find_header(header_params);
533  bulk_elements_id_.resize(point_header.n_entities);
534  for (unsigned int i=0; i<bulk_elements_id_.size(); ++i) bulk_elements_id_[i]=i;
535  this->get_element_data<double>(point_header.n_entities, point_header.n_components, false, 0 );
536 
537  // read offset data section
538  HeaderQuery offsets_params("offsets", 0.0, OutputTime::DiscreteSpace::MESH_DEFINITION);
539  auto offset_header = this->find_header(offsets_params);
540  for (unsigned int i=bulk_elements_id_.size(); i<offset_header.n_entities; ++i) bulk_elements_id_.push_back(i);
541  std::vector<unsigned int> &offsets_vec = *( this->get_element_data<unsigned int>(offset_header.n_entities, offset_header.n_components, false, 0 ) );
542 
543  // read connectivity data section
544  HeaderQuery con_params("connectivity", 0.0, OutputTime::DiscreteSpace::MESH_DEFINITION);
545  auto & con_header = this->find_header(con_params);
546  con_header.n_entities = offsets_vec[offsets_vec.size()-1];
547  for (unsigned int i=bulk_elements_id_.size(); i<con_header.n_entities; ++i) bulk_elements_id_.push_back(i);
548  this->get_element_data<unsigned int>(con_header.n_entities, con_header.n_components, false, 0 );
549 
550  has_compatible_mesh_ = false;
551  bulk_elements_id_.clear();
552 }
553 
554 
555 
556 // explicit instantiation of template methods
557 template unsigned int read_binary_value<unsigned int>(std::istream &data_stream);
558 template uint64_t read_binary_value<uint64_t>(std::istream &data_stream);
format
manipulators::Array< T, Delim > format(T const &deduce, Delim delim=", ")
Definition: logger.hh:325
VtkMeshReader::header_table_
HeaderTable header_table_
Table with data of DataArray headers.
Definition: msh_vtkreader.hh:174
BaseMeshReader::actual_header_
MeshDataHeader actual_header_
Header of actual loaded data.
Definition: msh_basereader.hh:257
BaseMeshReader::tok_
Tokenizer tok_
Tokenizer used for reading ASCII file format.
Definition: msh_basereader.hh:250
VtkMeshReader::create_node_element_caches
void create_node_element_caches()
Definition: msh_vtkreader.cc:519
VtkMeshReader::make_header_table
void make_header_table() override
Reads table of DataArray headers through pugixml interface.
Definition: msh_vtkreader.cc:207
VtkMeshReader::~VtkMeshReader
virtual ~VtkMeshReader()
Destructor.
Definition: msh_vtkreader.cc:91
bih_tree.hh
uint8
@ uint8
Definition: msh_basereader.hh:46
ElementDataCache
Definition: element_data_cache.hh:44
ElementDataCache::get_component_data
ComponentDataPtr get_component_data(unsigned int component_idx)
Return vector of element data for get component.
Definition: element_data_cache.cc:71
ASSERT
#define ASSERT(expr)
Allow use shorter versions of macro names if these names is not used with external library.
Definition: asserts.hh:347
undefined
@ undefined
Definition: msh_basereader.hh:46
uint64
@ uint64
Definition: msh_basereader.hh:46
FilePath
Dedicated class for storing path to input and output files.
Definition: file_path.hh:54
THROW
#define THROW(whole_exception_expr)
Wrapper for throw. Saves the throwing point.
Definition: exceptions.hh:53
BaseMeshReader::MeshDataHeader::type
DataType type
Type of data (used only for VTK reader)
Definition: msh_basereader.hh:137
std::vector< unsigned int >
system.hh
VtkMeshReader::get_appended_position
Tokenizer::Position get_appended_position()
Get position of AppendedData tag in VTK file.
Definition: msh_vtkreader.cc:130
BaseMeshReader::HeaderQuery::dof_handler_hash
std::size_t dof_handler_hash
Hash of DOF handler object.
Definition: msh_basereader.hh:140
arma::vec3
Definition: doxy_dummy_defs.hh:17
BaseMeshReader::MeshDataHeader::n_components
unsigned int n_components
Number of values on one row.
Definition: msh_basereader.hh:129
VtkMeshReader::create_header
MeshDataHeader create_header(pugi::xml_node node, unsigned int n_entities, Tokenizer::Position pos, OutputTime::DiscreteSpace disc)
Helper method that create DataArray header of given xml node (used from make_header_table)
Definition: msh_vtkreader.cc:160
read_binary_value< uint64_t >
template uint64_t read_binary_value< uint64_t >(std::istream &data_stream)
VtkMeshReader::parse_binary_data
void parse_binary_data(ElementDataCacheBase &data_cache, unsigned int n_components, unsigned int n_entities, Tokenizer::Position pos)
Parse binary data to data cache.
Definition: msh_vtkreader.cc:392
index_types.hh
BaseMeshReader::element_data_values_
std::shared_ptr< ElementDataFieldMap > element_data_values_
Cache with last read element data.
Definition: msh_basereader.hh:247
int8
@ int8
Definition: msh_basereader.hh:46
BaseMeshReader::MeshDataHeader::discretization
OutputTime::DiscreteSpace discretization
Flag marks input discretization of data of VTK file.
Definition: msh_basereader.hh:139
BaseMeshReader::HeaderQuery::field_name
std::string field_name
Name of field.
Definition: msh_basereader.hh:135
BaseMeshReader
Definition: msh_basereader.hh:58
accessors.hh
LogOut
#define LogOut()
Macro defining 'log' record of log.
Definition: logger.hh:281
int32
@ int32
Definition: msh_basereader.hh:46
read_binary_value< unsigned int >
template unsigned int read_binary_value< unsigned int >(std::istream &data_stream)
BaseMeshReader::MeshDataHeader::field_name
std::string field_name
Name of field.
Definition: msh_basereader.hh:121
uint16
@ uint16
Definition: msh_basereader.hh:46
VtkMeshReader::parse_compressed_data
void parse_compressed_data(ElementDataCacheBase &data_cache, unsigned int n_components, unsigned int n_entities, Tokenizer::Position pos)
Uncompress and parse binary compressed data to data cache.
Definition: msh_vtkreader.cc:407
BaseMeshReader::can_have_components_
bool can_have_components_
Definition: msh_basereader.hh:264
int16
@ int16
Definition: msh_basereader.hh:46
ElementDataCacheBase
Definition: element_data_cache_base.hh:33
VtkMeshReader::type_value_size
unsigned int type_value_size(DataType data_type)
Return size of value of data_type.
Definition: msh_vtkreader.cc:333
mesh.h
VtkMeshReader::find_header
MeshDataHeader & find_header(HeaderQuery &header_query) override
Definition: msh_vtkreader.cc:264
std::map
Definition: doxy_dummy_defs.hh:11
Mesh::add_element
void add_element(unsigned int elm_id, unsigned int dim, unsigned int region_id, unsigned int partition_id, std::vector< unsigned int > node_ids)
Add new element of given id to mesh.
Definition: mesh.cc:1088
BaseMeshReader::MeshDataHeader::dof_handler_hash
std::size_t dof_handler_hash
Hash of DOF handler object (only for native data of VTK file)
Definition: msh_basereader.hh:141
VtkMeshReader::read_element_data
void read_element_data(ElementDataCacheBase &data_cache, MeshDataHeader actual_header, unsigned int n_components, bool boundary_domain) override
Definition: msh_vtkreader.cc:342
Input::Type
Definition: balance.hh:41
VtkMeshReader::read_nodes
void read_nodes(Mesh *mesh)
Definition: msh_vtkreader.cc:466
VtkMeshReader::data_format_
DataFormat data_format_
variants of data format (ascii, appended, compressed appended)
Definition: msh_vtkreader.hh:171
BaseMeshReader::MeshDataHeader
Definition: msh_basereader.hh:100
MeshBase::init_node_vector
void init_node_vector(unsigned int size)
Initialize node_vec_, set size.
Definition: mesh.cc:1146
int64
@ int64
Definition: msh_basereader.hh:46
VtkMeshReader::point_tolerance
static const double point_tolerance
Tolerance during comparison point data with GMSH nodes.
Definition: msh_vtkreader.hh:165
uint32
@ uint32
Definition: msh_basereader.hh:46
LongIdx
int LongIdx
Define type that represents indices of large arrays (elements, nodes, dofs etc.)
Definition: index_types.hh:24
VtkMeshReader::parse_ascii_data
void parse_ascii_data(ElementDataCacheBase &data_cache, unsigned int n_components, unsigned int n_entities, Tokenizer::Position pos)
Parse ascii data to data cache.
Definition: msh_vtkreader.cc:373
ElementDataCacheBase::read_ascii_data
virtual void read_ascii_data(Tokenizer &tok, unsigned int n_components, unsigned int i_row)=0
Mesh
Definition: mesh.h:355
VtkMeshReader::VtkMeshReader
VtkMeshReader(const FilePath &file_name)
Definition: msh_vtkreader.cc:67
MeshBase::init_element_vector
void init_element_vector(unsigned int size)
Initialize element_vec_, set size and reset counters of boundary and bulk elements.
Definition: mesh.cc:1136
VtkMeshReader::read_base_vtk_attributes
void read_base_vtk_attributes(pugi::xml_node vtk_node, unsigned int &n_nodes, unsigned int &n_elements)
Set base attributes of VTK and get count of nodes and elements.
Definition: msh_vtkreader.cc:98
BaseMeshReader::HeaderQuery::discretization
OutputTime::DiscreteSpace discretization
Flag determinate type of discrete of Field (typically is used for native data of VTK)
Definition: msh_basereader.hh:139
WarningOut
#define WarningOut()
Macro defining 'warning' record of log.
Definition: logger.hh:278
BaseMeshReader::MeshDataHeader::position
Tokenizer::Position position
Position of data in mesh file.
Definition: msh_basereader.hh:135
read_header_type
uint64_t read_header_type(DataType data_header_type, std::istream &data_stream)
Definition: msh_vtkreader.cc:48
ElementDataCacheBase::read_binary_data
virtual void read_binary_data(std::istream &data_stream, unsigned int n_components, unsigned int i_row)=0
msh_vtkreader.hh
float64
@ float64
Definition: msh_basereader.hh:46
Mesh::add_node
void add_node(unsigned int node_id, arma::vec3 coords)
Add new node of given id and coordinates to mesh.
Definition: mesh.cc:1080
OutputTime::DiscreteSpace
DiscreteSpace
Definition: output_time.hh:108
read_binary_value
T read_binary_value(std::istream &data_stream)
Definition: msh_vtkreader.cc:40
BaseMeshReader::MeshDataHeader::n_entities
unsigned int n_entities
Number of rows.
Definition: msh_basereader.hh:131
BaseMeshReader::data_section_name_
std::string data_section_name_
Store name of field data section specify for type of mesh file.
Definition: msh_basereader.hh:244
BaseMeshReader::MeshDataHeader::time
double time
Time of field data (used only for GMSH reader)
Definition: msh_basereader.hh:125
ASSERT_PTR
#define ASSERT_PTR(ptr)
Definition of assert macro checking non-null pointer (PTR)
Definition: asserts.hh:336
BaseMeshReader::HeaderQuery::time
double time
Time of field data (used only for GMSH and PVD reader)
Definition: msh_basereader.hh:138
VtkMeshReader::time_step_
double time_step_
time of VTK file (getting only during initialization from PVD reader)
Definition: msh_vtkreader.hh:183
VtkMeshReader::header_type_
DataType header_type_
header type of VTK file (only for appended data)
Definition: msh_vtkreader.hh:168
BaseMeshReader::has_compatible_mesh_
bool has_compatible_mesh_
Definition: msh_basereader.hh:241
VtkMeshReader::get_data_type
DataType get_data_type(std::string type_str)
Get DataType by value of string.
Definition: msh_vtkreader.cc:305
float32
@ float32
Definition: msh_basereader.hh:46
BaseMeshReader::HeaderQuery
Definition: msh_basereader.hh:132
VtkMeshReader::read_physical_names
void read_physical_names(Mesh *mesh) override
Definition: msh_vtkreader.cc:460
VtkMeshReader::data_stream_
std::istream * data_stream_
input stream allow read appended data, used only if this tag exists
Definition: msh_vtkreader.hh:177
VtkMeshReader::n_read_
unsigned int n_read_
store count of read entities
Definition: msh_vtkreader.hh:180
BaseMeshReader::bulk_elements_id_
vector< LongIdx > bulk_elements_id_
Definition: msh_basereader.hh:254
DataType
DataType
Types of VTK data (value 'undefined' for empty value)
Definition: msh_basereader.hh:45
VtkMeshReader::read_elements
void read_elements(Mesh *mesh)
Definition: msh_vtkreader.cc:488