OGS
SizeDifferenceMetric.cpp
Go to the documentation of this file.
1 
15 #include "SizeDifferenceMetric.h"
16 
17 #include <limits>
18 
19 namespace MeshLib
20 {
22 {
23  std::vector<MeshLib::Element*> const& elements(_mesh.getElements());
24  std::size_t const nElements(_mesh.getNumberOfElements());
25  std::size_t const mesh_dim(_mesh.getDimension());
26 
27  for (std::size_t k = 0; k < nElements; ++k)
28  {
29  Element const& elem(*elements[k]);
30  if (elem.getDimension() < mesh_dim)
31  {
33  continue;
34  }
35 
36  std::size_t const n_neighbors(elem.getNumberOfNeighbors());
37  double const vol_a(elem.getContent());
38 
39  double worst_ratio(1.0);
40  for (std::size_t i = 0; i < n_neighbors; ++i)
41  {
42  MeshLib::Element const* const neighbor(elem.getNeighbor(i));
43  if (neighbor == nullptr)
44  {
45  continue;
46  }
47  double const vol_b(neighbor->getContent());
48  double const ratio =
49  (vol_a > vol_b) ? vol_b / vol_a : vol_a / vol_b;
50  if (ratio < worst_ratio)
51  {
52  worst_ratio = ratio;
53  }
54  }
55  _element_quality_metric[k] = worst_ratio;
56  }
57 }
58 
59 } // end namespace MeshLib
Definition of the SizeDifferenceMetric class.
std::vector< double > _element_quality_metric
virtual double getContent() const =0
Returns the length, area or volume of a 1D, 2D or 3D element.
virtual const Element * getNeighbor(unsigned i) const =0
Get the specified neighbor.
virtual unsigned getNumberOfNeighbors() const =0
Get the number of neighbors for this element.
virtual constexpr unsigned getDimension() const =0
Get dimension of the mesh element.
unsigned getDimension() const
Returns the dimension of the mesh (determined by the maximum dimension over all elements).
Definition: Mesh.h:71
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
void calculateQuality() override
Calculates the quality metric for each element of the mesh.