OGS
MeshToolsLib::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 MeshToolsLib::ElementQualityInterface:
[legend]

Public Member Functions

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

Private Attributes

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

Constructor & Destructor Documentation

◆ ElementQualityInterface()

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

Constructor.

Definition at line 39 of file ElementQualityInterface.h.

41 : _type(t), _mesh(mesh), _quality_tester(nullptr)
42 {
44 }
std::unique_ptr< MeshToolsLib::ElementQualityMetric > _quality_tester
void calculateElementQuality(MeshLib::Mesh const &mesh, MeshLib::MeshQualityType t)

References _mesh, _type, and calculateElementQuality().

Member Function Documentation

◆ calculateElementQuality()

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

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

Definition at line 85 of file ElementQualityInterface.h.

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

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

Referenced by ElementQualityInterface().

◆ getHistogram()

BaseLib::Histogram< double > MeshToolsLib::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 59 of file ElementQualityInterface.h.

60 {
62 return _quality_tester->getHistogram(
63 static_cast<std::size_t>(n_bins));
64
66 }

References _quality_tester.

◆ getQualityVector()

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

Returns the vector containing a quality measure for each element.

Definition at line 47 of file ElementQualityInterface.h.

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

References _quality_tester.

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

◆ writeHistogram()

int MeshToolsLib::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 69 of file ElementQualityInterface.h.

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(),
79 return 0;
80 }
const std::string getName() const
Get name of the mesh.
Definition Mesh.h:103
std::string MeshQualityType2String(const MeshQualityType t)

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

Referenced by MainWindow::showMeshQualitySelectionDialog().

Member Data Documentation

◆ _mesh

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

Definition at line 113 of file ElementQualityInterface.h.

Referenced by ElementQualityInterface(), and writeHistogram().

◆ _quality_tester

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

◆ _type

MeshLib::MeshQualityType const MeshToolsLib::ElementQualityInterface::_type
private

Definition at line 112 of file ElementQualityInterface.h.

Referenced by ElementQualityInterface(), and writeHistogram().


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