Vulpes  0.1.0
Versatile and parallel compUtational Library for high-order discontinuous Polytopal Element Simulations
Loading...
Searching...
No Matches
mesh_metrics.hpp
Go to the documentation of this file.
1// ----------------------------------------------------------------------
2//
3// Copyright (C) 2024 - 2026 by the Vulpes authors.
4// This file is part of Vulpes.
5//
6// Vulpes is free software; you can redistribute it and/or modify
7// it under the terms of the GNU General Public License as published by
8// the Free Software Foundation, either version 3 of the License, or
9// (at your option) any later version.
10//
11// Vulpes is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14// General Public License for more details.
15//
16// You should have received a copy of the GNU General Public License
17// along with Vulpes. If not, see <http://www.gnu.org/licenses/>.
18//
19// ----------------------------------------------------------------------
20
21// Author: Matteo Caldana <matteo.caldana@polimi.it>
22
23#ifndef VULPES_GEOMETRY_MESH_METRICS_HPP_
24#define VULPES_GEOMETRY_MESH_METRICS_HPP_
25
26#include <array>
27#include <cmath>
28#include <numbers>
29#include <vector>
30
33
34namespace vulpes {
35namespace geometry {
36
42
49
59
67
68using MetricsInitOptionsType = std::underlying_type_t<MetricsInitOptions>;
69
86
87template <typename MeshType>
89 public:
90 using float_t = typename MeshType::float_t;
91 using index_t = typename MeshType::index_t;
92
93 using MetricsVec = std::vector<float_t>;
95
96 static constexpr index_t dim = MeshType::self_dim;
97
105 explicit MeshMetrics(
106 const MeshType& mesh,
111 const MetricsVec& getCircleRatios() const;
119 const MetricsVec& getUniformityFactors() const;
123 const MetricsVec& getVolumeDifferences() const;
127 const std::array<MetricsVec, 4>& getMetrics() const;
128
132
133 void computeCircleRatios();
146
147 private:
148 const MeshType& m_mesh;
150
152 std::vector<CellType> m_cells;
153
154 std::array<MetricsVec, 4> m_all_metrics;
155};
156
157// MeshType -> Mesh2D, Mesh3D
158// float -> float, double
159// index -> int32_t, int64_t, u_int_32_t, u_int64_t
160
161// extern template class MeshMetrics<Mesh2D<float, int32_t>>;
162// extern template class MeshMetrics<Mesh2D<float, int64_t>>;
163
164extern template class MeshMetrics<Mesh2D<double, int32_t>>;
165// extern template class MeshMetrics<Mesh2D<double, int64_t>>;
166
167// extern template class MeshMetrics<Mesh3D<float, int32_t>>;
168// extern template class MeshMetrics<Mesh3D<float, int64_t>>;
169
170// extern template class MeshMetrics<Mesh3D<double, int32_t>>;
171// extern template class MeshMetrics<Mesh3D<double, int64_t>>;
172
173} // namespace geometry
174} // namespace vulpes
175
176#endif // VULPES_GEOMETRY_MESH_METRICS_HPP_
A class template that can be used to compute various mesh metrics (CircleRatio, AreaToPerimeterRatio,...
Definition mesh_metrics.hpp:88
void computeAreaToPerimeterRatios()
method used to compute the mesh area to perimeter ratios
Definition mesh_metrics.cpp:117
void computeCircleRatios()
method used to compute the mesh circle ratios
Definition mesh_metrics.cpp:90
MeshMetrics(const MeshType &mesh, MetricsInitOptionsType options=MetricsInitOptions::AllMetrics)
Construct a new Mesh Metrics object.
Definition mesh_metrics.cpp:32
std::array< MetricsVec, 4 > m_all_metrics
Definition mesh_metrics.hpp:154
typename MeshType::index_t index_t
Definition mesh_metrics.hpp:91
const MetricsVec & getCircleRatios() const
Getter for the vector of the cells' circle ratios.
Definition mesh_metrics.cpp:83
const MeshType & m_mesh
Definition mesh_metrics.hpp:148
std::vector< CellType > m_cells
Definition mesh_metrics.hpp:152
std::vector< float_t > MetricsVec
Definition mesh_metrics.hpp:93
const MetricsVec & getAreaToPerimeterRatios() const
Getter for the vector of the cells' area to perimeter ratios.
Definition mesh_metrics.cpp:111
void computeVolumeDifferences()
method used to compute the mesh volume differences
Definition mesh_metrics.cpp:184
const MetricsVec & getUniformityFactors() const
Getter for the vector of the cells' uniformity factors.
Definition mesh_metrics.cpp:146
typename MeshType::float_t float_t
Definition mesh_metrics.hpp:90
void computeUniformityFactors()
method used to compute the mesh uniformity factors
Definition mesh_metrics.cpp:152
const index_t m_n_cells
Definition mesh_metrics.hpp:151
const std::array< MetricsVec, 4 > & getMetrics() const
Getter for the array of all the metrics.
Definition mesh_metrics.cpp:211
static constexpr index_t dim
Definition mesh_metrics.hpp:96
const MetricsVec & getVolumeDifferences() const
Getter for the vector of the cells' volume difference.
Definition mesh_metrics.cpp:178
Cell< MeshType::self_dim, float_t, index_t > CellType
Definition mesh_metrics.hpp:94
const MetricsInitOptionsType m_options
Definition mesh_metrics.hpp:149
Definition abs_agg_model.cpp:40
std::underlying_type_t< MetricsInitOptions > MetricsInitOptionsType
Definition mesh_metrics.hpp:68
MetricId
An enum that definies the indexes of various metrics in the global metrics array.
Definition mesh_metrics.hpp:43
@ VolumeDifferenceID
Definition mesh_metrics.hpp:47
@ UniformityFactorID
Definition mesh_metrics.hpp:46
@ AreaPerimeterRatioID
Definition mesh_metrics.hpp:45
@ CircleRatioID
Definition mesh_metrics.hpp:44
std::conditional_t< Dim==2, Cell2D< FloatType, IndexType >, Cell3D< FloatType, IndexType > > Cell
Definition cell.hpp:267
MetricsInitOptions
An enum that can be used to specify the metrics that we desire to be computed.
Definition mesh_metrics.hpp:60
@ AllMetrics
Definition mesh_metrics.hpp:65
@ CircleRatio
Definition mesh_metrics.hpp:61
@ VolumeDifference
Definition mesh_metrics.hpp:64
@ AreaPerimeterRatio
Definition mesh_metrics.hpp:62
@ UniformityFactor
Definition mesh_metrics.hpp:63
Definition cell_manager.hpp:38