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.
RefineJson.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_REFINEJSON_H_
30 #define NEMOSYS_REFINEJSON_H_
31 
32 #include <jsoncons/json.hpp>
33 #include "Drivers/NemJsonMacros.H"
34 
37 
38 #ifdef HAVE_CFMSH
39 # define IF_CFMSH(a) a,
41 #else
42 # define IF_CFMSH(a)
43 #endif
44 
45 #if defined(MLAMR) && defined(HAVE_CFMSH)
46 # define IF_MLAMR_CFMSH(a) a,
47 #else
48 # define IF_MLAMR_CFMSH(a)
49 #endif
50 
51 #if defined(HAVE_GMSH)
52 # define IF_GMSH(a) a,
56 #else
57 # define IF_GMSH(a)
58 #endif
59 
60 namespace NEM {
61 namespace DRV {
62 namespace JSON {
63 
64 static constexpr auto refOpts = "Refinement Options";
65 static constexpr auto refOperator = "Refinement Operator";
66 static constexpr auto refMethod = "Refinement Method";
67 static constexpr auto refTransferData = "Transfer Data";
68 
69 } // namespace JSON
70 } // namespace DRV
71 } // namespace NEM
72 
73 // RefineDriver
76  (IF_MLAMR_CFMSH(NEM::DRV::FoamMLRefineDriver)
82  NEM::DRV::NemDriver, 2, (getFiles, setFiles, NEM::DRV::JSON::meshFiles),
86  [](const jsoncons::string_view &x) {
88  }))
89 
90 #ifdef HAVE_CFMSH
91 # ifdef MLAMR
93  NEM::DRV::FoamMLRefineDriver, NEM::DRV::RefineDriver, 1,
94  (getOpts, setOpts, NEM::DRV::JSON::refOpts, JSONCONS_RDWR))
95 
96 JSONCONS_N_MEMBER_NAME_TRAITS(
97  NEM::DRV::FoamMLRefineDriver::Opts, 2,
98  (method, NEM::DRV::JSON::refMethod, JSONCONS_RDONLY,
99  [](const jsoncons::string_view &x) {
100  return x == NEM::DRV::FoamMLRefineDriver::Opts::method;
101  }),
102  (refCriteria, NEM::DRV::JSON::refOperator, JSONCONS_RDONLY,
103  [](const jsoncons::string_view &x) {
104  return x == NEM::DRV::FoamMLRefineDriver::Opts::refCriteria;
105  }),
106  (refineInterval, "Refinement Interval"),
107  (maxRefinement, "Maximum Refinement"), (nBufferLayers, "Buffer Layers"),
108  (maxCells, "Max Cells"), (writeFieldData, "Write Field Data?"),
109  (writeMesh, "Write Mesh?"), (writeRefHistory, "Write Refinement Data?"),
110  (timeStep, "Time Step"), (endTime, "End Time"), (startTime, "Start Time"),
111  (mlModel, "ML Kernel"))
112 # endif
113 
116  (getOpts, setOpts, NEM::DRV::JSON::refOpts, JSONCONS_RDWR))
117 
118 JSONCONS_N_MEMBER_NAME_TRAITS(
120  (method, NEM::DRV::JSON::refMethod, JSONCONS_RDONLY,
121  [](const jsoncons::string_view &x) {
123  }),
124  (refCriteria, NEM::DRV::JSON::refOperator),
125  (inputFieldFile, "Input Field File"),
126  (refineInterval, "Refinement Interval"),
127  (maxRefinement, "Maximum Refinement"), (nBufferLayers, "Buffer Layers"),
128  (maxCells, "Max Cells"), (writeFieldData, "Write Field Data?"),
129  (writeMesh, "Write Mesh?"), (writeRefHistory, "Write Refinement Data?"),
130  (timeStep, "Time Step"), (endTime, "End Time"), (startTime, "Start Time"),
131  (lowerRefineLevel, "Lower Refinement Level"),
132  (upperRefineLevel, "Upper Refinement Level"),
133  (unrefineAbove, "Unrefinement Above"),
134  (unrefineBelow, "Unrefinement Below"))
135 
136 JSONCONS_ENUM_NAME_TRAITS(NEM::DRV::FoamRefineDriver::Opts::Criteria,
137  (VALUE, "Value"), (GRADIENT, "Gradient"))
138 #endif
139 
140 // OmegahRefineDriver
142  NEM::DRV::OmegahRefineDriver, NEM::DRV::RefineDriver, 1,
143  (getOpts, setOpts, NEM::DRV::JSON::refOpts, JSONCONS_RDWR))
144 
145 JSONCONS_N_MEMBER_NAME_TRAITS(
147  (method, NEM::DRV::JSON::refMethod, JSONCONS_RDONLY,
148  [](const jsoncons::string_view &x) {
150  }),
151  (MetricSources, "Metric Sources"), (reconstructGeo, "Reconstruct Geometry"),
152  (Verbose, "Verbose"), (ShouldLimitLengths, "Should Limit Lengths"),
153  (MaxLength, "Max Length"), (MinLength, "Min Length"),
154  (ShouldLimitGradation, "Should Limit Gradation"),
155  (MaxGradationRate, "Max Gradation Rate"),
156  (GradationConvergenceTolerance, "Gradation Convergence Tolerance"),
157  (ShouldLimitElementCount, "Should Limit Element Count"),
158  (MaxElementCount, "Max ElementCount"),
159  (MinElementCount, "Min Element Count"),
160  (ElementCountOverRelaxation, "Element Count Over Relaxation"),
161  (NsmoothingSteps, "N smoothing Steps"),
162  (MinLengthDesired, "Min Length Desired"),
163  (MaxLengthDesired, "Max Length Desired"),
164  (MaxLengthAllowed, "Max Length Desired"),
165  (MinQualityAllowed, "Min Quality Desired"),
166  (MinQualityDesired, "Min Quality Desired"),
167  (NsliverLayers, "N sliver Layers"), (Verbosity, "Verbosity"),
168  (LengthHistogramMin, "Length Histogram Min"),
169  (LengthHistogramMax, "Length Histogram Max"),
170  (NlengthHistogramBins, "N length Histogram Bins"),
171  (NqualityHistogramBins, "N quality Histogram Bins"),
172  (ShouldRefine, "Should Refine"), (ShouldCoarsen, "Should Coarsen"),
173  (ShouldSwap, "Should Swap"),
174  (ShouldCoarsenSlivers, "Should Coarsen Slivers"),
175  (ShouldPreventCoarsenFlip, "Should Prevent Coarsen Flip"),
176  (TransferOpts, "Transfer Options"),
177  (TransferOptsIntegralDiffuse, "Transfer Integral Options"))
178 
179 JSONCONS_N_MEMBER_NAME_TRAITS(NEM::SRV::omegahRefineMetricSource, 1,
180  (type, "Type"), (knob, "Knob"),
181  (tag_name, "Tag Name"), (isotropy, "Isotropy"),
182  (scales, "Scales"))
183 
184 JSONCONS_ENUM_NAME_TRAITS(Omega_h_Source, (OMEGA_H_CONSTANT, "Constant"),
185  (OMEGA_H_VARIATION, "Variation"),
186  (OMEGA_H_DERIVATIVE, "Derivative"),
187  (OMEGA_H_GIVEN, "Given"),
188  (OMEGA_H_IMPLIED, "Implied"),
189  (OMEGA_H_CURVATURE, "Curvature"))
190 
191 JSONCONS_ENUM_NAME_TRAITS(Omega_h_Isotropy,
192  (OMEGA_H_ANISOTROPIC, "Anisotropic"),
193  (OMEGA_H_ISO_LENGTH, "Length"),
194  (OMEGA_H_ISO_SIZE, "Size"))
195 
196 JSONCONS_ENUM_NAME_TRAITS(Omega_h_Scales, (OMEGA_H_ABSOLUTE, "Absolute"),
197  (OMEGA_H_SCALES, "Scales"))
198 
199 JSONCONS_N_MEMBER_NAME_TRAITS(NEM::DRV::OmegahRefineDriver::Transfer, 2,
200  (arrayName, "Name"), (method, "Method"),
201  (integralName, "Integral Name"))
202 
203 JSONCONS_ENUM_NAME_TRAITS(Omega_h_Transfer, (OMEGA_H_INHERIT, "Inherit"),
204  (OMEGA_H_LINEAR_INTERP, "Linear Interp"),
205  (OMEGA_H_METRIC, "Metric"),
206  (OMEGA_H_DENSITY, "Density"),
207  (OMEGA_H_CONSERVE, "Conserve"),
208  (OMEGA_H_MOMENTUM_VELOCITY, "Momentum Velocity"),
209  (OMEGA_H_POINTWISE, "Pointwise"))
210 
211 JSONCONS_N_MEMBER_NAME_TRAITS(NEM::DRV::OmegahRefineDriver::VarCompare, 1,
212  (integralName, "Integral Name"), (type, "Type"),
213  (tolerance, "Tolerance"), (floor, "Floor"))
214 
215 // SizeFieldRefineDriver
216 #ifdef HAVE_GMSH
219  (getOpts, setOpts, NEM::DRV::JSON::refOpts, JSONCONS_RDWR))
220 
221 JSONCONS_N_MEMBER_NAME_TRAITS(NEM::DRV::SizeFieldRefineDriver::Opts, 5,
222  (method, NEM::DRV::JSON::refMethod),
223  (arrayName, "Array Name"),
224  (stdDevMult, "StdDev Multiplier"),
225  (maxIsMin, "Max Is Min for Scaling"),
226  (transferData, NEM::DRV::JSON::refTransferData),
227  (sizeFactor, "Size Factor"))
228 
229 JSONCONS_ENUM_NAME_TRAITS(NEM::DRV::SizeFieldRefineDriver::Opts::Method,
230  (VALUE, "value"), (GRADIENT, "gradient"))
231 
232 // UniformRefineDriver
235  (getOpts, setOpts, NEM::DRV::JSON::refOpts, JSONCONS_RDWR))
236 
237 JSONCONS_ALL_MEMBER_NAME_TRAITS(
239  (method, NEM::DRV::JSON::refMethod, JSONCONS_RDONLY,
240  [](const jsoncons::string_view &x) {
242  }),
243  (transferData, NEM::DRV::JSON::refTransferData),
244  (edgeScale, "Edge Scaling"))
245 
246 // Z2RefineDriver
249  (getOpts, setOpts, NEM::DRV::JSON::refOpts, JSONCONS_RDWR))
250 
251 JSONCONS_ALL_MEMBER_NAME_TRAITS(
253  (method, NEM::DRV::JSON::refMethod, JSONCONS_RDONLY,
254  [](const jsoncons::string_view &x) {
256  }),
257  (transferData, NEM::DRV::JSON::refTransferData), (arrayName, "Array Name"),
258  (order, "Order"))
259 #endif
260 
261 #undef IF_CFMSH
262 #undef IF_MLAMR_CFMSH
263 #undef IF_GMSH
264 
265 #endif // NEMOSYS_REFINEJSON_H_
static constexpr auto refMethod
Definition: RefineJson.H:66
#define NEM_JSON_CHECK_KEY_ONLY(x)
base class for drivers
Definition: NemDriver.H:46
static constexpr const char * programType
Definition: RefineDriver.H:54
#define IF_MLAMR_CFMSH(a)
Definition: RefineJson.H:48
static constexpr auto refTransferData
Definition: RefineJson.H:67
#define IF_CFMSH(a)
Definition: RefineJson.H:39
#define NEM_JSON_N_GETTER_SETTER_NAME_TRAITS_FINAL(ValueType, ParentType, NumMandatoryParams,...)
static constexpr const char * method
static constexpr const char * method
#define NEM_JSON_N_GETTER_SETTER_NAME_TRAITS_INTERMEDIATE(BaseClass, ChildClasses, ParentClass, NumMandatoryParams,...)
#define IF_GMSH(a)
Definition: RefineJson.H:57
static constexpr const char * method
static constexpr const char * method
static constexpr auto refOpts
Definition: RefineJson.H:64
static constexpr auto programType
static constexpr auto meshFiles
static constexpr auto refOperator
Definition: RefineJson.H:65
Store variables to create Omega_h&#39;s MetricSource object used to define metrics for refinement...
#define NEM_JSON_RDONLY_OVERRIDE(X)
Definition: NemJsonMacros.H:39