From: bangerth Date: Tue, 7 Dec 2010 13:46:23 +0000 (+0000) Subject: When codim=1, we can't take for granted that the left neighbor of the right neighbor... X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cd0146b15487a7f22e673fa30b0bb9bba1529600;p=dealii-svn.git When codim=1, we can't take for granted that the left neighbor of the right neighbor is the current cell. git-svn-id: https://svn.dealii.org/trunk@22937 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/include/deal.II/grid/tria_accessor.templates.h b/deal.II/include/deal.II/grid/tria_accessor.templates.h index e9068436ac..6b95623667 100644 --- a/deal.II/include/deal.II/grid/tria_accessor.templates.h +++ b/deal.II/include/deal.II/grid/tria_accessor.templates.h @@ -2832,19 +2832,14 @@ inline unsigned int CellAccessor::neighbor_face_no (const unsigned int neighbor) const { - if (dim==1) - return neighbor_of_neighbor(neighbor); + const unsigned int n2=neighbor_of_neighbor_internal(neighbor); + if (n2!=numbers::invalid_unsigned_int) + // return this value as the + // neighbor is not coarser + return n2; else - { - const unsigned int n2=neighbor_of_neighbor_internal(neighbor); - if (n2!=numbers::invalid_unsigned_int) - // return this value as the - // neighbor is not coarser - return n2; - else - // the neighbor is coarser - return neighbor_of_coarser_neighbor(neighbor).first; - } + // the neighbor is coarser + return neighbor_of_coarser_neighbor(neighbor).first; } DEAL_II_NAMESPACE_CLOSE diff --git a/deal.II/source/grid/tria_accessor.cc b/deal.II/source/grid/tria_accessor.cc index 376c94744f..00b028184c 100644 --- a/deal.II/source/grid/tria_accessor.cc +++ b/deal.II/source/grid/tria_accessor.cc @@ -1322,7 +1322,16 @@ unsigned int CellAccessor::neighbor_of_neighbor_internal (const un { AssertIndexRange (neighbor, GeometryInfo::faces_per_cell); - if (dim==1) + // if we have a 1d mesh in 1d, we + // can assume that the left + // neighbor of the right neigbor is + // the current cell. but that is an + // invariant that isn't true if the + // mesh is embedded in a higher + // dimensional space, so we have to + // fall back onto the generic code + // below + if ((dim==1) && (spacedim==dim)) return GeometryInfo::opposite_face[neighbor]; const TriaIterator > neighbor_cell = this->neighbor(neighbor); @@ -1375,7 +1384,8 @@ template unsigned int CellAccessor::neighbor_of_neighbor (const unsigned int neighbor) const { const unsigned int n2=neighbor_of_neighbor_internal(neighbor); - Assert (n2!=numbers::invalid_unsigned_int, TriaAccessorExceptions::ExcNeighborIsCoarser()); + Assert (n2!=numbers::invalid_unsigned_int, + TriaAccessorExceptions::ExcNeighborIsCoarser()); return n2; }