libMesh
periodic_boundaries.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 // Local Includes
19 #include "libmesh/libmesh_config.h"
20 
21 #ifdef LIBMESH_ENABLE_PERIODIC
22 
23 #include "libmesh/periodic_boundaries.h"
24 #include "libmesh/point_locator_base.h"
25 #include "libmesh/elem.h"
26 #include "libmesh/periodic_boundary.h"
27 
28 namespace libMesh
29 {
30 
32 {
33  for (std::map<boundary_id_type, PeriodicBoundaryBase *>::iterator it = begin(); it != end(); ++it)
34  delete it->second;
35 }
36 
37 
38 
40 {
41  iterator i = this->find(id);
42  if (i == this->end())
43  return libmesh_nullptr;
44  return i->second;
45 }
46 
47 
48 
50 {
51  const_iterator i = this->find(id);
52  if (i == this->end())
53  return libmesh_nullptr;
54  return i->second;
55 }
56 
57 
58 
59 
61  const PointLocatorBase & point_locator,
62  const Elem * e,
63  unsigned int side) const
64 {
65  // Find a point on that side (and only that side)
66 
67  Point p = e->build_side_ptr(side)->centroid();
68 
69  const PeriodicBoundaryBase * b = this->boundary(boundary_id);
70  libmesh_assert (b);
71  p = b->get_corresponding_pos(p);
72 
73  return point_locator.operator()(p);
74 }
75 
76 } // namespace libMesh
77 
78 
79 
80 
81 
82 #endif // LIBMESH_ENABLE_PERIODIC
virtual UniquePtr< Elem > build_side_ptr(const unsigned int i, bool proxy=true)=0
virtual Point get_corresponding_pos(const Point &pt) const =0
This function should be overridden by derived classes to define how one finds corresponding nodes on ...
unsigned short int side
Definition: xdr_io.C:49
This is the base class from which all geometric element types are derived.
Definition: elem.h:89
PeriodicBoundaryBase * boundary(boundary_id_type id)
const class libmesh_nullptr_t libmesh_nullptr
IterBase * end
Also have a polymorphic pointer to the end object, this prevents iterating past the end...
The libMesh namespace provides an interface to certain functionality in the library.
libmesh_assert(j)
int8_t boundary_id_type
Definition: id_types.h:51
This is the base class for point locators.
The base class for defining periodic boundaries.
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition: point.h:38
const Elem * neighbor(boundary_id_type boundary_id, const PointLocatorBase &point_locator, const Elem *e, unsigned int side) const