18#include "libmesh/libmesh_config.h"
19#ifdef LIBMESH_HAVE_TETGEN
22#include "libmesh/libmesh_common.h"
23#include "libmesh/mesh_tetgen_wrapper.h"
33 tetgen_output(
std::make_unique<tetgenio>())
77 libmesh_error_msg_if(i >=
static_cast<unsigned>(
tetgen_output->numberofpoints),
78 "Error, requested point "
80 <<
", but there are only "
82 <<
" points available.");
143 libmesh_error_msg_if(this->
tetgen_data.pointlist !=
nullptr,
144 "Cannot allocate on top of previously allocated memory!");
160 libmesh_error_msg_if(s.size() >=
sizeof(buffer)-1,
161 "Fixed size buffer of length "
163 <<
" not large enough to hold TetGen switches.");
166 buffer[ s.copy( buffer ,
sizeof( buffer ) - 1 ) ] =
'\0' ;
168 if (!
tetgen_be.parse_commandline(buffer))
169 libMesh::out <<
"TetGen replies: Wrong switches!" << std::endl;
216 libmesh_error_msg_if(this->
tetgen_data.facetlist !=
nullptr,
217 "Cannot allocate on top of previously allocated memory!");
222 for (
int i=0; i<numoffacets; i++)
223 this->
tetgen_data.init(&(this->tetgen_data.facetlist[i]));
231 libmesh_error_msg_if(this->
tetgen_data.holelist !=
nullptr,
232 "Cannot allocate on top of previously allocated memory!");
248 libmesh_error_msg_if(this->
tetgen_data.regionlist !=
nullptr,
249 "Cannot allocate on top of previously allocated memory!");
261 this->
tetgen_data.facetlist[i].numberofpolygons = num;
269 this->
tetgen_data.facetlist[i].numberofholes = num;
281 if (numofpolygons > 0)
284 libmesh_error_msg_if(this->
tetgen_data.facetlist[i].polygonlist !=
nullptr,
285 "Cannot allocate on top of previously allocated memory!");
288 this->
tetgen_data.facetlist[i].polygonlist =
new tetgenio::polygon[numofpolygons];
290 for (
int j=0; j<this->
tetgen_data.facetlist[i].numberofpolygons; j++)
291 this->
tetgen_data.init(&(this->tetgen_data.facetlist[i].polygonlist[j]));
300 this->
tetgen_data.facetlist[i].polygonlist[j].numberofvertices = num;
310 if (numofvertices > 0)
313 libmesh_error_msg_if(this->
tetgen_data.facetlist[i].polygonlist[j].vertexlist !=
nullptr,
314 "Cannot allocate on top of previously allocated memory!");
317 this->
tetgen_data.facetlist[i].polygonlist[j].vertexlist =
new int[numofvertices];
327 this->
tetgen_data.facetlist[i].polygonlist[j].vertexlist[k] = nodeindex;
333 REAL attribute,
REAL vol_constraint)
335 unsigned index = i*5;
int get_element_node(unsigned i, unsigned j)
TetGenWrapper()
Constructor.
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.
int get_numberoftetrahedra()
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.
int get_numberoftrifaces()
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.
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.