OGS
ElementQualityInterface.h
Go to the documentation of this file.
1
15#pragma once
16
17#include <memory>
18#include <vector>
19
20#include "BaseLib/Histogram.h"
21#include "MeshLib/Mesh.h"
28
29namespace MeshLib
30{
31
36{
37public:
40 : _type(t), _mesh(mesh), _quality_tester(nullptr)
41 {
43 }
44
46 std::vector<double> const getQualityVector() const
47 {
49 return _quality_tester->getElementQuality();
50
51 std::vector<double> empty_quality_vec(0);
52 return empty_quality_vec;
53 }
54
57 BaseLib::Histogram<double> getHistogram(std::size_t n_bins = 0) const
58 {
60 return _quality_tester->getHistogram(static_cast<std::size_t>(n_bins));
61
63 }
64
66 int writeHistogram(std::string const& file_name, std::size_t n_bins = 0) const
67 {
68 if (_quality_tester == nullptr)
69 return 1;
70
71 BaseLib::Histogram<double> const histogram (_quality_tester->getHistogram(n_bins));
72 histogram.write(file_name, _mesh.getName(), MeshQualityType2String(_type));
73 return 0;
74 }
75
76private:
79 {
81 _quality_tester = std::make_unique<MeshLib::EdgeRatioMetric>(mesh);
82 else if (t == MeshQualityType::ELEMENTSIZE)
84 std::make_unique<MeshLib::ElementSizeMetric>(mesh);
87 std::make_unique<MeshLib::SizeDifferenceMetric>(mesh);
89 _quality_tester = std::make_unique<MeshLib::AngleSkewMetric>(mesh);
92 std::make_unique<MeshLib::RadiusEdgeRatioMetric>(mesh);
93 else
94 {
95 ERR("ElementQualityInterface::calculateElementQuality(): Unknown MeshQualityType.");
96 return;
97 }
98 _quality_tester->calculateQuality();
99 }
100
103 std::unique_ptr<MeshLib::ElementQualityMetric> _quality_tester;
104};
105
106} // namespace MeshLib
Definition of the AngleSkewMetric class.
Definition of the EdgeRatioMetric class.
Definition of the ElementQualityMetricBase class.
Implementation of the AreaMetric class.
Implementation of Histogram class.
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
Definition: Logging.h:44
Definition of the Mesh class.
Definition of the RadiusEdgeRatioMetric class.
Definition of the SizeDifferenceMetric class.
int write(std::string const &file_name, std::string const &data_set_name, std::string const &param_name) const
Definition: Histogram.cpp:21
int writeHistogram(std::string const &file_name, std::size_t n_bins=0) const
Writes a histogram of the quality vector to a specified file.
ElementQualityInterface(MeshLib::Mesh const &mesh, MeshQualityType t)
Constructor.
void calculateElementQuality(MeshLib::Mesh const &mesh, MeshQualityType t)
Calculates the quality of each mesh element based on the specified metric.
std::vector< double > const getQualityVector() const
Returns the vector containing a quality measure for each element.
std::unique_ptr< MeshLib::ElementQualityMetric > _quality_tester
BaseLib::Histogram< double > getHistogram(std::size_t n_bins=0) const
const std::string getName() const
Get name of the mesh.
Definition: Mesh.h:98
MeshQualityType
Describes a mesh quality metric.
Definition: MeshEnums.h:70
std::string MeshQualityType2String(const MeshQualityType t)
Definition: MeshEnums.cpp:186