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::MeshGenDriver Class Referenceabstract

Detailed Description

Definition at line 38 of file MeshGenDriver.H.

Classes

struct  MeshGenFiles
 

Public Member Functions

virtual void execute () const =0
 Run the workflow represented by the driver. More...
 

Static Public Member Functions

static std::unique_ptr< NemDriverreadJSON (const jsoncons::json &inputjson)
 Factory method for all drivers. More...
 

Protected Member Functions

 MeshGenDriver ()=default
 

Private Member Functions

jsoncons::string_view getProgramType () const override
 

Static Private Attributes

static constexpr const char * programType = "Mesh Generation"
 

Inherits NEM::DRV::NemDriver.

Inherited by NEM::DRV::BlockMeshMeshGenDriver, NEM::DRV::CFMeshMeshGenDriver, NEM::DRV::GmshMeshGenDriver, NEM::DRV::NetgenMeshGenDriver, and NEM::DRV::SnappyMeshMeshGenDriver.

Constructor & Destructor Documentation

◆ MeshGenDriver()

NEM::DRV::MeshGenDriver::MeshGenDriver ( )
protecteddefault

Definition at line 61 of file MeshGenDriver.C.

References cfmLclRefPatch::aditRefLvls, cfmPtchBndLyr::alwDiscont, NEM::GEN::TransfiniteBlock::axis, cfmPtchBndLyr::blNLyr, cfmPtchBndLyr::blThkRto, cfmLclRefPatch::cellSize, blockMeshParams::cellSize, blockMeshParams::cnvrtToMeters, NEM::GEN::TransfiniteBlock::coef, meshBase::Create(), meshGen::createMeshFromSTL(), meshBase::CreateShared(), cfmRenBndry::defName, cfmRenBndry::defType, shmLayers::expansionRatio, meshBase::exportGmshToVtk(), meshBase::exportVolToVtk(), shmFeatureEdgeRef::fileName, shmLayers::finalLayerThickness, nemAux::find_ext(), shmLayers::firstLyrThickness, snappymeshParams::geomFileName, meshGen::getDataSet(), meshGen::gmData, NEM::GEN::volSizeField::id, NEM::GEN::TransfiniteBlock::id, cfmPtchBndLyr::maxFrstLyrThk, shmRegionRefine::maxLvl, shmSurfRefine::maxLvl, shmFeatureEdgeRef::maxLvl, snappymeshParams::mergeTol, mesh, shmRegionRefine::minLvl, shmSurfRefine::minLvl, shmFeatureEdgeRef::minLvl, shmLayers::minThickness, shmRegionRefine::mode, cfmObjRef::name, NEM::MSH::New(), cfmRenBndry::newPatches, shmLayers::nSurfaceLayers, NEM::GEN::volSizeField::num_list_params, cfmObjRef::params, NEM::GEN::volSizeField::params, cfmLclRefPatch::patchName, cfmPtchBndLyr::patchName, shmLayers::patchName, shmSurfRefine::patchType, NEM::DRV::NemDriver::readJSON(), cfmLclRefPatch::refThickness, shmSTLDefinition::snappyPatchName, shmSTLDefinition::STLPatchName, NEM::GEN::volSizeField::strg_list_params, shmLayers::thickness, nemAux::trim_fname(), NEM::GEN::volSizeField::type, NEM::GEN::TransfiniteBlock::type, and NEM::GEN::TransfiniteBlock::vert.

64  {
65  std::cout << "MeshGenDriver created" << std::endl;
66  params = _params;
67 
68  meshGen *generator = nullptr;
69 
70  if (meshEngine == "netgen") {
71 #ifdef HAVE_NGEN
72  generator = new netgenGen(dynamic_cast<netgenParams *>(params));
73  std::string newname = nemAux::trim_fname(ifname, ".vol");
74 #else
75  std::cerr << "NETGEN is not enabled during build."
76  << " Build NEMoSys with ENABLE_NETGEN to use this method."
77  << std::endl;
78  exit(1);
79 #endif
80  } else if (meshEngine == "gmsh") {
81  generator =
82  new NEM::GEN::gmshGen(dynamic_cast<NEM::GEN::gmshParams *>(params));
83  std::string newname = nemAux::trim_fname(ifname, ".msh");
84 #ifdef HAVE_CFMSH
85  } else if (meshEngine == "cfmesh") {
86  generator = new cfmeshGen(dynamic_cast<cfmeshParams *>(params));
87  std::string newname = nemAux::trim_fname(ifname, ".vtu");
88  } else if (meshEngine == "snappyHexMesh") {
89  generator = new snappymeshGen(dynamic_cast<snappymeshParams *>(params));
90  std::string newname = nemAux::trim_fname(ifname, ".vtu");
91  } else if (meshEngine == "blockMesh") {
92  generator = new blockMeshGen(dynamic_cast<blockMeshParams *>(params));
93  std::string newname = nemAux::trim_fname(ifname, ".vtu");
94 #endif
95  } else {
96  std::cerr << meshEngine << " is not a supported meshing engine"
97  << std::endl;
98  exit(1);
99  }
100 
101  if (!generator) {
102  std::cerr << "Meshing with engine " << meshEngine << " failed. Aborting."
103  << std::endl;
104  exit(1);
105  }
106 
107  int status = generator->createMeshFromSTL(ifname.c_str());
108 
109  if (status) {
110  std::cerr << "Mesh Engine " << meshEngine << " not recognized" << std::endl;
111  exit(1);
112  }
113 
114  // output file type
115  std::string outputType = nemAux::find_ext(ofname);
116  std::shared_ptr<meshBase> mesh;
117  if (outputType == ".msh" && meshEngine == "gmsh") {
118  // createMeshFromSTL (in this case) outputs a .msh file by default
119  return;
120  }
121 
122  // otherwise, resort to meshBase
123 
124  if (meshEngine == "netgen") {
125  std::string newname = nemAux::trim_fname(ifname, ".vol");
127  } else if (meshEngine == "gmsh") {
128  std::string newname = nemAux::trim_fname(ifname, ".msh");
129  // conversion from STL using gmsh engine writes a ".msh" file by default
130  if (outputType == ".msh") return;
132  } else {
133  // default
134  std::string newname = nemAux::trim_fname(ifname, ".vtu");
135  mesh = meshBase::CreateShared(
136  meshBase::Create(generator->getDataSet(), newname));
137  }
138 
139  if (meshEngine == "cfmesh" || meshEngine == "snappyHexMesh" ||
140  meshEngine == "blockMesh") {
141  geoMesh = NEM::MSH::New(ofname);
142  geoMesh->takeGeoMesh(generator->gmData.get());
143  geoMesh->write(ofname);
144  geoMesh->Delete();
145  } else {
146  mesh->setFileName(ofname);
147  mesh->report();
148  mesh->write();
149  }
150 }
snappymeshGen facilitates full-hexahedral/hex-dominent meshing of complex geometries with surface...
Definition: snappymeshGen.H:55
blockMeshGen <– meshGen <– meshBase This class incorporates mesh generating method of blockMesh uti...
Definition: blockMeshGen.H:54
std::unique_ptr< NEM::MSH::geoMeshBase > gmData
Definition: meshGen.H:54
static meshBase * exportGmshToVtk(const std::string &fname)
construct vtkMesh from gmsh msh file (called in Create methods)
Definition: meshBase.C:409
static meshBase * exportVolToVtk(const std::string &fname)
construct vtkMesh from netgen vol file (called in Create methods)
Definition: meshBase.C:766
geoMeshBase * New(MeshType meshType)
Create a new mesh object.
static meshBase * Create(const std::string &fname)
Construct vtkMesh from filename.
Definition: meshBase.C:78
std::string find_ext(const std::string &fname)
std::string trim_fname(const std::string &name, const std::string &ext)
std::shared_ptr< meshBase > mesh
static std::shared_ptr< meshBase > CreateShared(const std::string &fname)
Create shared ptr from fname.
Definition: meshBase.C:171
virtual int createMeshFromSTL(const char *fname)=0
vtkSmartPointer< vtkDataSet > getDataSet() const
Definition: meshGen.H:53

Member Function Documentation

◆ execute()

◆ getProgramType()

jsoncons::string_view NEM::DRV::MeshGenDriver::getProgramType ( ) const
overrideprivatevirtual

Implements NEM::DRV::NemDriver.

Definition at line 38 of file MeshGen/MeshGenDriver.C.

References programType.

38  {
39  return programType;
40 }
static constexpr const char * programType
Definition: MeshGenDriver.H:59

◆ readJSON()

std::unique_ptr< NemDriver > NEM::DRV::NemDriver::readJSON ( const jsoncons::json &  inputjson)
staticinherited
Parameters
inputjsonjson input with "Program Type" key
Returns
pointer to base NemDriver class

Definition at line 37 of file NemDriver.C.

Referenced by MeshGenDriver().

37  {
38  return inputjson.as<std::unique_ptr<NemDriver>>();
39 }

Member Data Documentation

◆ programType

constexpr const char* NEM::DRV::MeshGenDriver::programType = "Mesh Generation"
staticprivate

Definition at line 59 of file MeshGenDriver.H.

Referenced by getProgramType(), and NEM::DRV::JSON::gmshColorMapFromJSON().


The documentation for this class was generated from the following files: