From c927f19820761f6a9523db2e836d23b982531e3b Mon Sep 17 00:00:00 2001 From: buerg Date: Sun, 11 Nov 2012 22:26:47 +0000 Subject: [PATCH] Add implementation of update_neighbors for dim=1. git-svn-id: https://svn.dealii.org/trunk@27511 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/source/grid/tria.cc | 76 ++++++++++++++++++++++++++++++++++++- 1 file changed, 74 insertions(+), 2 deletions(-) diff --git a/deal.II/source/grid/tria.cc b/deal.II/source/grid/tria.cc index 7c36f28c23..fe816b75b7 100644 --- a/deal.II/source/grid/tria.cc +++ b/deal.II/source/grid/tria.cc @@ -714,8 +714,80 @@ namespace */ template void - update_neighbors (Triangulation<1,spacedim> &/*triangulation*/) - {} + update_neighbors (Triangulation<1,spacedim> &triangulation) + { + // each face can be neighbored on two sides + // by cells. according to the face's + // fixed ordering in cells we define the left + // neighbor as the one for which the face + // is face number 1, and store that + // one first; the second one is then + // the right neighbor for which the + // face has number 0. + // + // There is one more point to + // consider, however: if we have + // 1::cell_iterator dummy; + std::vector::cell_iterator> + adjacent_cells (2 * (triangulation.n_cells () + 1), dummy); + + typename Triangulation::cell_iterator + cell = triangulation.begin(), + endc = triangulation.end(); + for (; cell != endc; ++cell) + for (unsigned int f=0; f::faces_per_cell; ++f) + { + const typename Triangulation::face_iterator + face=cell->face(f); + + const unsigned int + offset = (cell->direction_flag() ? 0 : 1); + + adjacent_cells[2*face->index() + offset] = cell; + } + + // now loop again over all cells and set the + // corresponding neighbor cell. Note, that we + // have to use the opposite of the offset in + // this case as we want the offset of the + // neighbor, not our own. + for (cell=triangulation.begin(); cell != endc; ++cell) + for (unsigned int f=0; f::faces_per_cell; ++f) + { + const unsigned int + offset = (cell->direction_flag() ? 0 : 1); + cell->set_neighbor(f, + adjacent_cells[2*cell->face(f)->index() + 1 - offset]); + } + } template -- 2.39.5