OGS
MeshToolsLib::MeshInformation Class Reference

Detailed Description

A set of tools for extracting information from a mesh.

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

35{
36 const std::vector<MeshLib::Node*>& nodes(mesh.getNodes());
37 return GeoLib::AABB(nodes.begin(), nodes.end());
38}
std::vector< Node * > const & getNodes() const
Get the nodes-vector for the mesh.
Definition Mesh.h:97

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

158{
159 auto const* matids = MeshLib::materialIDs(mesh);
160 if (!matids)
161 {
162 INFO("No MaterialIDs were found.");
163 return {};
164 }
165
166 return *matids | ranges::views::unique | ranges::to<std::vector> |
167 ranges::actions::sort | ranges::actions::unique |
168 ranges::to<std::vector>;
169}
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:28
PropertyVector< int > const * materialIDs(Mesh const &mesh)
Definition Mesh.cpp:258

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

42{
43 std::map<MeshLib::MeshElemType, unsigned> n_element_types;
44 const std::vector<MeshLib::Element*>& elements(mesh.getElements());
45 for (auto element : elements)
46 {
47 MeshLib::MeshElemType t = element->getGeomType();
48 n_element_types[t]++;
49 }
50 return n_element_types;
51}
std::vector< Element * > const & getElements() const
Get the element-vector for the mesh.
Definition Mesh.h:100
MeshElemType
Types of mesh elements supported by OpenGeoSys. Values are from VTKCellType enum.
Definition MeshEnums.h:37

References MeshLib::Mesh::getElements().

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

◆ getValueBounds()

template<typename T>
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 29 of file MeshInformation.h.

31 {
32 if (property.empty())
33 {
34 INFO("Mesh property vector '{:s}' is empty.",
35 property.getPropertyName());
36 return std::nullopt;
37 }
38
39 auto [min, max] = ranges::minmax(property);
40 return {{min, max}};
41 }
std::string const & getPropertyName() const
constexpr bool empty() const

References MeshLib::PropertyVector< PROP_VAL_TYPE >::empty(), MeshLib::PropertyVectorBase::getPropertyName(), and INFO().

Referenced by ProcessLib::LIE::HydroMechanics::HydroMechanicsProcess< DisplacementDim >::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 53 of file MeshInformation.cpp.

54{
55 auto const& nr_ele_types =
57
58 INFO("Number of elements in the mesh:");
59 for (auto entry : nr_ele_types)
60 {
61 INFO("\t{:s}s: {:d}",
63 static_cast<MeshLib::MeshElemType>(entry.first)),
64 entry.second);
65 }
66}
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:10

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

140{
141 INFO("Mesh Quality Control:");
145
146 unsigned const n_holes(MeshToolsLib::MeshValidation::detectHoles(mesh));
147 if (n_holes > 0)
148 {
149 INFO("{:d} hole(s) detected within the mesh", n_holes);
150 }
151 else
152 {
153 INFO("No holes found within the mesh.");
154 }
155}
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 68 of file MeshInformation.cpp.

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

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

Referenced by main().


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