Go to the documentation of this file.
   18 #include "libmesh/libmesh_config.h" 
   19 #ifdef LIBMESH_HAVE_TETGEN 
   26 #include "libmesh/cell_tet4.h" 
   27 #include "libmesh/face_tri3.h" 
   28 #include "libmesh/unstructured_mesh.h" 
   29 #include "libmesh/mesh_tetgen_interface.h" 
   30 #include "libmesh/utility.h"  
   31 #include "libmesh/mesh_tetgen_wrapper.h" 
   79   std::ostringstream oss;
 
   93   unsigned int node_labels[4];
 
   95   for (
unsigned int i=0; i<num_elements; ++i)
 
  144   unsigned int node_labels[3];
 
  146   for (
unsigned int i=0; i<num_elements; ++i)
 
  166                                                               double volume_constraint)
 
  169   std::vector<Point> noholes;
 
  176                                                                          double quality_constraint,
 
  177                                                                          double volume_constraint)
 
  197     (facet_num, cast_int<int>(holes.size()));
 
  209         for (
auto j : elem->node_index_range())
 
  213             unsigned libmesh_node_id = elem->node_id(j);
 
  217             std::vector<unsigned>::iterator node_iter =
 
  225               libmesh_error_msg(
"Global node " << libmesh_node_id << 
" not found in sequential node map!");
 
  227             int sequential_index = cast_int<int>
 
  250   if (holes.size() > 0)
 
  252       unsigned hole_index = 0;
 
  253       for (
Point ihole : holes)
 
  254         tetgen_wrapper.
set_hole(hole_index++,
 
  266   std::ostringstream oss;
 
  270   if (quality_constraint != 0)
 
  271     oss << 
"q" << std::fixed << quality_constraint;
 
  273   if (volume_constraint != 0)
 
  274     oss << 
"a" << std::fixed << volume_constraint;
 
  276   std::string params = oss.str();
 
  283   REAL x=0., y=0., z=0.;
 
  298   for (
unsigned int i=old_nodesnum; i<num_nodes; i++)
 
  322   unsigned int node_labels[4];
 
  324   for (
unsigned int i=0; i<num_elements; i++)
 
  406       if (elem->type() != 
TRI3)
 
  412       for (
auto neigh : elem->neighbor_ptr_range())
 
  414           if (neigh == 
nullptr)
 
  434       libMesh::err << 
"Error! Conforming Delaunay mesh tetrahedralization requires a convex hull." << std::endl;
 
  438           libMesh::err << 
"Non-TRI3 elements were found in the input Mesh.  ";
 
  439           libMesh::err << 
"A constrained Delaunay triangulation requires a convex hull of TRI3 elements." << std::endl;
 
  442       libmesh_error_msg(
"Consider calling TetGenMeshInterface::pointset_convexhull() followed by Mesh::find_neighbors() first.");
 
  456       if (elem->type() == 
TRI3)
 
  470 #endif // #ifdef LIBMESH_HAVE_TETGEN 
  
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
 
The TetGenWrapper provides an interface for basic access to TetGen data structures and methods.
 
virtual void delete_elem(Elem *e)=0
Removes element e from the mesh.
 
TetGenMeshInterface(UnstructuredMesh &mesh)
Constructor.
 
virtual dof_id_type n_elem() const =0
 
The libMesh namespace provides an interface to certain functionality in the library.
 
void fill_pointlist(TetGenWrapper &wrapper)
This function copies nodes from the _mesh into TetGen's pointlist.
 
IntRange< unsigned short > node_index_range() const
 
unsigned check_hull_integrity()
This function checks the integrity of the current set of elements in the Mesh to see if they comprise...
 
int get_element_node(unsigned i, unsigned j)
 
virtual const Node * node_ptr(const dof_id_type i) const =0
 
void triangulate_conformingDelaunayMesh_carvehole(const std::vector< Point > &holes, double quality_constraint=0., double volume_constraint=0.)
Method invokes TetGen library to compute a Delaunay tetrahedralization from the nodes point set.
 
UnstructuredMesh & _mesh
Local reference to the mesh we are working with.
 
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_hole(unsigned i, REAL x, REAL y, REAL z)
Sets coordinates of hole i in the TetGen input.
 
std::vector< unsigned > _sequential_to_libmesh_node_map
We should not assume libmesh nodes are numbered sequentially...
 
virtual SimpleRange< element_iterator > element_ptr_range()=0
 
void allocate_pointlist(int numofpoints)
Allocates memory, sets 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 process_hull_integrity_result(unsigned result)
This function prints an informative message and crashes based on the output of the check_hull_integri...
 
virtual SimpleRange< node_iterator > node_ptr_range()=0
 
std::string _switches
Parameter controlling the behaviour of tetgen.
 
void set_node(unsigned i, REAL x, REAL y, REAL z)
Sets coordinates of point i in the TetGen input.
 
int get_numberoftetrahedra()
 
void delete_2D_hull_elements()
Delete original convex hull elements from the Mesh after performing a Delaunay tetrahedralization.
 
A Point defines a location in LIBMESH_DIM dimensional Real space.
 
ForwardIterator binary_find(ForwardIterator first, ForwardIterator last, const T &value)
The STL provides std::binary_search() which returns true or false depending on whether the searched-f...
 
A Node is like a Point, but with more information.
 
The Tet4 is an element in 3D composed of 4 nodes.
 
void get_output_node(unsigned i, REAL &x, REAL &y, REAL &z)
 
void regenerate_id_sets()
Clears and regenerates the cached sets of ids.
 
virtual Node *& set_node(const unsigned int i)
 
void assign_nodes_to_elem(unsigned *node_labels, Elem *elem)
Assigns the node IDs contained in the 'node_labels' array to 'elem'.
 
The UnstructuredMesh class is derived from the MeshBase class.
 
virtual dof_id_type n_nodes() const =0
 
void set_switches(const std::string &s)
Method to set TetGen commandline switches -p Tetrahedralizes a piecewise linear complex (....
 
Real distance(const Point &p)
 
int get_triface_node(unsigned i, unsigned j)
 
int get_numberoftrifaces()
 
void triangulate_conformingDelaunayMesh(double quality_constraint=0., double volume_constraint=0.)
Method invokes TetGen library to compute a Delaunay tetrahedralization from the nodes point set.
 
virtual Elem * add_elem(Elem *e)=0
Add elem e to the end of the element array.
 
The Tri3 is an element in 2D composed of 3 nodes.
 
void triangulate_pointset()
Method invokes TetGen library to compute a Delaunay tetrahedralization from the nodes point set.
 
void set_switches(const std::string &)
Method to set switches to tetgen, allowing for different behaviours.
 
This is the base class from which all geometric element types are derived.
 
virtual Node * add_point(const Point &p, const dof_id_type id=DofObject::invalid_id, const processor_id_type proc_id=DofObject::invalid_processor_id)=0
Add a new Node at Point p to the end of the vertex array, with processor_id procid.
 
void allocate_facet_polygonlist(unsigned i, int numofpolygons)
Allocates memory, sets number of polygons for facet i in the TetGen input.
 
void allocate_facetlist(int numoffacets, int numofholes)
Allocates memory, sets number of facets, holes in the TetGen input.
 
void run_tetgen()
Starts the triangulation.
 
void pointset_convexhull()
Method invokes TetGen library to compute a Delaunay tetrahedralization from the nodes point set.