OGS
MeshLib::ElementQualityInterface Class Reference

Detailed Description

Interface class for handling mesh element quality metrics

Definition at line 35 of file ElementQualityInterface.h.

#include <ElementQualityInterface.h>

Collaboration diagram for MeshLib::ElementQualityInterface:
[legend]

Public Member Functions

 ElementQualityInterface (MeshLib::Mesh const &mesh, MeshQualityType t)
 Constructor.
 
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
 
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.
 

Private Member Functions

void calculateElementQuality (MeshLib::Mesh const &mesh, MeshQualityType t)
 Calculates the quality of each mesh element based on the specified metric.
 

Private Attributes

MeshQualityType const _type
 
MeshLib::Mesh const & _mesh
 
std::unique_ptr< MeshLib::ElementQualityMetric_quality_tester
 

Constructor & Destructor Documentation

◆ ElementQualityInterface()

MeshLib::ElementQualityInterface::ElementQualityInterface ( MeshLib::Mesh const &  mesh,
MeshQualityType  t 
)
inline

Constructor.

Definition at line 39 of file ElementQualityInterface.h.

40 : _type(t), _mesh(mesh), _quality_tester(nullptr)
41 {
43 }
void calculateElementQuality(MeshLib::Mesh const &mesh, MeshQualityType t)
Calculates the quality of each mesh element based on the specified metric.
std::unique_ptr< MeshLib::ElementQualityMetric > _quality_tester

References _mesh, _type, and calculateElementQuality().

Member Function Documentation

◆ calculateElementQuality()

void MeshLib::ElementQualityInterface::calculateElementQuality ( MeshLib::Mesh const &  mesh,
MeshQualityType  t 
)
inlineprivate

Calculates the quality of each mesh element based on the specified metric.

Definition at line 78 of file ElementQualityInterface.h.

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 }
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
Definition: Logging.h:44

References _quality_tester, MeshLib::EDGERATIO, MeshLib::ELEMENTSIZE, MeshLib::EQUIANGLESKEW, ERR(), MeshLib::RADIUSEDGERATIO, and MeshLib::SIZEDIFFERENCE.

Referenced by ElementQualityInterface().

◆ getHistogram()

BaseLib::Histogram< double > MeshLib::ElementQualityInterface::getHistogram ( std::size_t  n_bins = 0) const
inline

Returns a histogram of the quality vector separated into the given number of bins. If no number of bins is specified, one will be calculated based on the Sturges criterium.

Definition at line 57 of file ElementQualityInterface.h.

58 {
60 return _quality_tester->getHistogram(static_cast<std::size_t>(n_bins));
61
63 }

References _quality_tester.

◆ getQualityVector()

std::vector< double > const MeshLib::ElementQualityInterface::getQualityVector ( ) const
inline

Returns the vector containing a quality measure for each element.

Definition at line 46 of file ElementQualityInterface.h.

47 {
49 return _quality_tester->getElementQuality();
50
51 std::vector<double> empty_quality_vec(0);
52 return empty_quality_vec;
53 }

References _quality_tester.

Referenced by main(), and MainWindow::showMeshQualitySelectionDialog().

◆ writeHistogram()

int MeshLib::ElementQualityInterface::writeHistogram ( std::string const &  file_name,
std::size_t  n_bins = 0 
) const
inline

Writes a histogram of the quality vector to a specified file.

Definition at line 66 of file ElementQualityInterface.h.

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 }
const std::string getName() const
Get name of the mesh.
Definition: Mesh.h:98
std::string MeshQualityType2String(const MeshQualityType t)
Definition: MeshEnums.cpp:186

References _mesh, _quality_tester, _type, MeshLib::Mesh::getName(), MeshLib::MeshQualityType2String(), and BaseLib::Histogram< T >::write().

Referenced by MainWindow::showMeshQualitySelectionDialog().

Member Data Documentation

◆ _mesh

MeshLib::Mesh const& MeshLib::ElementQualityInterface::_mesh
private

Definition at line 102 of file ElementQualityInterface.h.

Referenced by ElementQualityInterface(), and writeHistogram().

◆ _quality_tester

std::unique_ptr<MeshLib::ElementQualityMetric> MeshLib::ElementQualityInterface::_quality_tester
private

◆ _type

MeshQualityType const MeshLib::ElementQualityInterface::_type
private

Definition at line 101 of file ElementQualityInterface.h.

Referenced by ElementQualityInterface(), and writeHistogram().


The documentation for this class was generated from the following file: