KratosMultiphysics
KRATOS Multiphysics (Kratos) is a framework for building parallel, multi-disciplinary simulation software, aiming at modularity, extensibility, and high performance. Kratos is written in C++, and counts with an extensive Python interface.
tetrahedral_mesh_3D_mesher.hpp
Go to the documentation of this file.
1 //
2 // Project Name: KratosDelaunayMeshingApplication $
3 // Created by: $Author: JMCarbonell $
4 // Last modified by: $Co-Author: $
5 // Date: $Date: April 2018 $
6 // Revision: $Revision: 0.0 $
7 //
8 //
9 
10 #if !defined (KRATOS_TETRAHEDRAL_MESH_3D_MESHER_H_INCLUDED)
11 #define KRATOS_TETRAHEDRAL_MESH_3D_MESHER_H_INCLUDED
12 
13 // External includes
14 #ifndef TETLIBRARY
15 #define TETLIBRARY
16 #endif
17 
18 #if !defined(KRATOS_TETGEN_EXTERNAL_H_INCLUDED)
19 #define KRATOS_TETGEN_EXTERNAL_H_INCLUDED
20 #include "tetgen.h"
21 #endif
22 
23 // System includes
24 
25 // Project includes
28 
29 namespace Kratos
30 {
33 
37 
41 
45 
49 
51 
53 class KRATOS_API(DELAUNAY_MESHING_APPLICATION) TetrahedralMesh3DMesher
54  : public Mesher
55 {
56 protected:
57 
58  enum TetgenErrors {INPUT_MEMORY_ERROR=1, INTERNAL_ERROR=2, INVALID_GEOMETRY_ERROR=3};
59 
60 public:
61 
64 
67 
71 
75 
78 
81 
84 
88 
89 
93 
94 
95 
99 
100 
104 
105 
109 
111  std::string Info() const override
112  {
113  return "";
114  }
115 
117  void PrintInfo(std::ostream& rOStream) const override{}
118 
120  void PrintData(std::ostream& rOStream) const override{}
121 
122 
126 
127 
129 
130 protected:
133 
134 
138 
139 
143 
144 
148 
149  //generate :: meshing step call to delaunay tessellation
150  void Generate (ModelPart& rModelPart, MeshingParametersType& rMeshingVariables) override;
151 
152  //generate the Delaunay Tesselation
153  int GenerateTessellation(MeshingParametersType& rMeshingVariables, tetgenio& in, tetgenio& out);
154 
155 
159 
160 
164 
165 
169 
170 
172 
173 private:
176 
177 
181 
182 
186 
189 
193 
194  //build the input for the mesher
195  void BuildInput ( ModelPart &rModelPart,
196  MeshingParametersType & rMeshingVariables,
197  tetgenio& in );
198 
199  //set and get from mesh container in meshing variables
200  void GetFromContainer(MesherUtilities::MeshContainer& rMesh, tetgenio& tr);
201 
202  void SetToContainer(MesherUtilities::MeshContainer& rMesh, tetgenio& tr);
203 
204  //delete in/out structures
205  void DeleteInContainer(MesherUtilities::MeshContainer& rMesh, tetgenio& tr);
206 
207  void DeleteOutContainer(MesherUtilities::MeshContainer& rMesh, tetgenio& tr);
208 
209  //set faces in the tetgenio before the Delaunay Tesselation
210  virtual void SetFaces( ModelPart &rModelPart, MeshingParametersType & rMeshingVariables, tetgenio &in );
211 
212  //check points
213  void CheckInOutPoints ( tetgenio& in, tetgenio& out );
214 
215  //print methods
216  void WriteTetrahedra ( tetgenio& tr );
217 
218  void WritePoints ( tetgenio& tr );
219 
220  //free memory of the mesher
221  void ClearTetgenIO ( tetgenio& tr );
222 
223  // void DeleteTetrahedraList ( tetgenio& tr );
224 
225  // void DeletePointsList ( tetgenio& tr );
226 
230 
231 
235 
236 
240 
242 
243 }; // Class TetrahedralMesh3DMesher
244 
246 
249 
250 
254 
255 
257  inline std::istream& operator >> (std::istream& rIStream,
258  TetrahedralMesh3DMesher& rThis);
259 
261  inline std::ostream& operator << (std::ostream& rOStream,
262  const TetrahedralMesh3DMesher& rThis)
263  {
264  rThis.PrintInfo(rOStream);
265  rOStream << std::endl;
266  rThis.PrintData(rOStream);
267 
268  return rOStream;
269  }
271 
272 
273 } // namespace Kratos.
274 
275 #endif // KRATOS_TETRAHEDRAL_MESH_3D_MESHER_H_INCLUDED defined
276 
277 
278 
279 
280 
281 //************************************************************************************
282 // Command line switches for TETGEN:
283 
284 //1.5.0
285 
286 // -p Tetrahedralizes a piecewise linear complex (PLC).
287 // -Y Preserves the input surface mesh (does not modify it).
288 // -r Reconstructs a previously generated mesh.
289 // -q Refines mesh (to improve mesh quality).
290 // -R Mesh coarsening (to reduce the mesh elements).
291 // -A Assigns attributes to tetrahedra in different regions.
292 // -a Applies a maximum tetrahedron volume constraint.
293 // -m Applies a mesh sizing function.
294 // -i Inserts a list of additional points.
295 // -O Specifies the level of mesh optimization.
296 // -S Specifies maximum number of added points.
297 // -T Sets a tolerance for coplanar test (default 10−8).
298 // -X Suppresses use of exact arithmetic.
299 // -M No merge of coplanar facets or very close vertices.
300 // -w Generates weighted Delaunay (regular) triangulation.
301 // -c Retains the convex hull of the PLC.
302 // -d Detects self-intersections of facets of the PLC.
303 // -z Numbers all output items starting from zero.
304 // -f Outputs all faces to .face file.
305 // -e Outputs all edges to .edge file.
306 // -n Outputs tetrahedra neighbors to .neigh file.
307 // -v Outputs Voronoi diagram to files.
308 // -g Outputs mesh to .mesh file for viewing by Medit.
309 // -k Outputs mesh to .vtk file for viewing by Paraview.
310 // -J No jettison of unused vertices from output .node file.
311 // -B Suppresses output of boundary information.
312 // -N Suppresses output of .node file.
313 // -E Suppresses output of .ele file.
314 // -F Suppresses output of .face and .edge file.
315 // -I Suppresses mesh iteration numbers.
316 // -C Checks the consistency of the final mesh.
317 // -Q Quiet: No terminal output except errors.
318 // -V Verbose: Detailed information, more terminal output.
319 // -h Help: A brief instruction for using TetGen.
320 
321 //1.4.3
322 
323 // -p Tetrahedralizes a piecewise linear complex (.poly or .smesh file).
324 // -q Quality mesh generation. A minimum radius-edge ratio may be specified (default 2.0).
325 // -a Applies a maximum tetrahedron volume constraint.
326 // -A Assigns attributes to identify tetrahedra in certain regions.
327 // -r Reconstructs and Refines a previously generated mesh.
328 // -Y Suppresses boundary facets/segments splitting.
329 // -i Inserts a list of additional points into mesh.
330 // -M Does not merge coplanar facets.
331 // -T Set a tolerance for coplanar test (default 1e-8).
332 // -d Detect intersections of PLC facets.
333 // -z Numbers all output items starting from zero.
334 // -o2 Generates second-order subparametric elements.
335 // -f Outputs faces (including non-boundary faces) to .face file.
336 // -e Outputs subsegments to .edge file.
337 // -n Outputs tetrahedra neighbors to .neigh file.
338 // -g Outputs mesh to .mesh file for viewing by Medit.
339 // -G Outputs mesh to .msh file for viewing by Gid.
340 // -O Outputs mesh to .off file for viewing by Geomview.
341 // -J No jettison of unused vertices from output .node file.
342 // -B Suppresses output of boundary information.
343 // -N Suppresses output of .node file.
344 // -E Suppresses output of .ele file.
345 // -F Suppresses output of .face file.
346 // -I Suppresses mesh iteration numbers.
347 // -C Checks the consistency of the final mesh.
348 // -Q Quiet: No terminal output except errors.
349 // -V Verbose: Detailed information, more terminal output.
350 // -v Prints the version information.
351 // -h Help: A brief instruction for using TetGen.
352 
PeriodicInterfaceProcess & operator=(const PeriodicInterfaceProcess &)=delete
Short class definition.
Definition: mesher.hpp:60
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
Short class definition.
Definition: tetrahedral_mesh_3D_mesher.hpp:55
MesherUtilities::MeshingInfoParameters InfoParametersType
Definition: tetrahedral_mesh_3D_mesher.hpp:68
virtual ~TetrahedralMesh3DMesher()
Destructor.
Definition: tetrahedral_mesh_3D_mesher.hpp:83
MesherUtilities::RefiningParameters RefineParametersType
Definition: tetrahedral_mesh_3D_mesher.hpp:70
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: tetrahedral_mesh_3D_mesher.hpp:120
TetrahedralMesh3DMesher(TetrahedralMesh3DMesher const &rOther)
Copy constructor.
Definition: tetrahedral_mesh_3D_mesher.hpp:80
MesherUtilities::MeshingParameters MeshingParametersType
Definition: tetrahedral_mesh_3D_mesher.hpp:69
TetrahedralMesh3DMesher()
Default constructor.
Definition: tetrahedral_mesh_3D_mesher.hpp:77
std::string Info() const override
Turn back information as a string.
Definition: tetrahedral_mesh_3D_mesher.hpp:111
TetgenErrors
Definition: tetrahedral_mesh_3D_mesher.hpp:58
KRATOS_CLASS_POINTER_DEFINITION(TetrahedralMesh3DMesher)
Pointer definition of TriGenCDT.
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: tetrahedral_mesh_3D_mesher.hpp:117
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
out
Definition: isotropic_damage_automatic_differentiation.py:200
Definition: mesher_utilities.hpp:149
Definition: mesher_utilities.hpp:269
Definition: mesher_utilities.hpp:631
Definition: mesher_utilities.hpp:479