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 16 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 11 of file EdgeRatioMetric.cpp.

12{
13 auto const& elements(_mesh.getElements());
14 auto const n_elements(_mesh.getNumberOfElements());
15 for (std::size_t k(0); k < n_elements; k++)
16 {
17 auto const& elem(*elements[k]);
18 std::unique_ptr<MeshLib::Element const> first_edge{elem.getEdge(0)};
19 auto sqr_min_edge_length =
20 MathLib::sqrDist(*first_edge->getNode(1), *first_edge->getNode(0));
21 auto sqr_max_edge_length = sqr_min_edge_length;
22 auto const n_edges(elem.getNumberOfEdges());
23 for (std::size_t i = 1; i < n_edges; i++)
24 {
25 std::unique_ptr<MeshLib::Element const> edge{elem.getEdge(i)};
26 auto const sqr_edge_length =
27 MathLib::sqrDist(*edge->getNode(1), *edge->getNode(0));
28 if (sqr_edge_length < sqr_min_edge_length)
29 {
30 sqr_min_edge_length = sqr_edge_length;
31 }
32 if (sqr_edge_length > sqr_max_edge_length)
33 {
34 sqr_max_edge_length = sqr_edge_length;
35 }
36 }
38 std::sqrt(sqr_min_edge_length / sqr_max_edge_length);
39 }
40}
std::vector< double > _element_quality_metric
double sqrDist(MathLib::Point3d const &p0, MathLib::Point3d const &p1)
Definition Point3d.cpp:19

References MeshToolsLib::ElementQualityMetric::_element_quality_metric, MeshToolsLib::ElementQualityMetric::_mesh, and MathLib::sqrDist().

◆ ElementQualityMetric()

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

Definition at line 22 of file ElementQualityMetric.cpp.

13 : _mesh(mesh)
14{
15 _element_quality_metric.resize(_mesh.getNumberOfElements(), -1.0);
16}

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