BELFEM
0.9.0
Berkeley Lab Finite Element Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
cl_Mesh_GmshReader.hpp
Go to the documentation of this file.
1
/*
2
* BELFEM -- The Berkeley Lab Finite Element Framework
3
* Copyright (c) 2026, The Regents of the University of California,
4
* through Lawrence Berkeley National Laboratory (subject to receipt of any required
5
* approvals from the U.S. Dept. of Energy). All rights reserved.
6
*
7
* Developers: Christian Messe, Gregory Giard
8
*
9
* See the top-level LICENSE file for the complete license and disclaimer.
10
*/
11
12
#ifndef BELFEM_CL_MESH_GMSHREADER_HPP
13
#define BELFEM_CL_MESH_GMSHREADER_HPP
14
15
#include "
typedefs.hpp
"
16
#include "
cl_Ascii.hpp
"
17
#include "
cl_Cell.hpp
"
18
#include "
cl_Node.hpp
"
19
#include "
cl_Element.hpp
"
20
#include "
cl_Facet.hpp
"
21
#include "
cl_Map.hpp
"
22
#include "
cl_Block.hpp
"
23
#include "
cl_SideSet.hpp
"
24
#include "
cl_Mesh.hpp
"
25
26
namespace
belfem
27
{
28
namespace
mesh
29
{
30
/*struct GmshPhysicalGroup
31
{
32
string mLabel = "untitled";
33
uint mID = 0;
34
uint mDimension = 0;
35
};*/
36
37
//------------------------------------------------------------------------------
38
39
class
GmshReader
:
public
Ascii
40
{
41
string
mFilename;
42
43
// scale factor to convert spatial unit of mesh into m
44
const
real
mMeshScale = 1.0 ;
45
46
real
mVersion = 0.0;
47
48
uint
mNumberOfNodes = 0;
49
uint
mNumberOfElements = 0;
50
uint
mNumberOfPhysicalGroups = 0;
51
52
// tags in the file
53
size_t
mNodesTag = 0;
54
size_t
mElementsTag = 0;
55
size_t
mPhysicalTag = 0;
56
57
// Pointer to mesh object
58
Mesh
* mMesh;
59
60
// dimensions
61
uint
mNumberOfDimensions = 0;
62
63
// cell containing Nodes
64
Cell< Node * >
mNodes;
65
66
// cell containing Elements
67
Cell< Element * >
mElements;
68
69
// map managing Nodes by ID
70
Map< id_t, Node* >
mNodeMap;
71
72
// MSH 4.1: first physical tag of each entity, per dimension,
73
// keyed by the entity ( geometry ) tag. Filled from $Entities
74
Map< id_t, uint >
mPhysicalTagOfEntity[ 4 ];
75
76
// number of elements per dimension
77
Vector< index_t >
mNumberOfElementsPerDimension;
78
79
Cell< Element * >
mVertices;
80
Cell< Element * >
mEdges;
81
Cell< Element * >
mFaces;
82
Cell< Element * >
mVolumes;
83
84
// groups ids
85
Vector< uint >
mNodeGroupIDs;
86
Vector< uint >
mEdgeGroupIDs;
87
Vector< uint >
mFaceGroupIDs;
88
Vector< uint >
mVolumeGroupIDs;
89
96
bool
mOwnMesh =
false
;
97
98
//------------------------------------------------------------------------------
99
public
:
100
//------------------------------------------------------------------------------
101
102
GmshReader
(
const
string
& aPath,
Mesh
* aMesh =
nullptr
,
const
bool
aComputeConnectivities=
true
,
const
real
aMeshScale = 1.0 );
103
104
//------------------------------------------------------------------------------
105
106
~GmshReader
()
override
;
107
108
//------------------------------------------------------------------------------
109
110
Mesh
*
111
mesh
()
112
{
113
114
mOwnMesh =
false
;
115
116
return
mMesh;
117
}
118
119
//------------------------------------------------------------------------------
120
private
:
121
//------------------------------------------------------------------------------
122
123
void
124
tidy_up_buffer();
125
126
//------------------------------------------------------------------------------
127
128
void
129
check_tag_existence();
130
131
//------------------------------------------------------------------------------
132
133
void
134
read_version();
135
136
//------------------------------------------------------------------------------
137
138
void
139
read_tags_v22();
140
141
//------------------------------------------------------------------------------
142
143
void
144
read_nodes_tag_v22(
size_t
& aCount );
145
146
//------------------------------------------------------------------------------
147
148
void
149
read_elements_tag_v22(
size_t
& aCount );
150
151
//------------------------------------------------------------------------------
152
153
void
154
read_physical_tag(
size_t
& aCount );
155
156
//------------------------------------------------------------------------------
157
158
void
159
read_nodes_v22();
160
161
//------------------------------------------------------------------------------
162
163
void
164
read_elements_v22();
165
166
//------------------------------------------------------------------------------
167
168
void
169
read_mesh_v41();
170
171
//------------------------------------------------------------------------------
172
173
void
174
read_entity_tag_v41(
size_t
& aCount );
175
176
//------------------------------------------------------------------------------
177
178
void
179
read_nodes_v41(
size_t
& aCount );
180
181
//------------------------------------------------------------------------------
182
183
void
184
read_elements_v41(
size_t
& aCount );
185
186
//------------------------------------------------------------------------------
187
188
void
189
convert_orders_for_quadratic_volume_elements_to_exo();
190
191
//------------------------------------------------------------------------------
192
193
void
194
create_node_map();
195
196
//------------------------------------------------------------------------------
197
201
void
202
read_mesh_dimension();
203
204
//------------------------------------------------------------------------------
205
206
void
207
create_element_containers_per_dimension();
208
209
//------------------------------------------------------------------------------
210
211
void
212
create_group_ids();
213
214
//------------------------------------------------------------------------------
215
216
void
217
create_blocks();
218
219
//------------------------------------------------------------------------------
220
221
void
222
create_sidesets();
223
224
//------------------------------------------------------------------------------
225
226
void
227
delete_unused_nodes_and_elements();
228
229
//------------------------------------------------------------------------------
230
231
void
232
create_mesh();
233
234
//------------------------------------------------------------------------------
235
236
void
237
create_vertices();
238
239
//------------------------------------------------------------------------------
240
};
241
}
242
}
243
#endif
//BELFEM_CL_MESH_GMSHREADER_HPP
cl_Ascii.hpp
cl_Block.hpp
cl_Cell.hpp
cl_Element.hpp
cl_Facet.hpp
cl_Map.hpp
cl_Mesh.hpp
cl_Node.hpp
cl_SideSet.hpp
belfem::Ascii::Ascii
Ascii(const string &aPath, const enum FileMode &aMode)
Definition
cl_Ascii.cpp:25
belfem::Cell
Cell is a wrapper around the standard vector.
Definition
cl_Cell.hpp:42
belfem::Map
Hash map (unordered key-value).
Definition
cl_Map.hpp:75
belfem::Mesh
Top-level container for all mesh entities.
Definition
cl_Mesh.hpp:60
belfem::Vector< index_t >
belfem::mesh::GmshReader::mesh
Mesh * mesh()
Definition
cl_Mesh_GmshReader.hpp:111
belfem::mesh::GmshReader::GmshReader
GmshReader(const string &aPath, Mesh *aMesh=nullptr, const bool aComputeConnectivities=true, const real aMeshScale=1.0)
Definition
cl_Mesh_GmshReader.cpp:32
belfem::mesh
Definition
cl_EF_EdgeFunction.hpp:17
belfem
USER GUIDES:
Definition
cl_Capacitor.cpp:16
belfem::uint
unsigned int uint
Definition
typedefs.hpp:30
belfem::real
double real
Definition
typedefs.hpp:36
typedefs.hpp
src
mesh
cl_Mesh_GmshReader.hpp
Generated by
1.18.0