Flow123d  release_2.1.0-87-gfbc1563
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
GmshMeshReader Class Reference

#include <msh_gmshreader.h>

Collaboration diagram for GmshMeshReader:
Collaboration graph
[legend]

Public Types

typedef std::map< std::string, std::vector< GMSH_DataHeader > > HeaderTable
 

Public Member Functions

 TYPEDEF_ERR_INFO (EI_FieldName, std::string)
 
 TYPEDEF_ERR_INFO (EI_GMSHFile, std::string)
 
 TYPEDEF_ERR_INFO (EI_Time, double)
 
 TYPEDEF_ERR_INFO (EI_Type, std::string)
 
 TYPEDEF_ERR_INFO (EI_TokenizerMsg, std::string)
 
 TYPEDEF_ERR_INFO (EI_Section, std::string)
 
 TYPEDEF_ERR_INFO (EI_ElementId, int)
 
 TYPEDEF_ERR_INFO (EI_ElementType, int)
 
 DECLARE_INPUT_EXCEPTION (ExcFieldNameNotFound,<< "No data for field: "<< EI_FieldName::qval<< " and time: "<< EI_Time::val<< " in the input file: "<< EI_GMSHFile::qval)
 
 DECLARE_EXCEPTION (ExcWrongFormat,<< "Wrong format of "<< EI_Type::val<< ", "<< EI_TokenizerMsg::val<< "\n"<< "in the input file: "<< EI_GMSHFile::qval)
 
 DECLARE_EXCEPTION (ExcMissingSection,<< "Missing section "<< EI_Section::qval<< " in the GMSH input file: "<< EI_GMSHFile::qval)
 
 DECLARE_EXCEPTION (ExcUnsupportedType,<< "Element "<< EI_ElementId::val<< "in the GMSH input file "<< EI_GMSHFile::qval<< " is of the unsupported type "<< EI_ElementType::val)
 
 GmshMeshReader (const FilePath &file_name)
 
 GmshMeshReader (std::istream &in)
 
 ~GmshMeshReader ()
 
void read_mesh (Mesh *mesh)
 
void read_physical_names (Mesh *mesh)
 
template<typename T >
ElementDataCache< T >::ComponentDataPtr get_element_data (GMSH_DataHeader &search_header, std::vector< int > const &el_ids, unsigned int component_idx)
 

Private Member Functions

void read_nodes (Mesh *)
 
void read_elements (Mesh *)
 
void read_data_header (GMSH_DataHeader &head)
 
void make_header_table ()
 
GMSH_DataHeaderfind_header (double time, std::string field_name)
 

Private Attributes

Tokenizer tok_
 Tokenizer used for reading ASCII GMSH file format. More...
 
HeaderTable header_table_
 Table with data of ElementData headers. More...
 
ElementDataCacheBasecurrent_cache_
 Cache with last read element data. More...
 

Detailed Description

Definition at line 78 of file msh_gmshreader.h.

Member Typedef Documentation

Map of ElementData sections in GMSH file.

For each field_name contains vector of GMSH_DataHeader. Headers are sorted by time in ascending order.

Definition at line 107 of file msh_gmshreader.h.

Constructor & Destructor Documentation

GmshMeshReader::GmshMeshReader ( const FilePath file_name)

Construct the GMSH format reader from given filename. This opens the file for reading.

Definition at line 38 of file msh_gmshreader.cc.

GmshMeshReader::GmshMeshReader ( std::istream &  in)

Construct the GMSH format reader from given input stream. The input stream should be correctly opened. To get correct information about line numbers there should be no previous reading from the stream.

Definition at line 48 of file msh_gmshreader.cc.

GmshMeshReader::~GmshMeshReader ( )

Destructor close the file if opened.

Definition at line 58 of file msh_gmshreader.cc.

Member Function Documentation

GmshMeshReader::DECLARE_EXCEPTION ( ExcWrongFormat  ,
<< "Wrong format of "<< EI_Type::val<< "  ,
"<< EI_TokenizerMsg::val<< "\n"<< "in the input file:"<< EI_GMSHFile::qval   
)
GmshMeshReader::DECLARE_EXCEPTION ( ExcMissingSection  ,
<< "Missing section "<< EI_Section::qval<< " in the GMSH input file: "<< EI_GMSHFile::qval   
)
GmshMeshReader::DECLARE_EXCEPTION ( ExcUnsupportedType  ,
<< "Element "<< EI_ElementId::val<< "in the GMSH input file "<< EI_GMSHFile::qval<< " is of the unsupported type "<< EI_ElementType::val   
)
GmshMeshReader::DECLARE_INPUT_EXCEPTION ( ExcFieldNameNotFound  ,
<< "No data for field: "<< EI_FieldName::qval<< " and time: "<< EI_Time::val<< " in the input file: "<< EI_GMSHFile::qval   
)
GMSH_DataHeader & GmshMeshReader::find_header ( double  time,
std::string  field_name 
)
private

Finds GMSH data header for ElementData given by time and field_name and return it as the first parameter.

Definition at line 418 of file msh_gmshreader.cc.

Here is the caller graph for this function:

template<typename T >
ElementDataCache< T >::ComponentDataPtr GmshMeshReader::get_element_data ( GMSH_DataHeader search_header,
std::vector< int > const &  el_ids,
unsigned int  component_idx 
)

Reads ElementData sections of opened GMSH file. The file is serached for the \$ElementData section with header that match the given search_header (same field_name, time of the next section is the first greater then that given in the search_header). If such section has not been yet read, we read the data section into raw buffer data. The map id_to_idx is used to convert IDs that marks individual input rows/entities into indexes to the raw buffer. The buffer must have size at least search_header.n_components * search_header.n_entities. Indexes in the map must be smaller then search_header.n_entities. If the data buffer is updated we set search_header.actual to true.

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.

Definition at line 294 of file msh_gmshreader.cc.

void GmshMeshReader::make_header_table ( )
private

Reads table of ElementData headers from the tokenizer file.

Definition at line 391 of file msh_gmshreader.cc.

Here is the caller graph for this function:

void GmshMeshReader::read_data_header ( GMSH_DataHeader head)
private

Reads the header from the tokenizer tok and return it as the second parameter.

Definition at line 237 of file msh_gmshreader.cc.

Here is the caller graph for this function:

void GmshMeshReader::read_elements ( Mesh mesh)
private

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

Definition at line 106 of file msh_gmshreader.cc.

Here is the caller graph for this function:

void GmshMeshReader::read_mesh ( Mesh mesh)

Reads mesh from the GMSH file. Input of the mesh allows changing regions within the input CON file.

Definition at line 63 of file msh_gmshreader.cc.

Here is the caller graph for this function:

void GmshMeshReader::read_nodes ( Mesh mesh)
private

private method for reading of nodes

Definition at line 74 of file msh_gmshreader.cc.

Here is the caller graph for this function:

void GmshMeshReader::read_physical_names ( Mesh mesh)

Read section '$PhysicalNames' of the GMSH 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.

Definition at line 207 of file msh_gmshreader.cc.

Here is the caller graph for this function:

GmshMeshReader::TYPEDEF_ERR_INFO ( EI_FieldName  ,
std::string   
)
GmshMeshReader::TYPEDEF_ERR_INFO ( EI_GMSHFile  ,
std::string   
)
GmshMeshReader::TYPEDEF_ERR_INFO ( EI_Time  ,
double   
)
GmshMeshReader::TYPEDEF_ERR_INFO ( EI_Type  ,
std::string   
)
GmshMeshReader::TYPEDEF_ERR_INFO ( EI_TokenizerMsg  ,
std::string   
)
GmshMeshReader::TYPEDEF_ERR_INFO ( EI_Section  ,
std::string   
)
GmshMeshReader::TYPEDEF_ERR_INFO ( EI_ElementId  ,
int   
)
GmshMeshReader::TYPEDEF_ERR_INFO ( EI_ElementType  ,
int   
)

Member Data Documentation

ElementDataCacheBase* GmshMeshReader::current_cache_
private

Cache with last read element data.

Definition at line 186 of file msh_gmshreader.h.

HeaderTable GmshMeshReader::header_table_
private

Table with data of ElementData headers.

Definition at line 184 of file msh_gmshreader.h.

Tokenizer GmshMeshReader::tok_
private

Tokenizer used for reading ASCII GMSH file format.

Definition at line 182 of file msh_gmshreader.h.


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