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.
GmshMeshGenDriver.C
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 *******************************************************************************/
30 
31 #include "AuxiliaryFunctions.H"
32 #include "MeshGeneration/gmshGen.H"
33 #include "Mesh/meshBase.H"
34 
35 namespace NEM {
36 namespace DRV {
37 
39  : params(std::move(params)) {}
40 
42  : files_(std::move(files)), opts_(std::move(params)) {}
43 
45 
47  return files_;
48 }
49 
51  this->opts_.params.ofname = files.outputMeshFile;
52  this->files_ = std::move(files);
53 }
54 
56  return getOpts().params;
57 }
58 
60  setOpts(Opts{std::move(params)});
61 }
62 
64  return opts_;
65 }
66 
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 }
76 
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 }
95 
96 } // namespace DRV
97 } // namespace NEM
static meshBase * exportGmshToVtk(const std::string &fname)
construct vtkMesh from gmsh msh file (called in Create methods)
Definition: meshBase.C:409
const Files & getFiles() const
STL namespace.
void execute() const override
Run the workflow represented by the driver.
std::string find_ext(const std::string &fname)
int createMeshFromSTL(const char *fname) override
Creates mesh from input STEP file.
Definition: gmshGen.C:60
const NEM::GEN::gmshParams & getParams() const
std::string trim_fname(const std::string &name, const std::string &ext)
gmshParams contains all parameters essential for mesh generation using gmshGen class methods...
Definition: gmshParams.H:92
std::string ofname
Output mesh file name.
Definition: gmshParams.H:100
void setParams(NEM::GEN::gmshParams params)
std::shared_ptr< meshBase > mesh
static std::shared_ptr< meshBase > CreateShared(const std::string &fname)
Create shared ptr from fname.
Definition: meshBase.C:171
const Opts & getOpts() const