mesh_triangle_holes.C
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2014 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  //
32  TriangleInterface::PolygonHole::PolygonHole(Point center, Real radius, unsigned int n_points_in)
33  : _center(center),
34  _radius(radius),
35  _n_points(n_points_in)
36  {}
37 
38 
40  {
41  return _n_points;
42  }
43 
44  Point TriangleInterface::PolygonHole::point(const unsigned int n) const
45  {
46  // The nth point lies at the angle theta = 2 * pi * n / _n_points
47  const Real theta = static_cast<Real>(n) * 2.0 * libMesh::pi / static_cast<Real>(_n_points);
48 
49  return Point(_center(0) + _radius*std::cos(theta), // x=r*cos(theta)
50  _center(1) + _radius*std::sin(theta), // y=r*sin(theta)
51  0.);
52  }
53 
54 
55 
57  {
58  // The center of the hole is definitely inside.
59  return _center;
60  }
61 
62 
63 
64 
65  //
66  // ArbitraryHole member functions
67  //
69  const std::vector<Point>& points)
70  : _center(center),
71  _points(points)
72  {}
73 
74 
76  {
77  return _points.size();
78  }
79 
80 
81  Point TriangleInterface::ArbitraryHole::point(const unsigned int n) const
82  {
83  libmesh_assert_less (n, _points.size());
84  return _points[n];
85  }
86 
87 
89  {
90  return _center;
91  }
92 
93 
94 } // namespace libMesh
95 
96 
97 #endif // LIBMESH_HAVE_TRIANGLE

Site Created By: libMesh Developers
Last modified: February 07 2014 16:57:06 UTC

Hosted By:
SourceForge.net Logo