Flow123d  master-f44eb46
Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Static Protected Attributes | Friends | List of all members
VtkMeshReader Class Reference

#include <msh_vtkreader.hh>

Inheritance diagram for VtkMeshReader:
Inheritance graph
[legend]
Collaboration diagram for VtkMeshReader:
Collaboration graph
[legend]

Public Types

enum  DataSections { points , cells , cell_data }
 Possible data sections in UnstructuredGrid - Piece node. More...
 
enum  DataFormat { ascii , binary_uncompressed , binary_zlib }
 Type of data formats - ascii, binary or compressed with zLib. More...
 

Public Member Functions

 TYPEDEF_ERR_INFO (EI_VTKFile, std::string)
 
 TYPEDEF_ERR_INFO (EI_ExpectedFormat, std::string)
 
 TYPEDEF_ERR_INFO (EI_ErrMessage, std::string)
 
 TYPEDEF_ERR_INFO (EI_SectionTypeName, std::string)
 
 TYPEDEF_ERR_INFO (EI_TagType, std::string)
 
 TYPEDEF_ERR_INFO (EI_TagName, std::string)
 
 DECLARE_EXCEPTION (ExcInvalidFormat,<< "Invalid format of DataArray "<< EI_FieldName::val<< ", expected "<< EI_ExpectedFormat::val<< "\n"<< "in the input file: "<< EI_VTKFile::qval)
 
 DECLARE_EXCEPTION (ExcUnknownFormat,<< "Unsupported or missing format of DataArray "<< EI_FieldName::val<< "\n"<< "in the input file: "<< EI_VTKFile::qval)
 
 DECLARE_EXCEPTION (ExcWrongType,<< EI_ErrMessage::val<< " data type of "<< EI_SectionTypeName::val<< "\n"<< "in the input file: "<< EI_VTKFile::qval)
 
 DECLARE_EXCEPTION (ExcIncompatibleMesh,<< "Incompatible meshes, "<< EI_ErrMessage::val<< "\n"<< "for VTK input file: "<< EI_VTKFile::qval)
 
 DECLARE_EXCEPTION (ExcMissingTag,<< "Missing "<< EI_TagType::val<< " "<< EI_TagName::val<< "\n"<< " in the input file: "<< EI_VTKFile::qval)
 
 DECLARE_EXCEPTION (ExcInvalidDofHandler,<< "Invalid DOF handler hash for field: "<< EI_FieldName::qval<< " in the input file: "<< EI_VTKFile::qval<< ".\n")
 
 VtkMeshReader (const FilePath &file_name)
 
virtual ~VtkMeshReader ()
 Destructor. More...
 
void read_physical_names (Mesh *mesh) override
 
MeshDataHeaderfind_header (HeaderQuery &header_query) override
 
- Public Member Functions inherited from BaseMeshReader
 TYPEDEF_ERR_INFO (EI_FieldName, std::string)
 
 TYPEDEF_ERR_INFO (EI_Time, double)
 
 TYPEDEF_ERR_INFO (EI_MeshFile, std::string)
 
 TYPEDEF_ERR_INFO (EI_Type, std::string)
 
 TYPEDEF_ERR_INFO (EI_TokenizerMsg, std::string)
 
 TYPEDEF_ERR_INFO (EI_FileExtension, std::string)
 
 DECLARE_INPUT_EXCEPTION (ExcFieldNameNotFound,<< "No data for field: "<< EI_FieldName::qval<< " and time: "<< EI_Time::val<< " in the input file: "<< EI_MeshFile::qval)
 
 DECLARE_INPUT_EXCEPTION (ExcMissingFieldDiscretization,<< "Missing data type specification for field: "<< EI_FieldName::qval<< " and time: "<< EI_Time::val<< " in the input file: "<< EI_MeshFile::qval<< "\nPlease, add value of key 'input_discretization'.")
 
 DECLARE_EXCEPTION (ExcWrongFormat,<< "Wrong format of "<< EI_Type::val<< ", "<< EI_TokenizerMsg::val<< "\n"<< "in the input file: "<< EI_MeshFile::qval)
 
 DECLARE_EXCEPTION (ExcWrongExtension,<< "Unsupported extension "<< EI_FileExtension::qval<< " of the input file: "<< EI_MeshFile::qval)
 
 DECLARE_EXCEPTION (ExcWrongComponentsCount,<< "Wrong number of components of field "<< EI_FieldName::qval<< " at time "<< EI_Time::val<< " in the input file: "<< EI_MeshFile::qval)
 
 BaseMeshReader (const FilePath &file_name)
 Constructor. More...
 
void read_raw_mesh (Mesh *mesh)
 
template<typename T >
ElementDataCache< T >::CacheData get_element_data (MeshDataHeader header, unsigned int expected_n_entities, unsigned int expected_n_components, unsigned int boundary_begin)
 
void set_element_ids (const Mesh &mesh)
 
std::vector< int > const & get_element_ids (bool boundary_domain)
 

Protected Types

typedef std::multimap< std::string, MeshDataHeaderHeaderTable
 
- Protected Types inherited from BaseMeshReader
typedef std::shared_ptr< ElementDataCacheBaseElementDataPtr
 
typedef std::map< string, ElementDataPtrElementDataFieldMap
 

Protected Member Functions

 VtkMeshReader (const FilePath &file_name, std::shared_ptr< ElementDataFieldMap > element_data_values, double time_step)
 
void read_nodes (Mesh *mesh)
 
void read_elements (Mesh *mesh)
 
void create_node_element_caches ()
 
void make_header_table () override
 Reads table of DataArray headers through pugixml interface. More...
 
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) More...
 
DataType get_data_type (std::string type_str)
 Get DataType by value of string. More...
 
unsigned int type_value_size (DataType data_type)
 Return size of value of data_type. More...
 
void parse_ascii_data (ElementDataCacheBase &data_cache, unsigned int n_components, unsigned int n_entities, Tokenizer::Position pos)
 Parse ascii data to data cache. More...
 
void parse_binary_data (ElementDataCacheBase &data_cache, unsigned int n_components, unsigned int n_entities, Tokenizer::Position pos)
 Parse binary data to data cache. More...
 
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. More...
 
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. More...
 
Tokenizer::Position get_appended_position ()
 Get position of AppendedData tag in VTK file. More...
 
void read_element_data (ElementDataCacheBase &data_cache, MeshDataHeader header) override
 
- Protected Member Functions inherited from BaseMeshReader
 BaseMeshReader (const FilePath &file_name, std::shared_ptr< ElementDataFieldMap > element_data_values)
 Constructor. More...
 

Protected Attributes

DataType header_type_
 header type of VTK file (only for appended data) More...
 
DataFormat data_format_
 variants of data format (ascii, appended, compressed appended) More...
 
HeaderTable header_table_
 Table with data of DataArray headers. More...
 
std::istream * data_stream_
 input stream allow read appended data, used only if this tag exists More...
 
unsigned int n_read_
 store count of read entities More...
 
double time_step_
 time of VTK file (getting only during initialization from PVD reader) More...
 
- Protected Attributes inherited from BaseMeshReader
bool has_compatible_mesh_
 
std::string data_section_name_
 Store name of field data section specify for type of mesh file. More...
 
std::shared_ptr< ElementDataFieldMapelement_data_values_
 Cache with last read element data. More...
 
Tokenizer tok_
 Tokenizer used for reading ASCII file format. More...
 
vector< LongIdxbulk_elements_id_
 
vector< LongIdxboundary_elements_id_
 

Static Protected Attributes

static const double point_tolerance = 1E-10
 Tolerance during comparison point data with GMSH nodes. More...
 

Friends

class PvdMeshReader
 

Additional Inherited Members

- Static Public Member Functions inherited from BaseMeshReader
static std::shared_ptr< BaseMeshReaderreader_factory (const FilePath &file_name)
 
static Meshmesh_factory (const Input::Record &input_mesh_rec)
 

Detailed Description

Definition at line 40 of file msh_vtkreader.hh.

Member Typedef Documentation

◆ HeaderTable

typedef std::multimap< std::string, MeshDataHeader > VtkMeshReader::HeaderTable
protected

Map of DataArray sections in VTK file.

For each field_name contains MeshDataHeader.

Definition at line 102 of file msh_vtkreader.hh.

Member Enumeration Documentation

◆ DataFormat

Type of data formats - ascii, binary or compressed with zLib.

Enumerator
ascii 
binary_uncompressed 
binary_zlib 

Definition at line 70 of file msh_vtkreader.hh.

◆ DataSections

Possible data sections in UnstructuredGrid - Piece node.

Enumerator
points 
cells 
cell_data 

Definition at line 65 of file msh_vtkreader.hh.

Constructor & Destructor Documentation

◆ VtkMeshReader() [1/2]

VtkMeshReader::VtkMeshReader ( const FilePath file_name)

Construct the VTK format reader from given FilePath. This opens the file for reading.

Definition at line 67 of file msh_vtkreader.cc.

◆ ~VtkMeshReader()

VtkMeshReader::~VtkMeshReader ( )
virtual

Destructor.

Definition at line 89 of file msh_vtkreader.cc.

◆ VtkMeshReader() [2/2]

VtkMeshReader::VtkMeshReader ( const FilePath file_name,
std::shared_ptr< ElementDataFieldMap element_data_values,
double  time_step 
)
protected

Special constructor of VTK files defined in PVD file. Constructor is called from PVD mesh reader.

Construct the VTK format reader from given FilePath and set shared map of element data values. This opens the file for reading.

Definition at line 78 of file msh_vtkreader.cc.

Member Function Documentation

◆ create_header()

BaseMeshReader::MeshDataHeader VtkMeshReader::create_header ( pugi::xml_node  node,
unsigned int  n_entities,
Tokenizer::Position  pos,
OutputTime::DiscreteSpace  disc 
)
protected

Helper method that create DataArray header of given xml node (used from make_header_table)

Definition at line 157 of file msh_vtkreader.cc.

Here is the caller graph for this function:

◆ create_node_element_caches()

void VtkMeshReader::create_node_element_caches ( )
protected

create data caches of node and elements DataArray tags

Definition at line 511 of file msh_vtkreader.cc.

Here is the caller graph for this function:

◆ DECLARE_EXCEPTION() [1/6]

VtkMeshReader::DECLARE_EXCEPTION ( ExcIncompatibleMesh  ,
<< "Incompatible  meshes,
"<< EI_ErrMessage::val<< "\n"<< "for VTK input file:"<< EI_VTKFile::qval   
)

◆ DECLARE_EXCEPTION() [2/6]

VtkMeshReader::DECLARE_EXCEPTION ( ExcInvalidDofHandler  ,
<< "Invalid DOF handler hash for field: "<< EI_FieldName::qval<< " in the input file: "<< EI_VTKFile::qval<< ".\n"   
)

◆ DECLARE_EXCEPTION() [3/6]

VtkMeshReader::DECLARE_EXCEPTION ( ExcInvalidFormat  ,
<< "Invalid format of DataArray "<< EI_FieldName::val<< "  ,
expected "<< EI_ExpectedFormat::val<< "\n"<< "in the input file:"<< EI_VTKFile::qval   
)

◆ DECLARE_EXCEPTION() [4/6]

VtkMeshReader::DECLARE_EXCEPTION ( ExcMissingTag  ,
<< "Missing "<< EI_TagType::val<< " "<< EI_TagName::val<< "\n"<< " in the input file: "<< EI_VTKFile::qval   
)

◆ DECLARE_EXCEPTION() [5/6]

VtkMeshReader::DECLARE_EXCEPTION ( ExcUnknownFormat  ,
<< "Unsupported or missing format of DataArray "<< EI_FieldName::val<< "\n"<< "in the input file: "<< EI_VTKFile::qval   
)

◆ DECLARE_EXCEPTION() [6/6]

VtkMeshReader::DECLARE_EXCEPTION ( ExcWrongType  ,
<< EI_ErrMessage::val<< " data type of "<< EI_SectionTypeName::val<< "\n"<< "in the input file: "<< EI_VTKFile::qval   
)

◆ find_header()

BaseMeshReader::MeshDataHeader & VtkMeshReader::find_header ( BaseMeshReader::HeaderQuery header_query)
overridevirtual

Find header of DataArray section of VTK file by field name given by header_query.

Implements BaseMeshReader.

Definition at line 261 of file msh_vtkreader.cc.

Here is the caller graph for this function:

◆ get_appended_position()

Tokenizer::Position VtkMeshReader::get_appended_position ( )
protected

Get position of AppendedData tag in VTK file.

Definition at line 127 of file msh_vtkreader.cc.

Here is the caller graph for this function:

◆ get_data_type()

DataType VtkMeshReader::get_data_type ( std::string  type_str)
protected

Get DataType by value of string.

Definition at line 300 of file msh_vtkreader.cc.

Here is the caller graph for this function:

◆ make_header_table()

void VtkMeshReader::make_header_table ( )
overrideprotectedvirtual

Reads table of DataArray headers through pugixml interface.

Implements BaseMeshReader.

Definition at line 204 of file msh_vtkreader.cc.

Here is the caller graph for this function:

◆ parse_ascii_data()

void VtkMeshReader::parse_ascii_data ( ElementDataCacheBase data_cache,
unsigned int  n_components,
unsigned int  n_entities,
Tokenizer::Position  pos 
)
protected

Parse ascii data to data cache.

Definition at line 365 of file msh_vtkreader.cc.

Here is the caller graph for this function:

◆ parse_binary_data()

void VtkMeshReader::parse_binary_data ( ElementDataCacheBase data_cache,
unsigned int  n_components,
unsigned int  n_entities,
Tokenizer::Position  pos 
)
protected

Parse binary data to data cache.

Definition at line 384 of file msh_vtkreader.cc.

Here is the caller graph for this function:

◆ parse_compressed_data()

void VtkMeshReader::parse_compressed_data ( ElementDataCacheBase data_cache,
unsigned int  n_components,
unsigned int  n_entities,
Tokenizer::Position  pos 
)
protected

Uncompress and parse binary compressed data to data cache.

Definition at line 399 of file msh_vtkreader.cc.

Here is the caller graph for this function:

◆ read_base_vtk_attributes()

void VtkMeshReader::read_base_vtk_attributes ( pugi::xml_node  vtk_node,
unsigned int &  n_nodes,
unsigned int &  n_elements 
)
protected

Set base attributes of VTK and get count of nodes and elements.

Definition at line 96 of file msh_vtkreader.cc.

Here is the caller graph for this function:

◆ read_element_data()

void VtkMeshReader::read_element_data ( ElementDataCacheBase data_cache,
MeshDataHeader  header 
)
overrideprotectedvirtual

Implements BaseMeshReader::read_element_data.

Implements BaseMeshReader.

Definition at line 337 of file msh_vtkreader.cc.

◆ read_elements()

void VtkMeshReader::read_elements ( Mesh mesh)
protectedvirtual

Method for reading of elements. Input of the mesh allows changing regions within the input file.

Implements BaseMeshReader.

Definition at line 480 of file msh_vtkreader.cc.

◆ read_nodes()

void VtkMeshReader::read_nodes ( Mesh mesh)
protectedvirtual

private method for reading of nodes

Implements BaseMeshReader.

Definition at line 458 of file msh_vtkreader.cc.

◆ read_physical_names()

void VtkMeshReader::read_physical_names ( Mesh mesh)
overridevirtual

Read regions from the VTK file and save the physical sections as regions in the RegionDB.

Region Labels starting with '!' are treated as boundary regions. Elements of these regions are used just to assign regions to the boundary and are not used in actual FEM computations.

Implements BaseMeshReader.

Definition at line 452 of file msh_vtkreader.cc.

◆ type_value_size()

unsigned int VtkMeshReader::type_value_size ( DataType  data_type)
protected

Return size of value of data_type.

Definition at line 328 of file msh_vtkreader.cc.

◆ TYPEDEF_ERR_INFO() [1/6]

VtkMeshReader::TYPEDEF_ERR_INFO ( EI_ErrMessage  ,
std::string   
)

◆ TYPEDEF_ERR_INFO() [2/6]

VtkMeshReader::TYPEDEF_ERR_INFO ( EI_ExpectedFormat  ,
std::string   
)

◆ TYPEDEF_ERR_INFO() [3/6]

VtkMeshReader::TYPEDEF_ERR_INFO ( EI_SectionTypeName  ,
std::string   
)

◆ TYPEDEF_ERR_INFO() [4/6]

VtkMeshReader::TYPEDEF_ERR_INFO ( EI_TagName  ,
std::string   
)

◆ TYPEDEF_ERR_INFO() [5/6]

VtkMeshReader::TYPEDEF_ERR_INFO ( EI_TagType  ,
std::string   
)

◆ TYPEDEF_ERR_INFO() [6/6]

VtkMeshReader::TYPEDEF_ERR_INFO ( EI_VTKFile  ,
std::string   
)

Friends And Related Function Documentation

◆ PvdMeshReader

friend class PvdMeshReader
friend

Definition at line 41 of file msh_vtkreader.hh.

Member Data Documentation

◆ data_format_

DataFormat VtkMeshReader::data_format_
protected

variants of data format (ascii, appended, compressed appended)

Definition at line 170 of file msh_vtkreader.hh.

◆ data_stream_

std::istream* VtkMeshReader::data_stream_
protected

input stream allow read appended data, used only if this tag exists

Definition at line 176 of file msh_vtkreader.hh.

◆ header_table_

HeaderTable VtkMeshReader::header_table_
protected

Table with data of DataArray headers.

Definition at line 173 of file msh_vtkreader.hh.

◆ header_type_

DataType VtkMeshReader::header_type_
protected

header type of VTK file (only for appended data)

Definition at line 167 of file msh_vtkreader.hh.

◆ n_read_

unsigned int VtkMeshReader::n_read_
protected

store count of read entities

Definition at line 179 of file msh_vtkreader.hh.

◆ point_tolerance

const double VtkMeshReader::point_tolerance = 1E-10
staticprotected

Tolerance during comparison point data with GMSH nodes.

Definition at line 164 of file msh_vtkreader.hh.

◆ time_step_

double VtkMeshReader::time_step_
protected

time of VTK file (getting only during initialization from PVD reader)

Definition at line 182 of file msh_vtkreader.hh.


The documentation for this class was generated from the following files: