Flow123d  release_2.2.0-34-g18a8075
msh_gmshreader.h
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_gmshreader.h
15  * @brief
16  * @author dalibor
17  */
18 
19 #ifndef _GMSHMESHREADER_H
20 #define _GMSHMESHREADER_H
21 
22 #include <string>
23 #include <vector>
24 #include <map>
25 
26 
27 #include "mesh/region.hh"
29 #include "io/msh_basereader.hh"
30 #include "input/input_exception.hh"
31 
32 class Mesh;
33 class FilePath;
34 
35 
36 
38 public:
39  TYPEDEF_ERR_INFO(EI_GMSHFile, std::string);
40  TYPEDEF_ERR_INFO(EI_Section, std::string);
41  TYPEDEF_ERR_INFO(EI_ElementId, int);
42  TYPEDEF_ERR_INFO(EI_ElementType, int);
43  DECLARE_EXCEPTION(ExcMissingSection,
44  << "Missing section " << EI_Section::qval << " in the GMSH input file: " << EI_GMSHFile::qval);
45  DECLARE_EXCEPTION(ExcUnsupportedType,
46  << "Element " << EI_ElementId::val << "in the GMSH input file " << EI_GMSHFile::qval
47  << " is of the unsupported type " << EI_ElementType::val );
48 
49  /**
50  * Map of ElementData sections in GMSH file.
51  *
52  * For each field_name contains vector of MeshDataHeader.
53  * Headers are sorted by time in ascending order.
54  */
56 
57  /**
58  * Construct the GMSH format reader from given FilePath.
59  * This opens the file for reading.
60  */
61  GmshMeshReader(const FilePath &file_name);
62 
63  /**
64  * Destructor close the file if opened.
65  */
66  virtual ~GmshMeshReader();
67 
68  /**
69  * Read section '$PhysicalNames' of the GMSH file and save the physical sections as regions in the RegionDB.
70  *
71  * Region Labels starting with '!' are treated as boundary regions. Elements of these regions are used just to
72  * assign regions to the boundary and are not used in actual FEM computations.
73  */
74  void read_physical_names(Mesh * mesh) override;
75 
76  /**
77  * Empty method for GMSH reader now.
78  *
79  * Implements @p BaseMeshReader::check_compatible_mesh.
80  */
81  void check_compatible_mesh(Mesh &mesh) override;
82 
83 protected:
84  /**
85  * private method for reading of nodes
86  */
87  void read_nodes(Mesh * mesh);
88  /**
89  * Method for reading of elements.
90  * Input of the mesh allows changing regions within the input CON file.
91  * Read section '$PhysicalNames' of the GMSH file and save the physical sections to general data structure.
92  *
93  * Region Labels starting with '!' are treated as boundary regions. Elements of these regions are used just to
94  * assign regions to the boundary and are not used in actual FEM computations.
95  */
96  void read_elements(Mesh * mesh);
97  /**
98  * Reads the header from the tokenizer @p tok and return it as the second parameter.
99  */
100  void read_data_header(MeshDataHeader &head);
101  /**
102  * Reads table of ElementData headers from the tokenizer file.
103  */
104  void make_header_table() override;
105  /**
106  * Finds GMSH data header for ElementData given by time and field_name and return it as the first parameter.
107  */
108  MeshDataHeader & find_header(double time, std::string field_name) override;
109  /**
110  * Implements @p BaseMeshReader::read_element_data.
111  */
112  void read_element_data(ElementDataCacheBase &data_cache, MeshDataHeader actual_header, unsigned int n_components,
113  bool boundary_domain) override;
114 
115 
116  /// Table with data of ElementData headers
117  HeaderTable header_table_;
118 };
119 
120 #endif /* _GMSHMESHREADER_H */
121 
122 
void make_header_table() override
void read_nodes(Mesh *mesh)
void read_data_header(MeshDataHeader &head)
MeshDataHeader & find_header(double time, std::string field_name) override
void check_compatible_mesh(Mesh &mesh) override
virtual ~GmshMeshReader()
Definition: mesh.h:97
void read_physical_names(Mesh *mesh) override
GmshMeshReader(const FilePath &file_name)
TYPEDEF_ERR_INFO(EI_GMSHFile, std::string)
void read_element_data(ElementDataCacheBase &data_cache, MeshDataHeader actual_header, unsigned int n_components, bool boundary_domain) override
std::map< std::string, std::vector< MeshDataHeader > > HeaderTable
Dedicated class for storing path to input and output files.
Definition: file_path.hh:54
void read_elements(Mesh *mesh)
HeaderTable header_table_
Table with data of ElementData headers.
DECLARE_EXCEPTION(ExcMissingSection,<< "Missing section "<< EI_Section::qval<< " in the GMSH input file: "<< EI_GMSHFile::qval)