libMesh
mesh_triangle_holes.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2019 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 #ifdef LIBMESH_HAVE_TRIANGLE
24 
25 // Local includes
26 #include "libmesh/mesh_triangle_interface.h"
27 #include "libmesh/point.h"
28 
29 // C++ includes
30 
31 namespace libMesh
32 {
33 
49 {
50 public:
54  Hole() {}
55 
59  virtual ~Hole() {}
60 
64  virtual unsigned int n_points() const = 0;
65 
69  virtual Point point(const unsigned int n) const = 0;
70 
74  virtual Point inside() const = 0;
75 
79  virtual std::vector<unsigned int> segment_indices() const
80  {
81  // default to only one enclosing boundary
82  std::vector<unsigned int> seg;
83  seg.push_back(0);
84  seg.push_back(n_points());
85  return seg;
86  }
87 };
88 
89 
90 
91 
92 
98 {
99 public:
105  PolygonHole(const Point & center, Real radius, unsigned int n_points);
106 
107  virtual unsigned int n_points() const override;
108 
109  virtual Point point(const unsigned int n) const override;
110 
111  virtual Point inside() const override;
112 
113 private:
118 
123 
129  unsigned int _n_points;
130 };
131 
132 
133 
134 
143 {
144 public:
149  ArbitraryHole(const Point & center,
150  const std::vector<Point> & points);
151 
152  ArbitraryHole(const Point & center,
153  const std::vector<Point> & points,
154  const std::vector<unsigned int> & segment_indices);
155 
156  virtual unsigned int n_points() const override;
157 
158  virtual Point point(const unsigned int n) const override;
159 
160  virtual Point inside() const override;
161 
162  virtual std::vector<unsigned int> segment_indices() const override;
163 
164 private:
168  const Point _center;
169 
174  const std::vector<Point> _points;
175 
176  std::vector<unsigned int> _segment_indices;
177 };
178 
179 
180 
181 
182 
187 {
188 public:
192  Region(const Point & center,
193  Real attribute = 0,
194  Real max_area = -std::numeric_limits<Real>::max())
195  : _center(center),
197  _max_area(max_area) {}
198 
199  Point inside() const { return _center; }
200 
201  Real attribute() const { return _attribute; }
202 
203  Real max_area() const { return _max_area; }
204 
205 private:
209  const Point _center;
210 
216 
222 };
223 
224 } // namespace libMesh
225 
226 #endif // LIBMESH_HAVE_TRIANGLE
227 
228 #endif // LIBMESH_MESH_TRIANGLE_HOLES_H
libMesh::TriangleInterface::PolygonHole
A concrete instantiation of the Hole class that describes polygonal (triangular, square,...
Definition: mesh_triangle_holes.h:97
libMesh::TriangleInterface::ArbitraryHole::_segment_indices
std::vector< unsigned int > _segment_indices
Definition: mesh_triangle_holes.h:176
libMesh::TriangleInterface::Hole::~Hole
virtual ~Hole()
Destructor.
Definition: mesh_triangle_holes.h:59
libMesh::TriangleInterface::Region::_max_area
Real _max_area
Maximum area that is allowed for all triangles in this region Default negative maximum area means tha...
Definition: mesh_triangle_holes.h:221
libMesh::TriangleInterface::Region::attribute
Real attribute() const
Definition: mesh_triangle_holes.h:201
libMesh::TriangleInterface::ArbitraryHole::point
virtual Point point(const unsigned int n) const override
Return the nth point defining the hole.
Definition: mesh_triangle_holes.C:89
libMesh::TriangleInterface::Region::inside
Point inside() const
Definition: mesh_triangle_holes.h:199
libMesh::TriangleInterface::Hole::n_points
virtual unsigned int n_points() const =0
The number of geometric points which define the hole.
libMesh::TriangleInterface::ArbitraryHole::_points
const std::vector< Point > _points
Reference to the vector of points which makes up the hole.
Definition: mesh_triangle_holes.h:174
libMesh::TriangleInterface::Hole::point
virtual Point point(const unsigned int n) const =0
Return the nth point defining the hole.
libMesh
The libMesh namespace provides an interface to certain functionality in the library.
Definition: factoryfunction.C:55
libMesh::TriangleInterface::Hole::segment_indices
virtual std::vector< unsigned int > segment_indices() const
Starting indices of points for a hole with multiple disconnected boundaries.
Definition: mesh_triangle_holes.h:79
libMesh::TriangleInterface::PolygonHole::_center
Point _center
(x,y) location of the center of the hole
Definition: mesh_triangle_holes.h:117
libMesh::TriangleInterface::PolygonHole::point
virtual Point point(const unsigned int n) const override
Return the nth point defining the hole.
Definition: mesh_triangle_holes.C:46
libMesh::TriangleInterface::ArbitraryHole::ArbitraryHole
ArbitraryHole(const Point &center, const std::vector< Point > &points)
The constructor requires a point which lies in the interior of the hole and a reference to a vector o...
Definition: mesh_triangle_holes.C:66
libMesh::TriangleInterface::Hole::inside
virtual Point inside() const =0
Return an (arbitrary) point which lies inside the hole.
libMesh::TriangleInterface::Hole
An abstract class for defining a 2-dimensional hole.
Definition: mesh_triangle_holes.h:48
libMesh::TriangleInterface::ArbitraryHole::n_points
virtual unsigned int n_points() const override
The number of geometric points which define the hole.
Definition: mesh_triangle_holes.C:83
libMesh::TriangleInterface::ArbitraryHole::_center
const Point _center
arbitrary (x,y) location inside the hole
Definition: mesh_triangle_holes.h:168
libMesh::TriangleInterface::ArbitraryHole::segment_indices
virtual std::vector< unsigned int > segment_indices() const override
Starting indices of points for a hole with multiple disconnected boundaries.
Definition: mesh_triangle_holes.C:101
libMesh::TriangleInterface::PolygonHole::n_points
virtual unsigned int n_points() const override
The number of geometric points which define the hole.
Definition: mesh_triangle_holes.C:41
libMesh::TriangleInterface::PolygonHole::_radius
Real _radius
circular hole radius
Definition: mesh_triangle_holes.h:122
libMesh::TriangleInterface::Region::_center
const Point _center
Arbitrary (x,y) location inside the region.
Definition: mesh_triangle_holes.h:209
radius
const Real radius
Definition: subdomains_ex3.C:48
libMesh::Point
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition: point.h:38
libMesh::TriangleInterface::Region::Region
Region(const Point &center, Real attribute=0, Real max_area=-std::numeric_limits< Real >::max())
Constructor.
Definition: mesh_triangle_holes.h:192
libMesh::TriangleInterface::PolygonHole::inside
virtual Point inside() const override
Return an (arbitrary) point which lies inside the hole.
Definition: mesh_triangle_holes.C:56
libMesh::TriangleInterface::Hole::Hole
Hole()
Constructor.
Definition: mesh_triangle_holes.h:54
libMesh::TriangleInterface::Region::_attribute
Real _attribute
Attribute of the region Default value for attribute is zero.
Definition: mesh_triangle_holes.h:215
libMesh::TriangleInterface::ArbitraryHole::inside
virtual Point inside() const override
Return an (arbitrary) point which lies inside the hole.
Definition: mesh_triangle_holes.C:96
libMesh::TriangleInterface::Region
A class for defining a 2-dimensional region for Triangle.
Definition: mesh_triangle_holes.h:186
libMesh::TriangleInterface::Region::max_area
Real max_area() const
Definition: mesh_triangle_holes.h:203
libMesh::TriangleInterface::ArbitraryHole
Another concrete instantiation of the hole, this one should be sufficiently general for most non-poly...
Definition: mesh_triangle_holes.h:142
libMesh::Real
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Definition: libmesh_common.h:121
libMesh::TriangleInterface::PolygonHole::PolygonHole
PolygonHole(const Point &center, Real radius, unsigned int n_points)
Constructor specifying the center, radius, and number of points which comprise the hole.
Definition: mesh_triangle_holes.C:32
libMesh::TriangleInterface::PolygonHole::_n_points
unsigned int _n_points
number of points used to describe the hole.
Definition: mesh_triangle_holes.h:129