OGS
ElementSizeMetric.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
4#include "ElementSizeMetric.h"
5
6#include <limits>
7
9
10namespace MeshToolsLib
11{
13{
14 std::size_t error_count(0);
15 if (_mesh.getDimension() == 1)
16 {
17 error_count = calc1dQuality();
18 }
19 else
20 {
21 error_count = calc2dOr3dQuality();
22 }
23
24 INFO(
25 "ElementSizeMetric::calculateQuality() minimum: {:f}, max_volume: {:f}",
26 _min,
27 _max);
28 if (error_count > 0)
29 {
30 WARN("Warning: {:d} elements with zero volume found.", error_count);
31 }
32}
33
35{
36 const std::vector<MeshLib::Element*>& elements(_mesh.getElements());
37 const std::size_t nElems(elements.size());
38 std::size_t error_count(0);
39
40 for (std::size_t k(0); k < nElems; k++)
41 {
42 double area(std::numeric_limits<double>::max());
46 std::sqrt(std::abs(std::numeric_limits<double>::epsilon())))
47 {
48 error_count++;
49 }
50
51 // update _min and _max values
52 if (_min > area)
53 {
54 _min = area;
55 }
56 if (_max < area)
57 {
58 _max = area;
59 }
60 }
61 return error_count;
62}
63
65{
66 const std::vector<MeshLib::Element*>& elements(_mesh.getElements());
67 const std::size_t nElems(elements.size());
68 std::size_t error_count(0);
69
70 for (std::size_t k(0); k < nElems; k++)
71 {
72 MeshLib::Element const& elem(*elements[k]);
73 if (elem.getDimension() < _mesh.getDimension())
74 {
76 continue;
77 }
78
79 double const volume =
81 if (volume < sqrt(std::abs(std::numeric_limits<double>::epsilon())))
82 {
83 error_count++;
84 }
85
86 if (_min > volume)
87 {
88 _min = volume;
89 }
90 if (_max < volume)
91 {
92 _max = volume;
93 }
94 _element_quality_metric[k] = volume;
95 }
96 return error_count;
97}
98
99} // namespace MeshToolsLib
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:28
void WARN(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:34
virtual constexpr unsigned getDimension() const =0
Get dimension of the mesh element.
std::vector< double > _element_quality_metric
void calculateQuality() override
Calculates the quality metric for each element of the mesh.
double computeElementVolumeNumerically(MeshLib::Element const &e)