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