libMesh
mesh_triangle_holes.C
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 
19 #include "libmesh/libmesh_config.h"
20 
21 #ifdef LIBMESH_HAVE_TRIANGLE
22 
23 // Local includes
24 #include "libmesh/mesh_triangle_holes.h"
25 
26 namespace libMesh
27 {
28 
29 //
30 // PolygonHole member functions
31 //
33  Real radius,
34  unsigned int n_points_in) :
35  _center(center),
36  _radius(radius),
37  _n_points(n_points_in)
38 {}
39 
40 
42 {
43  return _n_points;
44 }
45 
46 Point TriangleInterface::PolygonHole::point(const unsigned int n) const
47 {
48  // The nth point lies at the angle theta = 2 * pi * n / _n_points
49  const Real theta = static_cast<Real>(n) * 2.0 * libMesh::pi / static_cast<Real>(_n_points);
50 
51  return Point(_center(0) + _radius*std::cos(theta), // x=r*cos(theta)
52  _center(1) + _radius*std::sin(theta), // y=r*sin(theta)
53  0.);
54 }
55 
57 {
58  // The center of the hole is definitely inside.
59  return _center;
60 }
61 
62 
63 //
64 // ArbitraryHole member functions
65 //
67  const std::vector<Point> & points)
68  : _center(center),
69  _points(points)
70 {
71  _segment_indices.push_back(0);
72  _segment_indices.push_back(points.size());
73 }
74 
76  const std::vector<Point> & points,
77  const std::vector<unsigned int> & segment_indices)
78  : _center(center),
79  _points(points),
80  _segment_indices(segment_indices)
81 {}
82 
84 {
85  return _points.size();
86 }
87 
88 
90 {
91  libmesh_assert_less (n, _points.size());
92  return _points[n];
93 }
94 
95 
97 {
98  return _center;
99 }
100 
101 std::vector<unsigned int> TriangleInterface::ArbitraryHole::segment_indices() const
102 {
103  return _segment_indices;
104 }
105 
106 } // namespace libMesh
107 
108 
109 #endif // LIBMESH_HAVE_TRIANGLE
libMesh::pi
const Real pi
.
Definition: libmesh.h:237
libMesh::TriangleInterface::ArbitraryHole::_segment_indices
std::vector< unsigned int > _segment_indices
Definition: mesh_triangle_holes.h:176
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
The libMesh namespace provides an interface to certain functionality in the library.
Definition: factoryfunction.C:55
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::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::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
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::PolygonHole::inside
virtual Point inside() const override
Return an (arbitrary) point which lies inside the hole.
Definition: mesh_triangle_holes.C:56
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::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