libMesh
|
Class TetGenMeshInterface
provides an interface for tetrahedralization of meshes using the TetGen library.
More...
#include <mesh_tetgen_interface.h>
Public Member Functions | |
TetGenMeshInterface (UnstructuredMesh &mesh) | |
Constructor. More... | |
virtual | ~TetGenMeshInterface () override=default |
Empty destructor. More... | |
void | set_switches (std::string new_switches) |
Method to set switches to tetgen, allowing for different behaviours. More... | |
virtual void | triangulate () override |
Method invokes TetGen library to compute a Delaunay tetrahedralization. More... | |
void | triangulate_pointset () |
Method invokes TetGen library to compute a Delaunay tetrahedralization from the nodes point set. More... | |
void | pointset_convexhull () |
Method invokes TetGen library to compute a Delaunay tetrahedralization from the nodes point set. More... | |
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. More... | |
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. More... | |
Real & | desired_volume () |
Sets and/or gets the desired tetrahedron volume. More... | |
bool & | smooth_after_generating () |
Sets/gets flag which tells whether to do two steps of Laplace mesh smoothing after generating the grid. More... | |
ElemType & | elem_type () |
Sets and/or gets the desired element type. More... | |
void | attach_hole_list (std::unique_ptr< std::vector< std::unique_ptr< UnstructuredMesh >>> holes) |
Attaches a vector of Mesh pointers defining holes which will be meshed around. More... | |
Protected Member Functions | |
void | fill_pointlist (TetGenWrapper &wrapper) |
This function copies nodes from the _mesh into TetGen's pointlist. More... | |
void | assign_nodes_to_elem (unsigned *node_labels, Elem *elem) |
Assigns the node IDs contained in the 'node_labels' array to 'elem'. More... | |
unsigned | check_hull_integrity () |
This function checks the integrity of the current set of elements in the Mesh to see if they comprise a hull, that is: More... | |
void | process_hull_integrity_result (unsigned result) |
This function prints an informative message and crashes based on the output of the check_hull_integrity() function. More... | |
void | delete_2D_hull_elements () |
Delete original convex hull elements from the Mesh after performing a Delaunay tetrahedralization. More... | |
Static Protected Member Functions | |
static BoundingBox | volume_to_surface_mesh (UnstructuredMesh &mesh) |
Remove volume elements from the given mesh, after converting their outer boundary faces to surface elements. More... | |
Protected Attributes | |
std::vector< unsigned > | _sequential_to_libmesh_node_map |
We should not assume libmesh nodes are numbered sequentially... More... | |
MeshSerializer | _serializer |
Tetgen only operates on serial meshes. More... | |
std::string | _switches |
Parameter controlling the behaviour of tetgen. More... | |
Real | _desired_volume |
The desired volume for the elements in the resulting mesh. More... | |
bool | _smooth_after_generating |
Flag which tells whether we should smooth the mesh after it is generated. More... | |
ElemType | _elem_type |
The exact type of tetrahedra we intend to construct. More... | |
UnstructuredMesh & | _mesh |
Local reference to the mesh we are working with. More... | |
std::unique_ptr< std::vector< std::unique_ptr< UnstructuredMesh > > > | _holes |
A pointer to a vector of meshes each defining a hole. More... | |
Class TetGenMeshInterface
provides an interface for tetrahedralization of meshes using the TetGen library.
For information about TetGen cf. TetGen home page.
Definition at line 55 of file mesh_tetgen_interface.h.
|
explicit |
Constructor.
Takes a reference to the mesh.
Definition at line 41 of file mesh_tetgen_interface.C.
|
overridevirtualdefault |
Empty destructor.
|
protected |
Assigns the node IDs contained in the 'node_labels' array to 'elem'.
Definition at line 408 of file mesh_tetgen_interface.C.
References libMesh::MeshTetInterface::_mesh, _sequential_to_libmesh_node_map, libMesh::Elem::node_index_range(), libMesh::MeshBase::node_ptr(), and libMesh::Elem::set_node().
Referenced by pointset_convexhull(), triangulate_conformingDelaunayMesh_carvehole(), and triangulate_pointset().
|
inherited |
Attaches a vector of Mesh pointers defining holes which will be meshed around.
We use unique_ptr here because we expect that we may need to modify these meshes internally.
Definition at line 124 of file mesh_tet_interface.C.
Referenced by MeshTetTest::testHole(), and MeshTetTest::testSphereShell().
|
protectedinherited |
This function checks the integrity of the current set of elements in the Mesh to see if they comprise a hull, that is:
Definition at line 325 of file mesh_tet_interface.C.
References libMesh::MeshTetInterface::_mesh, libMesh::MeshBase::n_elem(), libMesh::Elem::neighbor_ptr_range(), libMesh::TRI3, and libMesh::Elem::type().
Referenced by libMesh::NetGenMeshInterface::triangulate(), and triangulate_conformingDelaunayMesh_carvehole().
|
protectedinherited |
Delete original convex hull elements from the Mesh after performing a Delaunay tetrahedralization.
Definition at line 377 of file mesh_tet_interface.C.
References libMesh::MeshTetInterface::_mesh, libMesh::MeshBase::delete_elem(), libMesh::MeshBase::get_boundary_info(), libMesh::BoundaryInfo::regenerate_id_sets(), libMesh::TRI3, and libMesh::Elem::type().
Referenced by triangulate_conformingDelaunayMesh_carvehole().
|
inlineinherited |
Sets and/or gets the desired tetrahedron volume.
Set to zero to disable volume constraint.
Definition at line 68 of file mesh_tet_interface.h.
References libMesh::MeshTetInterface::_desired_volume.
Referenced by main(), and MeshTetTest::testSphereShell().
|
inlineinherited |
Sets and/or gets the desired element type.
This should be a Tet type.
Definition at line 81 of file mesh_tet_interface.h.
References libMesh::MeshTetInterface::_elem_type.
|
protected |
This function copies nodes from the _mesh into TetGen's pointlist.
Takes some pains to ensure that non-sequential node numberings (which can happen with e.g. DistributedMesh) are handled.
Definition at line 380 of file mesh_tetgen_interface.C.
References libMesh::MeshTetInterface::_mesh, _sequential_to_libmesh_node_map, libMesh::TetGenWrapper::allocate_pointlist(), libMesh::MeshBase::n_nodes(), and libMesh::TetGenWrapper::set_node().
Referenced by pointset_convexhull(), triangulate_conformingDelaunayMesh_carvehole(), and triangulate_pointset().
void libMesh::TetGenMeshInterface::pointset_convexhull | ( | ) |
Method invokes TetGen library to compute a Delaunay tetrahedralization from the nodes point set.
Stores only 2D hull surface elements.
Definition at line 132 of file mesh_tetgen_interface.C.
References libMesh::MeshTetInterface::_mesh, libMesh::MeshTetInterface::_smooth_after_generating, _switches, libMesh::MeshBase::add_elem(), assign_nodes_to_elem(), libMesh::Elem::build(), libMesh::MeshBase::delete_elem(), fill_pointlist(), libMesh::MeshBase::get_boundary_info(), libMesh::TetGenWrapper::get_numberoftrifaces(), libMesh::TetGenWrapper::get_triface_node(), libMesh::BoundaryInfo::regenerate_id_sets(), libMesh::TetGenWrapper::run_tetgen(), libMesh::TetGenWrapper::set_switches(), libMesh::LaplaceMeshSmoother::smooth(), and libMesh::TRI3.
Referenced by add_cube_convex_hull_to_mesh().
|
protectedinherited |
This function prints an informative message and crashes based on the output of the check_hull_integrity() function.
It is a separate function so that you can check hull integrity without crashing if you desire.
Definition at line 359 of file mesh_tet_interface.C.
References libMesh::err.
Referenced by triangulate_conformingDelaunayMesh_carvehole().
void libMesh::TetGenMeshInterface::set_switches | ( | std::string | new_switches | ) |
Method to set switches to tetgen, allowing for different behaviours.
Definition at line 48 of file mesh_tetgen_interface.C.
References _switches.
Referenced by tetrahedralize_domain().
|
inlineinherited |
Sets/gets flag which tells whether to do two steps of Laplace mesh smoothing after generating the grid.
False by default (for compatibility with old TetGenMeshInterface behavior).
Definition at line 75 of file mesh_tet_interface.h.
References libMesh::MeshTetInterface::_smooth_after_generating.
|
overridevirtual |
Method invokes TetGen library to compute a Delaunay tetrahedralization.
Implements libMesh::MeshTetInterface.
Definition at line 62 of file mesh_tetgen_interface.C.
References triangulate_pointset().
void libMesh::TetGenMeshInterface::triangulate_conformingDelaunayMesh | ( | double | quality_constraint = 0. , |
double | volume_constraint = 0. |
||
) |
Method invokes TetGen library to compute a Delaunay tetrahedralization from the nodes point set.
Boundary constraints are taken from elements array.
Definition at line 189 of file mesh_tetgen_interface.C.
References triangulate_conformingDelaunayMesh_carvehole().
void libMesh::TetGenMeshInterface::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.
Boundary constraints are taken from elements array. Include carve-out functionality.
Definition at line 199 of file mesh_tetgen_interface.C.
References libMesh::MeshTetInterface::_mesh, _sequential_to_libmesh_node_map, libMesh::MeshTetInterface::_smooth_after_generating, _switches, libMesh::MeshBase::add_elem(), libMesh::MeshBase::add_point(), libMesh::TetGenWrapper::allocate_facet_polygonlist(), libMesh::TetGenWrapper::allocate_facetlist(), libMesh::TetGenWrapper::allocate_polygon_vertexlist(), assign_nodes_to_elem(), libMesh::Utility::binary_find(), libMesh::Elem::build(), libMesh::MeshTetInterface::check_hull_integrity(), libMesh::MeshTetInterface::delete_2D_hull_elements(), distance(), fill_pointlist(), libMesh::TetGenWrapper::get_element_node(), libMesh::TetGenWrapper::get_numberofpoints(), libMesh::TetGenWrapper::get_numberoftetrahedra(), libMesh::TetGenWrapper::get_output_node(), libMesh::DofObject::id(), libMesh::MeshBase::n_elem(), libMesh::MeshBase::n_nodes(), libMesh::MeshTetInterface::process_hull_integrity_result(), libMesh::TetGenWrapper::run_tetgen(), libMesh::TetGenWrapper::set_hole(), libMesh::TetGenWrapper::set_switches(), libMesh::TetGenWrapper::set_vertex(), libMesh::LaplaceMeshSmoother::smooth(), and libMesh::TET4.
Referenced by tetrahedralize_domain(), and triangulate_conformingDelaunayMesh().
void libMesh::TetGenMeshInterface::triangulate_pointset | ( | ) |
Method invokes TetGen library to compute a Delaunay tetrahedralization from the nodes point set.
Definition at line 68 of file mesh_tetgen_interface.C.
References libMesh::MeshTetInterface::_desired_volume, libMesh::MeshTetInterface::_mesh, libMesh::MeshTetInterface::_smooth_after_generating, _switches, libMesh::MeshBase::add_elem(), assign_nodes_to_elem(), libMesh::Elem::build(), fill_pointlist(), libMesh::TetGenWrapper::get_element_node(), libMesh::TetGenWrapper::get_numberoftetrahedra(), libMesh::TetGenWrapper::run_tetgen(), libMesh::TetGenWrapper::set_switches(), libMesh::LaplaceMeshSmoother::smooth(), and libMesh::TET4.
Referenced by triangulate().
|
staticprotectedinherited |
Remove volume elements from the given mesh, after converting their outer boundary faces to surface elements.
Returns the bounding box of the mesh; this is useful for detecting misplaced holes later.
Definition at line 130 of file mesh_tet_interface.C.
References libMesh::MeshBase::add_elem(), libMesh::MeshTools::Modification::all_tri(), libMesh::Elem::build_side_ptr(), libMesh::MeshBase::delete_elem(), libMesh::Elem::dim(), libMesh::Elem::flip(), libMesh::MeshBase::get_boundary_info(), libMesh::DofObject::id(), libMesh::MeshBase::is_prepared(), libMesh::MeshBase::is_replicated(), libMesh::Elem::level(), libMesh::Elem::low_order_key(), libMesh::make_range(), libMesh::MeshBase::max_elem_id(), mesh, libMesh::Elem::n_sides(), libMesh::Elem::neighbor_ptr(), libMesh::Elem::node_ref_range(), libMesh::MeshBase::parallel_max_unique_id(), libMesh::MeshBase::prepare_for_use(), libMesh::Real, libMesh::remote_elem, libMesh::DofObject::set_id(), libMesh::Elem::set_interior_parent(), libMesh::Elem::set_neighbor(), libMesh::DofObject::set_unique_id(), libMesh::Elem::side_index_range(), libMesh::Elem::side_ptr(), and libMesh::BoundingBox::union_with().
Referenced by libMesh::NetGenMeshInterface::triangulate().
|
protectedinherited |
The desired volume for the elements in the resulting mesh.
Unlimited (indicated by 0) by default
Definition at line 138 of file mesh_tet_interface.h.
Referenced by libMesh::MeshTetInterface::desired_volume(), libMesh::NetGenMeshInterface::triangulate(), and triangulate_pointset().
|
protectedinherited |
The exact type of tetrahedra we intend to construct.
Definition at line 149 of file mesh_tet_interface.h.
Referenced by libMesh::MeshTetInterface::elem_type().
|
protectedinherited |
A pointer to a vector of meshes each defining a hole.
If this is nullptr, there are no holes!
Definition at line 160 of file mesh_tet_interface.h.
Referenced by libMesh::NetGenMeshInterface::triangulate().
|
protectedinherited |
Local reference to the mesh we are working with.
Definition at line 154 of file mesh_tet_interface.h.
Referenced by assign_nodes_to_elem(), libMesh::MeshTetInterface::check_hull_integrity(), libMesh::MeshTetInterface::delete_2D_hull_elements(), fill_pointlist(), pointset_convexhull(), libMesh::NetGenMeshInterface::triangulate(), triangulate_conformingDelaunayMesh_carvehole(), and triangulate_pointset().
|
protected |
We should not assume libmesh nodes are numbered sequentially...
This is not the default behavior of DistributedMesh, for example, unless you specify node IDs explicitly. So this array allows us to keep a mapping between the sequential numbering in tetgen_data.pointlist.
Definition at line 133 of file mesh_tetgen_interface.h.
Referenced by assign_nodes_to_elem(), fill_pointlist(), and triangulate_conformingDelaunayMesh_carvehole().
|
protected |
Tetgen only operates on serial meshes.
Definition at line 138 of file mesh_tetgen_interface.h.
|
protectedinherited |
Flag which tells whether we should smooth the mesh after it is generated.
False by default.
Definition at line 144 of file mesh_tet_interface.h.
Referenced by pointset_convexhull(), libMesh::MeshTetInterface::smooth_after_generating(), triangulate_conformingDelaunayMesh_carvehole(), and triangulate_pointset().
|
protected |
Parameter controlling the behaviour of tetgen.
By default quiet.
Definition at line 144 of file mesh_tetgen_interface.h.
Referenced by pointset_convexhull(), set_switches(), triangulate_conformingDelaunayMesh_carvehole(), and triangulate_pointset().