OGS
MeshLib::MeshInformation Class Reference

Detailed Description

A set of tools for extracting information from a mesh.

Definition at line 33 of file MeshInformation.h.

#include <MeshInformation.h>

Static Public Member Functions

template<typename T >
static std::optional< std::pair< T, T > > const getValueBounds (PropertyVector< T > const &property)
 
static GeoLib::AABB getBoundingBox (const MeshLib::Mesh &mesh)
 Returns the bounding box of the mesh. More...
 
static std::map< MeshElemType, unsigned > getNumberOfElementTypes (const MeshLib::Mesh &mesh)
 
static void writeAllNumbersOfElementTypes (const MeshLib::Mesh &mesh)
 writes all numbers of element types More...
 
static void writePropertyVectorInformation (const MeshLib::Mesh &mesh)
 writes out property vector information More...
 
static void writeMeshValidationResults (MeshLib::Mesh &mesh)
 

Member Function Documentation

◆ getBoundingBox()

GeoLib::AABB MeshLib::MeshInformation::getBoundingBox ( const MeshLib::Mesh mesh)
static

Returns the bounding box of the mesh.

Definition at line 39 of file MeshInformation.cpp.

40{
41 const std::vector<MeshLib::Node*>& nodes(mesh.getNodes());
42 return GeoLib::AABB(nodes.begin(), nodes.end());
43}
Class AABB is an axis aligned bounding box around a given set of geometric points of (template) type ...
Definition: AABB.h:55
std::vector< Node * > const & getNodes() const
Get the nodes-vector for the mesh.
Definition: Mesh.h:100

References MeshLib::Mesh::getNodes().

Referenced by main(), and ElementTreeModel::setMesh().

◆ getNumberOfElementTypes()

std::map< MeshElemType, unsigned > MeshLib::MeshInformation::getNumberOfElementTypes ( const MeshLib::Mesh mesh)
static

Returns an array with the number of elements of each type in the given mesh. On completion, n_element_types array contains the number of elements of each of the seven supported types. The index to element type conversion is this: 0: #lines 1: #triangles 2: #quads 3: #tetrahedra 4: #hexahedra 5: #pyramids 6: #prisms

Definition at line 45 of file MeshInformation.cpp.

47{
48 std::map<MeshElemType, unsigned> n_element_types;
49 const std::vector<MeshLib::Element*>& elements(mesh.getElements());
50 for (auto element : elements)
51 {
52 MeshElemType t = element->getGeomType();
53 n_element_types[t]++;
54 }
55 return n_element_types;
56}
std::vector< Element * > const & getElements() const
Get the element-vector for the mesh.
Definition: Mesh.h:103
static const double t
MeshElemType
Types of mesh elements supported by OpenGeoSys. Values are from VTKCellType enum.
Definition: MeshEnums.h:27

References MeshLib::Mesh::getElements(), and MathLib::t.

Referenced by LayeredMeshGenerator::createLayers(), ElementTreeModel::setMesh(), FileIO::TetGenInterface::write2dElements(), and writeAllNumbersOfElementTypes().

◆ getValueBounds()

template<typename T >
static std::optional< std::pair< T, T > > const MeshLib::MeshInformation::getValueBounds ( PropertyVector< T > const &  property)
inlinestatic

Returns the smallest and largest value of a scalar array with the given name.

Definition at line 39 of file MeshInformation.h.

41 {
42 if (property.empty())
43 {
44 INFO("Mesh property vector '{:s}' is empty.",
45 property.getPropertyName());
46 return std::nullopt;
47 }
48
49 auto const [min, max] =
50 std::minmax_element(begin(property), end(property));
51 return {{*min, *max}};
52 }
void INFO(char const *fmt, Args const &... args)
Definition: Logging.h:34

References MeshLib::PropertyVectorBase::getPropertyName(), and INFO().

Referenced by ProcessLib::LIE::HydroMechanics::HydroMechanicsProcess< GlobalDim >::HydroMechanicsProcess(), MeshLib::convertMeshToGeo(), anonymous_namespace{MeshInformation.cpp}::printBounds(), and anonymous_namespace{ElementTreeModel.cpp}::propertyBounds().

◆ writeAllNumbersOfElementTypes()

void MeshLib::MeshInformation::writeAllNumbersOfElementTypes ( const MeshLib::Mesh mesh)
static

