NEMoSys  0.63.0
A modular, extensible resource with robust automated mesh generation, mesh quality analysis, adaptive mesh refinement, and data transfer between arbitrary meshes.
gmshParams.H
Go to the documentation of this file.
1 /*******************************************************************************
2 * Promesh *
3 * Copyright (C) 2022, IllinoisRocstar LLC. All rights reserved. *
4 * *
5 * Promesh is the property of IllinoisRocstar LLC. *
6 * *
7 * IllinoisRocstar LLC *
8 * Champaign, IL *
9 * www.illinoisrocstar.com *
10 * promesh@illinoisrocstar.com *
11 *******************************************************************************/
12 /*******************************************************************************
13 * This file is part of Promesh *
14 * *
15 * This version of Promesh is free software: you can redistribute it and/or *
16 * modify it under the terms of the GNU Lesser General Public License as *
17 * published by the Free Software Foundation, either version 3 of the License, *
18 * or (at your option) any later version. *
19 * *
20 * Promesh is distributed in the hope that it will be useful, but WITHOUT ANY *
21 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS *
22 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more *
23 * details. *
24 * *
25 * You should have received a copy of the GNU Lesser General Public License *
26 * along with this program. If not, see <https://www.gnu.org/licenses/>. *
27 * *
28 *******************************************************************************/
29 #ifndef NEMOSYS_GMSHPARAMS_H_
30 #define NEMOSYS_GMSHPARAMS_H_
31 
32 #include "nemosys_export.h"
34 
35 #include <array>
36 #include <map>
37 #include <set>
38 #include <string>
39 #include <tuple>
40 #include <vector>
41 
42 namespace NEM {
43 
44 namespace GEN {
45 
46 /**
47  * @brief A structure for defining volumetric mesh size fields.
48  Size fields supported in this structure are Ball, Cylinder, Box, and Frustum.
49 **/
50 struct NEMOSYS_EXPORT volSizeField {
51  std::string type; /**< Type of size field, eg. Ball,Cylinder,Box */
52  int id; /**< Size Field ID */
53  /**< Vector of pairs to store size field parameters */
54  std::vector<std::pair<std::string, double>> params;
55 
56  /**< Vector of pairs to store list of numbers */
57  std::vector<std::pair<std::string, std::vector<double>>> num_list_params;
58 
59  /**< Vector of pairs to store list of strings */
60  std::vector<std::pair<std::string, std::vector<std::string>>>
62 };
63 
64 /**
65  @brief A struct for defining hexahedral transfinite volumes.
66  */
67 struct NEMOSYS_EXPORT TransfiniteBlock {
68  // specified gmsh id (tag) of volume to be treated as transfinite
69  int id;
70 
71  // 3 direction vectors specifying axis of block (hexahedron)
72  std::array<std::array<double, 3>, 3> axis;
73 
74  // number of vertices in each axial direction
75  std::array<int, 3> vert;
76 
77  // each axis has either "Progression" or "Bump" type
78  // default is "Progression" with coef 1
79  std::array<std::string, 3> type{"Progression", "Progression", "Progression"};
80 
81  // value used in "Progression" or "Bump" along given axis
82  std::array<double, 3> coef{1.0, 1.0, 1.0};
83 
84  bool operator<(const TransfiniteBlock &rhs) const { return id < rhs.id; }
85 };
86 
87 /**
88  @brief gmshParams contains all parameters essential for mesh generation
89  using gmshGen class methods. These parameters are assigned a value
90  at time of user input parsing through JSON in meshGenDriver.
91 **/
92 class NEMOSYS_EXPORT gmshParams : public meshingParams {
93  public:
94  /** @brief gmshParams standard constructor
95  **/
96  gmshParams() = default;
97 
98  /** @brief Output mesh file name
99  **/
100  std::string ofname{};
101 
102  /** @brief Minimum global mesh size
103  **/
104  double minSize{0.01};
105 
106  /** @brief Maximum global mesh size
107  **/
108  double maxSize{50.0};
109 
110  /** @brief Surface meshing algorithm
111  **/
112  std::string algo2D{"Frontal"};
113 
114  /** @brief Volume meshing algorithm
115  **/
116  std::string algo3D{"HXT"};
117 
118  /** @brief Extend mesh size from boundary option
119  **/
120  bool extSizeFromBoundary{true};
121 
122  /** @brief Mesh size based on curvature option
123  **/
124  bool sizeFromCurvature{false};
125 
126  /** @brief Minimum number of mesh elements per two Pi
127  **/
128  int minElePer2Pi{6};
129 
130  /** @brief Whether to optimize mesh or not
131  **/
132  bool optimize{false};
133 
134  /** @brief Mesh optimization threshold, between 0 and 1
135  **/
136  double optimizeThreshold{0.3};
137 
138  /** @brief Size field ID to use as background field
139  **/
140  int bgField{-1};
141 
142  /**
143  * @brief Element order
144  */
145  int elementOrder{1};
146 
147  /**
148  * @brief Subdivision algorithm 0: none, 1: all quads, 2: all hexas
149  */
150  int subdivisionAlg{1};
151 
152  /**
153  * @brief Save all elements
154  */
155  bool saveAll{true};
156 
157  /**
158  * @brief Whether to call boolean fragments on all volumes
159  */
160  bool fragmentAll{false};
161 
162  /** @brief Vector for volSizeField struct
163  **/
164  std::vector<volSizeField> sizeFields;
165 
166  /** @brief Map from RGB to physical name
167  **/
168  std::map<std::array<int, 3>, std::string> color2groupMap;
169 
170  /** @brief Map from volume id to transfinite hexahedron information.
171  **/
172  std::set<TransfiniteBlock> transfiniteBlocks;
173 
174  /**
175  * @brief Get list of file extensions supported by gmsh
176  * @return supported gmsh mesh file extensions
177  */
178  static const std::array<const char *, 6> &getMeshExtensions() {
179  static constexpr std::array<const char *, 6> meshExtensions{
180  ".inp", ".unv", ".p3d", ".stl", ".vtk", ".su2"};
181  return meshExtensions;
182  }
183 };
184 
185 } // namespace GEN
186 
187 } // namespace NEM
188 
189 #endif // NEMOSYS_GMSHPARAMS_H_
std::string type
Type of size field, eg.
Definition: gmshParams.H:51
static const std::array< const char *, 6 > & getMeshExtensions()
Get list of file extensions supported by gmsh.
Definition: gmshParams.H:178
std::array< int, 3 > vert
Definition: gmshParams.H:75
std::vector< std::pair< std::string, double > > params
Vector of pairs to store list of numbers.
Definition: gmshParams.H:54
std::vector< std::pair< std::string, std::vector< std::string > > > strg_list_params
Definition: gmshParams.H:61
A struct for defining hexahedral transfinite volumes.
Definition: gmshParams.H:67
std::set< TransfiniteBlock > transfiniteBlocks
Map from volume id to transfinite hexahedron information.
Definition: gmshParams.H:172
std::map< std::array< int, 3 >, std::string > color2groupMap
Map from RGB to physical name.
Definition: gmshParams.H:168
gmshParams contains all parameters essential for mesh generation using gmshGen class methods...
Definition: gmshParams.H:92
std::array< std::array< double, 3 >, 3 > axis
Definition: gmshParams.H:72
std::vector< std::pair< std::string, std::vector< double > > > num_list_params
Vector of pairs to store list of strings.
Definition: gmshParams.H:57
int id
Size Field ID.
Definition: gmshParams.H:52
bool operator<(const TransfiniteBlock &rhs) const
Definition: gmshParams.H:84
A structure for defining volumetric mesh size fields.
Definition: gmshParams.H:50
std::vector< volSizeField > sizeFields
Vector for volSizeField struct.
Definition: gmshParams.H:164