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.
PackMeshJson.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_PACKMESHJSON_H_
30 #define NEMOSYS_PACKMESHJSON_H_
31 
32 #include <jsoncons/json.hpp>
33 #include "Drivers/NemJsonMacros.H"
34 
36 
37 #ifdef HAVE_CFMSH
38 # define IF_CFMSH(a) a,
40 #else
41 # define IF_CFMSH(a)
42 #endif
43 
44 #ifdef HAVE_GMSH
45 # define IF_GMSH(a) a,
47 #else
48 # define IF_GMSH(a)
49 #endif
50 
51 namespace NEM {
52 namespace DRV {
53 namespace JSON {
54 
55 static constexpr auto packMeshOpts = "Pack Mesh Options";
56 
57 } // namespace JSON
58 } // namespace DRV
59 } // namespace NEM
60 
61 // PackMeshDriver
66  void),
69  [](const jsoncons::string_view &x) {
71  }))
72 
73 #ifdef HAVE_GMSH
74 // SurfacePackMeshDriver
77  (getFiles, setFiles, NEM::DRV::JSON::meshFiles),
78  (getOpts, setOpts, NEM::DRV::JSON::packMeshOpts, JSONCONS_RDWR))
79 
80 JSONCONS_ALL_MEMBER_NAME_TRAITS(NEM::DRV::SurfacePackMeshDriver::Files,
81  (rocpackFile, "Input Rocpack File"),
82  (outputMeshFile, NEM::DRV::JSON::outMeshFile))
83 
84 JSONCONS_N_MEMBER_NAME_TRAITS(
86  (type, "Type", JSONCONS_RDONLY,
87  [](const jsoncons::string_view &x) {
89  }),
90  (engine, "Engine", JSONCONS_RDONLY,
91  [](const jsoncons::string_view &x) {
93  }),
94  (periodic3DOpts, "Periodic 3D Mesh"), (meshSize, "Mesh Size"),
95  (meshAlgorithm, "Mesh Algorithm"), (scaleValue, "Scale Value"),
96  (removeBoundaryPacks, "Remove geometries on boundary"),
97  (enableDefaultOut, "Enalbe Default Outputs"),
98  (preserveSize, "Enable Size Preservation"),
99  (refineLevel, "Refinement Levels"), (upperThreshold, "Upper Threshold"),
100  (lowerThreshold, "Lower Threshold"))
101 
102 JSONCONS_N_MEMBER_NAME_TRAITS(NEM::DRV::SurfacePackMeshDriver::Periodic3DOpts,
103  0, (physGrpOptions, "Physical Group Options"),
104  (createCohesive, "Create cohesive elements"),
105  (enablePatches, "Enable Patches"),
106  (setPeriodicGeo, "Set Periodic Geometry"),
107  (elemOrder, "Element Order"),
108  (customDomain, "Custom Domain"),
109  (transferMesh, "TransferMesh"))
110 
111 JSONCONS_ENUM_NAME_TRAITS(NEM::DRV::SurfacePackMeshDriver::PhysGrpOpts,
112  (NONE, "None"), (MULTI, "Multi Physical Groups"),
113  (TWO, "Two Physical Groups"),
114  (PER_SHAPE, "Physical Group per Shape"))
115 
116 JSONCONS_ALL_MEMBER_NAME_TRAITS(NEM::DRV::SurfacePackMeshDriver::CustomDomain,
117  (initial, "Initial"), (length, "Length"))
118 #endif
119 
120 #ifdef HAVE_CFMSH
121 // HexPackMeshDriver
124  (getFiles, setFiles, NEM::DRV::JSON::meshFiles),
125  (getOpts, setOpts, NEM::DRV::JSON::packMeshOpts, JSONCONS_RDWR))
126 
127 namespace jsoncons {
128 template <typename Json>
129 struct json_type_traits<Json, NEM::DRV::HexPackMeshDriver::Files> {
130  using value_type = NEM::DRV::HexPackMeshDriver::Files;
131  using allocator_type = typename Json::allocator_type;
132  static constexpr auto rockFile = "Input Rocpack File";
133  static constexpr auto pmFile = "Output Pack Mesh File";
134  static constexpr auto smFile = "Output Surrounding Mesh File";
135  static constexpr auto cmFile = "Output Combined Mesh File";
136  static bool is(const Json &ajson) noexcept {
137  return ajson.is_object() &&
138  (ajson.contains(rockFile) !=
139  ajson.contains(NEM::DRV::JSON::inGeoFile)) &&
140  ajson.contains(pmFile) && ajson.contains(smFile);
141  }
142  static value_type as(const Json &ajson) {
143  if (!is(ajson))
144  throw convert_error(convert_errc::conversion_failed,
145  "Not a HexPackMeshDriver::Files");
146  value_type aval{};
147  if (ajson.contains(rockFile))
148  aval.setRocpackFile(ajson.at(rockFile).as_string());
149  if (ajson.contains(NEM::DRV::JSON::inGeoFile))
150  aval.setGeoFile(ajson.at(NEM::DRV::JSON::inGeoFile).as_string());
151  json_traits_helper<Json>::set_udt_member(ajson, pmFile,
152  aval.outPackMeshFile);
153  json_traits_helper<Json>::set_udt_member(ajson, smFile,
154  aval.outSurroundingFile);
155  if (ajson.contains(cmFile))
156  json_traits_helper<Json>::set_udt_member(ajson, cmFile,
157  aval.outCombinedFile);
158  return aval;
159  }
160  static Json to_json(const value_type &aval,
161  allocator_type alloc = allocator_type()) {
162  Json ajson(json_object_arg, semantic_tag::none, alloc);
163  ajson.try_emplace(
164  aval.isInputRocpackFile() ? rockFile : NEM::DRV::JSON::inGeoFile,
165  aval.rocpackOrGeoFile);
166  ajson.try_emplace(pmFile, aval.outPackMeshFile);
167  ajson.try_emplace(smFile, aval.outSurroundingFile);
168  ajson.try_emplace(cmFile, aval.outCombinedFile);
169  return ajson;
170  }
171 };
172 template <>
173 struct is_json_type_traits_declared<NEM::DRV::HexPackMeshDriver::Files>
174  : public std::true_type {};
175 } // namespace jsoncons
176 
177 JSONCONS_N_MEMBER_NAME_TRAITS(
179  (type, "Type", JSONCONS_RDONLY,
180  [](const jsoncons::string_view &x) {
182  }),
183  (engine, "Engine", JSONCONS_RDONLY,
184  [](const jsoncons::string_view &x) {
186  }),
188  (mmfMergeParams, "MeshManipulation mergeMeshes Parameters"),
189  (mmfCreatePatchParams, "MeshManipulation createPatch Parameters"),
190  (locAdjust, "locInMesh_adjust"))
191 
192 JSONCONS_N_MEMBER_NAME_TRAITS(MeshManipulationFoamParams::MergeMeshes, 0,
193  (overwriteMergeMsh, "overwrite?"),
194  (masterCasePath, "Master Region Path"),
195  (addCasePath, "Add Region Path"))
196 
197 JSONCONS_N_MEMBER_NAME_TRAITS(MeshManipulationFoamParams::CreatePatch, 0,
198  (surroundingName, "Surrounding PatchName"),
199  (packsName, "Packs PatchName"),
200  (srrndngPatchType, "Surrounding PatchType"),
201  (packsPatchType, "Packs PatchType"),
202  (overwritecpMsh, "overwrite?"))
203 #endif
204 
205 #undef IF_CFMSH
206 #undef IF_GMSH
207 
208 #endif // NEMOSYS_PACKMESHJSON_H_
base class for drivers
Definition: NemDriver.H:46
static constexpr auto inGeoFile
static constexpr const char * engine
static constexpr auto packMeshOpts
Definition: PackMeshJson.H:55
static constexpr auto outMeshFile
static constexpr auto bmParams
static constexpr const char * type
This class drives the flow of pack meshing by using parameters provided by users. ...
static constexpr const char * engine
#define NEM_JSON_N_GETTER_SETTER_NAME_TRAITS_FINAL(ValueType, ParentType, NumMandatoryParams,...)
#define NEM_JSON_N_GETTER_SETTER_NAME_TRAITS_INTERMEDIATE(BaseClass, ChildClasses, ParentClass, NumMandatoryParams,...)
static constexpr auto smParams
#define IF_GMSH(a)
Definition: PackMeshJson.H:48
static constexpr auto programType
static constexpr const char * programType
static constexpr auto meshFiles
#define NEM_JSON_RDONLY_OVERRIDE(X)
Definition: NemJsonMacros.H:39
#define IF_CFMSH(a)
Definition: PackMeshJson.H:38