OGS
EdgeRatioMetric.cpp
Go to the documentation of this file.
1
15#include "EdgeRatioMetric.h"
16
17#include "MathLib/MathTools.h"
18#include "MeshLib/Node.h"
19
20namespace MeshToolsLib
21{
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}
52
53} // namespace MeshToolsLib
Definition of the EdgeRatioMetric class.
Definition of the Node class.
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
void calculateQuality() override
Calculates the quality metric for each element of the mesh.