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 MeshToolsLib
30{
31
36{
37public:
45
47 std::vector<double> const getQualityVector() const
48 {
50 return _quality_tester->getElementQuality();
51
52 std::vector<double> empty_quality_vec(0);
53 return empty_quality_vec;
54 }
55
59 BaseLib::Histogram<double> getHistogram(std::size_t n_bins = 0) const
60 {
62 return _quality_tester->getHistogram(
63 static_cast<std::size_t>(n_bins));
64
66 }
67
69 int writeHistogram(std::string const& file_name,
70 std::size_t n_bins = 0) const
71 {
72 if (_quality_tester == nullptr)
73 return 1;
74
75 BaseLib::Histogram<double> const histogram(
76 _quality_tester->getHistogram(n_bins));
77 histogram.write(file_name, _mesh.getName(),
78 MeshQualityType2String(_type));
79 return 0;
80 }
81
82private:
87 {
90 std::make_unique<MeshToolsLib::EdgeRatioMetric>(mesh);
93 std::make_unique<MeshToolsLib::ElementSizeMetric>(mesh);
96 std::make_unique<MeshToolsLib::SizeDifferenceMetric>(mesh);
99 std::make_unique<MeshToolsLib::AngleSkewMetric>(mesh);
102 std::make_unique<MeshToolsLib::RadiusEdgeRatioMetric>(mesh);
103 else
104 {
105 ERR("ElementQualityInterface::calculateElementQuality(): Unknown "
106 "MeshQualityType.");
107 return;
108 }
109 _quality_tester->calculateQuality();
110 }
111
114 std::unique_ptr<MeshToolsLib::ElementQualityMetric> _quality_tester;
115};
116
117} // namespace MeshToolsLib
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:45
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:22
const std::string getName() const
Get name of the mesh.
Definition Mesh.h:103
std::unique_ptr< MeshToolsLib::ElementQualityMetric > _quality_tester
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.
std::vector< double > const getQualityVector() const
Returns the vector containing a quality measure for each element.
BaseLib::Histogram< double > getHistogram(std::size_t n_bins=0) const
void calculateElementQuality(MeshLib::Mesh const &mesh, MeshLib::MeshQualityType t)
ElementQualityInterface(MeshLib::Mesh const &mesh, MeshLib::MeshQualityType t)
Constructor.
MeshQualityType
Describes a mesh quality metric.
Definition MeshEnums.h:70