OGS
MeshToolsLib::EdgeRatioMetric Struct Referencefinal

Detailed Description

Calculates the quality of mesh elements based on the ratio between shortest and longest edge of an element

Definition at line 27 of file EdgeRatioMetric.h.

#include <EdgeRatioMetric.h>

Inheritance diagram for MeshToolsLib::EdgeRatioMetric:
[legend]
Collaboration diagram for MeshToolsLib::EdgeRatioMetric:
[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::EdgeRatioMetric::calculateQuality ( )
overridevirtual

Calculates the quality metric for each element of the mesh.

Implements MeshToolsLib::ElementQualityMetric.

Definition at line 22 of file EdgeRatioMetric.cpp.

23{
24 auto const& elements(_mesh.getElements());
25 auto const n_elements(_mesh.getNumberOfElements());
26 for (std::size_t k(0); k < n_elements; k++)
27 {
28 auto const& elem(*elements[k]);
29 std::unique_ptr<MeshLib::Element const> first_edge{elem.getEdge(0)};
30 auto sqr_min_edge_length =
31 MathLib::sqrDist(*first_edge->getNode(1), *first_edge->getNode(0));
32 auto sqr_max_edge_length = sqr_min_edge_length;
33 auto const n_edges(elem.getNumberOfEdges());
34 for (std::size_t i = 1; i < n_edges; i++)
35 {
36 std::unique_ptr<MeshLib::Element const> edge{elem.getEdge(i)};
37 auto const sqr_edge_length =
38 MathLib::sqrDist(*edge->getNode(1), *edge->getNode(0));
39 if (sqr_edge_length < sqr_min_edge_length)
40 {
41 sqr_min_edge_length = sqr_edge_length;
42 }
43 if (sqr_edge_length > sqr_max_edge_length)
44 {
45 sqr_max_edge_length = sqr_edge_length;
46 }
47 }
49 std::sqrt(sqr_min_edge_length / sqr_max_edge_length);
50 }
51}
std::vector< Element * > const & getElements() const
Get the element-vector for the mesh.
Definition Mesh.h:109
std::size_t getNumberOfElements() const
Get the number of elements.
Definition Mesh.h:97
std::vector< double > _element_quality_metric
double sqrDist(MathLib::Point3d const &p0, MathLib::Point3d const &p1)
Definition Point3d.cpp:26

References MeshToolsLib::ElementQualityMetric::_element_quality_metric, MeshToolsLib::ElementQualityMetric::_mesh, MeshLib::Mesh::getElements(), MeshLib::Mesh::getNumberOfElements(), and MathLib::sqrDist().

◆ 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: