libMesh::PeriodicBoundaries Class Reference

Maps between boundary ids and PeriodicBoundaryBase objects. More...

#include <periodic_boundaries.h>

Inheritance diagram for libMesh::PeriodicBoundaries:

Public Member Functions

PeriodicBoundaryBaseboundary (boundary_id_type id)
 
const PeriodicBoundaryBaseboundary (boundary_id_type id) const
 
 PeriodicBoundaries ()
 
 ~PeriodicBoundaries ()
 
const Elemneighbor (boundary_id_type boundary_id, const PointLocatorBase &point_locator, const Elem *e, unsigned int side) const
 

Detailed Description

Maps between boundary ids and PeriodicBoundaryBase objects.

We're using a class instead of a typedef to allow forward declarations and future flexibility.

Note
std::map has no virtual destructor, so downcasting here would be dangerous.
Author
Roy Stogner
Date
2010

Definition at line 51 of file periodic_boundaries.h.

Constructor & Destructor Documentation

◆ PeriodicBoundaries()

libMesh::PeriodicBoundaries::PeriodicBoundaries ( )
inline

Definition at line 58 of file periodic_boundaries.h.

58 {}

◆ ~PeriodicBoundaries()

libMesh::PeriodicBoundaries::~PeriodicBoundaries ( )

Definition at line 32 of file periodic_boundaries.C.

33 {
34  for (auto & pr : *this)
35  delete pr.second;
36 }

Member Function Documentation

◆ boundary() [1/2]

PeriodicBoundaryBase * libMesh::PeriodicBoundaries::boundary ( boundary_id_type  id)

Definition at line 40 of file periodic_boundaries.C.

References end.

Referenced by libMesh::FEGenericBase< FEOutputType< T >::type >::compute_periodic_constraints(), libMesh::FEAbstract::compute_periodic_node_constraints(), neighbor(), and libMesh::Elem::topological_neighbor().

41 {
42  iterator i = this->find(id);
43  if (i == this->end())
44  return nullptr;
45  return i->second;
46 }
IterBase * end

◆ boundary() [2/2]

const PeriodicBoundaryBase * libMesh::PeriodicBoundaries::boundary ( boundary_id_type  id) const

Definition at line 50 of file periodic_boundaries.C.

References end.

51 {
52  const_iterator i = this->find(id);
53  if (i == this->end())
54  return nullptr;
55  return i->second;
56 }
IterBase * end

◆ neighbor()

const Elem * libMesh::PeriodicBoundaries::neighbor ( boundary_id_type  boundary_id,
const PointLocatorBase point_locator,
const Elem e,
unsigned int  side 
) const

Definition at line 61 of file periodic_boundaries.C.

References boundary(), libMesh::Elem::build_side_ptr(), libMesh::PeriodicBoundaryBase::get_corresponding_pos(), libMesh::PointLocatorBase::get_mesh(), libMesh::invalid_uint, mesh, libMesh::PeriodicBoundaryBase::pairedboundary, and side.

Referenced by libMesh::FEGenericBase< FEOutputType< T >::type >::compute_periodic_constraints(), libMesh::FEAbstract::compute_periodic_node_constraints(), and libMesh::Elem::topological_neighbor().

65 {
66  // Find a point on that side (and only that side)
67 
68  Point p = e->build_side_ptr(side)->centroid();
69 
70  const PeriodicBoundaryBase * b = this->boundary(boundary_id);
71  libmesh_assert (b);
72  p = b->get_corresponding_pos(p);
73 
74  std::set<const Elem *> candidate_elements;
75  point_locator.operator()(p, candidate_elements);
76 
77  // We might have found multiple elements, e.g. if two distinct periodic
78  // boundaries are overlapping (see systems_of_equations_ex9, for example).
79  // As a result, we need to search for the element that has boundary_id.
80  const MeshBase & mesh = point_locator.get_mesh();
81  for(const Elem * elem_it : candidate_elements)
82  {
83  unsigned int s_neigh =
84  mesh.get_boundary_info().side_with_boundary_id(elem_it, b->pairedboundary);
85 
86  // If s_neigh is not invalid then we have found an element that contains
87  // boundary_id, so return this element
88  if(s_neigh != libMesh::invalid_uint)
89  {
90  return elem_it;
91  }
92  }
93 
94  libmesh_error_msg("Periodic boundary neighbor not found");
95  return nullptr;
96 }
const unsigned int invalid_uint
Definition: libmesh.h:245
unsigned short int side
Definition: xdr_io.C:50
MeshBase & mesh
PeriodicBoundaryBase * boundary(boundary_id_type id)

The documentation for this class was generated from the following files: