OGS
RadiusEdgeRatioMetric.cpp
Go to the documentation of this file.
1 
15 #include "RadiusEdgeRatioMetric.h"
16 
18 #include "MeshLib/Node.h"
19 
20 namespace MeshLib
21 {
23 {
24  std::vector<MeshLib::Element*> const& elements(_mesh.getElements());
25  std::size_t const nElements(_mesh.getNumberOfElements());
26  for (std::size_t k(0); k < nElements; k++)
27  {
28  Element const& elem(*elements[k]);
29  std::size_t const n_nodes(elem.getNumberOfBaseNodes());
30  std::vector<MathLib::Point3d*> pnts(n_nodes);
31  std::copy_n(elem.getNodes(), n_nodes, pnts.begin());
32  GeoLib::MinimalBoundingSphere const s(pnts);
33  auto const& [min, max] = computeSqrEdgeLengthRange(elem);
34  _element_quality_metric[k] = std::sqrt(min) / (2 * s.getRadius());
35  }
36 }
37 
38 } // end namespace MeshLib
Calculation of a minimum bounding sphere for a vector of points.
Definition of the Node class.
Definition of the RadiusEdgeRatioMetric class.
double getRadius() const
Returns the radius of the sphere.
std::vector< double > _element_quality_metric
virtual Node *const * getNodes() const =0
Get array of element nodes.
virtual unsigned getNumberOfBaseNodes() const =0
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
std::pair< double, double > computeSqrEdgeLengthRange(Element const &element)
Compute the minimum and maximum squared edge length for this element.
Definition: Element.cpp:162
void calculateQuality() override
Calculates the quality metric for each element of the mesh.