OGS
MeshToolsLib::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 (MeshLib::PropertyVector< T > const &property)
 
static GeoLib::AABB getBoundingBox (const MeshLib::Mesh &mesh)
 Returns the bounding box of the mesh.
 
static std::map< MeshLib::MeshElemType, unsigned > getNumberOfElementTypes (const MeshLib::Mesh &mesh)
 
static void writeAllNumbersOfElementTypes (const MeshLib::Mesh &mesh)
 writes all numbers of element types
 
static void writePropertyVectorInformation (const MeshLib::Mesh &mesh)
 writes out property vector information
 
static void writeMeshValidationResults (MeshLib::Mesh &mesh)
 
static std::vector< int > getMaterialIDs (const MeshLib::Mesh &mesh)
 writes out a list of all material IDs that occur in the mesh.
 

Member Function Documentation

◆ getBoundingBox()

GeoLib::AABB MeshToolsLib::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:56
std::vector< Node * > const & getNodes() const
Get the nodes-vector for the mesh.
Definition Mesh.h:106

References MeshLib::Mesh::getNodes().

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

◆ getMaterialIDs()

std::vector< int > MeshToolsLib::MeshInformation::getMaterialIDs ( const MeshLib::Mesh & mesh)
static

writes out a list of all material IDs that occur in the mesh.

Definition at line 162 of file MeshInformation.cpp.

163{
164 auto const* matids = MeshLib::materialIDs(mesh);
165 if (!matids)
166 {
167 INFO("No MaterialIDs were found.");
168 return {};
169 }
170 std::vector<int> unique_matids = {};
171
172 for (auto matid : *matids)
173 {
174 if (std::find(unique_matids.begin(), unique_matids.end(), matid) ==
175 unique_matids.end())
176 {
177 unique_matids.push_back(matid);
178 }
179 }
180 std::sort(unique_matids.begin(), unique_matids.end());
181
182 return unique_matids;
183}
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:35
PropertyVector< int > const * materialIDs(Mesh const &mesh)
Definition Mesh.cpp:268

References INFO(), and MeshLib::materialIDs().

Referenced by main().

◆ getNumberOfElementTypes()

std::map< MeshLib::MeshElemType, unsigned > MeshToolsLib::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 46 of file MeshInformation.cpp.

47{
48 std::map<MeshLib::MeshElemType, unsigned> n_element_types;
49 const std::vector<MeshLib::Element*>& elements(mesh.getElements());
50 for (auto element : elements)
51 {
52 MeshLib::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:109
MeshElemType
Types of mesh elements supported by OpenGeoSys. Values are from VTKCellType enum.
Definition MeshEnums.h:27

References MeshLib::Mesh::getElements().

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

◆ getValueBounds()

template<typename T >
static std::optional< std::pair< T, T > > const MeshToolsLib::MeshInformation::getValueBounds ( MeshLib::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 }
std::string const & getPropertyName() const

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

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

◆ writeAllNumbersOfElementTypes()

void MeshToolsLib::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< MeshLib::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 MeshToolsLib::MeshInformation::writeMeshValidationResults ( MeshLib::Mesh & mesh)
static

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

Definition at line 144 of file MeshInformation.cpp.

145{
146 INFO("Mesh Quality Control:");
150
151 unsigned const n_holes(MeshToolsLib::MeshValidation::detectHoles(mesh));
152 if (n_holes > 0)
153 {
154 INFO("{:d} hole(s) detected within the mesh", n_holes);
155 }
156 else
157 {
158 INFO("No holes found within the mesh.");
159 }
160}
static bool existCollapsibleNodes(MeshLib::Mesh &mesh)
static unsigned detectHoles(MeshLib::Mesh const &mesh)
static bool allNodesUsed(MeshLib::Mesh const &mesh)
static void evaluateElementGeometry(MeshLib::Mesh const &mesh)

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

Referenced by main().

◆ writePropertyVectorInformation()

void MeshToolsLib::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 const* p =
81 dynamic_cast<MeshLib::PropertyVector<double>*>(property))
82 {
83 printBounds(*p);
84 }
85 else if (auto const* p =
86 dynamic_cast<MeshLib::PropertyVector<float>*>(property))
87 {
88 printBounds(*p);
89 }
90 else if (auto const* p =
91 dynamic_cast<MeshLib::PropertyVector<int>*>(property))
92 {
93 printBounds(*p);
94 }
95 else if (auto const* p =
96 dynamic_cast<MeshLib::PropertyVector<unsigned>*>(property))
97 {
98 printBounds(*p);
99 }
100 else if (auto const* p =
101 dynamic_cast<MeshLib::PropertyVector<long>*>(property))
102 {
103 printBounds(*p);
104 }
105 else if (auto const* p =
107 property))
108 {
109 printBounds(*p);
110 }
111 else if (auto const* p =
113 property))
114 {
115 printBounds(*p);
116 }
117 else if (auto const* p =
119 property))
120 {
121 printBounds(*p);
122 }
123 else if (auto const* p =
125 property))
126 {
127 printBounds(*p);
128 }
129 else if (auto const* p =
130 dynamic_cast<MeshLib::PropertyVector<char>*>(property))
131 {
132 printBounds(*p);
133 }
134 else
135 {
136 INFO(
137 "\t{:s}: Could not get value bounds for property vector of "
138 "type '{:s}'.",
139 name, typeid(*p).name());
140 }
141 }
142}
Properties & getProperties()
Definition Mesh.h:134
void printBounds(MeshLib::PropertyVector< T > const &property)

References MeshLib::Mesh::getProperties(), and INFO().

Referenced by main().


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