OGS
ElementSizeMetric.cpp
Go to the documentation of this file.
1
15#include "ElementSizeMetric.h"
16
17#include <limits>
18
20
21namespace MeshToolsLib
22{
24{
25 std::size_t error_count(0);
26 if (_mesh.getDimension() == 1)
27 {
28 error_count = calc1dQuality();
29 }
30 else
31 {
32 error_count = calc2dOr3dQuality();
33 }
34
35 INFO(
36 "ElementSizeMetric::calculateQuality() minimum: {:f}, max_volume: {:f}",
37 _min,
38 _max);
39 if (error_count > 0)
40 {
41 WARN("Warning: {:d} elements with zero volume found.", error_count);
42 }
43}
44
46{
47 const std::vector<MeshLib::Element*>& elements(_mesh.getElements());
48 const std::size_t nElems(elements.size());
49 std::size_t error_count(0);
50
51 for (std::size_t k(0); k < nElems; k++)
52 {
53 double area(std::numeric_limits<double>::max());
57 std::sqrt(std::abs(std::numeric_limits<double>::epsilon())))
58 {
59 error_count++;
60 }
61
62 // update _min and _max values
63 if (_min > area)
64 {
65 _min = area;
66 }
67 if (_max < area)
68 {
69 _max = area;
70 }
71 }
72 return error_count;
73}
74
76{
77 const std::vector<MeshLib::Element*>& elements(_mesh.getElements());
78 const std::size_t nElems(elements.size());
79 std::size_t error_count(0);
80
81 for (std::size_t k(0); k < nElems; k++)
82 {
83 MeshLib::Element const& elem(*elements[k]);
84 if (elem.getDimension() < _mesh.getDimension())
85 {
87 continue;
88 }
89
90 double const volume =
92 if (volume < sqrt(std::abs(std::numeric_limits<double>::epsilon())))
93 {
94 error_count++;
95 }
96
97 if (_min > volume)
98 {
99 _min = volume;
100 }
101 if (_max < volume)
102 {
103 _max = volume;
104 }
105 _element_quality_metric[k] = volume;
106 }
107 return error_count;
108}
109
110} // namespace MeshToolsLib
Implementation of the AreaMetric class.
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:35
void WARN(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:40
virtual constexpr unsigned getDimension() const =0
Get dimension of the mesh element.
std::vector< Element * > const & getElements() const
Get the element-vector for the mesh.
Definition Mesh.h:109
unsigned getDimension() const
Returns the dimension of the mesh (determined by the maximum dimension over all elements).
Definition Mesh.h:88
std::vector< double > _element_quality_metric
void calculateQuality() override
Calculates the quality metric for each element of the mesh.
double computeElementVolumeNumerically(MeshLib::Element const &e)