$extrastylesheet
periodic_boundaries.C
Go to the documentation of this file.
00001 // The libMesh Finite Element Library.
00002 // Copyright (C) 2002-2014 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
00003 
00004 // This library is free software; you can redistribute it and/or
00005 // modify it under the terms of the GNU Lesser General Public
00006 // License as published by the Free Software Foundation; either
00007 // version 2.1 of the License, or (at your option) any later version.
00008 
00009 // This library is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012 // Lesser General Public License for more details.
00013 
00014 // You should have received a copy of the GNU Lesser General Public
00015 // License along with this library; if not, write to the Free Software
00016 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017 
00018 // Local Includes -----------------------------------
00019 #include "libmesh/libmesh_config.h"
00020 
00021 #ifdef LIBMESH_ENABLE_PERIODIC
00022 
00023 #include "libmesh/periodic_boundaries.h"
00024 #include "libmesh/point_locator_base.h"
00025 #include "libmesh/elem.h"
00026 #include "libmesh/periodic_boundary.h"
00027 
00028 namespace libMesh {
00029 
00030 // ------------------------------------------------------------
00031 // PeriodicBoundaries member functions
00032 
00033 
00034 PeriodicBoundaries::~PeriodicBoundaries()
00035 {
00036   for (std::map<boundary_id_type, PeriodicBoundaryBase*>::iterator it = begin(); it != end(); ++it)
00037     delete it->second;
00038 }
00039 
00040 
00041 
00042 PeriodicBoundaryBase* PeriodicBoundaries::boundary(boundary_id_type id)
00043 {
00044   iterator i = this->find(id);
00045   if (i == this->end())
00046     return NULL;
00047   return i->second;
00048 }
00049 
00050 
00051 
00052 const PeriodicBoundaryBase* PeriodicBoundaries::boundary(boundary_id_type id) const
00053 {
00054   const_iterator i = this->find(id);
00055   if (i == this->end())
00056     return NULL;
00057   return i->second;
00058 }
00059 
00060 
00061 
00062 
00063 const Elem *PeriodicBoundaries::neighbor(boundary_id_type boundary_id,
00064                                          const PointLocatorBase& point_locator,
00065                                          const Elem* e,
00066                                          unsigned int side) const
00067 {
00068   // Find a point on that side (and only that side)
00069 
00070   Point p = e->build_side(side)->centroid();
00071 
00072   const PeriodicBoundaryBase *b = this->boundary(boundary_id);
00073   libmesh_assert (b);
00074   p = b->get_corresponding_pos(p);
00075 
00076   return point_locator.operator()(p);
00077 }
00078 
00079 } // namespace libMesh
00080 
00081 
00082 
00083 
00084 
00085 #endif // LIBMESH_ENABLE_PERIODIC