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.
snappymeshParams.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_SNAPPYMESHPARAMS_H_
30 #define NEMOSYS_SNAPPYMESHPARAMS_H_
31 
32 #ifdef HAVE_CFMSH
33 
34 # include "nemosys_export.h"
36 
37 # include <map>
38 # include <memory>
39 # include <string>
40 # include <tuple>
41 # include <vector>
42 
43 /**
44  @brief A structure to respresent regions
45  refining capability in snappymeshGen.
46 **/
47 struct NEMOSYS_EXPORT shmRegionRefine // Refinement Regions
48 {
49  std::string patchName; /**< Patch name */
50  std::string mode; /**< Inside, Outside */
51  double minLvl; /**< Minimum refinement level */
52  int maxLvl; /**< Maximum refinement level */
53 };
54 
55 /**
56  @brief A structure to respresent shape patches
57  defining capability in snappymeshGen.
58 **/
59 struct NEMOSYS_EXPORT shmSearchableShape {
60  std::string patchName;
61  virtual std::string getType() const = 0;
62  virtual ~shmSearchableShape() = default;
63 
64  protected:
65  shmSearchableShape() = default;
66  shmSearchableShape(const shmSearchableShape &) = default;
68  shmSearchableShape &operator=(const shmSearchableShape &) = default;
69  shmSearchableShape &operator=(shmSearchableShape &&) = default;
70 };
71 
72 struct NEMOSYS_EXPORT shmSearchableBox : public shmSearchableShape {
73  std::string getType() const override { return "searchableBox"; }
74  std::array<double, 3> minBound;
75  std::array<double, 3> maxBound;
76 };
77 
78 struct NEMOSYS_EXPORT shmSearchableCylinder : public shmSearchableShape {
79  std::string getType() const override { return "searchableCylinder"; }
80  std::array<double, 3> axisPoint1;
81  std::array<double, 3> axisPoint2;
82  double radius;
83 };
84 
85 struct NEMOSYS_EXPORT shmSearchableSphere : public shmSearchableShape {
86  std::string getType() const override { return "searchableSphere"; }
87  std::array<double, 3> center;
88  double radius;
89 };
90 
91 /**
92  @brief A structure to represent geometry surface
93  refining capability in snappymeshgGen
94 **/
95 struct NEMOSYS_EXPORT shmSurfRefine // Surface Refinement
96 {
97  std::string refPatchName; /**< Refining region patch name */
98  std::string patchType{"NO"}; /** < Patch Type in Mesh */
99  double minLvl{1.}; /**< Minimum refinement level */
100  int maxLvl; /**< Maximum refinement level */
101 };
102 
103 /** @brief A structure for STL definition
104  **/
105 struct NEMOSYS_EXPORT shmSTLDefinition {
106  std::string snappyPatchName;
107  std::string STLPatchName;
108 };
109 
110 /** @brief A structure for feature edge refinement
111  **/
112 struct NEMOSYS_EXPORT shmFeatureEdgeRef {
113  std::string fileName;
114  double minLvl{1.};
115  int maxLvl;
116 };
117 
118 /** @brief A struct for layer addition
119  **/
120 struct NEMOSYS_EXPORT shmLayers {
121  std::string patchName;
122  int nSurfaceLayers{1};
123  double expansionRatio{1.};
124  double finalLayerThickness{1.};
125  double firstLyrThickness{-1.};
126  double thickness{-1.};
127  double minThickness{1};
128 };
129 
130 /** @brief Geometry definition
131  **/
132 struct NEMOSYS_EXPORT shmGeo {
133  /** @brief Boolean for if user wants whole STL as one solid of has
134  different patches under STL
135  **/
137 
138  /** @brief patch name for input surface file for when not @c _withMultiPatches
139  **/
140  std::string singleSolidPatch;
141 
142  /** @brief Vector for STL patches, if @c _withMultiPatches
143  **/
144  std::vector<shmSTLDefinition> stlPatchDefs;
145 
146  /** @brief Vector for searchable shapes
147  **/
148  std::vector<std::shared_ptr<shmSearchableShape>> srchShape;
149 };
150 
151 /** @brief Castellated Mesh Controls
152  **/
153 struct NEMOSYS_EXPORT shmCastMeshControls {
154  /** @brief Enables defining cellzones and facezones
155  **/
156  bool withCellZones{false}; // Defining cellzones and facezones enabled?
157 
158  /** @brief Gap level increment
159  **/
160  int castMeshGpLvl{1};
161 
162  /** @brief max global cells allowed in mesh
163  **/
164  int maxLCells{2000000}; // max global cells
165 
166  /** @brief max local cells allowed (on 1 processor)
167  **/
168  int maxGCells{4000000}; // max local cells (on 1 processor)
169 
170  /** @brief minimum refinement cells
171  **/
172  int minRefCells{0}; // minimum refinement cells
173 
174  /** @brief number of cells between levels
175  **/
176  int cellsBetnLvls{3}; // number of cells between levels
177 
178  /** @brief minimum surface refinement
179  **/
180  int refSurfLvlMin{0}; // minimum surface refinement
181 
182  /** @brief maximum surface refinement
183  **/
184  int refSurfLvlMax{0}; // maximum surface refinement
185 
186  /** @brief resolve feature angle
187  **/
188  double featAngle{60.}; // resolve feature angle
189 
190  /** @brief Gap level increment
191  **/
192  int gapLvlInc{1};
193 
194  /** @brief Planar angle castallated mesh
195  **/
196  int planarAngle{30};
197 
198  /** @brief location in Mesh (cells are kept in regions accessinble from this
199  location)
200  **/
201  std::array<double, 3> locMesh{0, 0, 0};
202 
203  /** @brief allows free standing zones if enabled
204  **/
205  bool alwFreeZone{true}; // allow free standing zones
206 
207  /** @brief Vector for feature edge refinement
208  **/
209  std::vector<shmFeatureEdgeRef> ftrEdge;
210 
211  /** @brief Vector for shmSurfRefine struct
212  **/
213  std::vector<shmSurfRefine> surfRefs;
214 
215  /** @brief Vector for shmRegionRefine struct
216  **/
217  std::vector<shmRegionRefine> geomRefs;
218 };
219 
220 /** @brief Snapping Controls
221  **/
222 struct NEMOSYS_EXPORT shmSnapControls {
223  /** @brief Number of smoothing patches during snapping procedure
224  **/
225  int nSmoothPatch{4}; // nSmoothPatch
226 
227  /** @brief Snapping tolerance at shared interface (affects conformality of
228  mesh)
229  **/
230  double tolerance{0.5}; // Snap Tolerance
231 
232  /** @brief Maximum iterations during snapping procedure before ending the
233  process
234  **/
235  int nSolveIter{200}; // nSolveIter
236 
237  /** @brief Maximum number of relaxation iterations for snapping procedure
238  **/
239  int nRelaxIter{6}; // nRelaxIter
240 
241  /** @brief Feature snapping
242  **/
243  int nFeatureSnapIter{10};
244 
245  /** @brief Implicit feature snaping boolean
246  **/
247  bool implicitFeatureSnap{false};
248 
249  /** @brief Explicit feature snapping boolean
250  **/
251  bool explicitFeatureSnap{false};
252 
253  /** @brief Multi-region feature snapping boolean
254  **/
255  bool multiRegionFeatureSnap{false};
256 };
257 
258 /** @brief Layer Controls
259  **/
260 struct NEMOSYS_EXPORT shmLayerControls {
261  /** @brief Enables relative sizes option during layer addition
262  **/
263  bool relSize{true}; // Relative Sizes
264 
265  /** @brief Expansion Ratio for layer addition
266  **/
267  double expRatio{1.3}; // Expansion Ratio
268 
269  /** @brief Final Layer Thickness for layer addition
270  **/
271  double finLThick{1.}; // Final Layer Thickness
272 
273  /** @brief Minimum Thickness for layer addition
274  **/
275  double minThick{0.1}; // Minimum Thickness
276 
277  /** @brief First Layer Thickness
278  **/
279  double firstLyrThickness{-1.};
280 
281  /** @brief Thickness
282  **/
283  double thickness{-1.};
284 
285  /** @brief Growth rate of successive layers
286  **/
287  int nGrow{0};
288 
289  /** @brief Feature Angle for layer addition
290  **/
291  double featAngle{30.}; // Feature Angle
292 
293  /** @brief number of relaxation interations for layer addition
294  **/
295  int relaxIter{3}; // number of relaxation interations
296 
297  /** @brief Number of smooth surface normals for layer addition
298  **/
299  int smthSurfNorm{1}; // # of smooth surface normals
300 
301  /** @brief Number of smooth normals for layer addition
302  **/
303  int smthNorm{3}; // # of smooth normals
304 
305  /** @brief Number of smooth thickness for layer addition
306  **/
307  int smthThick{2}; // # of smooth thickness
308 
309  /** @brief Maximum face thickness ratio for layer addition
310  **/
311  double maxFcTR{0.5}; // Maximum face thickness ratio
312 
313  /** @brief Maximum thickness to medial ratio for layer addition
314  **/
315  double maxThickTMR{1}; // Maximum thickness to medial ratio
316 
317  /** @brief Minimum medial axis angle for layer addition
318  **/
319  double minMedAngl{90.}; // Minimum medial axis angle
320 
321  /** @brief Number of buffer cells no extrude for layer addition
322  **/
323  int bufferCells{0}; // # of buffer cells no extrude
324 
325  /** @brief Number of layer interations for layer addition
326  **/
327  int nIter{50}; // # of layer interations
328 
329  /** @brief Relaxed iteration
330  **/
331  int nRelaxedIter{20}; // # of relaxed iteration
332 
333  /** @brief Slip feature angles
334  **/
335  int slipFeatureAngle{30}; // Slip feature angle
336 
337  /** @brief Limits # of steps walking away from the surface
338  **/
339  int nMedialAxisIter{-1};
340 
341  /** @brief Smooth displacement after medial axis determination
342  **/
343  int nSmoothDisplacement{-1};
344 
345  /** @brief Vector for Layers
346  **/
347  std::vector<shmLayers> layerVec;
348 };
349 
350 /** @brief Mesh Quality Controls
351  **/
352 struct NEMOSYS_EXPORT shmMeshQualityControls {
353  /** @brief Maximum non-orthogonality
354  **/
355  int maxNonOrtho{65}; // Maximum non-orthogonality
356  /** @brief Max Boundary Skewness
357  **/
358  double maxBndrySkew{20.}; // Max Boundary Skewness
359  /** @brief Max Internal Skewness
360  **/
361  double maxIntSkew{4.}; // Max Internal Skewness
362  /** @brief Max Concativity
363  **/
364  double maxConc{80.}; // Max Concativity
365  /** @brief Minimum Cell Volume
366  **/
367  double minVol{1e-13}; // Minimum Cell Volume
368  /** @brief Minimum Tet Quality
369  **/
370  double minTetQ{1e-15}; // Minimum Tet Quality
371  /** @brief Minimum Area
372  **/
373  double minArea{-1.}; // Minimum Area
374  /** @brief Minimum Twist
375  **/
376  double minTwist{0.02}; // Minimum Twist
377  /** @brief Minimum Face Weight
378  **/
379  double minFaceW{0.05}; // Minimum Face Weight
380  /** @brief Minimum Volume Ratio
381  **/
382  double minVolRto{0.01}; // Minimum Volume Ratio
383  /** @brief Minimum Determinant
384  **/
385  double minDet{0.001}; // Minimum Determinant
386  /** @brief Minimum Triangle Twist
387  **/
388  double minTriTwist{-1.}; // Minimum Triangle Twist
389  /** @brief nSmoothScale
390  **/
391  int smoothScale{5}; // nSmoothScale
392  /** @brief Error Reduction
393  **/
394  double errReduction{0.75}; // Error Reduction
395 };
396 
397 /**
398  @brief snappymeshParams contains all parameters essential for mesh generation
399  using snappymeshGen class methods. These parameters are assigned a value
400  at time of user input parsing through JSON in meshGemDriver.
401 **/
402 class NEMOSYS_EXPORT snappymeshParams : public meshingParams {
403  // --- constructor and destructor
404  public:
405  /** @brief snappymeshParams standard constructor
406  **/
407  snappymeshParams() = default;
408 
409  /** @brief Geometry definition
410  **/
412 
413  /** @brief Enables castellated mesh option for snappymeshGen
414  **/
415  bool withCastMesh{true}; // Boolean for castellated mesh
416 
417  /** @brief Castellated mesh controls
418  **/
420 
421  /** @brief Enables surface snapping option for snappymeshGen
422  **/
423  bool withSnap{true}; // Boolean for snap
424 
425  /** @brief Snapping controls
426  **/
428 
429  /** @brief Enables add layers option for snappymeshGen
430  **/
431  bool withLayers{false}; // Boolean for add layers
432 
433  /** @brief Layer controls
434  **/
436 
437  /** @brief Input geometry STL name
438  **/
439  std::string geomFileName; // Input geometry STL name
440 
441  /** @brief Mesh Quality Controls
442  **/
444 
445  // --- Misc. General
446  /** @brief merge tolerance for mesh
447  **/
448  double mergeTol{1e-6}; // Merge Tolerance
449 
450  /** @brief Boolean for packmesh
451  **/
452  bool isPackMesh{true};
453 };
454 
455 #endif
456 
457 #endif // NEMOSYS_SNAPPYMESHPARAMS_H_
std::string singleSolidPatch
patch name for input surface file for when not _withMultiPatches
std::vector< shmSurfRefine > surfRefs
Vector for shmSurfRefine struct.
std::array< double, 3 > axisPoint2
shmMeshQualityControls qualityControls
Mesh Quality Controls.
snappymeshParams contains all parameters essential for mesh generation using snappymeshGen class meth...
A structure for STL definition.
std::string patchName
Patch name.
shmGeo geoDef
Geometry definition.
Castellated Mesh Controls.
double minLvl
Minimum refinement level.
std::vector< shmSTLDefinition > stlPatchDefs
Vector for STL patches, if _withMultiPatches.
Geometry definition.
std::string getType() const override
A structure to respresent regions refining capability in snappymeshGen.
int maxLvl
Maximum refinement level.
shmSnapControls snapControls
Snapping controls.
std::string snappyPatchName
std::vector< shmFeatureEdgeRef > ftrEdge
Vector for feature edge refinement.
std::string geomFileName
Input geometry STL name.
std::vector< shmLayers > layerVec
Vector for Layers.
Mesh Quality Controls.
std::array< double, 3 > center
std::string getType() const override
std::vector< std::shared_ptr< shmSearchableShape > > srchShape
Vector for searchable shapes.
bool withMultiPatches
Boolean for if user wants whole STL as one solid of has different patches under STL.
int maxLvl
Maximum refinement level.
std::array< double, 3 > maxBound
shmCastMeshControls castMeshControls
Castellated mesh controls.
std::string refPatchName
Refining region patch name.
A structure to respresent shape patches defining capability in snappymeshGen.
A structure for feature edge refinement.
A structure to represent geometry surface refining capability in snappymeshgGen.
std::array< double, 3 > axisPoint1
std::vector< shmRegionRefine > geomRefs
Vector for shmRegionRefine struct.
shmLayerControls layerControls
Layer controls.
std::string mode
Inside, Outside.
std::string STLPatchName
Layer Controls.
std::array< double, 3 > minBound
std::string patchName
Snapping Controls.
std::string getType() const override
A struct for layer addition.