OGS
MeshEnums.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
4#include "MeshEnums.h"
5
6#include <boost/algorithm/string/predicate.hpp>
7
8namespace MeshLib
9{
11{
12 if (t == MeshElemType::POINT)
13 {
14 return "Point";
15 }
16 if (t == MeshElemType::LINE)
17 {
18 return "Line";
19 }
20 if (t == MeshElemType::QUAD)
21 {
22 return "Quad";
23 }
25 {
26 return "Hexahedron";
27 }
29 {
30 return "Triangle";
31 }
33 {
34 return "Tetrahedron";
35 }
36 if (t == MeshElemType::PRISM)
37 {
38 return "Prism";
39 }
40 if (t == MeshElemType::PYRAMID)
41 {
42 return "Pyramid";
43 }
44 return "none";
45}
46
48{
49 if (t == MeshElemType::POINT)
50 {
51 return "point";
52 }
53 if (t == MeshElemType::LINE)
54 {
55 return "line";
56 }
57 if (t == MeshElemType::QUAD)
58 {
59 return "quad";
60 }
62 {
63 return "hex";
64 }
66 {
67 return "tri";
68 }
70 {
71 return "tet";
72 }
73 if (t == MeshElemType::PRISM)
74 {
75 return "pris";
76 }
77 if (t == MeshElemType::PYRAMID)
78 {
79 return "pyra";
80 }
81 return "none";
82}
83
84MeshElemType String2MeshElemType(const std::string& s)
85{
86 if (boost::iequals(s, "point"))
87 {
89 }
90 if (boost::iequals(s, "line"))
91 {
92 return MeshElemType::LINE;
93 }
94 if (boost::iequals(s, "quad") || boost::iequals(s, "Quadrilateral"))
95 {
96 return MeshElemType::QUAD;
97 }
98 if (boost::iequals(s, "hex") || boost::iequals(s, "Hexahedron"))
99 {
101 }
102 if (boost::iequals(s, "tri") || boost::iequals(s, "Triangle"))
103 {
105 }
106 if (boost::iequals(s, "tet") || boost::iequals(s, "Tetrahedron"))
107 {
109 }
110 if (boost::iequals(s, "pris") || boost::iequals(s, "Prism"))
111 {
112 return MeshElemType::PRISM;
113 }
114 if (boost::iequals(s, "pyra") || boost::iequals(s, "Pyramid"))
115 {
117 }
119}
120
121std::vector<MeshElemType> getMeshElemTypes()
122{
123 std::vector<MeshElemType> vec;
124 vec.push_back(MeshElemType::POINT);
125 vec.push_back(MeshElemType::LINE);
126 vec.push_back(MeshElemType::QUAD);
127 vec.push_back(MeshElemType::HEXAHEDRON);
128 vec.push_back(MeshElemType::TRIANGLE);
129 vec.push_back(MeshElemType::TETRAHEDRON);
130 vec.push_back(MeshElemType::PRISM);
131 vec.push_back(MeshElemType::PYRAMID);
132 return vec;
133}
134
135std::vector<std::string> getMeshElemTypeStringsShort()
136{
137 std::vector<std::string> vec;
138 auto const& mesh_elem_types = getMeshElemTypes();
139 std::transform(mesh_elem_types.begin(), mesh_elem_types.end(),
140 std::back_inserter(vec),
141 [](auto const& element_type)
142 { return MeshElemType2StringShort(element_type); });
143 return vec;
144}
145
146std::string CellType2String(const CellType t)
147{
148#define RETURN_CELL_TYPE_STR(t, type) \
149 if ((t) == CellType::type) \
150 return #type;
151
169
170 return "none";
171
172#undef RETURN_CELL_TYPE_STR
173}
174
176{
178 {
179 return "ElementSize";
180 }
182 {
183 return "EdgeRatio";
184 }
186 {
187 return "EquiAngleSkew";
188 }
190 {
191 return "RadiusEdgeRatio";
192 }
194 {
195 return "SizeDifference";
196 }
197 return "none";
198}
199
201{
202 if (boost::iequals(s, "ElementSize"))
203 {
205 }
206 if (boost::iequals(s, "EdgeRatio"))
207 {
209 }
210 if (boost::iequals(s, "EquiAngleSkew"))
211 {
213 }
214 if (boost::iequals(s, "RadiusEdgeRatio"))
215 {
217 }
218 if (boost::iequals(s, "SizeDifference"))
219 {
221 }
223}
224
225} // namespace MeshLib
#define RETURN_CELL_TYPE_STR(t, type)
MeshElemType String2MeshElemType(const std::string &s)
Given a string of the shortened name of the element type, this returns the corresponding MeshElemType...
Definition MeshEnums.cpp:84
CellType
Types of mesh elements supported by OpenGeoSys.
Definition MeshEnums.h:53
MeshLib::MeshQualityType String2MeshQualityType(std::string const &s)
std::string MeshElemType2String(const MeshElemType t)
Given a MeshElemType this returns the appropriate string.
Definition MeshEnums.cpp:10
MeshQualityType
Describes a mesh quality metric.
Definition MeshEnums.h:80
std::vector< MeshElemType > getMeshElemTypes()
Returns a vector of all mesh element types.
std::string MeshElemType2StringShort(const MeshElemType t)
Given a MeshElemType this returns the appropriate string with a short name.
Definition MeshEnums.cpp:47
std::vector< std::string > getMeshElemTypeStringsShort()
Returns a vector of strings of mesh element types.
std::string CellType2String(const CellType t)
Given a MeshElemType this returns the appropriate string.
std::string MeshQualityType2String(const MeshQualityType t)
MeshElemType
Types of mesh elements supported by OpenGeoSys. Values are from VTKCellType enum.
Definition MeshEnums.h:37