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.
NEM::DRV::JSON Namespace Reference

Classes

struct  colorMapPair
 
struct  function_traits
 
struct  function_traits< R(*)(Args...)>
 
struct  function_traits< R(Args...)>
 
struct  function_traits< R(T::*)(Args...)>
 

Typedefs

template<typename T >
using first_argument_type = typename std::tuple_element< 0, typename function_traits< T >::argument_types >::type
 

Functions

std::vector< PNTMesh::surfaceBCTagpntMeshBcTagFromJSON (const std::string &input)
 
std::string pntMeshBcTagToJSON (const std::vector< PNTMesh::surfaceBCTag > &input)
 
std::vector< int > rangeToVec (const std::pair< int, int > &input)
 
std::vector< colorMapPairgmshColorMapToJSON (const std::map< std::array< int, 3 >, std::string > &colorMap)
 
std::map< std::array< int, 3 >, std::string > gmshColorMapFromJSON (const std::vector< colorMapPair > &colorMap)
 
template<typename T , typename R , typename... Args>
void setter_helper (T &obj, R(T::*setter)(Args...), const jsoncons::json &json, jsoncons::string_view key, bool checkContains)
 
template<typename T >
std::unique_ptr< NEM::NUCMESH::ShapeBaseconstruct_helper (const jsoncons::json &json, const std::map< std::string, std::unique_ptr< NEM::NUCMESH::ShapeBase >> &savedShapes)
 
std::unique_ptr< NEM::NUCMESH::ShapeBaseas_shape (const jsoncons::json &json, const std::map< std::string, std::unique_ptr< NEM::NUCMESH::ShapeBase >> &savedShapes)
 
template<typename T >
std::enable_if< std::is_base_of< NEM::NUCMESH::ShapeBase, T >::value, void >::type modify_helper (const jsoncons::json &json, T &shape, const std::map< std::string, std::unique_ptr< NEM::NUCMESH::ShapeBase >> &savedShapes, bool checkRequired)
 
template<>
void modify_helper (const jsoncons::json &json, NEM::NUCMESH::ShapeBase &shape, const std::map< std::string, std::unique_ptr< NEM::NUCMESH::ShapeBase >> &, bool)
 
template<>
void modify_helper (const jsoncons::json &json, NEM::NUCMESH::Circles &shape, const std::map< std::string, std::unique_ptr< NEM::NUCMESH::ShapeBase >> &savedShapes, bool checkRequired)
 
template<>
std::unique_ptr< NEM::NUCMESH::ShapeBaseconstruct_helper< NEM::NUCMESH::Circles > (const jsoncons::json &json, const std::map< std::string, std::unique_ptr< NEM::NUCMESH::ShapeBase >> &savedShapes)
 
template<>
void modify_helper (const jsoncons::json &json, NEM::NUCMESH::CirclesAndPolys &shape, const std::map< std::string, std::unique_ptr< NEM::NUCMESH::ShapeBase >> &savedShapes, bool checkRequired)
 
template<>
std::unique_ptr< NEM::NUCMESH::ShapeBaseconstruct_helper< NEM::NUCMESH::CirclesAndPolys > (const jsoncons::json &json, const std::map< std::string, std::unique_ptr< NEM::NUCMESH::ShapeBase >> &savedShapes)
 
template<>
void modify_helper (const jsoncons::json &json, NEM::NUCMESH::ShapesArray &shape, const std::map< std::string, std::unique_ptr< NEM::NUCMESH::ShapeBase >> &savedShapes, bool checkRequired)
 
template<>
void modify_helper (const jsoncons::json &json, NEM::NUCMESH::PolarArray &shape, const std::map< std::string, std::unique_ptr< NEM::NUCMESH::ShapeBase >> &savedShapes, bool checkRequired)
 
template<>
std::unique_ptr< NEM::NUCMESH::ShapeBaseconstruct_helper< NEM::NUCMESH::PolarArray > (const jsoncons::json &json, const std::map< std::string, std::unique_ptr< NEM::NUCMESH::ShapeBase >> &savedShapes)
 
template<>
void modify_helper (const jsoncons::json &json, NEM::NUCMESH::RectangularArray &shape, const std::map< std::string, std::unique_ptr< NEM::NUCMESH::ShapeBase >> &savedShapes, bool checkRequired)
 
template<>
std::unique_ptr< NEM::NUCMESH::ShapeBaseconstruct_helper< NEM::NUCMESH::RectangularArray > (const jsoncons::json &json, const std::map< std::string, std::unique_ptr< NEM::NUCMESH::ShapeBase >> &savedShapes)
 
template<>
void modify_helper (const jsoncons::json &json, NEM::NUCMESH::HexagonalArray &shape, const std::map< std::string, std::unique_ptr< NEM::NUCMESH::ShapeBase >> &savedShapes, bool checkRequired)
 
template<>
std::unique_ptr< NEM::NUCMESH::ShapeBaseconstruct_helper< NEM::NUCMESH::HexagonalArray > (const jsoncons::json &json, const std::map< std::string, std::unique_ptr< NEM::NUCMESH::ShapeBase >> &savedShapes)
 
template<typename T >
std::unique_ptr< NEM::NUCMESH::ShapeBaseconstruct_from_alias_helper (const jsoncons::json &json, const T *const aliasShape, const std::map< std::string, std::unique_ptr< NEM::NUCMESH::ShapeBase >> &savedShapes)
 
std::unique_ptr< NEM::NUCMESH::ShapeBaseconstruct_from_alias (const jsoncons::json &json, const NEM::NUCMESH::ShapeBase *const aliasShape, const std::map< std::string, std::unique_ptr< NEM::NUCMESH::ShapeBase >> &savedShapes)
 

Variables

static constexpr auto convOptions = "Conversion Options"
 
static constexpr auto convMethod = "Method"
 
static constexpr auto programType = "Program Type"
 
static constexpr auto meshFiles = "Mesh File Options"
 
static constexpr auto inMeshFile = "Input Mesh File"
 
static constexpr auto inGeoFile = "Input Geometry File"
 
static constexpr auto outMeshFile = "Output Mesh File"
 
static constexpr auto bmParams = "blockMesh Parameters"
 
static constexpr auto smParams = "snappyHexMesh Parameters"
 
static constexpr auto meshGenOpts = "Mesh Generation Options"
 
static constexpr auto meshGenEngine = "Mesh Generation Engine"
 
static constexpr auto meshQualOpts = "Mesh Quality Options"
 
static constexpr auto meshQualEngine = "Mesh Quality Engine"
 
static constexpr auto shapeType = "Type"
 
static constexpr auto arrayPattern = "Pattern"
 
static constexpr auto arrayShapes = "Shapes"
 
static constexpr auto packMeshOpts = "Pack Mesh Options"
 
static constexpr auto refOpts = "Refinement Options"
 
static constexpr auto refOperator = "Refinement Operator"
 
static constexpr auto refMethod = "Refinement Method"
 
static constexpr auto refTransferData = "Transfer Data"
 

Typedef Documentation

◆ first_argument_type

template<typename T >
using NEM::DRV::JSON::first_argument_type = typedef typename std::tuple_element< 0, typename function_traits<T>::argument_types>::type

Definition at line 79 of file NucMeshJson.H.

Function Documentation

◆ as_shape()

std::unique_ptr< NEM::NUCMESH::ShapeBase > NEM::DRV::JSON::as_shape ( const jsoncons::json &  json,
const std::map< std::string, std::unique_ptr< NEM::NUCMESH::ShapeBase >> &  savedShapes 
)
inline

Definition at line 371 of file NucMeshJson.H.

References arrayShapes, construct_from_alias(), meshFiles, NEM_JSON_N_GETTER_SETTER_NAME_TRAITS_FINAL, NEM_JSON_RDONLY_OVERRIDE, programType, NEM::DRV::NucMeshDriver::programType, and QUAD.

Referenced by modify_helper(), and setter_helper().

374  {
375  if (json.is_null()) {
376  return nullptr;
377  }
378  static constexpr auto loadSavedStr = "Saved Object";
379  if (json.contains(loadSavedStr)) {
380  auto findIter = savedShapes.find(json.at(loadSavedStr).as_string());
381  if (findIter != savedShapes.end() && findIter->second) {
382  return construct_from_alias(json, findIter->second.get(), savedShapes);
383  }
384  }
385  static constexpr auto typeStr = "Type";
386  if (json.contains(typeStr)) {
387  auto jsonType = json.at(typeStr).as_string_view();
388  if (jsonType == "Circles") {
389  return construct_helper<NEM::NUCMESH::Circles>(json, savedShapes);
390  } else if (jsonType == "Circles And Polys") {
391  return construct_helper<NEM::NUCMESH::CirclesAndPolys>(json, savedShapes);
392  } else if (jsonType == "Polar Array") {
393  return construct_helper<NEM::NUCMESH::PolarArray>(json, savedShapes);
394  } else if (jsonType == "Rectangular Array") {
395  return construct_helper<NEM::NUCMESH::RectangularArray>(json,
396  savedShapes);
397  } else if (jsonType == "Hexagonal Array") {
398  return construct_helper<NEM::NUCMESH::HexagonalArray>(json, savedShapes);
399  }
400  }
401  throw jsoncons::convert_error(jsoncons::convert_errc::conversion_failed,
402  "Not a NEM::NUCMESH::ShapeBase");
403 }
std::unique_ptr< NEM::NUCMESH::ShapeBase > construct_from_alias(const jsoncons::json &json, const NEM::NUCMESH::ShapeBase *const aliasShape, const std::map< std::string, std::unique_ptr< NEM::NUCMESH::ShapeBase >> &savedShapes)
Definition: NucMeshJson.H:347

◆ construct_from_alias()

std::unique_ptr<NEM::NUCMESH::ShapeBase> NEM::DRV::JSON::construct_from_alias ( const jsoncons::json &  json,
const NEM::NUCMESH::ShapeBase *const  aliasShape,
const std::map< std::string, std::unique_ptr< NEM::NUCMESH::ShapeBase >> &  savedShapes 
)
inline

Definition at line 347 of file NucMeshJson.H.

References construct_from_alias_helper().

Referenced by as_shape().

350  {
351  if (auto circles = dynamic_cast<const NEM::NUCMESH::Circles *>(aliasShape)) {
352  return construct_from_alias_helper(json, circles, savedShapes);
353  } else if (auto circlesAndPolys =
354  dynamic_cast<const NEM::NUCMESH::CirclesAndPolys *>(
355  aliasShape)) {
356  return construct_from_alias_helper(json, circlesAndPolys, savedShapes);
357  } else if (auto polar =
358  dynamic_cast<const NEM::NUCMESH::PolarArray *>(aliasShape)) {
359  return construct_from_alias_helper(json, polar, savedShapes);
360  } else if (auto rect = dynamic_cast<const NEM::NUCMESH::RectangularArray *>(
361  aliasShape)) {
362  return construct_from_alias_helper(json, rect, savedShapes);
363  } else if (auto hex = dynamic_cast<const NEM::NUCMESH::HexagonalArray *>(
364  aliasShape)) {
365  return construct_from_alias_helper(json, hex, savedShapes);
366  }
367  throw jsoncons::convert_error(jsoncons::convert_errc::conversion_failed,
368  "Not a NEM::NUCMESH::ShapeBase");
369 }
std::unique_ptr< NEM::NUCMESH::ShapeBase > construct_from_alias_helper(const jsoncons::json &json, const T *const aliasShape, const std::map< std::string, std::unique_ptr< NEM::NUCMESH::ShapeBase >> &savedShapes)
Definition: NucMeshJson.H:338

◆ construct_from_alias_helper()

template<typename T >
std::unique_ptr<NEM::NUCMESH::ShapeBase> NEM::DRV::JSON::construct_from_alias_helper ( const jsoncons::json &  json,
const T *const  aliasShape,
const std::map< std::string, std::unique_ptr< NEM::NUCMESH::ShapeBase >> &  savedShapes 
)

Definition at line 338 of file NucMeshJson.H.

References modify_helper().

Referenced by construct_from_alias().

341  {
342  auto output = new T{*aliasShape};
343  modify_helper(json, *output, savedShapes, false);
344  return std::unique_ptr<NEM::NUCMESH::ShapeBase>{output};
345 }
void modify_helper(const jsoncons::json &json, NEM::NUCMESH::HexagonalArray &shape, const std::map< std::string, std::unique_ptr< NEM::NUCMESH::ShapeBase >> &savedShapes, bool checkRequired)
Definition: NucMeshJson.H:299

◆ construct_helper()

template<typename T >
std::unique_ptr<NEM::NUCMESH::ShapeBase> NEM::DRV::JSON::construct_helper ( const jsoncons::json &  json,
const std::map< std::string, std::unique_ptr< NEM::NUCMESH::ShapeBase >> &  savedShapes 
)

Referenced by setter_helper().

◆ construct_helper< NEM::NUCMESH::Circles >()

template<>
std::unique_ptr<NEM::NUCMESH::ShapeBase> NEM::DRV::JSON::construct_helper< NEM::NUCMESH::Circles > ( const jsoncons::json &  json,
const std::map< std::string, std::unique_ptr< NEM::NUCMESH::ShapeBase >> &  savedShapes 
)

Definition at line 149 of file NucMeshJson.H.

References modify_helper().

152  {
153  auto shape = new NEM::NUCMESH::Circles{{}};
154  std::unique_ptr<NEM::NUCMESH::ShapeBase> out{shape};
155  modify_helper(json, *shape, savedShapes, true);
156  return out;
157 }
void modify_helper(const jsoncons::json &json, NEM::NUCMESH::HexagonalArray &shape, const std::map< std::string, std::unique_ptr< NEM::NUCMESH::ShapeBase >> &savedShapes, bool checkRequired)
Definition: NucMeshJson.H:299
A set of concentric circles and the faces they enclose.

◆ construct_helper< NEM::NUCMESH::CirclesAndPolys >()

template<>
std::unique_ptr<NEM::NUCMESH::ShapeBase> NEM::DRV::JSON::construct_helper< NEM::NUCMESH::CirclesAndPolys > ( const jsoncons::json &  json,
const std::map< std::string, std::unique_ptr< NEM::NUCMESH::ShapeBase >> &  savedShapes 
)

Definition at line 175 of file NucMeshJson.H.

References modify_helper().

178  {
179  auto shape = new NEM::NUCMESH::CirclesAndPolys{{}, {}};
180  std::unique_ptr<NEM::NUCMESH::ShapeBase> out{shape};
181  modify_helper(json, *shape, savedShapes, true);
182  return out;
183 }
void modify_helper(const jsoncons::json &json, NEM::NUCMESH::HexagonalArray &shape, const std::map< std::string, std::unique_ptr< NEM::NUCMESH::ShapeBase >> &savedShapes, bool checkRequired)
Definition: NucMeshJson.H:299
A set of concentric circles and polygons and the faces they enclose.

◆ construct_helper< NEM::NUCMESH::HexagonalArray >()

template<>
std::unique_ptr<NEM::NUCMESH::ShapeBase> NEM::DRV::JSON::construct_helper< NEM::NUCMESH::HexagonalArray > ( const jsoncons::json &  json,
const std::map< std::string, std::unique_ptr< NEM::NUCMESH::ShapeBase >> &  savedShapes 
)

Definition at line 326 of file NucMeshJson.H.

References modify_helper().

329  {
330  auto shape = new NEM::NUCMESH::HexagonalArray{
331  json.at("Pattern").array_value()[0].size(), {}};
332  std::unique_ptr<NEM::NUCMESH::ShapeBase> out{shape};
333  modify_helper(json, *shape, savedShapes, true);
334  return out;
335 }
void modify_helper(const jsoncons::json &json, NEM::NUCMESH::HexagonalArray &shape, const std::map< std::string, std::unique_ptr< NEM::NUCMESH::ShapeBase >> &savedShapes, bool checkRequired)
Definition: NucMeshJson.H:299

◆ construct_helper< NEM::NUCMESH::PolarArray >()

template<>
std::unique_ptr<NEM::NUCMESH::ShapeBase> NEM::DRV::JSON::construct_helper< NEM::NUCMESH::PolarArray > ( const jsoncons::json &  json,
const std::map< std::string, std::unique_ptr< NEM::NUCMESH::ShapeBase >> &  savedShapes 
)

Definition at line 246 of file NucMeshJson.H.

References modify_helper().

249  {
250  auto shape = new NEM::NUCMESH::PolarArray{
251  json.at("Pattern").array_value().size(), {}, {}, {}};
252  std::unique_ptr<NEM::NUCMESH::ShapeBase> out{shape};
253  modify_helper(json, *shape, savedShapes, true);
254  return out;
255 }
Arrange a series of other ShapeBase objects along a circular arc.
Definition: PolarArray.H:43
void modify_helper(const jsoncons::json &json, NEM::NUCMESH::HexagonalArray &shape, const std::map< std::string, std::unique_ptr< NEM::NUCMESH::ShapeBase >> &savedShapes, bool checkRequired)
Definition: NucMeshJson.H:299

◆ construct_helper< NEM::NUCMESH::RectangularArray >()

template<>
std::unique_ptr<NEM::NUCMESH::ShapeBase> NEM::DRV::JSON::construct_helper< NEM::NUCMESH::RectangularArray > ( const jsoncons::json &  json,
const std::map< std::string, std::unique_ptr< NEM::NUCMESH::ShapeBase >> &  savedShapes 
)

Definition at line 286 of file NucMeshJson.H.

References modify_helper().

289  {
290  auto patternJson = json.at("Pattern").array_value();
291  auto shape = new NEM::NUCMESH::RectangularArray{
292  {patternJson[0].size(), patternJson.size()}, {}};
293  std::unique_ptr<NEM::NUCMESH::ShapeBase> out{shape};
294  modify_helper(json, *shape, savedShapes, true);
295  return out;
296 }
void modify_helper(const jsoncons::json &json, NEM::NUCMESH::HexagonalArray &shape, const std::map< std::string, std::unique_ptr< NEM::NUCMESH::ShapeBase >> &savedShapes, bool checkRequired)
Definition: NucMeshJson.H:299

◆ gmshColorMapFromJSON()

◆ gmshColorMapToJSON()

std::vector<colorMapPair> NEM::DRV::JSON::gmshColorMapToJSON ( const std::map< std::array< int, 3 >, std::string > &  colorMap)
inline

Definition at line 86 of file MeshGenJson.H.

Referenced by gmshColorMapFromJSON().

87  {
88  std::vector<colorMapPair> out(colorMap.size());
89  std::transform(colorMap.begin(), colorMap.end(), out.begin(),
90  [](const std::pair<const std::array<int, 3>, std::string> &x) {
91  return colorMapPair{x.first, x.second};
92  });
93  return out;
94 }

◆ modify_helper() [1/8]

template<typename T >
std::enable_if<std::is_base_of<NEM::NUCMESH::ShapeBase, T>::value, void>::type NEM::DRV::JSON::modify_helper ( const jsoncons::json &  json,
T &  shape,
const std::map< std::string, std::unique_ptr< NEM::NUCMESH::ShapeBase >> &  savedShapes,
bool  checkRequired 
)

◆ modify_helper() [2/8]

template<>
void NEM::DRV::JSON::modify_helper ( const jsoncons::json &  json,
NEM::NUCMESH::ShapeBase shape,
const std::map< std::string, std::unique_ptr< NEM::NUCMESH::ShapeBase >> &  ,
bool   
)

Definition at line 119 of file NucMeshJson.H.

References NEM::NUCMESH::ShapeBase::getRotatedPoint(), and NEM::NUCMESH::ShapeBase::setCenter().

122  {
123  if (json.contains("Center")) {
124  auto centerSize = json.at("Center").array_value().size();
125  if (centerSize == 3) {
126  shape.setCenter(json.at("Center").as<std::array<double, 3>>());
127  } else if (centerSize == 5) {
128  auto center = json.at("Center").as<std::array<double, 5>>();
130  {center[0], center[1], center[2]}, {center[3], center[4]}));
131  }
132  }
133 }
static std::array< double, 3 > getRotatedPoint(const std::array< double, 3 > &center, const std::array< double, 2 > &rotation)
Definition: ShapeBase.C:58
void setCenter(const std::array< double, 3 > &center)
Definition: ShapeBase.C:52

◆ modify_helper() [3/8]

template<>
void NEM::DRV::JSON::modify_helper ( const jsoncons::json &  json,
NEM::NUCMESH::Circles shape,
const std::map< std::string, std::unique_ptr< NEM::NUCMESH::ShapeBase >> &  savedShapes,
bool  checkRequired 
)

Definition at line 136 of file NucMeshJson.H.

References modify_helper(), NEM::NUCMESH::Circles::setRings(), and setter_helper().

140  {
141  setter_helper(shape, &NEM::NUCMESH::Circles::setRings, json, "Rings",
142  checkRequired);
143  modify_helper(json, dynamic_cast<NEM::NUCMESH::ShapeBase &>(shape),
144  savedShapes, checkRequired);
145 }
void setRings(std::vector< Ring > rings)
void modify_helper(const jsoncons::json &json, NEM::NUCMESH::HexagonalArray &shape, const std::map< std::string, std::unique_ptr< NEM::NUCMESH::ShapeBase >> &savedShapes, bool checkRequired)
Definition: NucMeshJson.H:299
void setter_helper(T &obj, R(T::*setter)(Args...), const jsoncons::json &json, jsoncons::string_view key, bool checkContains)
Definition: NucMeshJson.H:86

◆ modify_helper() [4/8]

template<>
void NEM::DRV::JSON::modify_helper ( const jsoncons::json &  json,
NEM::NUCMESH::CirclesAndPolys shape,
const std::map< std::string, std::unique_ptr< NEM::NUCMESH::ShapeBase >> &  savedShapes,
bool  checkRequired 
)

Definition at line 160 of file NucMeshJson.H.

References modify_helper(), NEM::NUCMESH::CirclesAndPolys::setNumSides(), NEM::NUCMESH::CirclesAndPolys::setRings(), and setter_helper().

164  {
166  "Number of Sides", checkRequired);
168  checkRequired);
169  modify_helper(json, dynamic_cast<NEM::NUCMESH::ShapeBase &>(shape),
170  savedShapes, checkRequired);
171 }
void setNumSides(int numSides)
void modify_helper(const jsoncons::json &json, NEM::NUCMESH::HexagonalArray &shape, const std::map< std::string, std::unique_ptr< NEM::NUCMESH::ShapeBase >> &savedShapes, bool checkRequired)
Definition: NucMeshJson.H:299
void setRings(std::vector< PolyRing > rings)
void setter_helper(T &obj, R(T::*setter)(Args...), const jsoncons::json &json, jsoncons::string_view key, bool checkContains)
Definition: NucMeshJson.H:86

◆ modify_helper() [5/8]

template<>
void NEM::DRV::JSON::modify_helper ( const jsoncons::json &  json,
NEM::NUCMESH::ShapesArray shape,
const std::map< std::string, std::unique_ptr< NEM::NUCMESH::ShapeBase >> &  savedShapes,
bool  checkRequired 
)

Definition at line 186 of file NucMeshJson.H.

References as_shape(), NEM::NUCMESH::ShapesArray::getNumPatternShapes(), modify_helper(), and NEM::NUCMESH::ShapesArray::setPatternShape().

190  {
191  if (json.contains(arrayShapes) && json.at(arrayShapes).is_array()) {
192  std::size_t idx = 0;
193  for (auto &shapeJson : json.at(arrayShapes).array_range()) {
194  shape.setPatternShape(idx, as_shape(shapeJson, savedShapes));
195  ++idx;
196  }
197  for (; idx < shape.getNumPatternShapes(); ++idx) {
198  shape.setPatternShape(idx, nullptr);
199  }
200  } else if (checkRequired) {
201  throw jsoncons::convert_error(jsoncons::convert_errc::conversion_failed,
202  "Not a NEM::NUCMESH::ShapesArray");
203  }
204  modify_helper(json, dynamic_cast<NEM::NUCMESH::ShapeBase &>(shape),
205  savedShapes, checkRequired);
206 }
std::size_t getNumPatternShapes() const
Definition: ShapesArray.C:45
void modify_helper(const jsoncons::json &json, NEM::NUCMESH::HexagonalArray &shape, const std::map< std::string, std::unique_ptr< NEM::NUCMESH::ShapeBase >> &savedShapes, bool checkRequired)
Definition: NucMeshJson.H:299
void setPatternShape(std::size_t idx, const std::shared_ptr< ShapeBase > &shape)
Definition: ShapesArray.C:57
std::unique_ptr< NEM::NUCMESH::ShapeBase > as_shape(const jsoncons::json &json, const std::map< std::string, std::unique_ptr< NEM::NUCMESH::ShapeBase >> &savedShapes)
Definition: NucMeshJson.H:371
static constexpr auto arrayShapes
Definition: NucMeshJson.H:83

◆ modify_helper() [6/8]

template<>
void NEM::DRV::JSON::modify_helper ( const jsoncons::json &  json,
NEM::NUCMESH::PolarArray shape,
const std::map< std::string, std::unique_ptr< NEM::NUCMESH::ShapeBase >> &  savedShapes,
bool  checkRequired 
)

Definition at line 209 of file NucMeshJson.H.

References NEM::NUCMESH::PolarArray::getNumSubshapes(), modify_helper(), NEM::NUCMESH::PolarArray::setEndAngle(), NEM::NUCMESH::ShapesArray::setPattern(), NEM::NUCMESH::PolarArray::setRadius(), NEM::NUCMESH::PolarArray::setRotateWithArray(), NEM::NUCMESH::PolarArray::setStartAngle(), and setter_helper().

213  {
214  setter_helper(shape, &NEM::NUCMESH::PolarArray::setRadius, json, "Radius",
215  checkRequired);
217  "Start Angle", checkRequired);
219  "End Angle", checkRequired);
221  "Rotate with Array", false);
222  if (json.contains(arrayPattern)) {
223  auto patternIdJson = json.at(arrayPattern).array_value();
224  if (!patternIdJson.empty()) {
225  auto patternIdIter = patternIdJson.begin();
226  const auto patternIdEnd = patternIdJson.end();
227  for (std::size_t patternIdx = 0; patternIdx < shape.getNumSubshapes();
228  ++patternIdx) {
229  shape.setPattern(patternIdx, patternIdIter->as<std::size_t>());
230  ++patternIdIter;
231  if (patternIdIter == patternIdEnd) {
232  patternIdIter = patternIdJson.begin();
233  }
234  }
235  }
236  } else if (checkRequired) {
237  throw jsoncons::convert_error(jsoncons::convert_errc::conversion_failed,
238  "Not a NEM::NUCMESH::PolarArray");
239  }
240  modify_helper(json, dynamic_cast<NEM::NUCMESH::ShapesArray &>(shape),
241  savedShapes, checkRequired);
242 }
void setEndAngle(double endAngle)
Definition: PolarArray.H:64
void setRotateWithArray(bool rotateWithArray)
Definition: PolarArray.H:66
void modify_helper(const jsoncons::json &json, NEM::NUCMESH::HexagonalArray &shape, const std::map< std::string, std::unique_ptr< NEM::NUCMESH::ShapeBase >> &savedShapes, bool checkRequired)
Definition: NucMeshJson.H:299
static constexpr auto arrayPattern
Definition: NucMeshJson.H:82
void setRadius(double radius)
Definition: PolarArray.H:60
void setter_helper(T &obj, R(T::*setter)(Args...), const jsoncons::json &json, jsoncons::string_view key, bool checkContains)
Definition: NucMeshJson.H:86
void setStartAngle(double startAngle)
Definition: PolarArray.H:62
std::size_t getNumSubshapes() const
Definition: PolarArray.H:58
void setPattern(std::size_t idx, std::size_t patternKey)
Definition: ShapesArray.C:77

◆ modify_helper() [7/8]

template<>
void NEM::DRV::JSON::modify_helper ( const jsoncons::json &  json,
NEM::NUCMESH::RectangularArray shape,
const std::map< std::string, std::unique_ptr< NEM::NUCMESH::ShapeBase >> &  savedShapes,
bool  checkRequired 
)

Definition at line 258 of file NucMeshJson.H.

References NEM::NUCMESH::RectangularArray::getGridDims(), modify_helper(), NEM::NUCMESH::RectangularArray::setGridDistance(), NEM::NUCMESH::RectangularArray::setPattern(), and setter_helper().

262  {
264  "Grid Distance", checkRequired);
265  if (json.contains(arrayPattern)) {
266  const auto gridSize = shape.getGridDims();
267  auto y = gridSize[1] - 1;
268  for (auto &patternRow : json.at(arrayPattern).array_range()) {
269  std::size_t x = 0;
270  for (auto &patternJson : patternRow.array_range()) {
271  shape.setPattern(x, y, patternJson.as<std::size_t>());
272  ++x;
273  }
274  --y;
275  }
276  } else if (checkRequired) {
277  throw jsoncons::convert_error(jsoncons::convert_errc::conversion_failed,
278  "Not a NEM::NUCMESH::RectangularArray");
279  }
280  modify_helper(json, dynamic_cast<NEM::NUCMESH::ShapesArray &>(shape),
281  savedShapes, checkRequired);
282 }
const std::array< std::size_t, 2 > & getGridDims() const
void setGridDistance(const std::array< double, 2 > &gridDistance)
void modify_helper(const jsoncons::json &json, NEM::NUCMESH::HexagonalArray &shape, const std::map< std::string, std::unique_ptr< NEM::NUCMESH::ShapeBase >> &savedShapes, bool checkRequired)
Definition: NucMeshJson.H:299
static constexpr auto arrayPattern
Definition: NucMeshJson.H:82
void setter_helper(T &obj, R(T::*setter)(Args...), const jsoncons::json &json, jsoncons::string_view key, bool checkContains)
Definition: NucMeshJson.H:86
void setPattern(std::size_t x, std::size_t y, std::size_t patternKey)
The shape at [x, y] will be translated by [(x - (getGridDims()[0] - 1) / 2) * getGridDistance()[0]...

◆ modify_helper() [8/8]

template<>
void NEM::DRV::JSON::modify_helper ( const jsoncons::json &  json,
NEM::NUCMESH::HexagonalArray shape,
const std::map< std::string, std::unique_ptr< NEM::NUCMESH::ShapeBase >> &  savedShapes,
bool  checkRequired 
)

Definition at line 299 of file NucMeshJson.H.

References modify_helper(), NEM::NUCMESH::HexagonalArray::setGridDistance(), NEM::NUCMESH::HexagonalArray::setPatternRowCol(), and setter_helper().

303  {
305  "Grid Distance", checkRequired);
306  if (json.contains(arrayPattern)) {
307  int x = 0;
308  for (auto &patternRow : json.at(arrayPattern).array_range()) {
309  int y = 0;
310  for (auto &patternJson : patternRow.array_range()) {
311  shape.setPatternRowCol(x, y, patternJson.as<std::size_t>());
312  ++y;
313  }
314  ++x;
315  }
316  } else if (checkRequired) {
317  throw jsoncons::convert_error(jsoncons::convert_errc::conversion_failed,
318  "Not a NEM::NUCMESH::HexagonalArray");
319  }
320  modify_helper(json, dynamic_cast<NEM::NUCMESH::ShapesArray &>(shape),
321  savedShapes, checkRequired);
322 }
void setPatternRowCol(int row, int col, std::size_t patternKey)
void modify_helper(const jsoncons::json &json, NEM::NUCMESH::HexagonalArray &shape, const std::map< std::string, std::unique_ptr< NEM::NUCMESH::ShapeBase >> &savedShapes, bool checkRequired)
Definition: NucMeshJson.H:299
void setGridDistance(double gridDistance)
static constexpr auto arrayPattern
Definition: NucMeshJson.H:82
void setter_helper(T &obj, R(T::*setter)(Args...), const jsoncons::json &json, jsoncons::string_view key, bool checkContains)
Definition: NucMeshJson.H:86

◆ pntMeshBcTagFromJSON()

std::vector<PNTMesh::surfaceBCTag> NEM::DRV::JSON::pntMeshBcTagFromJSON ( const std::string &  input)
inline

Definition at line 72 of file ConversionJson.H.

References PNTMesh::bcTagNum().

Referenced by rangeToVec().

73  {
74  return {PNTMesh::bcTagNum(input)};
75 }
surfaceBCTag bcTagNum(const std::string &tag)
Definition: pntMesh.C:78

◆ pntMeshBcTagToJSON()

std::string NEM::DRV::JSON::pntMeshBcTagToJSON ( const std::vector< PNTMesh::surfaceBCTag > &  input)
inline

Definition at line 77 of file ConversionJson.H.

References PNTMesh::bcTagStr().

Referenced by rangeToVec().

78  {
79  return input.empty() ? std::string{} : PNTMesh::bcTagStr(input.at(0));
80 }
std::string bcTagStr(surfaceBCTag tag)
Definition: pntMesh.C:88

◆ rangeToVec()

std::vector<int> NEM::DRV::JSON::rangeToVec ( const std::pair< int, int > &  input)
inline

◆ setter_helper()

template<typename T , typename R , typename... Args>
void NEM::DRV::JSON::setter_helper ( T &  obj,
R(T::*)(Args...)  setter,
const jsoncons::json &  json,
jsoncons::string_view  key,
bool  checkContains 
)

Definition at line 86 of file NucMeshJson.H.

References as_shape(), and construct_helper().

Referenced by modify_helper().

87  {
88  if (json.contains(key)) {
89  (obj.*setter)(json.at(key)
90  .as<typename std::decay<
92  } else if (checkContains) {
93  throw jsoncons::convert_error(jsoncons::convert_errc::conversion_failed,
94  "Not a NEM::NUCMESH::ShapeBase");
95  }
96 }
typename std::tuple_element< 0, typename function_traits< T >::argument_types >::type first_argument_type
Definition: NucMeshJson.H:79

Variable Documentation

◆ arrayPattern

constexpr auto NEM::DRV::JSON::arrayPattern = "Pattern"
static

Definition at line 82 of file NucMeshJson.H.

◆ arrayShapes

constexpr auto NEM::DRV::JSON::arrayShapes = "Shapes"
static

Definition at line 83 of file NucMeshJson.H.

Referenced by as_shape().

◆ bmParams

constexpr auto NEM::DRV::JSON::bmParams = "blockMesh Parameters"
static

Definition at line 89 of file DriverJsonTypeTraits.H.

Referenced by gmshColorMapFromJSON().

◆ convMethod

constexpr auto NEM::DRV::JSON::convMethod = "Method"
static

Definition at line 70 of file ConversionJson.H.

Referenced by rangeToVec().

◆ convOptions

constexpr auto NEM::DRV::JSON::convOptions = "Conversion Options"
static

Definition at line 69 of file ConversionJson.H.

Referenced by rangeToVec().

◆ inGeoFile

constexpr auto NEM::DRV::JSON::inGeoFile = "Input Geometry File"
static

Definition at line 87 of file DriverJsonTypeTraits.H.

Referenced by gmshColorMapFromJSON().

◆ inMeshFile

constexpr auto NEM::DRV::JSON::inMeshFile = "Input Mesh File"
static

Definition at line 86 of file DriverJsonTypeTraits.H.

Referenced by rangeToVec().

◆ meshFiles

constexpr auto NEM::DRV::JSON::meshFiles = "Mesh File Options"
static

Definition at line 85 of file DriverJsonTypeTraits.H.

Referenced by as_shape(), gmshColorMapFromJSON(), and rangeToVec().

◆ meshGenEngine

constexpr auto NEM::DRV::JSON::meshGenEngine = "Mesh Generation Engine"
static

Definition at line 79 of file MeshGenJson.H.

Referenced by gmshColorMapFromJSON().

◆ meshGenOpts

constexpr auto NEM::DRV::JSON::meshGenOpts = "Mesh Generation Options"
static

Definition at line 78 of file MeshGenJson.H.

Referenced by gmshColorMapFromJSON().

◆ meshQualEngine

constexpr auto NEM::DRV::JSON::meshQualEngine = "Mesh Quality Engine"
static

Definition at line 48 of file MeshQualityJson.H.

◆ meshQualOpts

constexpr auto NEM::DRV::JSON::meshQualOpts = "Mesh Quality Options"
static

Definition at line 47 of file MeshQualityJson.H.

◆ outMeshFile

constexpr auto NEM::DRV::JSON::outMeshFile = "Output Mesh File"
static

Definition at line 88 of file DriverJsonTypeTraits.H.

Referenced by gmshColorMapFromJSON(), and rangeToVec().

◆ packMeshOpts

constexpr auto NEM::DRV::JSON::packMeshOpts = "Pack Mesh Options"
static

Definition at line 55 of file PackMeshJson.H.

◆ programType

constexpr auto NEM::DRV::JSON::programType = "Program Type"
static

Definition at line 84 of file DriverJsonTypeTraits.H.

Referenced by as_shape(), gmshColorMapFromJSON(), and rangeToVec().

◆ refMethod

constexpr auto NEM::DRV::JSON::refMethod = "Refinement Method"
static

Definition at line 66 of file RefineJson.H.

◆ refOperator

constexpr auto NEM::DRV::JSON::refOperator = "Refinement Operator"
static

Definition at line 65 of file RefineJson.H.

◆ refOpts

constexpr auto NEM::DRV::JSON::refOpts = "Refinement Options"
static

Definition at line 64 of file RefineJson.H.

◆ refTransferData

constexpr auto NEM::DRV::JSON::refTransferData = "Transfer Data"
static

Definition at line 67 of file RefineJson.H.

◆ shapeType

◆ smParams

constexpr auto NEM::DRV::JSON::smParams = "snappyHexMesh Parameters"
static

Definition at line 90 of file DriverJsonTypeTraits.H.

Referenced by gmshColorMapFromJSON().