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.
netgenGen Class Reference

Detailed Description

Definition at line 46 of file netgenGen.H.

Public Member Functions

 netgenGen ()
 
 netgenGen (const netgenParams *params)
 
 ~netgenGen () override
 
void set_mp (const netgenParams *params)
 
int createMeshFromSTL (const char *fname) override
 
vtkSmartPointer< vtkDataSet > getDataSet () const
 

Public Attributes

std::unique_ptr< NEM::MSH::geoMeshBasegmData
 

Protected Attributes

vtkSmartPointer< vtkDataSet > dataSet
 

Private Attributes

nglib::Ng_Meshing_Parameters mp
 
nglib::Ng_Mesh * mesh
 
bool refine_with_geom
 
bool refine_without_geom
 

Inherits meshGen.

Constructor & Destructor Documentation

◆ netgenGen() [1/2]

netgenGen::netgenGen ( )

Definition at line 35 of file netgenGen.C.

References mesh.

37 {
38  std::cout << "initializing netgen mesh generator" << std::endl;
39  nglib::Ng_Init();
40  mesh = nglib::Ng_NewMesh();
41 }
bool refine_without_geom
Definition: netgenGen.H:64
nglib::Ng_Meshing_Parameters mp
Definition: netgenGen.H:61
bool refine_with_geom
Definition: netgenGen.H:63
nglib::Ng_Mesh * mesh
Definition: netgenGen.H:62

◆ netgenGen() [2/2]

netgenGen::netgenGen ( const netgenParams params)
explicit

Definition at line 43 of file netgenGen.C.

References mesh, and set_mp().

45 {
46  std::cout << "initializing netgen mesh generator" << std::endl;
47  nglib::Ng_Init();
48  set_mp(params);
49  mesh = nglib::Ng_NewMesh();
50 }
bool refine_without_geom
Definition: netgenGen.H:64
void set_mp(const netgenParams *params)
Definition: netgenGen.C:64
bool refine_with_geom
Definition: netgenGen.H:63
nglib::Ng_Mesh * mesh
Definition: netgenGen.H:62

◆ ~netgenGen()

netgenGen::~netgenGen ( )
override

Definition at line 52 of file netgenGen.C.

References mesh.

53 {
54  std::cout << "finalizing netgen mesh generator" << std::endl;
55  if (mesh)
56  {
57  nglib::Ng_DeleteMesh(mesh);
58  mesh = nullptr;
59  }
60  nglib::Ng_Exit();
61 }
nglib::Ng_Mesh * mesh
Definition: netgenGen.H:62

Member Function Documentation

◆ createMeshFromSTL()

int netgenGen::createMeshFromSTL ( const char *  fname)
overridevirtual

Implements meshGen.

Definition at line 88 of file netgenGen.C.

References mesh, mp, refine_with_geom, refine_without_geom, and nemAux::trim_fname().

89 {
90  // Define pointer to STL Geometry
91  nglib::Ng_STL_Geometry *stl_geom;
92 
93  // Result of Netgen Operations
94  nglib::Ng_Result ng_res;
95 
96  int np, ne;
97 
98  // Check that the STL file exists
99  std::ifstream inSTL(fname);
100  if (!inSTL.good()) {
101  std::cerr << "Error reading in STL file: " << fname << std::endl;
102  return 1;
103  }
104 
105  // Read in the STL File
106  stl_geom = nglib::Ng_STL_LoadGeometry(fname);
107 
108  // This object seems to always be defined. If the file does
109  // not exits, the process continues with no triangle facets
110  // loaded.
111  if (!stl_geom)
112  {
113  std::cerr << "Error reading in STL File: " << fname << std::endl;
114  return 1;
115  }
116  std::cout << "Successfully loaded STL File: " << fname << std::endl;
117 
118  std::cout << "Initialise the STL Geometry structure...." << std::endl;
119  ng_res = nglib::Ng_STL_InitSTLGeometry(stl_geom);
120  if (ng_res != nglib::NG_OK)
121  {
122  std::cerr << "Error Initialising the STL Geometry....Aborting!!" << std::endl;
123  return 1;
124  }
125 
126  std::cout << "Start Edge Meshing...." << std::endl;
127  ng_res = nglib::Ng_STL_MakeEdges(stl_geom, mesh, &mp);
128  if (ng_res != nglib::NG_OK)
129  {
130  std::cerr << "Error in Edge Meshing....Aborting!!" << std::endl;
131  return 1;
132  }
133 
134  std::cout << "Start Surface Meshing...." << std::endl;
135  ng_res = nglib::Ng_STL_GenerateSurfaceMesh(stl_geom, mesh, &mp);
136  if (ng_res != nglib::NG_OK)
137  {
138  std::cerr << "Error in Surface Meshing....Aborting!!" << std::endl;
139  return 1;
140  }
141 
142  std::cout << "Start Volume Meshing...." << std::endl;
143  ng_res = nglib::Ng_GenerateVolumeMesh(mesh, &mp);
144  if (ng_res != nglib::NG_OK)
145  {
146  std::cerr << "Error in Volume Meshing....Aborting!!" << std::endl;
147  return 1;
148  }
149 
150  std::cout << "Meshing successfully completed....!!" << std::endl;
151 
152  // volume mesh output
153  np = nglib::Ng_GetNP(mesh);
154  std::cout << "Points: " << np << std::endl;
155 
156  ne = nglib::Ng_GetNE(mesh);
157  std::cout << "Elements: " << ne << std::endl;
158 
159  // refinement without or with geometry adaption:
161  nglib::Ng_Uniform_Refinement(mesh);
162  else if (refine_with_geom)
163  nglib::Ng_STL_Uniform_Refinement(stl_geom, mesh);
164 
165  std::cout << "elements after refinement: " << nglib::Ng_GetNE(mesh)
166  << std::endl;
167  std::cout << "points after refinement: " << nglib::Ng_GetNP(mesh)
168  << std::endl;
169 
170  std::cout << "Saving Mesh in VOL Format...." << std::endl;
171  std::string newfname(fname);
172  nglib::Ng_SaveMesh(mesh, nemAux::trim_fname(newfname, ".vol").c_str());
173  return 0;
174 }
bool refine_without_geom
Definition: netgenGen.H:64
std::string trim_fname(const std::string &name, const std::string &ext)
nglib::Ng_Meshing_Parameters mp
Definition: netgenGen.H:61
bool refine_with_geom
Definition: netgenGen.H:63
nglib::Ng_Mesh * mesh
Definition: netgenGen.H:62

◆ getDataSet()

vtkSmartPointer<vtkDataSet> meshGen::getDataSet ( ) const
inlineinherited

Definition at line 53 of file meshGen.H.

Referenced by NEM::DRV::MeshGenDriver::MeshGenDriver().

53 { return dataSet; }
vtkSmartPointer< vtkDataSet > dataSet
Definition: meshGen.H:57

◆ set_mp()

void netgenGen::set_mp ( const netgenParams params)

Definition at line 64 of file netgenGen.C.

References netgenParams::check_overlap, netgenParams::check_overlapping_boundary, netgenParams::closeedgeenable, netgenParams::closeedgefact, netgenParams::elementspercurve, netgenParams::elementsperedge, netgenParams::fineness, netgenParams::grading, netgenParams::invert_tets, netgenParams::invert_trigs, netgenParams::maxh, netgenParams::meshsize_filename, mp, netgenParams::optsteps_2d, netgenParams::optsteps_3d, netgenParams::optvolmeshenable, netgenParams::quad_dominated, netgenParams::refine_with_geom, refine_with_geom, netgenParams::refine_without_geom, refine_without_geom, netgenParams::second_order, and netgenParams::uselocalh.

Referenced by netgenGen().

65 {
66  mp.uselocalh = params->uselocalh;
67  mp.maxh = params->maxh;
68  mp.fineness = params->fineness;
69  mp.grading = params->grading;
70  mp.elementsperedge = params->elementsperedge;
71  mp.elementspercurve = params->elementspercurve;
72  mp.closeedgeenable = params->closeedgeenable;
73  mp.closeedgefact = params->closeedgefact;
74  mp.second_order = params->second_order;
75  mp.meshsize_filename = const_cast<char *>(params->meshsize_filename.c_str());
76  mp.quad_dominated = params->quad_dominated;
77  mp.optvolmeshenable = params->optvolmeshenable;
78  mp.optsteps_2d = params->optsteps_2d;
79  mp.optsteps_3d = params->optsteps_3d;
80  mp.invert_tets = params->invert_tets;
81  mp.invert_trigs = params->invert_trigs;
82  mp.check_overlap = params->check_overlap;
83  mp.check_overlapping_boundary = params->check_overlapping_boundary;
86 }
bool refine_with_geom
Definition: netgenParams.H:62
double elementsperedge
Definition: netgenParams.H:48
bool second_order
Definition: netgenParams.H:52
bool refine_without_geom
Definition: netgenGen.H:64
bool quad_dominated
Definition: netgenParams.H:54
nglib::Ng_Meshing_Parameters mp
Definition: netgenGen.H:61
bool check_overlapping_boundary
Definition: netgenParams.H:61
double grading
Definition: netgenParams.H:47
bool invert_trigs
Definition: netgenParams.H:59
bool refine_without_geom
Definition: netgenParams.H:63
std::string meshsize_filename
Definition: netgenParams.H:53
bool check_overlap
Definition: netgenParams.H:60
bool optvolmeshenable
Definition: netgenParams.H:55
bool refine_with_geom
Definition: netgenGen.H:63
double closeedgefact
Definition: netgenParams.H:51
bool invert_tets
Definition: netgenParams.H:58
double fineness
Definition: netgenParams.H:46
bool closeedgeenable
Definition: netgenParams.H:50
double elementspercurve
Definition: netgenParams.H:49

Member Data Documentation

◆ dataSet

vtkSmartPointer<vtkDataSet> meshGen::dataSet
protectedinherited

Definition at line 57 of file meshGen.H.

◆ gmData

◆ mesh

nglib::Ng_Mesh* netgenGen::mesh
private

Definition at line 62 of file netgenGen.H.

Referenced by createMeshFromSTL(), netgenGen(), and ~netgenGen().

◆ mp

nglib::Ng_Meshing_Parameters netgenGen::mp
private

Definition at line 61 of file netgenGen.H.

Referenced by createMeshFromSTL(), and set_mp().

◆ refine_with_geom

bool netgenGen::refine_with_geom
private

Definition at line 63 of file netgenGen.H.

Referenced by createMeshFromSTL(), and set_mp().

◆ refine_without_geom

bool netgenGen::refine_without_geom
private

Definition at line 64 of file netgenGen.H.

Referenced by createMeshFromSTL(), and set_mp().


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