Flow123d  3.9.0-9663d1cde
Classes | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Friends | List of all members
BaseMeshReader Class Referenceabstract

#include <msh_basereader.hh>

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

Classes

struct  HeaderQuery
 
struct  MeshDataHeader
 

Public Member Functions

 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)
 
virtual void read_physical_names (Mesh *mesh)=0
 
template<typename T >
ElementDataCache< T >::CacheData get_element_data (MeshDataHeader header, unsigned int expected_n_entities, unsigned int expected_n_components, bool boundary_domain)
 
void set_element_ids (const Mesh &mesh)
 
const std::vector< int > & get_element_ids (bool boundary_domain)
 
virtual MeshDataHeaderfind_header (HeaderQuery &header_query)=0
 
CheckResult scale_and_check_limits (string field_name, double coef, double default_val, double lower_bound=-std::numeric_limits< double >::max(), double upper_bound=std::numeric_limits< double >::max())
 

Static Public Member Functions

static std::shared_ptr< BaseMeshReaderreader_factory (const FilePath &file_name)
 
static Meshmesh_factory (const Input::Record &input_mesh_rec)
 

Protected Types

typedef std::shared_ptr< ElementDataCacheBaseElementDataPtr
 
typedef std::map< string, ElementDataPtrElementDataFieldMap
 

Protected Member Functions

 BaseMeshReader (const FilePath &file_name, std::shared_ptr< ElementDataFieldMap > element_data_values)
 Constructor. More...
 
virtual void read_nodes (Mesh *mesh)=0
 
virtual void read_elements (Mesh *mesh)=0
 
virtual void make_header_table ()=0
 
virtual void read_element_data (ElementDataCacheBase &data_cache, MeshDataHeader header, bool boundary_domain)=0
 

Protected Attributes

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_
 

Friends

class ReaderCache
 

Detailed Description

Abstract parent of mesh readers.

Supported are:

Definition at line 58 of file msh_basereader.hh.

Member Typedef Documentation

◆ ElementDataFieldMap

Definition at line 223 of file msh_basereader.hh.

◆ ElementDataPtr

typedef std::shared_ptr<ElementDataCacheBase> BaseMeshReader::ElementDataPtr
protected

Definition at line 222 of file msh_basereader.hh.

Constructor & Destructor Documentation

◆ BaseMeshReader() [1/2]

BaseMeshReader::BaseMeshReader ( const FilePath file_name)

Constructor.

Definition at line 28 of file msh_basereader.cc.

◆ BaseMeshReader() [2/2]

BaseMeshReader::BaseMeshReader ( const FilePath file_name,
std::shared_ptr< ElementDataFieldMap element_data_values 
)
protected

Constructor.

Definition at line 33 of file msh_basereader.cc.

Member Function Documentation

◆ DECLARE_EXCEPTION() [1/3]

BaseMeshReader::DECLARE_EXCEPTION ( ExcWrongComponentsCount  ,
<< "Wrong number of components of field "<< EI_FieldName::qval<< " at time "<< EI_Time::val<< " in the input file: "<< EI_MeshFile::qval   
)

◆ DECLARE_EXCEPTION() [2/3]

BaseMeshReader::DECLARE_EXCEPTION ( ExcWrongExtension  ,
<< "Unsupported extension "<< EI_FileExtension::qval<< " of the input file: "<< EI_MeshFile::qval   
)

◆ DECLARE_EXCEPTION() [3/3]

BaseMeshReader::DECLARE_EXCEPTION ( ExcWrongFormat  ,
<< "Wrong format of "<< EI_Type::val<< "  ,
"<< EI_TokenizerMsg::val<< "\n"<< "in the input file:"<< EI_MeshFile::qval   
)

◆ DECLARE_INPUT_EXCEPTION() [1/2]

BaseMeshReader::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() [2/2]

BaseMeshReader::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'."   
)

◆ find_header()

virtual MeshDataHeader& BaseMeshReader::find_header ( HeaderQuery header_query)
pure virtual

Find data header for time and field given by header_query.

Implemented in VtkMeshReader, GmshMeshReader, and PvdMeshReader.

◆ get_element_data()

template<typename T >
ElementDataCache< T >::CacheData BaseMeshReader::get_element_data ( MeshDataHeader  header,
unsigned int  expected_n_entities,
unsigned int  expected_n_components,
bool  boundary_domain 
)

Reads ElementData sections of opened mesh file. Method must be call after set_data_header method. If such section has not been yet read, we read the data section into raw buffer data. The buffer must have size at least n_components * n_entities. Indexes in the map must be smaller then n_entities.

Possible optimizations: If the map ID lookup seem slow, we may assume that IDs are in increasing order, use simple array of IDs instead of map and just check that they comes in in correct order.

Parameters
n_entitiescount of entities (elements)
n_componentscount of components (size of returned data is given by n_entities*n_components)
boundary_domainflag determines that data is read for boundary or bulk elements
component_idxcomponent index of MultiField; 0 for single component fields.

Definition at line 95 of file msh_basereader.cc.

◆ get_element_ids()

const std::vector< int > & BaseMeshReader::get_element_ids ( bool  boundary_domain)

Returns vector of boundary or bulk element IDs to read. Used by GMSH reader only.

Definition at line 88 of file msh_basereader.cc.

Here is the caller graph for this function:

◆ make_header_table()

virtual void BaseMeshReader::make_header_table ( )
protectedpure virtual

Reads table of data headers specific for each descendants.

