libMesh
|
A C++ interface between LibMesh and the Triangle library written by J.R. More...
#include <mesh_triangle_interface.h>
Public Types | |
enum | TriangulationType { GENERATE_CONVEX_HULL = 0, PSLG = 1, INVALID_TRIANGULATION_TYPE } |
The TriangulationType is used with the general triangulate function defined below. More... | |
Public Member Functions | |
TriangleInterface (UnstructuredMesh &mesh) | |
The constructor. More... | |
virtual | ~TriangleInterface ()=default |
Empty destructor. More... | |
virtual void | triangulate () override |
Internally, this calls Triangle's triangulate routine. More... | |
std::string & | extra_flags () |
Sets and/or gets additional flags to be passed to triangle. More... | |
ElemType & | elem_type () |
Sets and/or gets the desired element type. More... | |
Real & | desired_area () |
Sets and/or gets the desired triangle area. More... | |
virtual void | set_desired_area_function (FunctionBase< Real > *) |
Set a function giving desired triangle area as a function of position. More... | |
virtual FunctionBase< Real > * | get_desired_area_function () |
Get the function giving desired triangle area as a function of position, or nullptr if no such function has been set. More... | |
Real & | minimum_angle () |
Sets and/or gets the minimum desired angle. More... | |
TriangulationType & | triangulation_type () |
Sets and/or gets the desired triangulation type. More... | |
bool & | insert_extra_points () |
Sets and/or gets the flag for inserting add'l points. More... | |
void | set_interpolate_boundary_points (int n_points) |
Complicated setter, for compatibility with insert_extra_points() More... | |
int | get_interpolate_boundary_points () const |
Complicated getter, for compatibility with insert_extra_points() More... | |
virtual void | set_refine_boundary_allowed (bool) |
Set whether or not the triangulation is allowed to refine the mesh boundary when refining the interior. More... | |
virtual bool | refine_boundary_allowed () const |
Get whether or not the triangulation is allowed to refine the mesh boundary when refining the interior. More... | |
bool & | smooth_after_generating () |
Sets/gets flag which tells whether to do two steps of Laplace mesh smoothing after generating the grid. More... | |
bool & | quiet () |
Whether not to silence internal messages to stdout. More... | |
void | attach_hole_list (const std::vector< Hole *> *holes) |
Attaches a vector of Hole* pointers which will be meshed around. More... | |
void | set_verify_hole_boundaries (bool v) |
Verifying that hole boundaries don't cross the outer boundary or each other is something like O(N_bdys^2*N_points_per_bdy^2), so we only do it if requested. More... | |
bool | get_verify_hole_boundaries () const |
void | attach_boundary_marker (const std::vector< int > *markers) |
Attaches boundary markers. More... | |
void | attach_region_list (const std::vector< Region *> *regions) |
Attaches regions for using attribute to set subdomain IDs and better controlling the triangle sizes within the regions. More... | |
void | set_outer_boundary_ids (std::set< std::size_t > bdy_ids) |
A set of ids to allow on the outer boundary loop: interpreted as boundary ids of 2D elements and/or subdomain ids of 1D edges. More... | |
const std::set< std::size_t > & | get_outer_boundary_ids () const |
Public Attributes | |
std::vector< std::pair< unsigned int, unsigned int > > | segments |
When constructing a PSLG, if the node numbers do not define the desired boundary segments implicitly through the ordering of the points, you can use the segments vector to specify the segments explicitly, Ex: unit square numbered counter-clockwise starting from origin segments[0] = (0,1) segments[1] = (1,2) segments[2] = (2,3) segments[3] = (3,0) (For the above case you could actually use the implicit ordering!) More... | |
Protected Member Functions | |
void | elems_to_segments () |
Helper function to create PSLG segments from our other boundary-defining options (1D mesh edges, 2D mesh boundary sides), if no segments already exist. More... | |
void | nodes_to_segments (dof_id_type max_node_id) |
Helper function to create PSLG segments from our node ordering, up to the maximum node id, if no segments already exist. More... | |
void | insert_any_extra_boundary_points () |
Helper function to add extra points (midpoints of initial segments) to a PSLG triangulation. More... | |
void | verify_holes (const Hole &outer_bdy) |
Helper function to check holes for intersections if requested. More... | |
unsigned int | total_hole_points () |
Helper function to count points in and verify holes. More... | |
Protected Attributes | |
UnstructuredMesh & | _mesh |
Reference to the mesh which is to be created by triangle. More... | |
const std::vector< Hole * > * | _holes |
A pointer to a vector of Hole*s. More... | |
const std::vector< int > * | _markers |
Boundary markers. More... | |
const std::vector< Region * > * | _regions |
A pointer to a vector of Regions*s. More... | |
std::set< std::size_t > | _bdy_ids |
A set of ids to allow on the outer boundary loop. More... | |
ElemType | _elem_type |
The type of elements to generate. More... | |
Real | _desired_area |
The desired area for the elements in the resulting mesh. More... | |
Real | _minimum_angle |
Minimum angle in triangles. More... | |
TriangulationType | _triangulation_type |
The type of triangulation to perform: choices are: convex hull PSLG. More... | |
bool | _insert_extra_points |
Flag which tells whether or not to insert additional nodes before triangulation. More... | |
int | _interpolate_boundary_points |
Flag which tells how many additional nodes should be inserted between each pair of original mesh points. More... | |
bool | _smooth_after_generating |
Flag which tells whether we should smooth the mesh after it is generated. More... | |
bool | _quiet |
Flag which tells if we want to suppress stdout outputs. More... | |
bool | _verify_hole_boundaries |
Flag which tells if we want to check hole geometry. More... | |
Private Attributes | |
std::string | _extra_flags |
Additional flags to be passed to triangle. More... | |
MeshSerializer | _serializer |
Triangle only operates on serial meshes. More... | |
A C++ interface between LibMesh and the Triangle library written by J.R.
Shewchuk.
Definition at line 41 of file mesh_triangle_interface.h.
|
inherited |
The TriangulationType is used with the general triangulate function defined below.
Definition at line 61 of file triangulator_interface.h.
|
explicit |
The constructor.
A reference to the mesh containing the points which are to be triangulated must be provided. Unless otherwise specified, a convex hull will be computed for the set of input points and the convex hull will be meshed.
Definition at line 48 of file mesh_triangle_interface.C.
|
virtualdefault |
Empty destructor.
|
inlineinherited |
Attaches boundary markers.
If segments is set, the number of markers must be equal to the size of segments, otherwise, it is equal to the number of points.
Definition at line 236 of file triangulator_interface.h.
References libMesh::TriangulatorInterface::_markers.
|
inlineinherited |
Attaches a vector of Hole* pointers which will be meshed around.
Definition at line 205 of file triangulator_interface.h.
References libMesh::TriangulatorInterface::_holes.
Referenced by libMesh::MeshTools::Generation::build_delaunay_square(), MeshTriangulationTest::testPoly2TriHolesInterpRefined(), MeshTriangulationTest::testPoly2TriRefinementBase(), MeshTriangulationTest::testTriangulatorHoles(), MeshTriangulationTest::testTriangulatorMeshedHoles(), and triangulate_domain().
|
inlineinherited |
Attaches regions for using attribute to set subdomain IDs and better controlling the triangle sizes within the regions.
Definition at line 242 of file triangulator_interface.h.
References libMesh::TriangulatorInterface::_regions.
|
inlineinherited |
Sets and/or gets the desired triangle area.
Set to zero to disable area constraint.
If a desired_area_function
is set, then desired_area()
should be used to set a minimum desired area; this will reduce "false negatives" by suggesting how finely to sample desired_area_function
inside large triangles, where ideally the desired_area_function
will be satisfied in the triangle interior and not just at the triangle vertices.
Definition at line 127 of file triangulator_interface.h.
References libMesh::TriangulatorInterface::_desired_area.
Referenced by libMesh::MeshTools::Generation::build_delaunay_square(), MeshTriangulationTest::commonSettings(), libMesh::Poly2TriTriangulator::insert_refinement_points(), libMesh::Poly2TriTriangulator::should_refine_elem(), MeshTriangulationTest::testPoly2TriRefinementBase(), MeshTriangulationTest::testTriangulatorInterp(), and triangulate_domain().
|
inlineinherited |
Sets and/or gets the desired element type.
Definition at line 114 of file triangulator_interface.h.
References libMesh::TriangulatorInterface::_elem_type.
Referenced by libMesh::MeshTools::Generation::build_delaunay_square().
|
protectedinherited |
Helper function to create PSLG segments from our other boundary-defining options (1D mesh edges, 2D mesh boundary sides), if no segments already exist.
Definition at line 87 of file triangulator_interface.C.
References libMesh::TriangulatorInterface::_bdy_ids, libMesh::TriangulatorInterface::_holes, libMesh::TriangulatorInterface::_mesh, libMesh::TriangulatorInterface::_verify_hole_boundaries, libMesh::MeshBase::clear_elems(), libMesh::MeshBase::delete_node(), libMesh::make_range(), libMesh::MeshBase::n_elem(), libMesh::MeshBase::node_ptr(), libMesh::TriangulatorInterface::segments, and libMesh::TriangulatorInterface::verify_holes().
Referenced by triangulate(), and libMesh::Poly2TriTriangulator::triangulate().
|
inline |
Sets and/or gets additional flags to be passed to triangle.
Definition at line 66 of file mesh_triangle_interface.h.
References _extra_flags.
|
inlinevirtualinherited |
Get the function giving desired triangle area as a function of position, or nullptr
if no such function has been set.
Reimplemented in libMesh::Poly2TriTriangulator.
Definition at line 143 of file triangulator_interface.h.
|
inherited |
Complicated getter, for compatibility with insert_extra_points()
Definition at line 75 of file triangulator_interface.C.
References libMesh::TriangulatorInterface::_insert_extra_points, and libMesh::TriangulatorInterface::_interpolate_boundary_points.
Referenced by libMesh::TriangulatorInterface::insert_any_extra_boundary_points().
|
inlineinherited |
Definition at line 251 of file triangulator_interface.h.
References libMesh::TriangulatorInterface::_bdy_ids.
|
inlineinherited |
Definition at line 214 of file triangulator_interface.h.
References libMesh::TriangulatorInterface::_verify_hole_boundaries.
|
protectedinherited |
Helper function to add extra points (midpoints of initial segments) to a PSLG triangulation.
Definition at line 197 of file triangulator_interface.C.
References libMesh::TriangulatorInterface::_mesh, libMesh::TriangulatorInterface::_triangulation_type, libMesh::MeshBase::add_point(), libMesh::TriangulatorInterface::get_interpolate_boundary_points(), libMesh::DofObject::id(), libMesh::libmesh_assert(), libMesh::make_range(), libMesh::MeshBase::max_node_id(), libMesh::MeshBase::node_ptr(), libMesh::TriangulatorInterface::PSLG, and libMesh::TriangulatorInterface::segments.
Referenced by triangulate(), and libMesh::Poly2TriTriangulator::triangulate().
|
inlineinherited |
Sets and/or gets the flag for inserting add'l points.
Definition at line 160 of file triangulator_interface.h.
References libMesh::TriangulatorInterface::_insert_extra_points.
|
inlineinherited |
Sets and/or gets the minimum desired angle.
Set to zero to disable angle constraint.
Definition at line 150 of file triangulator_interface.h.
References libMesh::TriangulatorInterface::_minimum_angle.
Referenced by MeshTriangulationTest::commonSettings(), and libMesh::Poly2TriTriangulator::insert_refinement_points().
|
protectedinherited |
Helper function to create PSLG segments from our node ordering, up to the maximum node id, if no segments already exist.
Definition at line 158 of file triangulator_interface.C.
References libMesh::TriangulatorInterface::_holes, libMesh::TriangulatorInterface::_mesh, libMesh::TriangulatorInterface::_triangulation_type, libMesh::TriangulatorInterface::_verify_hole_boundaries, libMesh::DofObject::id(), libMesh::MeshBase::point(), libMesh::TriangulatorInterface::PSLG, libMesh::TriangulatorInterface::segments, and libMesh::TriangulatorInterface::verify_holes().
Referenced by triangulate(), and libMesh::Poly2TriTriangulator::triangulate().
|
inlineinherited |
Whether not to silence internal messages to stdout.
Definition at line 199 of file triangulator_interface.h.
References libMesh::TriangulatorInterface::_quiet.
|
inlinevirtualinherited |
Get whether or not the triangulation is allowed to refine the mesh boundary when refining the interior.
True by default.
Reimplemented in libMesh::Poly2TriTriangulator.
Definition at line 187 of file triangulator_interface.h.
|
inlinevirtualinherited |
Set a function giving desired triangle area as a function of position.
Set this to nullptr to disable position-dependent area constraint (falling back on desired_area()).
This may not be implemented in all subclasses.
Reimplemented in libMesh::Poly2TriTriangulator.
Definition at line 136 of file triangulator_interface.h.
|
inherited |
Complicated setter, for compatibility with insert_extra_points()
Definition at line 61 of file triangulator_interface.C.
References libMesh::TriangulatorInterface::_insert_extra_points, libMesh::TriangulatorInterface::_interpolate_boundary_points, and libMesh::libmesh_assert().
Referenced by MeshTriangulationTest::testTriangulatorInterp().
|
inlineinherited |
A set of ids to allow on the outer boundary loop: interpreted as boundary ids of 2D elements and/or subdomain ids of 1D edges.
If this is empty, then the outer boundary may be constructed from boundary edges of any id!
Definition at line 250 of file triangulator_interface.h.
References libMesh::TriangulatorInterface::_bdy_ids.
Referenced by MeshTriangulationTest::testHalfDomain().
|
inlinevirtualinherited |
Set whether or not the triangulation is allowed to refine the mesh boundary when refining the interior.
This is true by default, but may be set to false to make the mesh boundary more predictable (and so easier to stitch to other meshes) later.
This may not be implemented in all subclasses.
Reimplemented in libMesh::Poly2TriTriangulator.
Definition at line 180 of file triangulator_interface.h.
|
inlineinherited |
Verifying that hole boundaries don't cross the outer boundary or each other is something like O(N_bdys^2*N_points_per_bdy^2), so we only do it if requested.
Definition at line 212 of file triangulator_interface.h.
References libMesh::TriangulatorInterface::_verify_hole_boundaries.
Referenced by MeshTriangulationTest::commonSettings().
|
inlineinherited |
Sets/gets flag which tells whether to do two steps of Laplace mesh smoothing after generating the grid.
Definition at line 194 of file triangulator_interface.h.
References libMesh::TriangulatorInterface::_smooth_after_generating.
Referenced by MeshTriangulationTest::commonSettings(), and triangulate_domain().
|
protectedinherited |
Helper function to count points in and verify holes.
Definition at line 276 of file triangulator_interface.C.
References libMesh::TriangulatorInterface::_holes.
Referenced by triangulate().
|
overridevirtual |
Internally, this calls Triangle's triangulate routine.
Implements libMesh::TriangulatorInterface.
Definition at line 58 of file mesh_triangle_interface.C.
References libMesh::TriangulatorInterface::_desired_area, libMesh::TriangulatorInterface::_elem_type, _extra_flags, libMesh::TriangulatorInterface::_holes, libMesh::TriangulatorInterface::_markers, libMesh::TriangulatorInterface::_mesh, libMesh::TriangulatorInterface::_minimum_angle, libMesh::TriangulatorInterface::_quiet, libMesh::TriangulatorInterface::_regions, libMesh::TriangulatorInterface::_smooth_after_generating, libMesh::TriangulatorInterface::_triangulation_type, libMesh::TriangleWrapper::copy_tri_to_mesh(), libMesh::TriangleWrapper::destroy(), libMesh::TriangulatorInterface::elems_to_segments(), libMesh::Utility::enum_to_string(), libMesh::TriangulatorInterface::GENERATE_CONVEX_HULL, libMesh::TriangleWrapper::init(), libMesh::TriangleWrapper::INPUT, libMesh::TriangulatorInterface::insert_any_extra_boundary_points(), libMesh::TriangulatorInterface::INVALID_TRIANGULATION_TYPE, libMesh::MeshBase::max_node_id(), libMesh::MeshBase::n_nodes(), libMesh::TriangulatorInterface::nodes_to_segments(), libMesh::TriangleWrapper::OUTPUT, libMesh::MeshBase::prepare_for_use(), libMesh::TriangulatorInterface::PSLG, libMesh::TriangulatorInterface::segments, libMesh::MeshBase::set_mesh_dimension(), libMesh::LaplaceMeshSmoother::smooth(), libMesh::TOLERANCE, libMesh::TriangulatorInterface::total_hole_points(), libMesh::TRI3, and libMesh::TRI6.
Referenced by libMesh::MeshTools::Generation::build_delaunay_square(), and triangulate_domain().
|
inlineinherited |
Sets and/or gets the desired triangulation type.
Definition at line 155 of file triangulator_interface.h.
References libMesh::TriangulatorInterface::_triangulation_type.
Referenced by libMesh::MeshTools::Generation::build_delaunay_square(), MeshTriangulationTest::commonSettings(), and triangulate_domain().
|
protectedinherited |
Helper function to check holes for intersections if requested.
Definition at line 251 of file triangulator_interface.C.
References libMesh::TriangulatorInterface::_holes, libMesh::TriangulatorInterface::Hole::contains(), and libMesh::make_range().
Referenced by libMesh::TriangulatorInterface::elems_to_segments(), and libMesh::TriangulatorInterface::nodes_to_segments().
|
protectedinherited |
A set of ids to allow on the outer boundary loop.
Definition at line 308 of file triangulator_interface.h.
Referenced by libMesh::TriangulatorInterface::elems_to_segments(), libMesh::TriangulatorInterface::get_outer_boundary_ids(), and libMesh::TriangulatorInterface::set_outer_boundary_ids().
|
protectedinherited |
The desired area for the elements in the resulting mesh.
Definition at line 319 of file triangulator_interface.h.
Referenced by libMesh::TriangulatorInterface::desired_area(), and triangulate().
|
protectedinherited |
The type of elements to generate.
(Defaults to TRI3).
Definition at line 314 of file triangulator_interface.h.
Referenced by libMesh::TriangulatorInterface::elem_type(), triangulate(), and libMesh::Poly2TriTriangulator::triangulate().
|
private |
Additional flags to be passed to triangle.
Definition at line 72 of file mesh_triangle_interface.h.
Referenced by extra_flags(), and triangulate().
|
protectedinherited |
A pointer to a vector of Hole*s.
If this is nullptr, there are no holes!
Definition at line 292 of file triangulator_interface.h.
Referenced by libMesh::TriangulatorInterface::attach_hole_list(), libMesh::TriangulatorInterface::elems_to_segments(), libMesh::Poly2TriTriangulator::insert_refinement_points(), libMesh::TriangulatorInterface::nodes_to_segments(), libMesh::TriangulatorInterface::total_hole_points(), triangulate(), libMesh::Poly2TriTriangulator::triangulate_current_points(), and libMesh::TriangulatorInterface::verify_holes().
|
protectedinherited |
Flag which tells whether or not to insert additional nodes before triangulation.
This can sometimes be used to "de-regularize" the resulting triangulation.
This flag is supported for backwards compatibility; setting _interpolate_boundary_points = 1 is equivalent.
Definition at line 341 of file triangulator_interface.h.
Referenced by libMesh::TriangulatorInterface::get_interpolate_boundary_points(), libMesh::TriangulatorInterface::insert_extra_points(), and libMesh::TriangulatorInterface::set_interpolate_boundary_points().
|
protectedinherited |
Flag which tells how many additional nodes should be inserted between each pair of original mesh points.
Definition at line 347 of file triangulator_interface.h.
Referenced by libMesh::TriangulatorInterface::get_interpolate_boundary_points(), and libMesh::TriangulatorInterface::set_interpolate_boundary_points().
|
protectedinherited |
Boundary markers.
Definition at line 297 of file triangulator_interface.h.
Referenced by libMesh::TriangulatorInterface::attach_boundary_marker(), triangulate(), and libMesh::Poly2TriTriangulator::triangulate().
|
protectedinherited |
Reference to the mesh which is to be created by triangle.
Definition at line 286 of file triangulator_interface.h.
Referenced by libMesh::TriangulatorInterface::elems_to_segments(), libMesh::TriangulatorInterface::insert_any_extra_boundary_points(), libMesh::Poly2TriTriangulator::insert_refinement_points(), libMesh::TriangulatorInterface::nodes_to_segments(), triangulate(), libMesh::Poly2TriTriangulator::triangulate(), and libMesh::Poly2TriTriangulator::triangulate_current_points().
|
protectedinherited |
Minimum angle in triangles.
Definition at line 324 of file triangulator_interface.h.
Referenced by libMesh::TriangulatorInterface::minimum_angle(), and triangulate().
|
protectedinherited |
Flag which tells if we want to suppress stdout outputs.
Definition at line 358 of file triangulator_interface.h.
Referenced by libMesh::TriangulatorInterface::quiet(), and triangulate().
|
protectedinherited |
A pointer to a vector of Regions*s.
If this is nullptr, there are no regions!
Definition at line 303 of file triangulator_interface.h.
Referenced by libMesh::TriangulatorInterface::attach_region_list(), triangulate(), and libMesh::Poly2TriTriangulator::triangulate().
|
private |
Triangle only operates on serial meshes.
Definition at line 77 of file mesh_triangle_interface.h.
|
protectedinherited |
Flag which tells whether we should smooth the mesh after it is generated.
True by default.
Definition at line 353 of file triangulator_interface.h.
Referenced by libMesh::TriangulatorInterface::smooth_after_generating(), triangulate(), and libMesh::Poly2TriTriangulator::triangulate().
|
protectedinherited |
The type of triangulation to perform: choices are: convex hull PSLG.
Definition at line 331 of file triangulator_interface.h.
Referenced by libMesh::TriangulatorInterface::insert_any_extra_boundary_points(), libMesh::TriangulatorInterface::nodes_to_segments(), triangulate(), libMesh::Poly2TriTriangulator::triangulate(), and libMesh::TriangulatorInterface::triangulation_type().
|
protectedinherited |
Flag which tells if we want to check hole geometry.
Definition at line 363 of file triangulator_interface.h.
Referenced by libMesh::TriangulatorInterface::elems_to_segments(), libMesh::TriangulatorInterface::get_verify_hole_boundaries(), libMesh::TriangulatorInterface::nodes_to_segments(), and libMesh::TriangulatorInterface::set_verify_hole_boundaries().
|
inherited |
When constructing a PSLG, if the node numbers do not define the desired boundary segments implicitly through the ordering of the points, you can use the segments vector to specify the segments explicitly, Ex: unit square numbered counter-clockwise starting from origin segments[0] = (0,1) segments[1] = (1,2) segments[2] = (2,3) segments[3] = (3,0) (For the above case you could actually use the implicit ordering!)
Definition at line 229 of file triangulator_interface.h.
Referenced by libMesh::TriangulatorInterface::elems_to_segments(), libMesh::TriangulatorInterface::insert_any_extra_boundary_points(), libMesh::Poly2TriTriangulator::insert_refinement_points(), libMesh::TriangulatorInterface::nodes_to_segments(), MeshTriangulationTest::testTriangulatorSegments(), triangulate(), and libMesh::Poly2TriTriangulator::triangulate_current_points().