libMesh
poly2tri_triangulator.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2025 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18 
19 #ifndef LIBMESH_POLY2TRI_TRIANGULATOR_H
20 #define LIBMESH_POLY2TRI_TRIANGULATOR_H
21 
22 #include <memory>
23 
24 #include "libmesh/libmesh_config.h"
25 
26 #ifdef LIBMESH_HAVE_POLY2TRI
27 
28 // Local Includes
29 #include "libmesh/dof_object.h"
30 #include "libmesh/triangulator_interface.h"
31 
32 namespace libMesh
33 {
34 
35 // Forward Declarations
36 class BoundaryInfo;
37 class Elem;
38 
47 {
48 public:
60  explicit
62  dof_id_type n_boundary_nodes =
64 
69  virtual ~Poly2TriTriangulator();
70 
76  virtual void triangulate() override;
77 
83  virtual void set_desired_area_function (FunctionBase<Real> * desired) override;
84 
89  virtual FunctionBase<Real> * get_desired_area_function () override;
90 
97  virtual void set_refine_boundary_allowed (bool refine_bdy_allowed) override
98  { _refine_bdy_allowed = refine_bdy_allowed; }
99 
104  virtual bool refine_boundary_allowed () const override
105  { return _refine_bdy_allowed; }
106 
107 
108 protected:
112  bool is_refine_boundary_allowed(const BoundaryInfo & boundary_info,
113  const Elem & elem,
114  unsigned int side);
115 
120 
126 
131  bool should_refine_elem(Elem & elem);
132 
133 private:
134 
139  std::map<const Hole *, std::unique_ptr<ArbitraryHole>> replaced_holes;
140 
145 
149  std::unique_ptr<FunctionBase<Real>> _desired_area_func;
150 
155 };
156 
157 } // namespace libMesh
158 
159 #endif // LIBMESH_HAVE_TRIANGLE
160 
161 #endif // ifndef LIBMESH_POLY2TRI_TRIANGULATOR_H
virtual bool refine_boundary_allowed() const override
Get whether or not the triangulation is allowed to refine the mesh boundary when refining the interio...
std::unique_ptr< FunctionBase< Real > > _desired_area_func
Location-dependent area requirements.
virtual void set_refine_boundary_allowed(bool refine_bdy_allowed) override
Set whether or not the triangulation is allowed to refine the mesh boundary when refining the interio...
This is the base class from which all geometric element types are derived.
Definition: elem.h:94
MeshBase & mesh
bool _refine_bdy_allowed
Whether to allow boundary refinement.
The libMesh namespace provides an interface to certain functionality in the library.
virtual FunctionBase< Real > * get_desired_area_function() override
Get the function giving desired triangle area as a function of position, or nullptr if no such functi...
void triangulate_current_points()
Triangulate the current mesh and hole points.
virtual void set_desired_area_function(FunctionBase< Real > *desired) override
Set a function giving desired triangle area as a function of position.
The UnstructuredMesh class is derived from the MeshBase class.
Poly2TriTriangulator(UnstructuredMesh &mesh, dof_id_type n_boundary_nodes=DofObject::invalid_id)
The constructor.
std::map< const Hole *, std::unique_ptr< ArbitraryHole > > replaced_holes
We might have to replace the user-provided holes with refined versions.
bool insert_refinement_points()
Add Steiner points as new mesh nodes, as necessary to refine an existing trangulation.
The BoundaryInfo class contains information relevant to boundary conditions including storing faces...
Definition: boundary_info.h:57
static const dof_id_type invalid_id
An invalid id to distinguish an uninitialized DofObject.
Definition: dof_object.h:482
virtual void triangulate() override
Internally, this calls the poly2tri triangulation code in a loop, inserting our owner Steiner points ...
bool is_refine_boundary_allowed(const BoundaryInfo &boundary_info, const Elem &elem, unsigned int side)
Is refining this element&#39;s boundary side allowed?
virtual ~Poly2TriTriangulator()
Empty destructor.
A C++ interface between LibMesh and the poly2tri library, with custom code for Steiner point insertio...
dof_id_type _n_boundary_nodes
Keep track of how many mesh nodes are boundary nodes.
bool should_refine_elem(Elem &elem)
Returns true if the given element ought to be refined according to current criteria.
uint8_t dof_id_type
Definition: id_types.h:67