libMesh
Loading...
Searching...
No Matches
mesh_triangle_holes.h
Go to the documentation of this file.
1// The libMesh Finite Element Library.
2// Copyright (C) 2002-2026 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#ifndef LIBMESH_MESH_TRIANGLE_HOLES_H
19#define LIBMESH_MESH_TRIANGLE_HOLES_H
20
21#include "libmesh/libmesh_config.h"
22
23// Local includes
24#include "libmesh/boundary_info.h" // invalid_id
25#include "libmesh/point.h"
26#include "libmesh/triangulator_interface.h"
27#include "libmesh/vector_value.h"
28
29// C++ includes
30
31namespace libMesh
32{
33
49{
50public:
54 Hole() = default;
55
59 virtual ~Hole() = default;
60
64 virtual unsigned int n_points() const = 0;
65
70 virtual unsigned int n_midpoints() const { return 0; }
71
75 virtual Point point(const unsigned int n) const = 0;
76
80 virtual Point midpoint(const unsigned int /* m */,
81 const unsigned int /* n */) const
82 { libmesh_error(); /* by default holes are polygonal */ }
83
87 virtual Point inside() const = 0;
88
95 bool contains(Point p) const;
96
103 Real area() const;
104
113 RealGradient areavec() const;
114
118 virtual std::vector<unsigned int> segment_indices() const
119 {
120 // default to only one enclosing boundary
121 std::vector<unsigned int> seg;
122 seg.push_back(0);
123 seg.push_back(n_points());
124 return seg;
125 }
126
133 virtual void set_refine_boundary_allowed (bool refine_bdy_allowed)
134 { _refine_bdy_allowed = refine_bdy_allowed; }
135
140 virtual bool refine_boundary_allowed () const
141 { return _refine_bdy_allowed; }
142
143protected:
144
148 std::vector<Real> find_ray_intersections(Point ray_start,
149 Point ray_target) const;
150
155
161};
162
163
164
165
166
172{
173public:
179 PolygonHole(const Point & center, Real radius, unsigned int n_points);
180
181 virtual unsigned int n_points() const override;
182
183 virtual Point point(const unsigned int n) const override;
184
185 virtual Point inside() const override;
186
187private:
192
197
203 unsigned int _n_points;
204};
205
206
207
214{
215public:
221 AffineHole(const Hole & underlying, Real angle, const Point & shift)
222 : _underlying(underlying), _angle(angle), _shift(shift) {}
223
224 virtual unsigned int n_points() const override
225 { return _underlying.n_points(); }
226
227 virtual Point point(const unsigned int n) const override;
228
229 virtual Point inside() const override;
230
231private:
235 Point transform(const Point & p) const;
236
241
246
251};
252
253
254
255
256
265{
266public:
272 ArbitraryHole(const Point & center,
273 std::vector<Point> points);
274
275 ArbitraryHole(const Point & center,
276 std::vector<Point> points,
277 std::vector<unsigned int> segment_indices);
278
282 ArbitraryHole(std::vector<Point> points);
283
288 ArbitraryHole(const Hole & orig);
289
290 ArbitraryHole(const ArbitraryHole & orig) = default;
291
292 virtual unsigned int n_points() const override;
293
294 virtual Point point(const unsigned int n) const override;
295
296 virtual Point inside() const override;
297
298 virtual std::vector<unsigned int> segment_indices() const override;
299
300 const std::vector<Point> & get_points() const
301 {
302 return _points;
303 }
304
305 void set_points(std::vector<Point> points)
306 {
307 _points = std::move(points);
309 }
310
311private:
316
321 std::vector<Point> _points;
322
323 std::vector<unsigned int> _segment_indices;
324};
325
326
327
344{
345public:
350 MeshedHole(const MeshBase & mesh,
351 std::set<std::size_t> ids = {});
352
353 virtual unsigned int n_points() const override;
354
355 virtual unsigned int n_midpoints() const override;
356
357 virtual Point point(const unsigned int n) const override;
358
359 virtual Point midpoint(const unsigned int m,
360 const unsigned int n) const override;
361
362 virtual Point inside() const override;
363
364private:
370 mutable Point _center;
371
375 std::vector<Point> _points;
376
383 std::vector<Point> _midpoints;
384};
385
386
387
388
389
390
395{
396public:
400 Region(const Point & center,
401 Real attribute = 0,
402 Real max_area = -std::numeric_limits<Real>::max())
403 : _center(center),
406
407 Point inside() const { return _center; }
408
409 Real attribute() const { return _attribute; }
410
411 Real max_area() const { return _max_area; }
412
413private:
418
424
430};
431
432} // namespace libMesh
433
434#endif // LIBMESH_MESH_TRIANGLE_HOLES_H
This is the MeshBase class.
Definition mesh_base.h:81
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition point.h:40
A way to translate and/or rotate an existing hole; perhaps to tile it in many places or to put it at ...
Point transform(const Point &p) const
Rotate-and-shift equations.
virtual unsigned int n_points() const override
The number of geometric points which define the hole.
Real _angle
Angle to rotate (counter-clockwise) by.
AffineHole(const Hole &underlying, Real angle, const Point &shift)
Constructor specifying the underlying hole, and the rotation angle (in radians, done first) and trans...
virtual Point point(const unsigned int n) const override
Return the nth point defining the hole.
Point _shift
(x,y) location to shift (0,0) to
virtual Point inside() const override
Return an (arbitrary) point which lies inside the hole.
Another concrete instantiation of the hole, this one should be sufficiently general for most non-poly...
virtual Point inside() const override
Return an (arbitrary) point which lies inside the hole.
ArbitraryHole(const ArbitraryHole &orig)=default
virtual unsigned int n_points() const override
The number of geometric points which define the hole.
std::vector< Point > _points
Reference to the vector of points which makes up the hole.
Point _center
arbitrary (x,y) location inside the hole
virtual std::vector< unsigned int > segment_indices() const override
Starting indices of points for a hole with multiple disconnected boundaries.
const std::vector< Point > & get_points() const
virtual Point point(const unsigned int n) const override
Return the nth point defining the hole.
void set_points(std::vector< Point > points)
An abstract class for defining a 2-dimensional hole.
bool contains(Point p) const
Return true iff p lies inside the hole.
std::vector< Real > find_ray_intersections(Point ray_start, Point ray_target) const
Helper function for contains(), also useful for MeshedHole::inside()
virtual bool refine_boundary_allowed() const
Get whether or not the triangulation is allowed to refine the mesh boundary when refining the interio...
virtual Point midpoint(const unsigned int, const unsigned int) const
Return the midpoint m along the side n defining the hole.
Real area() const
Return the area of the hole.
virtual Point point(const unsigned int n) const =0
Return the nth point defining the hole.
Point calculate_inside_point() const
Calculate an inside point based on our boundary.
virtual unsigned int n_points() const =0
The number of geometric points which define the hole.
virtual unsigned int n_midpoints() const
The number of geometric midpoints along each of the sides defining the hole.
virtual std::vector< unsigned int > segment_indices() const
Starting indices of points for a hole with multiple disconnected boundaries.
virtual void set_refine_boundary_allowed(bool refine_bdy_allowed)
Set whether or not a triangulator is allowed to refine the hole boundary when refining the mesh inter...
virtual ~Hole()=default
Destructor.
bool _refine_bdy_allowed
Whether to allow boundary refinement.
virtual Point inside() const =0
Return an (arbitrary) point which lies inside the hole.
RealGradient areavec() const
Return a vector with right-hand-rule orientation and length of twice area() squared.
Another concrete instantiation of the hole, as general as ArbitraryHole, but based on an existing 1D ...
virtual Point point(const unsigned int n) const override
Return the nth point defining the hole.
virtual Point midpoint(const unsigned int m, const unsigned int n) const override
Return the midpoint m along the side n defining the hole.
virtual unsigned int n_points() const override
The number of geometric points which define the hole.
virtual Point inside() const override
Return an (arbitrary) point which lies inside the hole.
std::vector< Point > _midpoints
The sorted vector of midpoints in between points along the edges of the hole.
std::vector< Point > _points
The sorted vector of points which makes up the hole.
Point _center
An (x,y) location inside the hole.
virtual unsigned int n_midpoints() const override
The number of geometric midpoints along each of the sides defining the hole.
A concrete instantiation of the Hole class that describes polygonal (triangular, square,...
Point _center
(x,y) location of the center of the hole
virtual Point inside() const override
Return an (arbitrary) point which lies inside the hole.
virtual Point point(const unsigned int n) const override
Return the nth point defining the hole.
virtual unsigned int n_points() const override
The number of geometric points which define the hole.
unsigned int _n_points
number of points used to describe the hole.
A class for defining a 2-dimensional region for Triangle.
Region(const Point &center, Real attribute=0, Real max_area=-std::numeric_limits< Real >::max())
Constructor.
const Point _center
Arbitrary (x,y) location inside the region.
Real _attribute
Attribute of the region Default value for attribute is zero.
Real _max_area
Maximum area that is allowed for all triangles in this region Default negative maximum area means tha...
MeshBase & mesh
The libMesh namespace provides an interface to certain functionality in the library.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const Real radius