LehrFEM++ 1.0.0
A simple Finite Element Library for teaching
|
Reads a Gmsh *.msh
file into a mesh::MeshFactory and provides a link between mesh::Entity objects and the gmsh's physical entities.
More...
#include <lf/io/gmsh_reader.h>
Public Types | |
using | size_type = mesh::Mesh::size_type |
using | dim_t = base::RefEl::dim_t |
using | GmshFileVariant = std::variant<GMshFileV2, GMshFileV4> |
Public Member Functions | |
std::shared_ptr< mesh::Mesh > | mesh () |
Get the mesh that was read by this reader. | |
std::shared_ptr< const mesh::Mesh > | mesh () const |
Get the mesh that was read by this reader. | |
size_type | PhysicalEntityName2Nr (const std::string &name, dim_t codim=-1) const |
maps the name of a physical entity to the physical entity number of gmsh. | |
std::string | PhysicalEntityNr2Name (size_type number, dim_t codim=-1) const |
Gives the name of a physical entity (inverse of PhysicalEntityName2Nr()) | |
std::vector< std::pair< size_type, std::string > > | PhysicalEntities (dim_t codim) const |
Retrieve a list of all (Gmsh) physical entities of the given codim. | |
std::vector< size_type > | PhysicalEntityNr (const mesh::Entity &e) const |
Return the Physical Entity Numbers associated with this mesh entity, sorted ascending. | |
bool | IsPhysicalEntity (const mesh::Entity &e, size_type physical_entity_nr) const |
Test whether the given entity belongs to a Gmsh physical entity. | |
GmshReader (std::unique_ptr< mesh::MeshFactory > factory, const GmshFileVariant &msh_file) | |
Create a new GmshReader from the given MshFile (advanced usage) | |
GmshReader (std::unique_ptr< mesh::MeshFactory > factory, const std::string &filename) | |
Create a new GmshReader by reading from the specified file. | |
Private Member Functions | |
void | InitGmshFile (const GMshFileV2 &msh_file) |
void | InitGmshFile (const GMshFileV4 &msh_file) |
Private Attributes | |
std::shared_ptr< mesh::Mesh > | mesh_ |
The underlying grid created by the grid factory. | |
std::unique_ptr< mesh::MeshFactory > | mesh_factory_ |
std::shared_ptr< mesh::utils::AllCodimMeshDataSet< std::vector< size_type > > > | physical_nrs_ |
The PhysicalEntityNr of every entity (0 if not set): | |
std::multimap< std::string, std::pair< size_type, dim_t > > | name_2_nr_ |
Map from physicalEntity name -> nr, codim. | |
std::multimap< size_type, std::pair< std::string, dim_t > > | nr_2_name_ |
Map from physicalEntity nr -> name, codim. | |
Reads a Gmsh *.msh
file into a mesh::MeshFactory and provides a link between mesh::Entity objects and the gmsh's physical entities.
In order to import the *.msh
file successfully make sure that:
*.msh
file format (Version 2 ASCII
, Version 2 Binary
, Version 4 ASCII
or Version 4 Binary
)Save all (ignore physical groups)
and make sure that every surface (2d) / volume (3d) belongs to at least one physical entity. (Otherwise the corresponding mesh elements are not exported by Gmsh)Save all (ignore physical groups)
.The import of meshes from Gmsh-generated mesh files is also discussed in Lecture Document Example 2.7.1.11.
In principle, Gmsh can export meshes that are not "complete", i.e. meshes containing entities with codim>0 that are not sub-entities of cell-entities. Also, if Gmsh exports a higher-order mesh, it has to introduce "auxilliary nodes" in order to define the higher-order mesh elements (these auxilliary nodes are normally placed on edges, faces or in the interior of cells).
Since incomplete meshes are usually not useful in a FEM context, GmshReader doesn't insert into the mesh auxilliary nodes or nodes not belonging to at least one cell. Auxilliary nodes are however used in the construction of higher order geometry objects.
Definition at line 70 of file gmsh_reader.h.
Definition at line 73 of file gmsh_reader.h.
using lf::io::GmshReader::GmshFileVariant = std::variant<GMshFileV2, GMshFileV4> |
Definition at line 74 of file gmsh_reader.h.
Definition at line 72 of file gmsh_reader.h.
lf::io::GmshReader::GmshReader | ( | std::unique_ptr< mesh::MeshFactory > | factory, |
const GmshFileVariant & | msh_file ) |
Create a new GmshReader from the given MshFile (advanced usage)
factory | The mesh::MeshFactory that is used to construct the mesh. |
msh_file | A LehrFEM++ specific representation of a GmshFile. |
Definition at line 24 of file gmsh_reader.cc.
References InitGmshFile().
lf::io::GmshReader::GmshReader | ( | std::unique_ptr< mesh::MeshFactory > | factory, |
const std::string & | filename ) |
Create a new GmshReader by reading from the specified file.
factory | The mesh::MeshFactory that is used to construct the mesh. |
filename | The filename of the .msh file that is read. |
factory.DimWorld() == 3
, there must be at least one 3D mesh element in the *.msh file. Similarly, if factory.DimWorld() == 2
there should be only 2D mesh elements in the *.msh file! .msh
files. Definition at line 30 of file gmsh_reader.cc.
|
private |
Definition at line 120 of file gmsh_reader.cc.
References lf::io::DimOf(), lf::io::GMshFileV2::EDGE2, lf::io::GMshFileV2::EDGE3, lf::io::GMshFileV2::Elements, lf::base::RefEl::kPoint(), lf::base::RefEl::kQuad(), lf::base::RefEl::kSegment(), lf::base::RefEl::kTria(), mesh_, mesh_factory_, name_2_nr_, lf::io::GMshFileV2::Nodes, nr_2_name_, lf::io::GMshFileV2::Periodic, physical_nrs_, lf::io::GMshFileV2::PhysicalEntities, lf::io::GMshFileV2::POINT, lf::io::GMshFileV2::QUAD4, lf::io::GMshFileV2::QUAD8, lf::io::GMshFileV2::QUAD9, lf::io::RefElOf(), lf::io::GMshFileV2::TRIA3, and lf::io::GMshFileV2::TRIA6.
Referenced by GmshReader().
|
private |
Definition at line 349 of file gmsh_reader.cc.
References lf::io::DimOf(), lf::io::GMshFileV4::EDGE2, lf::io::GMshFileV4::EDGE3, lf::io::GMshFileV4::Elements::element_blocks, lf::io::GMshFileV4::elements, lf::io::GMshFileV4::entities, lf::base::RefEl::kPoint(), lf::base::RefEl::kQuad(), lf::base::RefEl::kSegment(), lf::base::RefEl::kTria(), lf::io::GMshFileV4::Nodes::max_node_tag, mesh_, mesh_factory_, lf::io::GMshFileV4::Nodes::min_node_tag, name_2_nr_, lf::io::GMshFileV4::Nodes::node_blocks, lf::io::GMshFileV4::nodes, nr_2_name_, lf::io::GMshFileV4::PartitionedEntities::num_partitions, lf::io::GMshFileV4::PartitionedEntities::partitioned_entities, lf::io::GMshFileV4::partitioned_entities, lf::io::GMshFileV4::periodic_links, lf::io::GMshFileV4::physical_names, physical_nrs_, lf::io::GMshFileV4::QUAD4, lf::io::GMshFileV4::QUAD8, lf::io::GMshFileV4::QUAD9, lf::io::RefElOf(), lf::io::GMshFileV4::TRIA3, and lf::io::GMshFileV4::TRIA6.
bool lf::io::GmshReader::IsPhysicalEntity | ( | const mesh::Entity & | e, |
size_type | physical_entity_nr ) const |
Test whether the given entity belongs to a Gmsh physical entity.
e | The entity that should be tested. |
physical_entity_nr | The number of the gmsh physical entity. |
e
belongs to the physical entity.This method is related to the method PhysicalEntityNr(): It returns true, if the vector returned by PhysicalEntityNr(e)
contains physical_entity_nr
Definition at line 17 of file gmsh_reader.cc.
References PhysicalEntityNr().
|
inline |
Get the mesh that was read by this reader.
Definition at line 79 of file gmsh_reader.h.
References mesh_.
|
inline |
Get the mesh that was read by this reader.
Definition at line 84 of file gmsh_reader.h.
References mesh_.
std::vector< std::pair< size_type, std::string > > lf::io::GmshReader::PhysicalEntities | ( | dim_t | codim | ) | const |
Retrieve a list of all (Gmsh) physical entities of the given codim.
codim | The codimension |
See the code snippet in the documentation of GmshReader.
Definition at line 102 of file gmsh_reader.cc.
References nr_2_name_.
size_type lf::io::GmshReader::PhysicalEntityName2Nr | ( | const std::string & | name, |
dim_t | codim = -1 ) const |
maps the name of a physical entity to the physical entity number of gmsh.
name | Name of the physical entity. |
codim | Optionally the codimension of the physical entity (w.r.t dimMesh), only needed if there are physical entities with the same name but different dimensions. |
Definition at line 34 of file gmsh_reader.cc.
References name_2_nr_.
std::vector< size_type > lf::io::GmshReader::PhysicalEntityNr | ( | const mesh::Entity & | e | ) | const |
Return the Physical Entity Numbers associated with this mesh entity, sorted ascending.
e | The entity of the grid. |
Definition at line 114 of file gmsh_reader.cc.
References physical_nrs_.
Referenced by IsPhysicalEntity().
Gives the name of a physical entity (inverse of PhysicalEntityName2Nr())
number | The number of the physical entity (as obtained from PhysicalEntityName2Nr() ) |
codim | Specify additionally the codimension of the physical entity. If not specified and there is exactly one physical entity with the given number, that entity is returned. If there are multiple entities with the same number and codim=-1 , an error is thrown. |
number
Definition at line 68 of file gmsh_reader.cc.
References nr_2_name_.
|
private |
The underlying grid created by the grid factory.
Definition at line 178 of file gmsh_reader.h.
Referenced by InitGmshFile(), InitGmshFile(), mesh(), and mesh().
|
private |
Definition at line 180 of file gmsh_reader.h.
Referenced by InitGmshFile(), and InitGmshFile().
Map from physicalEntity name -> nr, codim.
Definition at line 187 of file gmsh_reader.h.
Referenced by InitGmshFile(), InitGmshFile(), and PhysicalEntityName2Nr().
Map from physicalEntity nr -> name, codim.
Definition at line 190 of file gmsh_reader.h.
Referenced by InitGmshFile(), InitGmshFile(), PhysicalEntities(), and PhysicalEntityNr2Name().
|
private |
The PhysicalEntityNr of every entity (0 if not set):
Definition at line 184 of file gmsh_reader.h.
Referenced by InitGmshFile(), InitGmshFile(), and PhysicalEntityNr().