From: Ali Samii Date: Thu, 24 Mar 2016 15:47:30 +0000 (-0500) Subject: Added neighbor_or_periodic_neighbor X-Git-Tag: v8.5.0-rc1~1151^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bf30ebf803ed0ce4d792af043b7a49d220b894e5;p=dealii.git Added neighbor_or_periodic_neighbor neighbor_or_periodic_neighbor is added. Added neighbor_or_periodic_neighbor --- diff --git a/include/deal.II/grid/tria_accessor.h b/include/deal.II/grid/tria_accessor.h index 1e863e86bc..5ddae5fa41 100644 --- a/include/deal.II/grid/tria_accessor.h +++ b/include/deal.II/grid/tria_accessor.h @@ -2526,6 +2526,16 @@ public: TriaIterator > 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 > + 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 @@ -2588,8 +2598,9 @@ public: 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; diff --git a/source/grid/tria_accessor.cc b/source/grid/tria_accessor.cc index 0cf66d063b..4377710d09 100644 --- a/source/grid/tria_accessor.cc +++ b/source/grid/tria_accessor.cc @@ -1933,6 +1933,21 @@ periodic_neighbor (const unsigned int i_face) const +template +TriaIterator > +CellAccessor:: +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 TriaIterator > CellAccessor::