OGS
MeshLib::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 26 of file EdgeRatioMetric.h.

#include <EdgeRatioMetric.h>

Inheritance diagram for MeshLib::EdgeRatioMetric:
[legend]
Collaboration diagram for MeshLib::EdgeRatioMetric:
[legend]

Public Member Functions

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

Additional Inherited Members

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

Member Function Documentation

◆ calculateQuality()

void MeshLib::EdgeRatioMetric::calculateQuality ( )
overridevirtual

Calculates the quality metric for each element of the mesh.

Implements MeshLib::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<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<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< double > _element_quality_metric
std::vector< Element * > const & getElements() const
Get the element-vector for the mesh.
Definition: Mesh.h:98
std::size_t getNumberOfElements() const
Get the number of elements.
Definition: Mesh.h:86
double sqrDist(MathLib::Point3d const &p0, MathLib::Point3d const &p1)
Definition: Point3d.h:48

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

◆ ElementQualityMetric()

MeshLib::ElementQualityMetric::ElementQualityMetric
explicit

Definition at line 33 of file ElementQualityMetric.cpp.

23  : _mesh(mesh)
24 {
26 }

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