Implemented in VtkMeshReader, GmshMeshReader, and PvdMeshReader.

◆ mesh_factory()

Mesh * BaseMeshReader::mesh_factory ( const Input::Record input_mesh_rec)
static

This static method gets accessor to record with function input, dispatch to correct constructor and initialize appropriate function object from the input. Allow to make optimization of elements and nodes order if flag optimize_mesh is set Returns pointer to Mesh.

Definition at line 52 of file msh_basereader.cc.

Here is the caller graph for this function:

◆ read_element_data()

virtual void BaseMeshReader::read_element_data ( ElementDataCacheBase data_cache,
MeshDataHeader  header,
bool  boundary_domain 
)
protectedpure virtual

Read element data to data cache

Implemented in VtkMeshReader, GmshMeshReader, and PvdMeshReader.

Here is the caller graph for this function:

◆ read_elements()

virtual void BaseMeshReader::read_elements ( Mesh mesh)
protectedpure virtual

Method for reading of elements.

Implemented in PvdMeshReader, VtkMeshReader, and GmshMeshReader.

Here is the caller graph for this function:

◆ read_nodes()

virtual void BaseMeshReader::read_nodes ( Mesh mesh)
protectedpure virtual

private method for reading of nodes

Implemented in PvdMeshReader, VtkMeshReader, and GmshMeshReader.

Here is the caller graph for this function:

◆ read_physical_names()

virtual void BaseMeshReader::read_physical_names ( Mesh mesh)
pure virtual

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

Implemented in VtkMeshReader, GmshMeshReader, and PvdMeshReader.

◆ read_raw_mesh()

void BaseMeshReader::read_raw_mesh ( Mesh mesh)

Reads raw data of mesh (only nodes and elements) from the GMSH or VTKfile. Input of the mesh allows changing regions within the input file.

Definition at line 74 of file msh_basereader.cc.

◆ reader_factory()

std::shared_ptr< BaseMeshReader > BaseMeshReader::reader_factory ( const FilePath file_name)
static

This static method gets file path object of reader, dispatch to correct constructor and initialize appropriate function object from the input. Returns shared pointer to BaseMeshReader.

Definition at line 38 of file msh_basereader.cc.

Here is the caller graph for this function:

◆ scale_and_check_limits()

CheckResult BaseMeshReader::scale_and_check_limits ( string  field_name,
double  coef,
double  default_val,
double  lower_bound = -std::numeric_limits<double>::max(),
double  upper_bound = std::numeric_limits<double>::max() 
)

Scale and check data stored in ElementDataCache of given field.

Definition at line 132 of file msh_basereader.cc.

◆ set_element_ids()

void BaseMeshReader::set_element_ids ( const Mesh mesh)

Set ID vectors from a different mesh. Must be set in order to determine for which IDs the GMSH reader should read the data. Could possibly read just a subset.

Definition at line 81 of file msh_basereader.cc.

◆ TYPEDEF_ERR_INFO() [1/6]

BaseMeshReader::TYPEDEF_ERR_INFO ( EI_FieldName  ,
std::string   
)

◆ TYPEDEF_ERR_INFO() [2/6]

BaseMeshReader::TYPEDEF_ERR_INFO ( EI_FileExtension  ,
std::string   
)

◆ TYPEDEF_ERR_INFO() [3/6]

BaseMeshReader::TYPEDEF_ERR_INFO ( EI_MeshFile  ,
std::string   
)

◆ TYPEDEF_ERR_INFO() [4/6]

BaseMeshReader::TYPEDEF_ERR_INFO ( EI_Time  ,
double   
)

◆ TYPEDEF_ERR_INFO() [5/6]

BaseMeshReader::TYPEDEF_ERR_INFO ( EI_TokenizerMsg  ,
std::string   
)

◆ TYPEDEF_ERR_INFO() [6/6]

BaseMeshReader::TYPEDEF_ERR_INFO ( EI_Type  ,
std::string   
)

Friends And Related Function Documentation

◆ ReaderCache

friend class ReaderCache
friend

Definition at line 271 of file msh_basereader.hh.

Member Data Documentation

◆ boundary_elements_id_

vector<LongIdx> BaseMeshReader::boundary_elements_id_
protected

Definition at line 269 of file msh_basereader.hh.

◆ bulk_elements_id_

vector<LongIdx> BaseMeshReader::bulk_elements_id_
protected

Vector of both bulk and boundary IDs. Bulk elements come first, then boundary elements, but only the portion that appears in input mesh file and has ID assigned. If set through set_element_ids, the GMSH reader only reads given IDs and check that all IDs are read.

Definition at line 269 of file msh_basereader.hh.

◆ data_section_name_

std::string BaseMeshReader::data_section_name_
protected

Store name of field data section specify for type of mesh file.

Definition at line 258 of file msh_basereader.hh.

◆ element_data_values_

std::shared_ptr<ElementDataFieldMap> BaseMeshReader::element_data_values_
protected

Cache with last read element data.

Definition at line 261 of file msh_basereader.hh.

◆ has_compatible_mesh_

bool BaseMeshReader::has_compatible_mesh_
protected

Flag stores that check of compatible mesh was performed.

This flag has effect only for VTK reader.

Definition at line 255 of file msh_basereader.hh.

◆ tok_

Tokenizer BaseMeshReader::tok_
protected

Tokenizer used for reading ASCII file format.

Definition at line 264 of file msh_basereader.hh.


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