OGS
MeshToolsLib::anonymous_namespace{AngleSkewMetric.cpp} Namespace Reference

## Functions

template<unsigned long N>
std::tuple< double, double > getMinMaxAngle (std::array< MeshLib::Node, N > const &nodes)

double checkTriangle (MeshLib::Element const &elem)

double checkTetrahedron (MeshLib::Element const &elem)

double checkHexahedron (MeshLib::Element const &elem)

double checkPrism (MeshLib::Element const &elem)

## ◆ checkHexahedron()

 double MeshToolsLib::anonymous_namespace{AngleSkewMetric.cpp}::checkHexahedron ( MeshLib::Element const & elem )

Definition at line 82 of file AngleSkewMetric.cpp.

83{
84 std::array<double, 6> min;
85 std::array<double, 6> max;
86 for (auto face_number = 0; face_number < 6; ++face_number)
87 {
88 std::unique_ptr<MeshLib::Element const> face{elem.getFace(face_number)};
89 std::array const nodes = {*face->getNode(0), *face->getNode(1),
90 *face->getNode(2), *face->getNode(3)};
91 std::tie(min[face_number], max[face_number]) = getMinMaxAngle(nodes);
92 }
93
94 double const min_angle = *std::min_element(min.begin(), min.end());
95 double const max_angle = *std::max_element(max.begin(), max.end());
96
97 using namespace std::numbers;
98 return std::max((max_angle - pi / 2), (pi / 2 - min_angle)) * 2 / pi;
99}

Referenced by checkHexahedron().

## ◆ checkPrism()

 double MeshToolsLib::anonymous_namespace{AngleSkewMetric.cpp}::checkPrism ( MeshLib::Element const & elem )

Definition at line 101 of file AngleSkewMetric.cpp.

102{
103 // face 0: triangle (0,1,2)
104 std::unique_ptr<MeshLib::Element const> f0{elem.getFace(0)};
105 std::array const nodes_f0 = {*f0->getNode(0), *f0->getNode(1),
106 *f0->getNode(2)};
107 auto const& [min_angle_tri0, max_angle_tri0] = getMinMaxAngle(nodes_f0);
108
109 // face 4: triangle (3,4,5)
110 std::unique_ptr<MeshLib::Element const> f4{elem.getFace(4)};
111 std::array const nodes_f4 = {*f4->getNode(0), *f4->getNode(1),
112 *f4->getNode(2)};
113 auto const& [min_angle_tri1, max_angle_tri1] = getMinMaxAngle(nodes_f4);
114
115 auto const min_angle_tri = std::min(min_angle_tri0, min_angle_tri1);
116 auto const max_angle_tri = std::max(max_angle_tri0, max_angle_tri1);
117
118 using namespace std::numbers;
119 double const tri_criterion =
120 std::max((max_angle_tri - pi / 3) / 2, (pi / 3 - min_angle_tri)) * 3 /
121 pi;
122
123 std::array<double, 3> min;
124 std::array<double, 3> max;
125 for (int i = 1; i < 4; ++i)
126 {
127 std::unique_ptr<MeshLib::Element const> f{elem.getFace(i)};
128 std::array const nodes = {*f->getNode(0), *f->getNode(1),
129 *f->getNode(2), *f->getNode(3)};
130 std::tie(min[i - 1], max[i - 1]) = getMinMaxAngle(nodes);
131 }
132
133 double const min_angle_quad = *std::min_element(min.begin(), min.end());
134 double const max_angle_quad = *std::max_element(max.begin(), max.end());
135
136 using namespace std::numbers;
138 std::max((max_angle_quad - pi / 2), (pi / 2 - min_angle_quad)) * 2 / pi;
139
141}
std::tuple< double, double > getMinMaxAngle(std::array< MeshLib::Node, N > const &nodes)

Referenced by checkPrism().

 double MeshToolsLib::anonymous_namespace{AngleSkewMetric.cpp}::checkQuad ( MeshLib::Element const & elem )

Definition at line 53 of file AngleSkewMetric.cpp.

54{
55 std::array const nodes = {*elem.getNode(0), *elem.getNode(1),
56 *elem.getNode(2), *elem.getNode(3)};
57 auto const& [min_angle, max_angle] = getMinMaxAngle(nodes);
58
59 using namespace std::numbers;
60 return std::max((max_angle - pi / 2), (pi / 2 - min_angle)) * 2 / pi;
61}

## ◆ checkTetrahedron()

 double MeshToolsLib::anonymous_namespace{AngleSkewMetric.cpp}::checkTetrahedron ( MeshLib::Element const & elem )

Definition at line 63 of file AngleSkewMetric.cpp.

64{
65 std::array<double, 4> min;
66 std::array<double, 4> max;
67 for (auto face_number = 0; face_number < 4; ++face_number)
68 {
69 std::unique_ptr<MeshLib::Element const> face{elem.getFace(face_number)};
70 std::array const nodes = {*face->getNode(0), *face->getNode(1),
71 *face->getNode(2)};
72 std::tie(min[face_number], max[face_number]) = getMinMaxAngle(nodes);
73 }
74
75 double const min_angle = *std::min_element(min.begin(), min.end());
76 double const max_angle = *std::max_element(max.begin(), max.end());
77
78 using namespace std::numbers;
79 return std::max((max_angle - pi / 3) / 2, (pi / 3 - min_angle)) * 3 / pi;
80}

Referenced by checkTetrahedron().

## ◆ checkTriangle()

 double MeshToolsLib::anonymous_namespace{AngleSkewMetric.cpp}::checkTriangle ( MeshLib::Element const & elem )

Definition at line 44 of file AngleSkewMetric.cpp.

45{
46 using namespace std::numbers;
47 std::array const nodes = {*elem.getNode(0), *elem.getNode(1),
48 *elem.getNode(2)};
49 auto const& [min_angle, max_angle] = getMinMaxAngle(nodes);
50 return std::max((max_angle - pi / 3) / 2, (pi / 3 - min_angle)) * 3 / pi;
51}

References checkTriangle(), getMinMaxAngle(), and MeshLib::Element::getNode().

Referenced by checkTriangle().

## ◆ getMinMaxAngle()

template<unsigned long N>
 std::tuple< double, double > MeshToolsLib::anonymous_namespace{AngleSkewMetric.cpp}::getMinMaxAngle ( std::array< MeshLib::Node, N > const & nodes )

Definition at line 28 of file AngleSkewMetric.cpp.

30{
31 double min_angle(2 * std::numbers::pi);
32 double max_angle(0.0);
33
34 for (decltype(N) i = 0; i < N; ++i)
35 {
36 const double angle(MathLib::getAngle(nodes[i], nodes[(i + 1) % N],
37 nodes[(i + 2) % N]));
38 min_angle = std::min(angle, min_angle);
39 max_angle = std::max(angle, max_angle);
40 }
41 return {min_angle, max_angle};
42}
double getAngle(Point3d const &p0, Point3d const &p1, Point3d const &p2)
Definition MathTools.cpp:42

References MathLib::getAngle(), and getMinMaxAngle().

Referenced by checkHexahedron(), checkPrism(), checkQuad(), checkTetrahedron(), checkTriangle(), and getMinMaxAngle().