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::GmshMeshGenDriver Class Reference

Detailed Description

Definition at line 39 of file GmshMeshGenDriver.H.

Classes

struct  Opts
 

Public Types

using Files = MeshGenFiles
 

Public Member Functions

 GmshMeshGenDriver (Files files, NEM::GEN::gmshParams params)
 
const FilesgetFiles () const
 
void setFiles (Files files)
 
const NEM::GEN::gmshParamsgetParams () const
 
void setParams (NEM::GEN::gmshParams params)
 
void execute () const override
 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...
 

Private Member Functions

 GmshMeshGenDriver ()
 
const OptsgetOpts () const
 
void setOpts (Opts opts)
 

Private Attributes

Files files_
 
Opts opts_
 

Inherits NEM::DRV::MeshGenDriver.

Member Typedef Documentation

◆ Files

using NEM::DRV::GmshMeshGenDriver::Files = MeshGenFiles

Definition at line 41 of file GmshMeshGenDriver.H.

Constructor & Destructor Documentation

◆ GmshMeshGenDriver() [1/2]

NEM::DRV::GmshMeshGenDriver::GmshMeshGenDriver ( Files  files,
NEM::GEN::gmshParams  params 
)

Definition at line 41 of file GmshMeshGenDriver.C.

42  : files_(std::move(files)), opts_(std::move(params)) {}

◆ GmshMeshGenDriver() [2/2]

NEM::DRV::GmshMeshGenDriver::GmshMeshGenDriver ( )
private

Definition at line 44 of file GmshMeshGenDriver.C.

Member Function Documentation

◆ execute()

void NEM::DRV::GmshMeshGenDriver::execute ( ) const
overridevirtual

Implements NEM::DRV::NemDriver.

Definition at line 77 of file GmshMeshGenDriver.C.

References NEM::GEN::gmshGen::createMeshFromSTL(), meshBase::CreateShared(), meshBase::exportGmshToVtk(), files_, nemAux::find_ext(), mesh, opts_, NEM::DRV::GmshMeshGenDriver::Opts::params, and nemAux::trim_fname().

77  {
78  auto paramsCopy = this->opts_.params;
79  NEM::GEN::gmshGen generator{&paramsCopy};
80  int status = generator.createMeshFromSTL(this->files_.inputGeoFile.c_str());
81  if (status) {
82  std::cerr << "Mesh Generation encountered error." << std::endl;
83  exit(1);
84  }
85  std::string outputType = nemAux::find_ext(this->files_.outputMeshFile);
86  if (outputType == ".msh") {
87  return;
88  }
89  std::string newname = nemAux::trim_fname(this->files_.inputGeoFile, ".msh");
91  mesh->setFileName(this->files_.outputMeshFile);
92  mesh->report();
93  mesh->write();
94 }
static meshBase * exportGmshToVtk(const std::string &fname)
construct vtkMesh from gmsh msh file (called in Create methods)
Definition: meshBase.C:409
std::string find_ext(const std::string &fname)
int createMeshFromSTL(const char *fname) override
Creates mesh from input STEP file.
Definition: gmshGen.C:60
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

◆ getFiles()

const GmshMeshGenDriver::Files & NEM::DRV::GmshMeshGenDriver::getFiles ( ) const

Definition at line 46 of file GmshMeshGenDriver.C.

References files_.

46  {
47  return files_;
48 }

◆ getOpts()

const GmshMeshGenDriver::Opts & NEM::DRV::GmshMeshGenDriver::getOpts ( ) const
private

Definition at line 63 of file GmshMeshGenDriver.C.

References opts_.

Referenced by getParams().

63  {
64  return opts_;
65 }

◆ getParams()

const NEM::GEN::gmshParams & NEM::DRV::GmshMeshGenDriver::getParams ( ) const

Definition at line 55 of file GmshMeshGenDriver.C.

References getOpts(), and NEM::DRV::GmshMeshGenDriver::Opts::params.

55  {
56  return getOpts().params;
57 }
const Opts & getOpts() const

◆ 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 NEM::DRV::MeshGenDriver::MeshGenDriver().

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

◆ setFiles()

void NEM::DRV::GmshMeshGenDriver::setFiles ( Files  files)

Definition at line 50 of file GmshMeshGenDriver.C.

References files_, NEM::GEN::gmshParams::ofname, opts_, and NEM::DRV::GmshMeshGenDriver::Opts::params.

50  {
51  this->opts_.params.ofname = files.outputMeshFile;
52  this->files_ = std::move(files);
53 }
std::string ofname
Output mesh file name.
Definition: gmshParams.H:100

◆ setOpts()

void NEM::DRV::GmshMeshGenDriver::setOpts ( Opts  opts)
private

Definition at line 67 of file GmshMeshGenDriver.C.

References files_, NEM::GEN::gmshParams::ofname, opts_, and NEM::DRV::GmshMeshGenDriver::Opts::params.

Referenced by setParams().

67  {
68  if (!opts.params.ofname.empty()) {
69  this->files_.outputMeshFile = opts.params.ofname;
70  this->opts_ = std::move(opts);
71  } else {
72  this->opts_ = std::move(opts);
73  this->opts_.params.ofname = this->files_.outputMeshFile;
74  }
75 }
std::string ofname
Output mesh file name.
Definition: gmshParams.H:100

◆ setParams()

void NEM::DRV::GmshMeshGenDriver::setParams ( NEM::GEN::gmshParams  params)

Definition at line 59 of file GmshMeshGenDriver.C.

References setOpts().

59  {
60  setOpts(Opts{std::move(params)});
61 }

Member Data Documentation

◆ files_

Files NEM::DRV::GmshMeshGenDriver::files_
private

Definition at line 66 of file GmshMeshGenDriver.H.

Referenced by execute(), getFiles(), setFiles(), and setOpts().

◆ opts_

Opts NEM::DRV::GmshMeshGenDriver::opts_
private

Definition at line 67 of file GmshMeshGenDriver.H.

Referenced by execute(), getOpts(), setFiles(), and setOpts().


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