LehrFEM++ 1.0.0
A simple Finite Element Library for teaching
Loading...
Searching...
No Matches
gmsh_file_v4.h
1
10#ifndef INCG0eae50bb4868430ebde754b70d7f7f47
11#define INCG0eae50bb4868430ebde754b70d7f7f47
12
13#include <lf/mesh/mesh.h>
14
15#include <optional>
16
17namespace lf::io {
18
20struct GMshFileV4 {
22 std::string version_number = "4.1";
24 bool is_binary = false;
26 int size_t_size = 8;
40 struct PhysicalName {
43 int dimension = 0;
50 int physical_tag = 0;
52 std::string name;
53 };
54
60 std::vector<PhysicalName> physical_names;
61
68 struct PointEntity {
71 int tag = -1;
73 Eigen::Vector3d coord;
75 std::vector<int> physical_tags;
76 };
77
89 struct Entity {
92 int tag = -1;
97 Eigen::Vector3d min_coord;
99 Eigen::Vector3d max_coord;
100
105 std::vector<int> physical_tags;
110 std::vector<int> bounding_entities;
111 };
112
123 std::tuple<std::vector<PointEntity>, std::vector<Entity>, std::vector<Entity>,
124 std::vector<Entity>>
126
127 struct GhostEntity {
131 int tag;
132
138 };
139
149 int tag = -1;
150
155 int parent_dim = -1;
156
161 int parent_tag = -1;
162
166 std::vector<int> partitions;
167
171 Eigen::Vector3d coord;
172
176 std::vector<int> physical_tags;
177 };
178
186 int tag = -1;
187
192 int parent_dim = -1;
193
198 int parent_tag = -1;
199
203 std::vector<int> partitions;
204
209 Eigen::Vector3d min_coord;
210
212 Eigen::Vector3d max_coord;
213
217 std::vector<int> physical_tags;
218
223 std::vector<int> bounding_entities;
224 };
225
231 std::size_t num_partitions = 0;
232
240 std::vector<GhostEntity> ghost_entities;
241
255 std::tuple<std::vector<PartitionedPointEntity>,
256 std::vector<PartitionedEntity>, std::vector<PartitionedEntity>,
257 std::vector<PartitionedEntity>>
259 };
260
266
267 struct NodeBlock {
272 int entity_dim = -1;
273
278 int entity_tag = -1;
279
283 bool parametric = false;
284
294 std::vector<std::pair<std::size_t, Eigen::Vector3d>> nodes;
295 };
296
297 struct Nodes {
299 std::size_t num_nodes = -1;
300
302 std::size_t min_node_tag = 0;
303
305 std::size_t max_node_tag = 0;
306
311 std::vector<NodeBlock> node_blocks;
312 };
313
315
317 enum class ElementType : int {
318 EDGE2 = 1,
319 TRIA3 = 2,
320 QUAD4 = 3,
321 TET4 = 4,
322 HEX8 = 5,
323 PRISM6 = 6,
324 PYRAMID5 = 7,
325 EDGE3 = 8,
327 TRIA6 = 9,
329 QUAD9 = 10,
331 TET10 = 11,
333 HEX27 = 12,
336 PRISM18 = 13,
339 PYRAMID14 = 14,
342 POINT = 15,
343 QUAD8 = 16,
345 HEX20 = 17,
347 PRISM15 = 18,
349 PYRAMID13 = 19,
351 TRIA9 = 20,
353 TRIA10 = 21,
355 TRIA12 = 22,
357 TRIA15 = 23,
359 TRIA15_5 = 24,
361 TRIA21 = 25,
363 EDGE4 = 26,
365 EDGE5 = 27,
367 EDGE6 = 28,
369 TET20 = 29,
371 TET35 = 30,
374 TET56 = 31,
377 HEX64 = 92,
380 HEX125 = 93
383 };
384
386 static const std::vector<ElementType> AllElementTypes;
387
396 int dimension = -1;
397
403 int entity_tag = -1;
404
407
415 std::vector<std::pair<std::size_t, std::vector<std::size_t>>> elements;
416 };
417
418 struct Elements {
420 std::size_t num_elements = 0;
421
423 std::size_t min_element_tag = 0;
424
426 std::size_t max_element_tag = 0;
427
437 std::vector<ElementBlock> element_blocks;
438 };
439
444
457 int dimension = 0;
462
465 std::optional<Eigen::Matrix4d> affine_transform;
466
476 std::vector<std::pair<std::size_t, std::size_t>> node_mapping;
477 };
478
481 std::vector<PeriodicLink> periodic_links;
482
485 std::size_t element_tag = 0;
486
489
492 std::vector<int> ghost_partition_tags;
493 };
494
498 std::vector<GhostElement> ghost_elements;
499};
500
506
509
512
514std::ostream& operator<<(std::ostream& stream, GMshFileV4::ElementType et);
515
529GMshFileV4 ReadGmshFileV4(std::string::const_iterator begin,
530 std::string::const_iterator end,
531 const std::string& version, bool is_binary,
532 int size_t_size, int one,
533 const std::string& filename);
534
535} // namespace lf::io
536
538
542template <>
543struct fmt::formatter<lf::io::GMshFileV4::ElementType> : ostream_formatter {};
545
546#endif // INCG0eae50bb4868430ebde754b70d7f7f47
Represents a reference element with all its properties.
Definition ref_el.h:109
Mesh input (from file) and output (in various formats) facilities.
GMshFileV4 ReadGmshFileV4(std::string::const_iterator begin, std::string::const_iterator end, const std::string &version, bool is_binary, int size_t_size, int one, const std::string &filename)
Read a GmshFile with format 4 and return it as an in-memory struct.
int DimOf(GMshFileV2::ElementType et)
Dimension of the GmshElement type.
base::RefEl RefElOf(GMshFileV2::ElementType et)
Reference element type of a GmshElementType.
std::ostream & operator<<(std::ostream &stream, GMshFileV2::ElementType et)
Output the element type onto the console:
size_type NumNodes(GMshFileV2::ElementType et)
Number of nodes that this element type has.
Definition assemble.h:31
Represents number of mesh elements (such as triangles/quadrilaterals/points/lines) that share the sam...
int entity_tag
Tag of the entity to which elements in this block belong. If the mesh is not partitioned,...
ElementType element_type
type of the elements in this block
std::vector< std::pair< std::size_t, std::vector< std::size_t > > > elements
The elements in this block.
int dimension
Dimension of the elements in this block.
std::vector< ElementBlock > element_blocks
A list of all Elements (Points,Lines,Surfaces or Volumes) present in the *.msh file organized in bloc...
std::size_t max_element_tag
maximum element tag
std::size_t num_elements
Total number of elements in the mesh.
std::size_t min_element_tag
minimum element tag
A higher-dimensional entity (which is not a point) such as a curve, surface or volume....
Eigen::Vector3d min_coord
min_coord and max_coord define a bounding box within which the entity lies.
std::vector< int > physical_tags
The physical tags that identify the physical names to which this entity belongs.
Eigen::Vector3d max_coord
min_coord and max_coord define a bounding box within which the entity lies.
std::vector< int > bounding_entities
The bounding entities (one dimension smaller) that bound this entity.
int partition_tag
defines the partition to which this element belongs (mainly)
std::size_t element_tag
uniquely identifies a mesh element (
std::vector< int > ghost_partition_tags
references a ghost_entities by tag, if this mesh element is a ghost entity for that mesh partition.
int partition
the partition for which the elements in this ghost entity are ghost entities.
int tag
uniquely identifies this ghost entity
int entity_tag
The tag of the (partitioned) entity to which the nodes in this block belong.
int entity_dim
Dimension of the (partitioned) entity to which the nodes in this block belong.
std::vector< std::pair< std::size_t, Eigen::Vector3d > > nodes
a list of nodes in this block
bool parametric
Are the nodes in this block parametric?
std::size_t num_nodes
Total number of nodes in the mesh.
std::size_t min_node_tag
Smallest node tag that exists.
std::size_t max_node_tag
biggest node tag that exists
std::vector< NodeBlock > node_blocks
The nodes that make up this mesh organized in blocks.
std::tuple< std::vector< PartitionedPointEntity >, std::vector< PartitionedEntity >, std::vector< PartitionedEntity >, std::vector< PartitionedEntity > > partitioned_entities
a list of partitioned entities in this mesh.
std::size_t num_partitions
total number of mesh partitions
std::vector< GhostEntity > ghost_entities
Ghost entities of this mesh.
A higher dimensional partitioned entity.
int parent_dim
The dimension of the parent entity to which this partitioned entity belongs.
Eigen::Vector3d min_coord
the min_coord and max_coord define the (axis-aligned) bounding box within which this partitioned enti...
std::vector< int > physical_tags
the physical tags to which this partitioned entity belongs
int parent_tag
The tag of the parent entity to which this partitioned entity belongs.
Eigen::Vector3d max_coord
the min_coord and max_coord define the (axis-aligned) bounding box within which this partitioned enti...
int tag
unique number that identifies this partitioned entity.
std::vector< int > partitions
to which partitions does this entity belong?
std::vector< int > bounding_entities
The tags of the partitioned entities of one smaller dimension that bound this partitioned entity.
When a mesh is partitioned, the entities are also partitioned. This is a node entity which is typical...
int tag
unique number that identifies this partitioned point.
int parent_tag
The tag of the parent entity to which this partitioned entity belongs.
Eigen::Vector3d coord
the coordinates of this point
std::vector< int > physical_tags
the physical tags to which this partitioned node entity belongs
std::vector< int > partitions
to which partitions does this entity belong?
int parent_dim
The dimension of the parent entity to which this partitioned node belongs.
Represents a physical name as defined in gmsh. In GMSH a Physical name is created through one of the ...
int physical_tag
The identification number of the Physical name This number is assigned to a physical entity as the fi...
std::string name
The name of this Physical Entity (provided.
An entity of dimension 0. Usually an entity corresponds to a geometric construct as it is defined in ...
std::vector< int > physical_tags
The physical tags to which this entity belongs.
Eigen::Vector3d coord
the coordinates of the point
A representation of a .msh file (V4) in a c++ data structure.
std::vector< PeriodicLink > periodic_links
ElementType
All possible element types (see GMSH documentation)
std::string version_number
The version of GMSH of the msh file, equals usually 4.1.
int size_t_size
how many bytes is a size_t?
Elements elements
Information about all mesh elements in this file.
PartitionedEntities partitioned_entities
Information about partitioned entities (in case the mesh has been partitioned)
std::vector< PhysicalName > physical_names
A list of all Physical entities that have a name.
std::tuple< std::vector< PointEntity >, std::vector< Entity >, std::vector< Entity >, std::vector< Entity > > entities
the (Gmsh-) entities present in this mesh. An entity typically corresponds to a geometrical object sp...
static const std::vector< ElementType > AllElementTypes
Contains a list of all element types that are possible.
bool is_binary
Is it a binary file?
std::vector< GhostElement > ghost_elements
A list of ghost elements in the mesh.