OGS
MeshToolsLib::ElementSizeMetric Class Referencefinal

Detailed Description

Calculates the quality of mesh elements based on length/area/volume

Definition at line 25 of file ElementSizeMetric.h.

#include <ElementSizeMetric.h>

Inheritance diagram for MeshToolsLib::ElementSizeMetric:
[legend]
Collaboration diagram for MeshToolsLib::ElementSizeMetric:
[legend]

Public Member Functions

void calculateQuality () override
 Calculates the quality metric for each element of the mesh.
 
 ElementQualityMetric (MeshLib::Mesh const &mesh)
 
- Public Member Functions inherited from MeshToolsLib::ElementQualityMetric
 ElementQualityMetric (MeshLib::Mesh const &mesh)
 
virtual ~ElementQualityMetric ()=default
 
std::vector< double > const & getElementQuality () const
 Returns the result vector.
 
virtual BaseLib::Histogram< double > getHistogram (std::size_t n_bins=0) const
 

Private Member Functions

std::size_t calc1dQuality ()
 
std::size_t calc2dOr3dQuality ()
 

Additional Inherited Members

- Protected Attributes inherited from MeshToolsLib::ElementQualityMetric
double _min = std::numeric_limits<double>::max()
 
double _max = 0
 
MeshLib::Mesh const & _mesh
 
std::vector< double > _element_quality_metric
 

Member Function Documentation

◆ calc1dQuality()

std::size_t MeshToolsLib::ElementSizeMetric::calc1dQuality ( )
private

Definition at line 45 of file ElementSizeMetric.cpp.

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}
std::vector< Element * > const & getElements() const
Get the element-vector for the mesh.
Definition Mesh.h:109
std::vector< double > _element_quality_metric
double computeElementVolumeNumerically(MeshLib::Element const &e)

References MeshToolsLib::ElementQualityMetric::_element_quality_metric, MeshToolsLib::ElementQualityMetric::_max, MeshToolsLib::ElementQualityMetric::_mesh, MeshToolsLib::ElementQualityMetric::_min, MeshToolsLib::computeElementVolumeNumerically(), and MeshLib::Mesh::getElements().

Referenced by calculateQuality().

◆ calc2dOr3dQuality()

std::size_t MeshToolsLib::ElementSizeMetric::calc2dOr3dQuality ( )
private

Definition at line 75 of file ElementSizeMetric.cpp.

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 }
106 }
107 return error_count;
108}
unsigned getDimension() const
Returns the dimension of the mesh (determined by the maximum dimension over all elements).
Definition Mesh.h:88

References MeshToolsLib::ElementQualityMetric::_element_quality_metric, MeshToolsLib::ElementQualityMetric::_max, MeshToolsLib::ElementQualityMetric::_mesh, MeshToolsLib::ElementQualityMetric::_min, MeshToolsLib::computeElementVolumeNumerically(), MeshLib::Element::getDimension(), MeshLib::Mesh::getDimension(), and MeshLib::Mesh::getElements().

Referenced by calculateQuality().

◆ calculateQuality()

void MeshToolsLib::ElementSizeMetric::calculateQuality ( )
overridevirtual

Calculates the quality metric for each element of the mesh.

Implements MeshToolsLib::ElementQualityMetric.

Definition at line 23 of file ElementSizeMetric.cpp.

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}
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

References MeshToolsLib::ElementQualityMetric::_max, MeshToolsLib::ElementQualityMetric::_mesh, MeshToolsLib::ElementQualityMetric::_min, calc1dQuality(), calc2dOr3dQuality(), MeshLib::Mesh::getDimension(), INFO(), and WARN().

◆ ElementQualityMetric()

MeshToolsLib::ElementQualityMetric::ElementQualityMetric ( MeshLib::Mesh const & mesh)
explicit

Definition at line 33 of file ElementQualityMetric.cpp.

24 : _mesh(mesh)
25{
27}
std::size_t getNumberOfElements() const
Get the number of elements.
Definition Mesh.h:97

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