libMesh
|
#include <triangulator_interface.h>
Classes | |
class | AffineHole |
A way to translate and/or rotate an existing hole; perhaps to tile it in many places or to put it at an angle that the underlying hole doesn't support. More... | |
class | ArbitraryHole |
Another concrete instantiation of the hole, this one should be sufficiently general for most non-polygonal purposes. More... | |
class | Hole |
An abstract class for defining a 2-dimensional hole. More... | |
class | MeshedHole |
Another concrete instantiation of the hole, as general as ArbitraryHole, but based on an existing 1D or 2D mesh. More... | |
class | PolygonHole |
A concrete instantiation of the Hole class that describes polygonal (triangular, square, pentagonal, ...) holes. More... | |
class | Region |
A class for defining a 2-dimensional region for Triangle. More... | |
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 | |
TriangulatorInterface (UnstructuredMesh &mesh) | |
The constructor. More... | |
virtual | ~TriangulatorInterface ()=default |
Empty destructor. More... | |
virtual void | triangulate ()=0 |
This is the main public interface for this function. 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_auto_area_function (const Parallel::Communicator &comm, const unsigned int num_nearest_pts, const unsigned int power, const Real background_value, const Real background_eff_dist) |
Generate an auto area function based on spacing of boundary points. More... | |
bool | has_auto_area_function () |
Whether or not an auto area function has been set. More... | |
FunctionBase< Real > * | get_auto_area_function () |
Get the auto area function. More... | |
void | calculate_auto_desired_area_samples (std::vector< Point > &function_points, std::vector< Real > &function_sizes, const Real &area_factor=1.5) |
The external boundary and all hole boundaries are collected. 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... | |
std::vector< Point > | segment_midpoints |
When constructing a second-order triangulation from a second-order boundary, we may do the triangulation using first-order elements, in which case we need to save midpoint location data in order to reconstruct curvature along boundaries. 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 | increase_triangle_order () |
Helper function to upconvert Tri3 to any higher order triangle type if requested via _elem_type . 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... | |
std::unique_ptr< AutoAreaFunction > | _auto_area_function |
The auto area function based on the spacing of boundary points. More... | |
Definition at line 90 of file triangulator_interface.h.
The TriangulationType is used with the general triangulate function defined below.
Definition at line 111 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 107 of file triangulator_interface.C.
|
virtualdefault |
Empty destructor.
|
inline |
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 294 of file triangulator_interface.h.
References _markers.
|
inline |
Attaches a vector of Hole* pointers which will be meshed around.
Definition at line 255 of file triangulator_interface.h.
References _holes.
Referenced by libMesh::MeshTools::Generation::build_delaunay_square(), MeshTriangulationTest::testPoly2TriHolesInterpRefined(), MeshTriangulationTest::testPoly2TriRefinementBase(), MeshTriangulationTest::testTriangulatorHoles(), MeshTriangulationTest::testTriangulatorMeshedHoles(), MeshTriangulationTest::testTriangulatorRoundHole(), and triangulate_domain().
|
inline |
Attaches regions for using attribute to set subdomain IDs and better controlling the triangle sizes within the regions.
Definition at line 300 of file triangulator_interface.h.
References _regions.
void libMesh::TriangulatorInterface::calculate_auto_desired_area_samples | ( | std::vector< Point > & | function_points, |
std::vector< Real > & | function_sizes, | ||
const Real & | area_factor = 1.5 |
||
) |
The external boundary and all hole boundaries are collected.
The centroid of each EDGE element is used as the point position and the desired area is calculated as the area of the equilateral triangle with the edge length as the length of the EDGE element times an area_factor (default is 1.5).
Definition at line 500 of file triangulator_interface.C.
References _bdy_ids, _holes, _mesh, and libMesh::Real.
Referenced by get_auto_area_function().
|
inline |
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 177 of file triangulator_interface.h.
References _desired_area.
Referenced by libMesh::MeshTools::Generation::build_delaunay_square(), MeshTriangulationTest::commonSettings(), libMesh::Poly2TriTriangulator::insert_refinement_points(), main(), libMesh::Poly2TriTriangulator::should_refine_elem(), MeshTriangulationTest::testPoly2TriRefinementBase(), MeshTriangulationTest::testTriangulatorInterp(), and triangulate_domain().
|
inline |
Sets and/or gets the desired element type.
Definition at line 164 of file triangulator_interface.h.
References _elem_type.
Referenced by libMesh::MeshTools::Generation::build_delaunay_square(), and MeshTriangulationTest::testTriangulatorRoundHole().
|
protected |
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 149 of file triangulator_interface.C.
References _bdy_ids, _holes, _mesh, _verify_hole_boundaries, libMesh::MeshBase::clear_elems(), libMesh::MeshBase::delete_node(), libMesh::make_range(), libMesh::MeshBase::n_elem(), libMesh::MeshBase::node_ptr(), segment_midpoints, segments, and verify_holes().
Referenced by libMesh::TriangleInterface::triangulate(), and libMesh::Poly2TriTriangulator::triangulate().
FunctionBase< Real > * libMesh::TriangulatorInterface::get_auto_area_function | ( | ) |
Get the auto area function.
Definition at line 487 of file triangulator_interface.C.
References _auto_area_function, and calculate_auto_desired_area_samples().
Referenced by libMesh::Poly2TriTriangulator::should_refine_elem().
|
inlinevirtual |
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 193 of file triangulator_interface.h.
int libMesh::TriangulatorInterface::get_interpolate_boundary_points | ( | ) | const |
Complicated getter, for compatibility with insert_extra_points()
Definition at line 137 of file triangulator_interface.C.
References _insert_extra_points, and _interpolate_boundary_points.
Referenced by insert_any_extra_boundary_points().
|
inline |
Definition at line 352 of file triangulator_interface.h.
References _bdy_ids.
|
inline |
Definition at line 264 of file triangulator_interface.h.
References _verify_hole_boundaries.
|
inline |
Whether or not an auto area function has been set.
Definition at line 329 of file triangulator_interface.h.
References _auto_area_function.
Referenced by libMesh::Poly2TriTriangulator::insert_refinement_points(), and libMesh::Poly2TriTriangulator::should_refine_elem().
|
protected |
Helper function to upconvert Tri3 to any higher order triangle type if requested via _elem_type
.
Should be called at the end of triangulate()
Definition at line 332 of file triangulator_interface.C.
References _elem_type, _holes, _mesh, libMesh::MeshBase::all_complete_order(), libMesh::MeshBase::all_second_order(), libMesh::FIRST, libMesh::libmesh_assert(), libMesh::make_range(), libMesh::MeshBase::point(), segment_midpoints, segments, libMesh::TRI3, libMesh::TRI6, and libMesh::TRI7.
Referenced by libMesh::TriangleInterface::triangulate(), and libMesh::Poly2TriTriangulator::triangulate().
|
protected |
Helper function to add extra points (midpoints of initial segments) to a PSLG triangulation.
Definition at line 278 of file triangulator_interface.C.
References _mesh, _triangulation_type, libMesh::MeshBase::add_point(), get_interpolate_boundary_points(), libMesh::DofObject::id(), libMesh::libmesh_assert(), libMesh::make_range(), libMesh::MeshBase::max_node_id(), libMesh::MeshBase::node_ptr(), PSLG, and segments.
Referenced by libMesh::TriangleInterface::triangulate(), and libMesh::Poly2TriTriangulator::triangulate().
|
inline |
Sets and/or gets the flag for inserting add'l points.
Definition at line 210 of file triangulator_interface.h.
References _insert_extra_points.
|
inline |
Sets and/or gets the minimum desired angle.
Set to zero to disable angle constraint.
Definition at line 200 of file triangulator_interface.h.
References _minimum_angle.
Referenced by MeshTriangulationTest::commonSettings(), libMesh::Poly2TriTriangulator::insert_refinement_points(), and main().
|
protected |
Helper function to create PSLG segments from our node ordering, up to the maximum node id, if no segments already exist.
Definition at line 239 of file triangulator_interface.C.
References _holes, _mesh, _triangulation_type, _verify_hole_boundaries, libMesh::DofObject::id(), libMesh::MeshBase::point(), PSLG, segments, and verify_holes().
Referenced by libMesh::TriangleInterface::triangulate(), and libMesh::Poly2TriTriangulator::triangulate().
|
inline |
Whether not to silence internal messages to stdout.
Definition at line 249 of file triangulator_interface.h.
References _quiet.
|
inlinevirtual |
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 237 of file triangulator_interface.h.
void libMesh::TriangulatorInterface::set_auto_area_function | ( | const Parallel::Communicator & | comm, |
const unsigned int | num_nearest_pts, | ||
const unsigned int | power, | ||
const Real | background_value, | ||
const Real | background_eff_dist | ||
) |
Generate an auto area function based on spacing of boundary points.
The external boundary as well as the hole boundaries are taken into consideration to generate the auto area function based on inverse distance interpolation. For each EDGE element on these boundaries, its centroid (midpoint) is used as the point position and the desired area is calculated as 1.5 times of the area of the equilateral triangle with the edge length as the length of the EDGE element. For a given position, the inverse distance interpolation only considers a number of nearest points (set by num_nearest_pts) to calculate the desired area. The weight of the value at each point is calculated as 1/distance^power.
In addition to these conventional inverse distance interpolation features, a concept of "background value" and "background effective distance" is introduced. The background value belongs to a virtual point located at a constant distance (background effective distance) from the given position. The weight of the value at this virtual point is calculated as 1/background_effective_distance^power. Effectively, the background value is the value when the given position is far away from the boundary points.
Definition at line 478 of file triangulator_interface.C.
References _auto_area_function.
|
inlinevirtual |
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 186 of file triangulator_interface.h.
void libMesh::TriangulatorInterface::set_interpolate_boundary_points | ( | int | n_points | ) |
Complicated setter, for compatibility with insert_extra_points()
Definition at line 123 of file triangulator_interface.C.
References _insert_extra_points, _interpolate_boundary_points, and libMesh::libmesh_assert().
Referenced by MeshTriangulationTest::testTriangulatorInterp().
|
inline |
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 351 of file triangulator_interface.h.
References _bdy_ids.
Referenced by MeshTriangulationTest::testHalfDomain().
|
inlinevirtual |
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 230 of file triangulator_interface.h.
|
inline |
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 262 of file triangulator_interface.h.
References _verify_hole_boundaries.
Referenced by MeshTriangulationTest::commonSettings().
|
inline |
Sets/gets flag which tells whether to do two steps of Laplace mesh smoothing after generating the grid.
Definition at line 244 of file triangulator_interface.h.
References _smooth_after_generating.
Referenced by MeshTriangulationTest::commonSettings(), and triangulate_domain().
|
protected |
Helper function to count points in and verify holes.
Definition at line 454 of file triangulator_interface.C.
References _holes.
Referenced by libMesh::TriangleInterface::triangulate().
|
pure virtual |
This is the main public interface for this function.
Implemented in libMesh::Poly2TriTriangulator, and libMesh::TriangleInterface.
Referenced by MeshTriangulationTest::testTriangulatorBase(), MeshTriangulationTest::testTriangulatorHoles(), MeshTriangulationTest::testTriangulatorInterp(), MeshTriangulationTest::testTriangulatorMeshedHoles(), and MeshTriangulationTest::testTriangulatorRoundHole().
|
inline |
Sets and/or gets the desired triangulation type.
Definition at line 205 of file triangulator_interface.h.
References _triangulation_type.
Referenced by libMesh::MeshTools::Generation::build_delaunay_square(), MeshTriangulationTest::commonSettings(), main(), and triangulate_domain().
|
protected |
Helper function to check holes for intersections if requested.
Definition at line 429 of file triangulator_interface.C.
References _holes, libMesh::TriangulatorInterface::Hole::contains(), and libMesh::make_range().
Referenced by elems_to_segments(), and nodes_to_segments().
|
protected |
The auto area function based on the spacing of boundary points.
Definition at line 476 of file triangulator_interface.h.
Referenced by get_auto_area_function(), has_auto_area_function(), and set_auto_area_function().
|
protected |
A set of ids to allow on the outer boundary loop.
Definition at line 416 of file triangulator_interface.h.
Referenced by calculate_auto_desired_area_samples(), elems_to_segments(), get_outer_boundary_ids(), and set_outer_boundary_ids().
|
protected |
The desired area for the elements in the resulting mesh.
Definition at line 427 of file triangulator_interface.h.
Referenced by desired_area(), and libMesh::TriangleInterface::triangulate().
|
protected |
The type of elements to generate.
(Defaults to TRI3).
Definition at line 422 of file triangulator_interface.h.
Referenced by elem_type(), increase_triangle_order(), libMesh::TriangleInterface::triangulate(), and libMesh::Poly2TriTriangulator::triangulate().
|
protected |
A pointer to a vector of Hole*s.
If this is nullptr, there are no holes!
Definition at line 400 of file triangulator_interface.h.
Referenced by attach_hole_list(), calculate_auto_desired_area_samples(), elems_to_segments(), increase_triangle_order(), libMesh::Poly2TriTriangulator::insert_refinement_points(), nodes_to_segments(), total_hole_points(), libMesh::TriangleInterface::triangulate(), libMesh::Poly2TriTriangulator::triangulate_current_points(), and verify_holes().
|
protected |
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 449 of file triangulator_interface.h.
Referenced by get_interpolate_boundary_points(), insert_extra_points(), and set_interpolate_boundary_points().
|
protected |
Flag which tells how many additional nodes should be inserted between each pair of original mesh points.
Definition at line 455 of file triangulator_interface.h.
Referenced by get_interpolate_boundary_points(), and set_interpolate_boundary_points().
|
protected |
Boundary markers.
Definition at line 405 of file triangulator_interface.h.
Referenced by attach_boundary_marker(), libMesh::TriangleInterface::triangulate(), and libMesh::Poly2TriTriangulator::triangulate().
|
protected |
Reference to the mesh which is to be created by triangle.
Definition at line 394 of file triangulator_interface.h.
Referenced by calculate_auto_desired_area_samples(), elems_to_segments(), increase_triangle_order(), insert_any_extra_boundary_points(), libMesh::Poly2TriTriangulator::insert_refinement_points(), nodes_to_segments(), libMesh::TriangleInterface::triangulate(), libMesh::Poly2TriTriangulator::triangulate(), and libMesh::Poly2TriTriangulator::triangulate_current_points().
|
protected |
Minimum angle in triangles.
Definition at line 432 of file triangulator_interface.h.
Referenced by minimum_angle(), and libMesh::TriangleInterface::triangulate().
|
protected |
Flag which tells if we want to suppress stdout outputs.
Definition at line 466 of file triangulator_interface.h.
Referenced by quiet(), and libMesh::TriangleInterface::triangulate().
|
protected |
A pointer to a vector of Regions*s.
If this is nullptr, there are no regions!
Definition at line 411 of file triangulator_interface.h.
Referenced by attach_region_list(), libMesh::TriangleInterface::triangulate(), and libMesh::Poly2TriTriangulator::triangulate().
|
protected |
Flag which tells whether we should smooth the mesh after it is generated.
True by default.
Definition at line 461 of file triangulator_interface.h.
Referenced by smooth_after_generating(), libMesh::TriangleInterface::triangulate(), and libMesh::Poly2TriTriangulator::triangulate().
|
protected |
The type of triangulation to perform: choices are: convex hull PSLG.
Definition at line 439 of file triangulator_interface.h.
Referenced by insert_any_extra_boundary_points(), nodes_to_segments(), libMesh::TriangleInterface::triangulate(), libMesh::Poly2TriTriangulator::triangulate(), and triangulation_type().
|
protected |
Flag which tells if we want to check hole geometry.
Definition at line 471 of file triangulator_interface.h.
Referenced by elems_to_segments(), get_verify_hole_boundaries(), nodes_to_segments(), and set_verify_hole_boundaries().
std::vector<Point> libMesh::TriangulatorInterface::segment_midpoints |
When constructing a second-order triangulation from a second-order boundary, we may do the triangulation using first-order elements, in which case we need to save midpoint location data in order to reconstruct curvature along boundaries.
Definition at line 287 of file triangulator_interface.h.
Referenced by elems_to_segments(), and increase_triangle_order().
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 279 of file triangulator_interface.h.
Referenced by elems_to_segments(), increase_triangle_order(), insert_any_extra_boundary_points(), libMesh::Poly2TriTriangulator::insert_refinement_points(), nodes_to_segments(), MeshTriangulationTest::testTriangulatorSegments(), libMesh::TriangleInterface::triangulate(), and libMesh::Poly2TriTriangulator::triangulate_current_points().