writes all numbers of element types

Definition at line 58 of file MeshInformation.cpp.

59{
60 auto const& nr_ele_types =
62
63 INFO("Number of elements in the mesh:");
64 for (auto entry : nr_ele_types)
65 {
66 INFO("\t{:s}s: {:d}",
68 static_cast<MeshLib::MeshElemType>(entry.first)),
69 entry.second);
70 }
71}
static std::map< MeshElemType, unsigned > getNumberOfElementTypes(const MeshLib::Mesh &mesh)
std::string MeshElemType2String(const MeshElemType t)
Given a MeshElemType this returns the appropriate string.
Definition: MeshEnums.cpp:21

References getNumberOfElementTypes(), INFO(), and MeshLib::MeshElemType2String().

Referenced by main().

◆ writeMeshValidationResults()

void MeshLib::MeshInformation::writeMeshValidationResults ( MeshLib::Mesh mesh)
static

writes out mesh validation results Remark: MeshValidation can modify the original mesh

Definition at line 132 of file MeshInformation.cpp.

133{
134 INFO("Mesh Quality Control:");
138
139 unsigned const n_holes(MeshLib::MeshValidation::detectHoles(mesh));
140 if (n_holes > 0)
141 {
142 INFO("{:d} hole(s) detected within the mesh", n_holes);
143 }
144 else
145 {
146 INFO("No holes found within the mesh.");
147 }
148}
static bool existCollapsibleNodes(MeshLib::Mesh &mesh)
static bool allNodesUsed(MeshLib::Mesh const &mesh)
static void evaluateElementGeometry(MeshLib::Mesh const &mesh)
static unsigned detectHoles(MeshLib::Mesh const &mesh)

References MeshLib::MeshValidation::allNodesUsed(), MeshLib::MeshValidation::detectHoles(), MeshLib::MeshValidation::evaluateElementGeometry(), MeshLib::MeshValidation::existCollapsibleNodes(), and INFO().

Referenced by main().

◆ writePropertyVectorInformation()

void MeshLib::MeshInformation::writePropertyVectorInformation ( const MeshLib::Mesh mesh)
static

writes out property vector information

Definition at line 73 of file MeshInformation.cpp.

74{
75 auto const& properties = mesh.getProperties();
76 INFO("There are {:d} properties in the mesh:", properties.size());
77
78 for (auto [name, property] : properties)
79 {
80 if (auto p = dynamic_cast<PropertyVector<double>*>(property))
81 {
82 printBounds(*p);
83 }
84 else if (auto p = dynamic_cast<PropertyVector<float>*>(property))
85 {
86 printBounds(*p);
87 }
88 else if (auto p = dynamic_cast<PropertyVector<int>*>(property))
89 {
90 printBounds(*p);
91 }
92 else if (auto p = dynamic_cast<PropertyVector<unsigned>*>(property))
93 {
94 printBounds(*p);
95 }
96 else if (auto p = dynamic_cast<PropertyVector<long>*>(property))
97 {
98 printBounds(*p);
99 }
100 else if (auto p = dynamic_cast<PropertyVector<long long>*>(property))
101 {
102 printBounds(*p);
103 }
104 else if (auto p =
105 dynamic_cast<PropertyVector<unsigned long>*>(property))
106 {
107 printBounds(*p);
108 }
109 else if (auto p = dynamic_cast<PropertyVector<unsigned long long>*>(
110 property))
111 {
112 printBounds(*p);
113 }
114 else if (auto p = dynamic_cast<PropertyVector<std::size_t>*>(property))
115 {
116 printBounds(*p);
117 }
118 else if (auto p = dynamic_cast<PropertyVector<char>*>(property))
119 {
120 printBounds(*p);
121 }
122 else
123 {
124 INFO(
125 "\t{:s}: Could not get value bounds for property vector of "
126 "type '{:s}'.",
127 name, typeid(*p).name());
128 }
129 }
130}
Properties & getProperties()
Definition: Mesh.h:128
void printBounds(MeshLib::PropertyVector< T > const &property)

References MeshLib::Mesh::getProperties(), INFO(), MaterialPropertyLib::name, and anonymous_namespace{MeshInformation.cpp}::printBounds().

Referenced by main().


The documentation for this class was generated from the following files: