62 const std::string &meshEngine,
64 const std::string &ofname) {
65 std::cout <<
"MeshGenDriver created" << std::endl;
70 if (meshEngine ==
"netgen") {
72 generator =
new netgenGen(dynamic_cast<netgenParams *>(params));
75 std::cerr <<
"NETGEN is not enabled during build." 76 <<
" Build NEMoSys with ENABLE_NETGEN to use this method." 80 }
else if (meshEngine ==
"gmsh") {
85 }
else if (meshEngine ==
"cfmesh") {
86 generator =
new cfmeshGen(dynamic_cast<cfmeshParams *>(params));
88 }
else if (meshEngine ==
"snappyHexMesh") {
89 generator =
new snappymeshGen(dynamic_cast<snappymeshParams *>(params));
91 }
else if (meshEngine ==
"blockMesh") {
92 generator =
new blockMeshGen(dynamic_cast<blockMeshParams *>(params));
96 std::cerr << meshEngine <<
" is not a supported meshing engine" 102 std::cerr <<
"Meshing with engine " << meshEngine <<
" failed. Aborting." 110 std::cerr <<
"Mesh Engine " << meshEngine <<
" not recognized" << std::endl;
116 std::shared_ptr<meshBase>
mesh;
117 if (outputType ==
".msh" && meshEngine ==
"gmsh") {
124 if (meshEngine ==
"netgen") {
127 }
else if (meshEngine ==
"gmsh") {
130 if (outputType ==
".msh")
return;
139 if (meshEngine ==
"cfmesh" || meshEngine ==
"snappyHexMesh" ||
140 meshEngine ==
"blockMesh") {
142 geoMesh->takeGeoMesh(generator->
gmData.get());
143 geoMesh->write(ofname);
146 mesh->setFileName(ofname);
152 std::shared_ptr<meshBase> MeshGenDriver::getNewMesh()
const {
156 MeshGenDriver::~MeshGenDriver() {
157 std::cout <<
"MeshGenDriver destroyed" << std::endl;
162 inputjson[
"Mesh File Options"][
"Input Geometry File"].as<std::string>();
164 inputjson[
"Mesh File Options"][
"Output Mesh File"].as<std::string>();
165 return readJSON(ifname, ofname, inputjson);
169 const std::string &ofname,
170 const jsoncons::json &inputjson) {
171 std::string meshEngine =
172 inputjson[
"Mesh Generation Engine"].as<std::string>();
173 if (meshEngine ==
"netgen") {
175 std::string defaults =
176 inputjson[
"Meshing Parameters"][
"Netgen Parameters"].as<std::string>();
177 if (defaults ==
"default") {
179 auto *mshgndrvobj =
new MeshGenDriver(ifname, meshEngine, params, ofname);
182 jsoncons::json ngparams =
183 inputjson[
"Meshing Parameters"][
"Netgen Parameters"];
187 if (ngparams.contains(
"uselocalh"))
188 params->uselocalh = ngparams[
"uselocalh"].as<
bool>();
189 if (ngparams.contains(
"maxh"))
190 params->maxh = ngparams[
"maxh"].as<
double>();
191 if (ngparams.contains(
"fineness"))
192 params->fineness = ngparams[
"fineness"].as<
double>();
193 if (ngparams.contains(
"grading"))
194 params->grading = ngparams[
"grading"].as<
double>();
195 if (ngparams.contains(
"elementsperedge"))
196 params->elementsperedge = ngparams[
"elementsperedge"].as<
double>();
197 if (ngparams.contains(
"elementspercurve"))
198 params->elementspercurve = ngparams[
"elementspercurve"].as<
double>();
199 if (ngparams.contains(
"closeedgeenable"))
200 params->closeedgeenable = ngparams[
"closeedgeenable"].as<
bool>();
201 if (ngparams.contains(
"closeedgefact"))
202 params->closeedgefact = ngparams[
"closeedgefact"].as<
double>();
203 if (ngparams.contains(
"second_order"))
204 params->second_order = ngparams[
"second_order"].as<
bool>();
205 if (ngparams.contains(
"meshsize_filename"))
206 params->meshsize_filename =
207 ngparams[
"meshsize_filename"].as<std::string>();
208 if (ngparams.contains(
"quad_dominated"))
209 params->quad_dominated = ngparams[
"quad_dominated"].as<
bool>();
210 if (ngparams.contains(
"optvolmeshenable"))
211 params->optvolmeshenable = ngparams[
"optvolmeshenable"].as<
bool>();
212 if (ngparams.contains(
"optsteps_2d"))
213 params->optsteps_2d = ngparams[
"optsteps_2d"].as<
int>();
214 if (ngparams.contains(
"optsteps_3d"))
215 params->optsteps_3d = ngparams[
"optsteps_3d"].as<
int>();
216 if (ngparams.contains(
"invert_tets"))
217 params->invert_tets = ngparams[
"invert_tets"].as<
bool>();
218 if (ngparams.contains(
"invert_trigs"))
219 params->invert_trigs = ngparams[
"invert_trigs"].as<
bool>();
220 if (ngparams.contains(
"check_overlap"))
221 params->check_overlap = ngparams[
"check_overlap"].as<
bool>();
222 if (ngparams.contains(
"check_overlapping_boundary"))
223 params->check_overlapping_boundary =
224 ngparams[
"check_overlapping_boundary"].as<
bool>();
225 if (ngparams.contains(
"refine_with_geometry_adaptation"))
226 params->refine_with_geom =
227 ngparams[
"refine_with_geometry_adaptation"].as<
bool>();
228 if (ngparams.contains(
"refine_without_geometry_adaptation"))
229 params->refine_without_geom =
230 ngparams[
"refine_without_geometry_adaptation"].as<
bool>();
232 auto *mshgndrvobj =
new MeshGenDriver(ifname, meshEngine, params, ofname);
238 }
else if (meshEngine ==
"gmsh") {
239 std::cout <<
"Gmsh mesh engine selected" << std::endl;
241 std::string defaults;
242 if (inputjson.contains(
"Meshing Parameters")) {
243 if (inputjson[
"Meshing Parameters"].contains(
"Gmsh Parameters")) {
245 inputjson[
"Meshing Parameters"][
"Gmsh Parameters"].as_string();
247 std::cerr <<
"Error: 'Gmsh Parameters' not found in JSON" << std::endl;
251 std::cerr <<
"Error: 'Meshing Parameters' not found in JSON" << std::endl;
254 if (defaults ==
"default") {
256 auto *mshgndrvobj =
new MeshGenDriver(ifname, meshEngine, params, ofname);
259 jsoncons::json gparams =
260 inputjson[
"Meshing Parameters"][
"Gmsh Parameters"];
266 inputjson[
"Mesh File Options"][
"Output Mesh File"].as_string();
267 params->ofname = ofname;
269 if (gparams.contains(
"minSize"))
270 params->minSize = gparams[
"minSize"].as_double();
271 if (gparams.contains(
"maxSize"))
272 params->maxSize = gparams[
"maxSize"].as_double();
273 if (gparams.contains(
"surfaceAlgorithm"))
274 params->algo2D = gparams[
"surfaceAlgorithm"].as_string();
275 if (gparams.contains(
"volumeAlgorithm"))
276 params->algo3D = gparams[
"volumeAlgorithm"].as_string();
277 if (gparams.contains(
"extendSizeFromBoundary"))
278 params->extSizeFromBoundary =
279 gparams[
"extendSizeFromBoundary"].as<
bool>();
280 if (gparams.contains(
"sizeFromCurvature"))
281 params->sizeFromCurvature = gparams[
"sizeFromCurvature"].as<
bool>();
282 if (gparams.contains(
"minElementsPer2Pi"))
283 params->minElePer2Pi = gparams[
"minElementsPer2Pi"].as<
int>();
284 if (gparams.contains(
"optimize"))
285 params->optimize = gparams[
"optimize"].as<
bool>();
286 if (gparams.contains(
"optimizeThreshold"))
287 params->optimizeThreshold = gparams[
"optimizeThreshold"].as_double();
288 if (gparams.contains(
"elementOrder"))
289 params->elementOrder = gparams[
"elementOrder"].as<
int>();
290 if (gparams.contains(
"subdivisionAlgorithm"))
291 params->subdivisionAlg = gparams[
"subdivisionAlgorithm"].as<
int>();
292 if (gparams.contains(
"saveAll"))
293 params->saveAll = gparams[
"saveAll"].as<
bool>();
294 if (gparams.contains(
"fragment"))
295 params->fragmentAll = gparams[
"fragment"].as<
bool>();
297 if (gparams.contains(
"ColorMap")) {
298 std::map<std::string, std::string> color2groupMap;
299 for (
const auto &cm : gparams[
"ColorMap"].array_range()) {
302 if (cm.contains(
"Color")) {
304 r = cm[
"Color"].at(0).as<
int>();
305 g = cm[
"Color"].at(1).as<
int>();
306 b = cm[
"Color"].at(2).as<
int>();
307 color = std::to_string(r) +
"," + std::to_string(g) +
"," +
310 std::cerr <<
"Error: Keyword 'Color' for Color Map not found." 314 if (cm.contains(
"Group")) {
315 name = cm[
"Group"].as<std::string>();
317 std::cerr <<
"Error: Keyword 'Group' for Color Map not found." 321 color2groupMap[color] = name;
323 params->mColorMap =
true;
324 params->color2groupMap = color2groupMap;
327 if (gparams.contains(
"TransfiniteBlocks")) {
328 for (
const auto &tb : gparams[
"TransfiniteBlocks"].array_range()) {
330 if (tb.contains(
"Volume")) {
331 block.
id = tb[
"Volume"].as<
int>();
333 std::cerr <<
"Error: Keyword 'id' for transfinite block not found." 337 if (tb.contains(
"Axis")) {
339 for (
int i = 0; i < 3; ++i) {
340 double x = tb[
"Axis"].at(i).at(0).as<
double>();
341 double y = tb[
"Axis"].at(i).at(1).as<
double>();
342 double z = tb[
"Axis"].at(i).at(2).as<
double>();
343 double axis_len = std::sqrt(x * x + y * y + z * z);
344 if (axis_len < 1e-3) {
345 std::cerr <<
"Axis " << i <<
" for block " << block.
id 346 <<
" is too small. Please prescribe an axis with " 351 block.
axis[i][0] = x / axis_len;
352 block.
axis[i][1] = y / axis_len;
353 block.
axis[i][2] = z / axis_len;
357 <<
"Error: Keyword 'axis' for transfinite block not found." 362 auto setTransfiniteCurve = [&tb,
363 &block](
const std::string &axis) ->
void {
365 if (axis ==
"x") idx = 0;
366 if (axis ==
"y") idx = 1;
367 if (axis ==
"z") idx = 2;
369 std::cerr <<
"Invalid axis name '" << axis
370 <<
"'. Valid axis names are : " 371 <<
"'x', 'y', and 'z'. Aborting." << std::endl;
374 if (tb.contains(axis)) {
375 block.
vert[idx] = tb[axis][
"Vertices"].as<
int>();
376 if (tb[axis].contains(
"Bump")) {
377 block.
type[idx] =
"Bump";
378 block.
coef[idx] = tb[axis][
"Bump"].as<
double>();
379 }
else if (tb[axis].contains(
"Progression")) {
380 block.
type[idx] =
"Progression";
381 block.
coef[idx] = tb[axis][
"Progression"].as<
double>();
384 std::cerr <<
"Error : Keyword '" << axis
385 <<
"' for transfinite block not found." << std::endl;
390 setTransfiniteCurve(
"x");
391 setTransfiniteCurve(
"y");
392 setTransfiniteCurve(
"z");
394 params->transfiniteBlocks[block.
id] = block;
396 params->mTransfiniteVolumes =
true;
400 std::string cap =
"SizeFields";
401 if (gparams.contains(cap)) {
402 std::cout <<
"Parsing SizeFields ...";
403 params->mSizeField =
true;
404 for (
const auto &sf : gparams[cap].array_range()) {
409 if (sf.contains(
"Type"))
410 sizeField.
type = sf[
"Type"].as_string();
412 std::cerr <<
"Error: Keyword 'Type' for Size Field not found." 418 if (sf.contains(
"ID"))
419 sizeField.
id = sf[
"ID"].as<
int>();
421 std::cerr <<
"Error: Keyword 'ID' for Size Field not found." 427 if (sf.contains(
"Params")) {
430 std::pair<std::string, double> p;
432 for (
const auto &prm : sf[
"Params"].object_range()) {
433 key = std::string(prm.key());
436 if (prm.value().is_array()) {
437 if (prm.value()[0].is_string()) {
438 std::pair<std::string, std::vector<std::string>> p_strg;
440 for (
int i = 0; i < prm.value().size(); i++) {
441 p_strg.second.push_back(prm.value()[i].as_string());
446 std::pair<std::string, std::vector<double>> p_num;
448 for (
int i = 0; i < prm.value().size(); i++) {
449 p_num.second.push_back(prm.value()[i].as_double());
455 val = prm.value().as_double();
457 sizeField.
params.push_back(p);
460 (params->sizeFields).push_back(sizeField);
462 std::cerr <<
"Error: Size Field of Type " << sizeField.
type 463 <<
" and ID " << sizeField.
id 464 <<
" has no 'Params' keyword" << std::endl;
470 if (gparams.contains(
"BackgroundField")) {
471 params->bgField = gparams[
"BackgroundField"].as<
int>();
472 }
else if (params->mSizeField && !gparams.contains(
"BackgroundField") &&
473 gparams[cap].size() > 1) {
474 std::cout <<
"Warning: Mesh Background Field not specified." 475 <<
" Using size field with highest ID." << std::endl;
477 std::cout <<
" Done." << std::endl;
479 auto *mshgndrvobj =
new MeshGenDriver(ifname, meshEngine, params, ofname);
482 }
else if (meshEngine ==
"cfmesh") {
484 std::cerr <<
"NEMoSys must be recompiled with cfMesh support." << std::endl;
488 std::string defaults =
489 inputjson[
"Meshing Parameters"][
"CFMesh Parameters"].as<std::string>();
490 if (defaults ==
"default") {
491 auto *mshgndrvobj =
new MeshGenDriver(ifname, meshEngine, params, ofname);
494 jsoncons::json cfmparams =
495 inputjson[
"Meshing Parameters"][
"CFMesh Parameters"];
499 if (inputjson[
"Mesh File Options"].contains(
"Input Geometry File"))
500 params->geomFilePath =
501 inputjson[
"Mesh File Options"][
"Input Geometry File"]
504 std::cerr <<
"A geometry file should be supplied.\n";
509 if (cfmparams.contains(
"Generator"))
510 params->generator = cfmparams[
"Generator"].as<std::string>();
512 std::cerr <<
"A mesh generation method should be selected.\n";
513 std::cerr <<
"Options: cartesian2D tetMesh\n";
518 if (cfmparams.contains(
"MaxCellSize"))
519 params->maxCellSize = cfmparams[
"MaxCellSize"].as<
double>();
520 if (cfmparams.contains(
"MinCellSize"))
521 params->minCellSize = cfmparams[
"MinCellSize"].as<
double>();
522 if (cfmparams.contains(
"BoundaryCellSize"))
523 params->bndryCellSize = cfmparams[
"BoundaryCellSize"].as<
double>();
524 if (cfmparams.contains(
"BoundaryCellSizeRefinementThickness"))
525 params->bndryCellSizeRefThk =
526 cfmparams[
"BoundaryCellSizeRefinementThickness"].as<
double>();
527 if (cfmparams.contains(
"KeepCellsIntersectingBoundary"))
529 cfmparams[
"KeepCellsIntersectingBoundary"].as<
bool>();
530 if (cfmparams.contains(
"CheckForGluedMesh"))
531 params->chkGluMsh = cfmparams[
"CheckForGluedMesh"].as<
bool>();
532 if (cfmparams.contains(
"AllowDisconnectedDomains"))
533 params->_alwDiscDomains =
534 cfmparams[
"AllowDisconnectedDomains"].as<
bool>();
536 params->_alwDiscDomains =
false;
539 std::string cap =
"BoundaryLayers";
540 if (cfmparams.contains(cap)) {
541 params->_withBndLyr =
true;
542 params->blNLyr = cfmparams[cap][
"NLayers"].as<
int>();
543 params->blThkRto = cfmparams[cap][
"ThicknessRatio"].as<
double>();
544 if (cfmparams[cap].contains(
"MaxFirstLayerThickness"))
545 params->maxFrstLyrThk =
546 cfmparams[cap][
"MaxFirstLayerThickness"].as<
double>();
547 if (cfmparams[cap].contains(
"AllowDiscontinuity"))
548 params->alwDiscont = cfmparams[cap][
"AllowDiscontinuity"].as<
bool>();
551 std::string subcap =
"PatchBoundaryLayers";
552 if (cfmparams[cap].contains(subcap)) {
553 params->_withBndLyrPtch =
true;
554 for (
const auto &jptch : cfmparams[cap][subcap].array_range()) {
556 blPatch.
patchName = jptch[
"PatchName"].as<std::string>();
557 if (jptch.contains(
"AllowDiscontinuity"))
558 blPatch.
alwDiscont = jptch[
"AllowDiscontinuity"].as<
bool>();
561 if (jptch.contains(
"MaxFirstLayerThickness"))
562 blPatch.
maxFrstLyrThk = jptch[
"MaxFirstLayerThickness"].as<
int>();
565 if (jptch.contains(
"NLayers"))
566 blPatch.
blNLyr = jptch[
"NLayers"].as<
int>();
569 if (jptch.contains(
"ThicknessRatio"))
570 blPatch.
blThkRto = jptch[
"ThicknessRatio"].as<
double>();
573 (params->blPatches).push_back(blPatch);
579 cap =
"SurfaceFeatureEdges";
580 if (cfmparams.contains(cap)) {
581 params->_withSrfEdg =
true;
582 params->srfEdgAng = cfmparams[cap][
"Angle"].as<
double>();
586 cap =
"ObjectRefinements";
587 if (cfmparams.contains(cap)) {
588 params->_withObjRfn =
true;
589 for (
const auto &refObj : cfmparams[cap].array_range()) {
591 objRef.
name = refObj[
"Name"].as<std::string>();
592 for (
const auto &prm : refObj[
"Params"].object_range()) {
593 std::string key = std::string(prm.key());
594 std::string val = prm.value().as<std::string>();
597 (params->objRefLst).push_back(objRef);
602 cap =
"ImproveMeshQuality";
603 if (cfmparams.contains(cap)) {
604 params->_withMshQlt =
true;
605 params->qltNItr = cfmparams[cap][
"NIterations"].as<
int>();
606 params->qltNLop = cfmparams[cap][
"NLoops"].as<
int>();
607 params->qltQltThr = cfmparams[cap][
"QualityThreshold"].as<
double>();
608 params->qltNSrfItr = cfmparams[cap][
"NSurfaceIterations"].as<
int>();
609 params->qltConCelSet =
610 cfmparams[cap].get_with_default(
"ConstrainedCellsSet",
"none");
614 cap =
"LocalRefinement";
615 if (cfmparams.contains(cap)) {
616 params->_withLclRef =
true;
617 for (
const auto &jptch : cfmparams[cap].array_range()) {
619 refPatch.
patchName = jptch[
"PatchName"].as<std::string>();
620 if (jptch.contains(
"AdditionalRefinementLevels"))
622 jptch[
"AdditionalRefinementLevels"].as<
int>();
625 if (jptch.contains(
"RefinementThickness"))
626 refPatch.
refThickness = jptch[
"RefinementThickness"].as<
double>();
629 if (jptch.contains(
"CellSize"))
630 refPatch.
cellSize = jptch[
"CellSize"].as<
double>();
633 (params->refPatches).push_back(refPatch);
638 cap =
"RenameBoundary";
639 if (cfmparams.contains(cap)) {
640 params->_withRenBndry =
true;
642 renBndry.
defName = cfmparams[cap][
"DefaultName"].as<std::string>();
643 renBndry.
defType = cfmparams[cap][
"DefaultType"].as<std::string>();
644 for (
const auto &jnw : cfmparams[cap][
"NewPatchNames"].array_range()) {
646 jnw[
"Name"].as<std::string>(), jnw[
"NewName"].as<std::string>(),
647 jnw[
"NewType"].as<std::string>());
650 (params->renBndry) = renBndry;
653 auto *mshgndrvobj =
new MeshGenDriver(ifname, meshEngine, params, ofname);
657 }
else if (!meshEngine.compare(
"snappyHexMesh")) {
659 std::cerr <<
"Nemosys must be recompiled with cfMesh support" << std::endl;
663 std::string defaults =
664 inputjson[
"Meshing Parameters"][
"snappyHexMesh Parameters"]
666 if (!defaults.compare(
"default")) {
671 jsoncons::json shmparams =
672 inputjson[
"Meshing Parameters"][
"snappyHexMesh Parameters"];
674 jsoncons::json geomParams = shmparams[
"Geometry Definition"];
675 jsoncons::json castMeshParams = shmparams[
"Castellated Mesh Controls"];
676 jsoncons::json snapParams = shmparams[
"Snapping Controls"];
677 jsoncons::json layerParams = shmparams[
"Mesh Layers Controls"];
678 jsoncons::json qcMeshParams = shmparams[
"Mesh Quality Controls"];
680 if (inputjson[
"Mesh File Options"].contains(
"Input Geometry File"))
682 inputjson[
"Mesh File Options"][
"Input Geometry File"]
685 std::cerr <<
"A geometry file should be supplied.\n";
690 if (shmparams.contains(
"Castellated Mesh"))
691 params->_withCastMesh = shmparams[
"Castellated Mesh"].as<
bool>();
693 std::cerr <<
"Please specify on/off choice using \"Castellated Mesh\"" 698 if (shmparams.contains(
"Snapping"))
699 params->_withSnap = shmparams[
"Snapping"].as<
bool>();
701 std::cerr <<
"Please specify on/off choice using \"Snapping\"" 706 if (shmparams.contains(
"Layer Addition"))
707 params->_withLayers = shmparams[
"Layer Addition"].as<
bool>();
709 std::cerr <<
"Please specify on/off choice using \"Layer Addition\"" 716 bool multiPatches =
false;
717 if (geomParams.contains(
"Enable Multi Patches"))
718 multiPatches = geomParams[
"Enable Multi Patches"].as<bool>();
720 std::cerr <<
"Please provide boolean \"Enable Multi Patches\".\n";
725 if (geomParams.contains(
"InputPatchName"))
726 params->singleSolidPatch =
727 geomParams[
"InputPatchName"].as<std::string>();
729 std::cerr <<
"A patch name for input geometry must be defined.\n";
734 std::string cap4 =
"Geometry Patches";
735 if (geomParams.contains(cap4)) {
736 params->_withMultiPatches =
true;
738 for (
auto jptch3 : geomParams[cap4].array_range()) {
741 if (jptch3.contains(
"Geometry Patch Name"))
743 jptch3[
"Geometry Patch Name"].as<std::string>();
746 <<
"Please provide Output Patch Name for STL file provided" 751 if (jptch3.contains(
"Output Patch Name"))
753 jptch3[
"Output Patch Name"].as<std::string>();
756 <<
"Please provide Output Patch Name for STL file provided" 761 (params->stlPatchDefs).push_back(stlPatches);
765 <<
"User has selected to define multiple geometry patches.\n" 766 <<
"Please define them using \"Geometry Patches\" keyword" 773 std::string cap5 =
"Custom Patches";
774 if (geomParams.contains(cap5)) {
775 for (
auto jptch3 : geomParams[cap5].array_range()) {
776 shmSearchableShapes SSS;
777 if (jptch3.contains(
"Custom Patch Name"))
778 SSS.patchNm = jptch3[
"Custom Patch Name"].as<std::string>();
780 std::cerr <<
"Please provide Custom Patch Name" << std::endl;
784 if (jptch3.contains(
"Searchable Shape"))
785 SSS.searchableName = jptch3[
"Searchable Shape"].as<std::string>();
787 std::cerr <<
"Please provide Searchable Shape Name" << std::endl;
791 if (SSS.searchableName ==
"searchableBox") {
792 if (jptch3.contains(
"minimum bound"))
793 SSS.shapeParameters1 = jptch3[
"minimum bound"].as<std::string>();
795 std::cerr <<
"Please provide minimum bound (i.e (-1 -1 -1))" 799 if (jptch3.contains(
"maximum bound"))
800 SSS.shapeParameters2 = jptch3[
"maximum bound"].as<std::string>();
802 std::cerr <<
"Please provide maximum bound (i.e (1 1 1))" 806 }
else if (SSS.searchableName ==
"searchableCylinder") {
807 if (jptch3.contains(
"Axis Point 1"))
808 SSS.shapeParameters1 = jptch3[
"Axis Point 1"].as<std::string>();
810 std::cerr <<
"Please provide Axis Point 1 (i.e (-1 -1 -1))" 814 if (jptch3.contains(
"Axis Point 2"))
815 SSS.shapeParameters2 = jptch3[
"Axis Point 2"].as<std::string>();
817 std::cerr <<
"Please provide Axis Point 2 (i.e (1 1 1))" 821 if (jptch3.contains(
"Radius"))
822 SSS.rad = jptch3[
"Radius"].as<
double>();
824 std::cerr <<
"Please provide Radius" << std::endl;
827 }
else if (SSS.searchableName ==
"searchableSphere") {
828 if (jptch3.contains(
"Center"))
829 SSS.shapeParameters1 = jptch3[
"Center"].as<std::string>();
831 std::cerr <<
"Please provide Center (i.e (1 1 1))" << std::endl;
834 if (jptch3.contains(
"Radius"))
835 SSS.rad = jptch3[
"Radius"].as<
double>();
837 std::cerr <<
"Please provide Radius" << std::endl;
841 std::cerr << SSS.searchableName <<
" is not supported yet!" 845 (params->srchShape).push_back(SSS);
850 if (castMeshParams.contains(
"CellZones"))
851 params->_withCellZones = castMeshParams[
"CellZones"].as<
bool>();
853 std::cerr <<
"Please specify on/off choice using \"CellZones\"" 858 if (castMeshParams.contains(
"RegionRefine"))
859 params->_withGeomRefReg = castMeshParams[
"RegionRefine"].as<
bool>();
861 std::cerr <<
"Please specify on/off choice using \"RegionRefine\"" 866 if (castMeshParams.contains(
"SurfaceRefine"))
867 params->_withSurfRefReg = castMeshParams[
"SurfaceRefine"].as<
bool>();
869 std::cerr <<
"Please specify on/off choice using \"SurfaceRefine\"" 874 if (castMeshParams.contains(
"GeneralGapLevelIncrement"))
875 params->castMeshGpLvl =
876 castMeshParams[
"GeneralGapLevelIncrement"].as<
int>();
878 params->castMeshGpLvl = 1;
880 if (castMeshParams.contains(
"maxLocalCells"))
881 params->maxLCells = castMeshParams[
"maxLocalCells"].as<
int>();
883 params->maxLCells = 2000000;
885 if (castMeshParams.contains(
"maxGlobalCells"))
886 params->maxGCells = castMeshParams[
"maxGlobalCells"].as<
int>();
888 params->maxGCells = 4000000;
890 if (castMeshParams.contains(
"minRefCells"))
891 params->minRefCells = castMeshParams[
"minRefCells"].as<
int>();
893 params->minRefCells = 0;
895 if (castMeshParams.contains(
"nCellsBetweenLevels"))
896 params->cellsBetnLvls = castMeshParams[
"nCellsBetweenLevels"].as<
int>();
898 params->cellsBetnLvls = 3;
900 if (castMeshParams.contains(
"surfaceRefinementLvlMin"))
901 params->refSurfLvlMin =
902 castMeshParams[
"surfaceRefinementLvlMin"].as<
int>();
904 params->refSurfLvlMin = 0;
906 if (castMeshParams.contains(
"surfaceRefinementLvlMax"))
907 params->refSurfLvlMax =
908 castMeshParams[
"surfaceRefinementLvlMax"].as<
int>();
910 params->refSurfLvlMax = 0;
912 if (castMeshParams.contains(
"resolveFeatureAngle"))
913 params->featAngle = castMeshParams[
"resolveFeatureAngle"].as<
double>();
915 params->featAngle = 60;
917 if (castMeshParams.contains(
"gapLevelIncrement"))
918 params->gPLvlInc = castMeshParams[
"gapLevelIncrement"].as<
int>();
920 params->gPLvlInc = 1;
921 if (castMeshParams.contains(
"planarAngle"))
922 params->planarAngle = castMeshParams[
"planarAngle"].as<
int>();
924 params->planarAngle = 1;
925 if (castMeshParams.contains(
"locationInMeshX"))
926 params->locMeshX = castMeshParams[
"locationInMeshX"].as<
double>();
928 std::cerr <<
"Location of a point in region you want to" 929 <<
"keep cells is needed!" << std::endl;
932 if (castMeshParams.contains(
"locationInMeshY"))
933 params->locMeshY = castMeshParams[
"locationInMeshY"].as<
double>();
935 std::cerr <<
"Location of a point in region you want to" 936 <<
"keep cells is needed!" << std::endl;
939 if (castMeshParams.contains(
"locationInMeshZ"))
940 params->locMeshZ = castMeshParams[
"locationInMeshZ"].as<
double>();
942 std::cerr <<
"Location of a point in region you want to" 943 <<
"keep cells is needed!" << std::endl;
946 if (castMeshParams.contains(
"allowFreeStandingZoneFaces"))
947 params->_alwFreeZone =
948 castMeshParams[
"allowFreeStandingZoneFaces"].as<
bool>();
950 params->_alwFreeZone =
true;
954 std::string cap3 =
"SurfaceRefinementRegions";
955 if (castMeshParams.contains(cap3)) {
958 for (
auto jptch3 : castMeshParams[cap3].array_range()) {
961 if (jptch3.contains(
"Patch Name"))
962 surfRef.refPatchNm = jptch3[
"Patch Name"].as<std::string>();
964 surfRef.refPatchNm = params->singleSolidPatch;
967 if (jptch3.contains(
"Patch Type"))
968 surfRef.
patchType = jptch3[
"Patch Type"].as<std::string>();
973 if (jptch3.contains(
"MinLevel"))
974 surfRef.
minLvl = jptch3[
"MinLevel"].as<
double>();
979 if (jptch3.contains(
"MaxLevel"))
980 surfRef.
maxLvl = jptch3[
"MaxLevel"].as<
int>();
982 std::cerr <<
"Please define maximum surface refinement" 987 (params->surfRefs).push_back(surfRef);
992 std::string cap2 =
"GeomRefinementRegions";
993 if (castMeshParams.contains(cap2)) {
996 for (
auto jptch2 : castMeshParams[cap2].array_range()) {
999 if (jptch2.contains(
"Patch Name"))
1000 geomRef.patchNm = jptch2[
"Patch Name"].as<std::string>();
1002 std::cerr <<
"Please define \"PatchName\"\n" << std::endl;
1005 if (jptch2.contains(
"Mode"))
1006 geomRef.
mode = jptch2[
"Mode"].as<std::string>();
1008 std::cerr <<
"Please define \"Mode\"\n" << std::endl;
1011 if (jptch2.contains(
"MinLevel"))
1012 geomRef.
minLvl = jptch2[
"MinLevel"].as<
double>();
1014 std::cerr <<
"Please define \"MinLevel\"\n" << std::endl;
1017 if (jptch2.contains(
"MaxLevel"))
1018 geomRef.
maxLvl = jptch2[
"MaxLevel"].as<
int>();
1020 std::cerr <<
"Please define \"MaxLevel\"\n" << std::endl;
1024 (params->geomRefs).push_back(geomRef);
1029 std::string cap6 =
"Feature File";
1030 if (castMeshParams.contains(cap6)) {
1031 params->_withFeatureEdgeFile =
true;
1032 for (
auto jptch3 : castMeshParams[cap6].array_range()) {
1034 if (jptch3.contains(
"File Name"))
1035 ftrOne.
fileName = jptch3[
"File Name"].as<std::string>();
1037 std::cerr <<
"Please provide feature file name" << std::endl;
1041 if (jptch3.contains(
"MinLevel"))
1042 ftrOne.
minLvl = jptch3[
"MinLevel"].as<
double>();
1047 if (jptch3.contains(
"MaxLevel"))
1048 ftrOne.
maxLvl = jptch3[
"MaxLevel"].as<
int>();
1050 std::cerr <<
"Please define maximum surface refinement" 1055 (params->ftrEdge).push_back(ftrOne);
1060 if (snapParams.contains(
"nSmoothPatch"))
1061 params->snapSmthPatch = snapParams[
"nSmoothPatch"].as<
int>();
1063 params->snapSmthPatch = 4;
1065 if (snapParams.contains(
"tolerance"))
1066 params->snapTol = snapParams[
"tolerance"].as<
double>();
1068 params->snapTol = 0.5;
1070 if (snapParams.contains(
"snapSolveIter"))
1071 params->solveSnapIter = snapParams[
"snapSolveIter"].as<
int>();
1073 params->solveSnapIter = 200;
1075 if (snapParams.contains(
"snapRelaxIter"))
1076 params->relaxSnapIter = snapParams[
"snapRelaxIter"].as<
int>();
1078 params->relaxSnapIter = 6;
1080 if (snapParams.contains(
"nFeatureSnapIter"))
1081 params->nFeatureSnapIter = snapParams[
"nFeatureSnapIter"].as<
int>();
1083 params->nFeatureSnapIter = 10;
1084 if (snapParams.contains(
"implicitFeatureSnap"))
1085 params->implicitFeatureSnap =
1086 snapParams[
"implicitFeatureSnap"].as<
bool>();
1088 params->implicitFeatureSnap =
false;
1089 if (snapParams.contains(
"explicitFeatureSnap"))
1090 params->explicitFeatureSnap =
1091 snapParams[
"explicitFeatureSnap"].as<
bool>();
1093 params->explicitFeatureSnap =
true;
1094 if (snapParams.contains(
"multiRegionFeatureSnap"))
1095 params->multiRegionFeatureSnap =
1096 snapParams[
"multiRegionFeatureSnap"].as<
bool>();
1098 params->multiRegionFeatureSnap =
false;
1101 if (layerParams.contains(
"relativeSizes"))
1102 params->_relSize = layerParams[
"relativeSizes"].as<
bool>();
1104 params->_relSize = 1;
1106 if (layerParams.contains(
"expansionRatio"))
1107 params->expRatio = layerParams[
"expansionRatio"].as<
double>();
1109 params->expRatio = 1.3;
1111 if (layerParams.contains(
"finalLayerThickness"))
1112 params->finLThick = layerParams[
"finalLayerThickness"].as<
double>();
1114 params->finLThick = 1.0;
1116 if (layerParams.contains(
"minThickness"))
1117 params->minThick = layerParams[
"minThickness"].as<
double>();
1119 params->minThick = 0.1;
1121 if (layerParams.contains(
"firstLayerThickness"))
1122 params->firstLyrThickness =
1123 layerParams[
"firstLayerThickness"].as<
double>();
1125 params->firstLyrThickness = -1.0;
1126 if (layerParams.contains(
"thickness"))
1127 params->thickness = layerParams[
"thickness"].as<
double>();
1129 params->thickness = -1.0;
1130 if (layerParams.contains(
"nGrow"))
1131 params->nGrow = layerParams[
"nGrow"].as<
int>();
1135 if (layerParams.contains(
"featureAngle"))
1136 params->lyrFeatAngle = layerParams[
"featureAngle"].as<
double>();
1138 params->lyrFeatAngle = 30;
1140 if (layerParams.contains(
"nRelaxIter"))
1141 params->lyrRelaxIter = layerParams[
"nRelaxIter"].as<
int>();
1143 params->lyrRelaxIter = 3;
1145 if (layerParams.contains(
"nSmoothSurfaceNormals"))
1146 params->lyrSmthSurfNorm =
1147 layerParams[
"nSmoothSurfaceNormals"].as<
int>();
1149 params->lyrSmthSurfNorm = 1;
1151 if (layerParams.contains(
"nSmoothNormals"))
1152 params->lyrSmthNorm = layerParams[
"nSmoothNormals"].as<
int>();
1154 params->lyrSmthNorm = 3;
1156 if (layerParams.contains(
"nSmoothThickness"))
1157 params->lyrSmthThick = layerParams[
"nSmoothThickness"].as<
int>();
1159 params->lyrSmthThick = 2;
1161 if (layerParams.contains(
"maxFaceThicknessRatio"))
1162 params->lyrMaxFcTR = layerParams[
"maxFaceThicknessRatio"].as<
double>();
1164 params->lyrMaxFcTR = 0.5;
1166 if (layerParams.contains(
"maxThicknessToMedialRatio"))
1167 params->lyrMaxThickTMR =
1168 layerParams[
"maxThicknessToMedialRatio"].as<
double>();
1170 params->lyrMaxThickTMR = 1.0;
1172 if (layerParams.contains(
"minMedialAxisAngle"))
1173 params->lyrMinMedAngl = layerParams[
"minMedialAxisAngle"].as<
double>();
1175 params->lyrMinMedAngl = 90;
1177 if (layerParams.contains(
"nBufferCellsNoExtrude"))
1178 params->lyrBuffrCells = layerParams[
"nBufferCellsNoExtrude"].as<
int>();
1180 params->lyrBuffrCells = 0;
1182 if (layerParams.contains(
"nLayerIter"))
1183 params->lyrIter = layerParams[
"nLayerIter"].as<
int>();
1185 params->lyrIter = 50;
1187 if (layerParams.contains(
"nRelaxedIter"))
1188 params->nRelaxedIter = layerParams[
"nRelaxedIter"].as<
int>();
1190 params->nRelaxedIter = 20;
1192 if (layerParams.contains(
"slipFeatureAngle"))
1193 params->slipFeatureAngle = layerParams[
"slipFeatureAngle"].as<
int>();
1195 params->slipFeatureAngle = 20;
1197 if (layerParams.contains(
"nMedialAxisIter"))
1198 params->nMedialAxisIter = layerParams[
"nMedialAxisIter"].as<
int>();
1200 params->nMedialAxisIter = -1;
1201 if (layerParams.contains(
"nSmoothDisplacement"))
1202 params->nSmoothDisplacement =
1203 layerParams[
"nSmoothDisplacement"].as<
int>();
1205 params->nSmoothDisplacement = -1;
1208 std::string cap7 =
"Layers";
1209 if (layerParams.contains(cap7)) {
1210 for (
auto jptch3 : layerParams[cap7].array_range()) {
1212 if (jptch3.contains(
"Patch Name"))
1213 lyrOne.
patchName = jptch3[
"Patch Name"].as<std::string>();
1215 std::cerr <<
"Please provide patch name for layers" << std::endl;
1219 if (jptch3.contains(
"nSurfaceLayers"))
1225 if (jptch3.contains(
"expansionRatio"))
1231 if (jptch3.contains(
"finalLayerThickness"))
1233 jptch3[
"finalLayerThickness"].as<
double>();
1238 if (jptch3.contains(
"firstLayerThickness"))
1240 jptch3[
"firstLayerThickness"].as<
double>();
1245 if (jptch3.contains(
"thickness"))
1251 if (jptch3.contains(
"minThickness"))
1252 lyrOne.
minThickness = jptch3[
"minThickness"].as<
double>();
1256 params->layerVec.push_back(lyrOne);
1261 if (qcMeshParams.contains(
"maxNonOrtho"))
1262 params->qcMaxNOrtho = qcMeshParams[
"maxNonOrtho"].as<
int>();
1264 params->qcMaxNOrtho = 65;
1266 if (qcMeshParams.contains(
"maxBoundarySkewness"))
1267 params->qcMaxBndrySkew =
1268 qcMeshParams[
"maxBoundarySkewness"].as<
double>();
1270 params->qcMaxBndrySkew = 20;
1272 if (qcMeshParams.contains(
"maxInternalSkewness"))
1273 params->qcMaxIntSkew = qcMeshParams[
"maxInternalSkewness"].as<
double>();
1275 params->qcMaxIntSkew = 4;
1277 if (qcMeshParams.contains(
"maxConcave"))
1278 params->qcMaxConc = qcMeshParams[
"maxConcave"].as<
double>();
1280 params->qcMaxConc = 80;
1282 if (qcMeshParams.contains(
"minVol"))
1283 params->qcMinVol = qcMeshParams[
"minVol"].as<
double>();
1285 params->qcMinVol = 1e-13;
1287 if (qcMeshParams.contains(
"minTetQuality"))
1288 params->qcMinTetQ = qcMeshParams[
"minTetQuality"].as<
double>();
1290 params->qcMinTetQ = 1e-15;
1292 if (qcMeshParams.contains(
"minArea"))
1293 params->qcMinArea = qcMeshParams[
"minArea"].as<
double>();
1295 params->qcMinArea = -1;
1297 if (qcMeshParams.contains(
"minTwist"))
1298 params->qcMinTwist = qcMeshParams[
"minTwist"].as<
double>();
1300 params->qcMinTwist = 0.02;
1302 if (qcMeshParams.contains(
"minFaceWeight"))
1303 params->qcMinFaceW = qcMeshParams[
"minFaceWeight"].as<
double>();
1305 params->qcMinFaceW = 0.05;
1307 if (qcMeshParams.contains(
"minVolRatio"))
1308 params->qcMinVolRto = qcMeshParams[
"minVolRatio"].as<
double>();
1310 params->qcMinVolRto = 0.01;
1312 if (qcMeshParams.contains(
"minDeterminant"))
1313 params->qcMinDet = qcMeshParams[
"minDeterminant"].as<
double>();
1315 params->qcMinDet = 0.001;
1317 if (qcMeshParams.contains(
"minTriangleTwist"))
1318 params->qcMinTrTwist = qcMeshParams[
"minTriangleTwist"].as<
double>();
1320 params->qcMinTrTwist = -1;
1322 if (qcMeshParams.contains(
"qcnSmoothScale"))
1323 params->qcSmthScale = qcMeshParams[
"qcnSmoothScale"].as<
int>();
1325 params->qcSmthScale = 5;
1327 if (qcMeshParams.contains(
"errorReduction"))
1328 params->qcErrRedctn = qcMeshParams[
"errorReduction"].as<
double>();
1330 params->qcErrRedctn = 0.75;
1332 if (shmparams.contains(
"mergeTolerance"))
1333 params->
mergeTol = shmparams[
"mergeTolerance"].as<
double>();
1338 auto *mshgndrvobj =
new MeshGenDriver(ifname, meshEngine, params, ofname);
1342 }
else if (!meshEngine.compare(
"blockMesh")) {
1344 std::cerr <<
"Nemosys must be recompiled with cfMesh support" << std::endl;
1348 std::string defaults =
1349 inputjson[
"Meshing Parameters"][
"blockMesh Parameters"]
1351 if (!defaults.compare(
"default")) {
1356 jsoncons::json bmshparams =
1357 inputjson[
"Meshing Parameters"][
"blockMesh Parameters"];
1359 if (inputjson[
"Mesh File Options"].contains(
"Input Dict File"))
1360 params->_ownBlockMshDict =
1361 inputjson[
"Mesh File Options"][
"Input Dict File"].as<
bool>();
1364 if (bmshparams.contains(
"Block Geometry"))
1365 params->_isBlock = bmshparams[
"Block Geometry"].as<
bool>();
1367 std::cerr <<
"Define your choice of geometry using bool keys" 1372 if (bmshparams.contains(
"Sphere Geometry"))
1373 params->_isSphere = bmshparams[
"Sphere Geometry"].as<
bool>();
1375 std::cerr <<
"Define your choice of geometry using bool keys" 1380 if (bmshparams.contains(
"Cylinder/Tapered_Cone Geometry"))
1381 params->_isCylinder_TCone =
1382 bmshparams[
"Cylinder/Tapered_Cone Geometry"].as<
bool>();
1384 std::cerr <<
"Define your choice of geometry using bool keys" 1389 if (bmshparams.contains(
"scaleToMeters"))
1390 params->
cnvrtToMeters = bmshparams[
"scaleToMeters"].as<
double>();
1392 std::cerr <<
"Define your choice of geometry using bool keys" 1398 if (bmshparams.contains(
"Cell_Size")) {
1399 params->_cellSizeDefined =
true;
1400 params->
cellSize = bmshparams[
"Cell_Size"].as<
double>();
1403 params->_cellSizeDefined =
false;
1406 if (bmshparams.contains(
"XdirectionCells"))
1407 params->cellsXDir = bmshparams[
"XdirectionCells"].as<
int>();
1409 if (params->_cellSizeDefined) {
1412 std::cerr <<
"Define cell numbers in X direction" 1418 if (bmshparams.contains(
"YdirectionCells"))
1419 params->cellsYDir = bmshparams[
"YdirectionCells"].as<
int>();
1421 if (params->_cellSizeDefined) {
1424 std::cerr <<
"Define cell numbers in Y direction" 1430 if (bmshparams.contains(
"ZdirectionCells"))
1431 params->cellsZDir = bmshparams[
"ZdirectionCells"].as<
int>();
1433 if (params->_cellSizeDefined) {
1436 std::cerr <<
"Define cell size for mesh" 1443 if (bmshparams.contains(
"Block Parameters")) {
1444 if (bmshparams[
"Block Parameters"].contains(
"Auto_Generate")) {
1445 params->_autoGenerateBox =
true;
1447 if (inputjson[
"Mesh File Options"].contains(
"Input Geometry File"))
1448 params->packFileName =
1449 inputjson[
"Mesh File Options"][
"Input Geometry File"]
1452 std::cerr <<
"A geometry file should be supplied.\n";
1456 if (bmshparams[
"Block Parameters"][
"Auto_Generate"].contains(
1459 bmshparams[
"Block Parameters"][
"Auto_Generate"][
"Offset_XDir"]
1462 params->offsetX = 0.1;
1464 if (bmshparams[
"Block Parameters"][
"Auto_Generate"].contains(
1467 bmshparams[
"Block Parameters"][
"Auto_Generate"][
"Offset_YDir"]
1470 params->offsetY = 0.1;
1472 if (bmshparams[
"Block Parameters"][
"Auto_Generate"].contains(
1475 bmshparams[
"Block Parameters"][
"Auto_Generate"][
"Offset_ZDir"]
1478 params->offsetZ = 0.1;
1482 params->_autoGenerateBox =
false;
1485 if (bmshparams[
"Block Parameters"].contains(
"X1"))
1486 params->initX = bmshparams[
"Block Parameters"][
"X1"].as<
double>();
1488 if (!(params->_autoGenerateBox)) {
1489 std::cerr <<
"Define initial point for block (X Y Z)!\n" 1493 std::cout <<
"Box will be generated automatically" << std::endl;
1496 if (bmshparams[
"Block Parameters"].contains(
"Y1"))
1497 params->initY = bmshparams[
"Block Parameters"][
"Y1"].as<
double>();
1499 if (!(params->_autoGenerateBox)) {
1500 std::cerr <<
"Define initial point for block (X Y Z)!\n" 1504 std::cout <<
"Box will be generated automatically" << std::endl;
1507 if (bmshparams[
"Block Parameters"].contains(
"Z1"))
1508 params->initZ = bmshparams[
"Block Parameters"][
"Z1"].as<
double>();
1510 if (!(params->_autoGenerateBox)) {
1511 std::cerr <<
"Define initial point for block (X Y Z)!\n" 1515 std::cout <<
"Box will be generated automatically" << std::endl;
1518 if (bmshparams[
"Block Parameters"].contains(
"LengthX"))
1519 params->lenX = bmshparams[
"Block Parameters"][
"LengthX"].as<
double>();
1521 if (!(params->_autoGenerateBox)) {
1522 std::cerr <<
"Define desired box length in X,Y,Z direction\n" 1526 std::cout <<
"Box will be generated automatically" << std::endl;
1529 if (bmshparams[
"Block Parameters"].contains(
"LengthY"))
1530 params->lenY = bmshparams[
"Block Parameters"][
"LengthY"].as<
double>();
1532 if (!(params->_autoGenerateBox)) {
1533 std::cerr <<
"Define desired box length in X,Y,Z direction\n" 1537 std::cout <<
"Box will be generated automatically" << std::endl;
1540 if (bmshparams[
"Block Parameters"].contains(
"LengthZ"))
1541 params->lenZ = bmshparams[
"Block Parameters"][
"LengthZ"].as<
double>();
1543 if (!(params->_autoGenerateBox)) {
1544 std::cerr <<
"Define desired box length in X,Y,Z direction\n" 1548 std::cout <<
"Box will be generated automatically" << std::endl;
1551 if (bmshparams[
"Block Parameters"].contains(
"GradingXdir"))
1552 params->smplGradingX =
1553 bmshparams[
"Block Parameters"][
"GradingXdir"].as<
double>();
1555 params->smplGradingX = 1;
1557 if (bmshparams[
"Block Parameters"].contains(
"GradingYdir"))
1558 params->smplGradingY =
1559 bmshparams[
"Block Parameters"][
"GradingYdir"].as<
double>();
1561 params->smplGradingY = 1;
1563 if (bmshparams[
"Block Parameters"].contains(
"GradingZdir"))
1564 params->smplGradingZ =
1565 bmshparams[
"Block Parameters"][
"GradingZdir"].as<
double>();
1567 params->smplGradingZ = 1;
1571 if (bmshparams.contains(
"Sphere Parameters")) {
1572 if (bmshparams[
"Sphere Parameters"].contains(
"Center X"))
1574 bmshparams[
"Sphere Parameters"][
"Center X"].as<
double>();
1576 std::cerr <<
"Define sphere center!\n" << std::endl;
1579 if (bmshparams[
"Sphere Parameters"].contains(
"Center Y"))
1581 bmshparams[
"Sphere Parameters"][
"Center Y"].as<
double>();
1583 std::cerr <<
"Define sphere center!\n" << std::endl;
1586 if (bmshparams[
"Sphere Parameters"].contains(
"Center Z"))
1588 bmshparams[
"Sphere Parameters"][
"Center Z"].as<
double>();
1590 std::cerr <<
"Define sphere center!\n" << std::endl;
1593 if (bmshparams[
"Sphere Parameters"].contains(
"Radius"))
1595 bmshparams[
"Sphere Parameters"][
"Radius"].as<
double>();
1597 std::cerr <<
"Define sphere radius!\n" << endl;
1600 if (bmshparams[
"Sphere Parameters"].contains(
"GradingXdir"))
1601 params->sphrGradingX =
1602 bmshparams[
"Sphere Parameters"][
"GradingXdir"].as<
double>();
1604 params->sphrGradingX = 1;
1606 if (bmshparams[
"Sphere Parameters"].contains(
"GradingYdir"))
1607 params->sphrGradingY =
1608 bmshparams[
"Sphere Parameters"][
"GradingYdir"].as<
double>();
1610 params->sphrGradingY = 1;
1612 if (bmshparams[
"Sphere Parameters"].contains(
"GradingXdir"))
1613 params->sphrGradingZ =
1614 bmshparams[
"Sphere Parameters"][
"GradingZdir"].as<
double>();
1616 params->sphrGradingZ = 1;
1620 if (bmshparams.contains(
"Cylinder/Tapered_Cone Parameters")) {
1621 if (bmshparams[
"Cylinder/Tapered_Cone Parameters"].contains(
"Center X"))
1622 params->centerCyl[0] =
1623 bmshparams[
"Cylinder/Tapered_Cone Parameters"][
"Center X"]
1626 std::cerr <<
"Define center point for cylinder axis\n" << std::endl;
1629 if (bmshparams[
"Cylinder/Tapered_Cone Parameters"].contains(
"Center Y"))
1630 params->centerCyl[1] =
1631 bmshparams[
"Cylinder/Tapered_Cone Parameters"][
"Center Y"]
1634 std::cerr <<
"Define center point for cylinder axis\n" << std::endl;
1637 if (bmshparams[
"Cylinder/Tapered_Cone Parameters"].contains(
"Center Z"))
1638 params->centerCyl[2] =
1639 bmshparams[
"Cylinder/Tapered_Cone Parameters"][
"Center Z"]
1642 std::cerr <<
"Define center point for cylinder axis\n" << std::endl;
1645 if (bmshparams[
"Cylinder/Tapered_Cone Parameters"].contains(
"Radius1"))
1647 bmshparams[
"Cylinder/Tapered_Cone Parameters"][
"Radius1"]
1650 if (bmshparams[
"Cylinder/Tapered_Cone Parameters"].contains(
1653 bmshparams[
"Cylinder/Tapered_Cone Parameters"][
"Radius2"]
1657 bmshparams[
"Cylinder/Tapered_Cone Parameters"][
"Radius1"]
1661 if (bmshparams[
"Cylinder/Tapered_Cone Parameters"].contains(
1663 params->cylGrading[0] =
1664 bmshparams[
"Cylinder/Tapered_Cone Parameters"][
"GradingXdir"]
1667 params->cylGrading[0] = 1;
1669 if (bmshparams[
"Cylinder/Tapered_Cone Parameters"].contains(
1671 params->cylGrading[1] =
1672 bmshparams[
"Cylinder/Tapered_Cone Parameters"][
"GradingYdir"]
1675 params->cylGrading[1] = 1;
1677 if (bmshparams[
"Cylinder/Tapered_Cone Parameters"].contains(
1679 params->cylGrading[2] =
1680 bmshparams[
"Cylinder/Tapered_Cone Parameters"][
"GradingZdir"]
1683 params->cylGrading[2] = 1;
1686 if (bmshparams[
"Cylinder/Tapered_Cone Parameters"].contains(
"Height"))
1688 bmshparams[
"Cylinder/Tapered_Cone Parameters"][
"Height"]
1691 std::cerr <<
"Define cylinder height\n" << endl;
1695 auto *mshgndrvobj =
new MeshGenDriver(ifname, meshEngine, params, ofname);
1703 std::cerr <<
"Mesh generation engine " << meshEngine <<
" is not supported"
snappymeshGen facilitates full-hexahedral/hex-dominent meshing of complex geometries with surface...
blockMeshGen <– meshGen <– meshBase This class incorporates mesh generating method of blockMesh uti...
snappymeshParams contains all parameters essential for mesh generation using snappymeshGen class meth...
A structure for STL definition.
std::unique_ptr< NEM::MSH::geoMeshBase > gmData
double cnvrtToMeters
Defines mesh scale to meters.
static meshBase * exportGmshToVtk(const std::string &fname)
construct vtkMesh from gmsh msh file (called in Create methods)
static meshBase * exportVolToVtk(const std::string &fname)
construct vtkMesh from netgen vol file (called in Create methods)
std::string type
Type of size field, eg.
double minLvl
Minimum refinement level.
std::array< int, 3 > vert
geoMeshBase * New(MeshType meshType)
Create a new mesh object.
std::vector< std::pair< std::string, double > > params
Vector of pairs to store list of numbers.
std::vector< std::pair< std::string, std::vector< std::string > > > strg_list_params
A structure to respresent regions refining capability in snappymeshGen.
blockMeshParams contains the parameters important for automatic meshing using blockMeshGen class...
static meshBase * Create(const std::string &fname)
Construct vtkMesh from filename.
A struct for defining hexahedral transfinite volumes.
std::array< std::string, 3 > type
std::string find_ext(const std::string &fname)
int maxLvl
Maximum refinement level.
std::string snappyPatchName
std::string geomFileName
Input geometry STL name.
std::string trim_fname(const std::string &name, const std::string &ext)
jsoncons::optional< double > cellSize
user can define mesh cell size here (if not set, nCells used instead).
std::array< double, 3 > coef
double finalLayerThickness
gmshParams contains all parameters essential for mesh generation using gmshGen class methods...
std::array< std::array< double, 3 >, 3 > axis
std::vector< std::pair< std::string, std::vector< double > > > num_list_params
Vector of pairs to store list of strings.
std::shared_ptr< meshBase > mesh
static std::shared_ptr< meshBase > CreateShared(const std::string &fname)
Create shared ptr from fname.
int maxLvl
Maximum refinement level.
double minLvl
< Patch Type in Mesh
std::vector< cfmNewPatch > newPatches
A structure for feature edge refinement.
A structure to represent geometry surface refining capability in snappymeshgGen.
double mergeTol
merge tolerance for mesh
std::map< std::string, std::string > params
std::string mode
Inside, Outside.
static std::unique_ptr< NemDriver > readJSON(const jsoncons::json &inputjson)
Factory method for all drivers.
virtual int createMeshFromSTL(const char *fname)=0
A structure for defining volumetric mesh size fields.
vtkSmartPointer< vtkDataSet > getDataSet() const
A struct for layer addition.