TriaIterator<CellAccessor<dim, spacedim> >
periodic_neighbor (const unsigned int i) const;
+ /**
+ * For a cell whose @c ith face is not at a boundary, this function returns
+ * the same result as neighbor(). If the @c ith face is at a periodic boundary
+ * this function returns the same result as periodic_neighbor(). If neither of
+ * the aforementioned conditions are met, i.e. the @c ith face is on a
+ * nonperiodic boundary, an exception will be thrown.
+ */
+ TriaIterator<CellAccessor<dim, spacedim> >
+ neighbor_or_periodic_neighbor (const unsigned int i) const;
+
/**
* Returns an iterator to the periodic neighbor of the cell at a given
* face and subface number. The general guidelines for using this function
periodic_neighbor_of_periodic_neighbor (const unsigned int i) const;
/**
- * If a cell has periodic neighbor, this function returns the face number
- * of the neighbor, which is connected to this cell.
+ * If a cell has a periodic neighbor at its @c ith face, this function
+ * returns the face number of the periodic neighbor, which is connected
+ * to the @c ith face of this cell.
*/
unsigned int
periodic_neighbor_face_no (const unsigned int i) const;
+template <int dim, int spacedim>
+TriaIterator<CellAccessor<dim,spacedim> >
+CellAccessor<dim, spacedim>::
+neighbor_or_periodic_neighbor (const unsigned int i_face) const
+{
+ if (!(this->face(i_face)->at_boundary()))
+ return this->neighbor(i_face);
+ else if (this->has_periodic_neighbor(i_face))
+ return this->periodic_neighbor(i_face);
+ else
+ Assert (false, TriaAccessorExceptions::ExcNoPeriodicNeighbor());
+}
+
+
+
template <int dim, int spacedim>
TriaIterator<CellAccessor<dim, spacedim> >
CellAccessor<dim, spacedim>::