mesh_triangle_holes.C
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2018 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
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 point(const unsigned int n) const override
virtual unsigned int n_points() const override
ArbitraryHole(const Point &center, const std::vector< Point > &points)
virtual Point inside() const override
virtual unsigned int n_points() const override
PolygonHole(const Point &center, Real radius, unsigned int n_points)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual Point inside() const override
A geometric point in (x,y,z) space.
Definition: point.h:38
virtual Point point(const unsigned int n) const override
const Real pi
Definition: libmesh.h:233