libMesh
mesh_triangle_holes.C
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2017 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 
56 
57 
59 {
60  // The center of the hole is definitely inside.
61  return _center;
62 }
63 
64 
65 
66 //
67 // ArbitraryHole member functions
68 //
70  const std::vector<Point> & points)
71  : _center(center),
72  _points(points)
73 {}
74 
75 
77 {
78  return _points.size();
79 }
80 
81 
83 {
84  libmesh_assert_less (n, _points.size());
85  return _points[n];
86 }
87 
88 
90 {
91  return _center;
92 }
93 
94 
95 } // namespace libMesh
96 
97 
98 #endif // LIBMESH_HAVE_TRIANGLE
virtual Point inside() const libmesh_override
Return an (arbitrary) point which lies inside the hole.
virtual Point inside() const libmesh_override
Return an (arbitrary) point which lies inside the hole.
const Real radius
virtual unsigned int n_points() const libmesh_override
The number of geometric points which define the hole.
virtual Point point(const unsigned int n) const libmesh_override
Return the nth point defining the hole.
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...
The libMesh namespace provides an interface to certain functionality in the library.
virtual unsigned int n_points() const libmesh_override
The number of geometric points which define the hole.
const std::vector< Point > & _points
Reference to the vector of points which makes up the hole.
PolygonHole(const Point &center, Real radius, unsigned int n_points)
Constructor specifying the center, radius, and number of points which comprise the hole...
Point _center
(x,y) location of the center of the hole
Point _center
arbitrary (x,y) location inside the hole
unsigned int _n_points
number of points used to describe the hole.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual Point point(const unsigned int n) const libmesh_override
Return the nth point defining the hole.
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition: point.h:38
const Real pi
.
Definition: libmesh.h:172