From: heltai Date: Thu, 17 Jul 2008 13:12:45 +0000 (+0000) Subject: Fixed bug in find_cells_adjacent_to_vertex X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4fc5019dc1eb10205403b4a303d1969d87b93140;p=dealii-svn.git Fixed bug in find_cells_adjacent_to_vertex git-svn-id: https://svn.dealii.org/trunk@16450 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/source/grid/grid_tools.cc b/deal.II/deal.II/source/grid/grid_tools.cc index c4e4d402fe..c552eaf894 100644 --- a/deal.II/deal.II/source/grid/grid_tools.cc +++ b/deal.II/deal.II/source/grid/grid_tools.cc @@ -599,7 +599,12 @@ GridTools::find_cells_adjacent_to_vertex(const Container &container, Assert(get_tria(container).get_used_vertices()[vertex], ExcVertexNotUsed(vertex)); - std::vector::active_cell_iterator> adjacent_cells; + // We use a set instead of a vector + // to ensure that cells are inserted only + // once. A bug in the previous version + // prevented some cases to be + // treated correctly + std::set::active_cell_iterator> adj_cells_set; typename Container::active_cell_iterator cell = container.begin_active(), @@ -614,7 +619,7 @@ GridTools::find_cells_adjacent_to_vertex(const Container &container, // OK, we found a cell that contains // the particular vertex. We add it // to the list. - adjacent_cells.push_back(cell); + adj_cells_set.insert(cell); // Now we need to make sure that the // vertex is not a locally refined @@ -665,32 +670,25 @@ GridTools::find_cells_adjacent_to_vertex(const Container &container, break; } if (!found) - // The - // coarser - // cell - // needs to - // be added - // only - // once. In - // order to - // do so, we - // add it - // only if - // the - // current - // cell face - // is child - // zero of - // its face. - if(cell->neighbor_of_coarser_neighbor(face).second == 0) - adjacent_cells.push_back(nb); + adj_cells_set.insert(nb); } } } break; } + + std::vector::active_cell_iterator> adjacent_cells; + // We now produce the output vector + // from the set that we assembled above. + typename std::set::active_cell_iterator>::iterator + it = adj_cells_set.begin(), + endit = adj_cells_set.end(); + for(; it != endit; ++it) + adjacent_cells.push_back(*it); + + Assert(adjacent_cells.size() > 0, ExcInternalError()); return adjacent_cells; diff --git a/deal.II/doc/news/changes.h b/deal.II/doc/news/changes.h index c3f22bec32..82bb232981 100644 --- a/deal.II/doc/news/changes.h +++ b/deal.II/doc/news/changes.h @@ -209,6 +209,14 @@ inconvenience this causes.
  1. +

    + Fixed: GridTools::find_cells_adjacent_to_vertex had a bug that + prevented its correct functioning in three dimensions. Some + cases were left out due to uncorrect assumptions on the various + refinement possibilities. + (Luca Heltai 2008/07/17) +

  2. +

    New: There is now a new Triangulation::prevent_distorted_boundary_cells function which