OGS
MeshInformation.cpp
Go to the documentation of this file.
1
15#include "MeshInformation.h"
16
19
20namespace
21{
22template <typename T>
24{
25 auto const bounds = MeshToolsLib::MeshInformation::getValueBounds(property);
26 if (!bounds.has_value())
27 {
28 INFO("\t{:s}: Could not get value bounds for property vector.",
29 property.getPropertyName());
30 return;
31 }
32 INFO("\t{:s}: ({:d} values) [{}, {}]", property.getPropertyName(),
33 property.size(), bounds->first, bounds->second);
34}
35} // namespace
36
37namespace MeshToolsLib
38{
40{
41 const std::vector<MeshLib::Node*>& nodes(mesh.getNodes());
42 return GeoLib::AABB(nodes.begin(), nodes.end());
43}
44
45std::map<MeshLib::MeshElemType, unsigned>
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}
57
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}
72
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}
143
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}
161
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}
184
185} // namespace MeshToolsLib
Definition of the Element class.
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:35
Definition of the MeshInformation class.
Definition of the MeshValidation class.
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
std::vector< Element * > const & getElements() const
Get the element-vector for the mesh.
Definition Mesh.h:109
Properties & getProperties()
Definition Mesh.h:134
std::string const & getPropertyName() const
std::size_t size() const
static GeoLib::AABB getBoundingBox(const MeshLib::Mesh &mesh)
Returns the bounding box of the mesh.
static void writeMeshValidationResults(MeshLib::Mesh &mesh)
static std::optional< std::pair< T, T > > const getValueBounds(MeshLib::PropertyVector< T > const &property)
static std::vector< int > getMaterialIDs(const MeshLib::Mesh &mesh)
writes out a list of all material IDs that occur in the mesh.
static void writeAllNumbersOfElementTypes(const MeshLib::Mesh &mesh)
writes all numbers of element types
static std::map< MeshLib::MeshElemType, unsigned > getNumberOfElementTypes(const MeshLib::Mesh &mesh)
static void writePropertyVectorInformation(const MeshLib::Mesh &mesh)
writes out property vector information
std::string MeshElemType2String(const MeshElemType t)
Given a MeshElemType this returns the appropriate string.
Definition MeshEnums.cpp:21
PropertyVector< int > const * materialIDs(Mesh const &mesh)
Definition Mesh.cpp:268
MeshElemType
Types of mesh elements supported by OpenGeoSys. Values are from VTKCellType enum.
Definition MeshEnums.h:27
void printBounds(MeshLib::PropertyVector< T > const &property)
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)