Loading [MathJax]/extensions/tex2jax.js
OGS
MeshToolsLib::MeshInformation Class Reference

Detailed Description

A set of tools for extracting information from a mesh.

Definition at line 34 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 44 of file MeshInformation.cpp.

45{
46 const std::vector<MeshLib::Node*>& nodes(mesh.getNodes());
47 return GeoLib::AABB(nodes.begin(), nodes.end());
48}
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:108

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 167 of file MeshInformation.cpp.

168{
169 auto const* matids = MeshLib::materialIDs(mesh);
170 if (!matids)
171 {
172 INFO("No MaterialIDs were found.");
173 return {};
174 }
175
176 return *matids | ranges::views::unique | ranges::to<std::vector> |
177 ranges::actions::sort | ranges::actions::unique |
178 ranges::to<std::vector>;
179}
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 51 of file MeshInformation.cpp.

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

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 40 of file MeshInformation.h.

42 {
43 if (property.empty())
44 {
45 INFO("Mesh property vector '{:s}' is empty.",
46 property.getPropertyName());
47 return std::nullopt;
48 }
49
50 auto [min, max] = ranges::minmax(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 63 of file MeshInformation.cpp.

64{
65 auto const& nr_ele_types =
67
68 INFO("Number of elements in the mesh:");
69 for (auto entry : nr_ele_types)
70 {
71 INFO("\t{:s}s: {:d}",
73 static_cast<MeshLib::MeshElemType>(entry.first)),
74 entry.second);
75 }
76}
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 149 of file MeshInformation.cpp.

150{
151 INFO("Mesh Quality Control:");
155
156 unsigned const n_holes(MeshToolsLib::MeshValidation::detectHoles(mesh));
157 if (n_holes > 0)
158 {
159 INFO("{:d} hole(s) detected within the mesh", n_holes);
160 }
161 else
162 {
163 INFO("No holes found within the mesh.");
164 }
165}
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 78 of file MeshInformation.cpp.

79{
80 auto const& properties = mesh.getProperties();
81 INFO("There are {:d} properties in the mesh:", properties.size());
82
83 for (auto [name, property] : properties)
84 {
85 if (auto const* p =
86 dynamic_cast<MeshLib::PropertyVector<double>*>(property))
87 {
88 printBounds(*p);
89 }
90 else if (auto const* p =
91 dynamic_cast<MeshLib::PropertyVector<float>*>(property))
92 {
93 printBounds(*p);
94 }
95 else if (auto const* p =
96 dynamic_cast<MeshLib::PropertyVector<int>*>(property))
97 {
98 printBounds(*p);
99 }
100 else if (auto const* p =
101 dynamic_cast<MeshLib::PropertyVector<unsigned>*>(property))
102 {
103 printBounds(*p);
104 }
105 else if (auto const* p =
106 dynamic_cast<MeshLib::PropertyVector<long>*>(property))
107 {
108 printBounds(*p);
109 }
110 else if (auto const* p =
112 property))
113 {
114 printBounds(*p);
115 }
116 else if (auto const* p =
118 property))
119 {
120 printBounds(*p);
121 }
122 else if (auto const* p =
124 property))
125 {
126 printBounds(*p);
127 }
128 else if (auto const* p =
130 property))
131 {
132 printBounds(*p);
133 }
134 else if (auto const* p =
135 dynamic_cast<MeshLib::PropertyVector<char>*>(property))
136 {
137 printBounds(*p);
138 }
139 else
140 {
141 INFO(
142 "\t{:s}: Could not get value bounds for property vector of "
143 "type '{:s}'.",
144 name, typeid(*p).name());
145 }
146 }
147}
Properties & getProperties()
Definition Mesh.h:136
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: