libMesh
Loading...
Searching...
No Matches
mesh_tetgen_wrapper.h
Go to the documentation of this file.
1// The libMesh Finite Element Library.
2// Copyright (C) 2002-2026 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3
4// This library is free software; you can redistribute it and/or
5// modify it under the terms of the GNU Lesser General Public
6// License as published by the Free Software Foundation; either
7// version 2.1 of the License, or (at your option) any later version.
8
9// This library is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12// Lesser General Public License for more details.
13
14// You should have received a copy of the GNU Lesser General Public
15// License along with this library; if not, write to the Free Software
16// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
18#ifndef LIBMESH_MESH_TETGEN_WRAPPER_H
19#define LIBMESH_MESH_TETGEN_WRAPPER_H
20
21#include "libmesh/libmesh_config.h"
22#ifdef LIBMESH_HAVE_TETGEN
23
24// TetGen include file
25// tetgen.h triggers -Werror=switch-default
26#include "libmesh/ignore_warnings.h"
27#include "tetgen.h" // Defines REAL and other Tetgen types
28#include "libmesh/restore_warnings.h"
29
30// C++ includes
31#include <string>
32#include <memory>
33
34namespace libMesh
35{
46{
47public:
48
53
58
91 void set_switches(std::string_view s);
92
96 void run_tetgen();
97
102
107
111 void set_numberofpoints(int i);
112
116 int get_numberofpoints();
117
121 void set_numberoffacets(int i);
122
126 void set_numberofholes(int i);
127
131 void set_numberofregions(int i);
132
136 void allocate_pointlist(int numofpoints);
137
141 void allocate_facetlist(int numoffacets, int numofholes);
142
146 void allocate_regionlist(int numofregions);
147
151 void set_node(unsigned i, REAL x, REAL y, REAL z);
152
156 void get_output_node(unsigned i, REAL & x, REAL & y, REAL & z);
157
161 int get_element_node(unsigned i, unsigned j);
162
166 int get_triface_node(unsigned i, unsigned j);
167
171 REAL get_element_attribute(unsigned i);
172
176 void set_hole(unsigned i, REAL x, REAL y, REAL z);
177
181 void set_facet_numberofpolygons(unsigned i, int num);
182
186 void set_facet_numberofholes(unsigned i, int num);
187
192 void allocate_facet_polygonlist(unsigned i, int numofpolygons);
193
197 void set_polygon_numberofvertices(unsigned i, unsigned j, int num);
198
203 void allocate_polygon_vertexlist(unsigned i, unsigned j, int numofvertices);
204
209 void set_vertex(unsigned i, unsigned j, unsigned k, int nodeindex);
210
219 void set_region(unsigned i, REAL x, REAL y, REAL z,
220 REAL attribute, REAL vol_constraint);
221
225 tetgenio tetgen_data;
226
230 std::unique_ptr<tetgenio> tetgen_output;
231
235 tetgenmesh tetgen_mesh;
236
240 tetgenbehavior tetgen_be;
241};
242
243
244
245} // namespace libMesh
246
247
248#endif // LIBMESH_HAVE_TETGEN
249#endif // LIBMESH_MESH_TETGEN_WRAPPER_H
The TetGenWrapper provides an interface for basic access to TetGen data structures and methods.
int get_element_node(unsigned i, unsigned j)
void run_tetgen()
Starts the triangulation.
void set_region(unsigned i, REAL x, REAL y, REAL z, REAL attribute, REAL vol_constraint)
Sets coordinates, attribute, and volume constraint for region i in the TetGen input.
std::unique_ptr< tetgenio > tetgen_output
TetGen output structure.
void allocate_facetlist(int numoffacets, int numofholes)
Allocates memory, sets number of facets, holes in the TetGen input.
~TetGenWrapper()
Destructor.
void set_numberofregions(int i)
Sets the number of regions in the TetGen input.
REAL get_element_attribute(unsigned i)
tetgenio tetgen_data
TetGen input structure.
void get_output_node(unsigned i, REAL &x, REAL &y, REAL &z)
void set_polygon_numberofvertices(unsigned i, unsigned j, int num)
Sets the number of vertices for polygon j, facet i in the TetGen input.
void set_hole(unsigned i, REAL x, REAL y, REAL z)
Sets coordinates of hole i in the TetGen input.
void allocate_facet_polygonlist(unsigned i, int numofpolygons)
Allocates memory, sets number of polygons for facet i in the TetGen input.
void set_node(unsigned i, REAL x, REAL y, REAL z)
Sets coordinates of point i in the TetGen input.
void set_numberoffacets(int i)
Sets the number of facets in the TetGen input.
int get_triface_node(unsigned i, unsigned j)
void allocate_regionlist(int numofregions)
Allocates memory, sets number of regions in the TetGen input.
tetgenbehavior tetgen_be
TetGen control class (from the TetGen library).
void set_numberofholes(int i)
Sets the number of holes in the TetGen input.
void set_numberofpoints(int i)
Sets the number of nodes in the TetGen input.
void set_vertex(unsigned i, unsigned j, unsigned k, int nodeindex)
Sets index of ith facet, jth polygon, kth vertex in the TetGen input.
void allocate_pointlist(int numofpoints)
Allocates memory, sets number of nodes in the TetGen input.
void allocate_polygon_vertexlist(unsigned i, unsigned j, int numofvertices)
Allocates memory, sets number of vertices for polygon j, facet i in the TetGen input.
void set_facet_numberofpolygons(unsigned i, int num)
Sets the number of polygons for facet i in the TetGen input.
tetgenmesh tetgen_mesh
TetGen mesh structure (from the TetGen library).
void set_switches(std::string_view s)
Method to set TetGen commandline switches -p Tetrahedralizes a piecewise linear complex (....
void set_facet_numberofholes(unsigned i, int num)
Sets the number of holes for facet i in the TetGen input.
The libMesh namespace provides an interface to certain functionality in the library.