OGS
MeshToolsLib::SizeDifferenceMetric Struct Referencefinal

Detailed Description

Calculates the quality of mesh elements based on the difference of element size in comparison to the size of its neighbors.

Definition at line 26 of file SizeDifferenceMetric.h.

#include <SizeDifferenceMetric.h>

Inheritance diagram for MeshToolsLib::SizeDifferenceMetric:
[legend]
Collaboration diagram for MeshToolsLib::SizeDifferenceMetric:
[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
 

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

◆ calculateQuality()

void MeshToolsLib::SizeDifferenceMetric::calculateQuality ( )
overridevirtual

Calculates the quality metric for each element of the mesh.

Implements MeshToolsLib::ElementQualityMetric.

Definition at line 21 of file SizeDifferenceMetric.cpp.

22{
23 std::vector<MeshLib::Element*> const& elements(_mesh.getElements());
24 std::size_t const nElements(_mesh.getNumberOfElements());
25 std::size_t const mesh_dim(_mesh.getDimension());
26
27 for (std::size_t k = 0; k < nElements; ++k)
28 {
29 MeshLib::Element const& elem(*elements[k]);
30 if (elem.getDimension() < mesh_dim)
31 {
33 continue;
34 }
35
36 std::size_t const n_neighbors(elem.getNumberOfNeighbors());
37 double const vol_a(elem.getContent());
38
39 double worst_ratio(1.0);
40 for (std::size_t i = 0; i < n_neighbors; ++i)
41 {
42 MeshLib::Element const* const neighbor(elem.getNeighbor(i));
43 if (neighbor == nullptr)
44 {
45 continue;
46 }
47 double const vol_b(neighbor->getContent());
48 double const ratio =
49 (vol_a > vol_b) ? vol_b / vol_a : vol_a / vol_b;
50 if (ratio < worst_ratio)
51 {
52 worst_ratio = ratio;
53 }
54 }
55 _element_quality_metric[k] = worst_ratio;
56 }
57}
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::size_t getNumberOfElements() const
Get the number of elements.
Definition Mesh.h:97
std::vector< double > _element_quality_metric

References MeshToolsLib::ElementQualityMetric::_element_quality_metric, MeshToolsLib::ElementQualityMetric::_mesh, MeshLib::Element::getContent(), MeshLib::Element::getDimension(), MeshLib::Mesh::getDimension(), MeshLib::Mesh::getElements(), MeshLib::Element::getNeighbor(), MeshLib::Mesh::getNumberOfElements(), and MeshLib::Element::getNumberOfNeighbors().

◆ ElementQualityMetric()

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

Definition at line 33 of file ElementQualityMetric.cpp.

24 : _mesh(mesh)
25{
27}

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