]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Fixed bug in find_cells_adjacent_to_vertex
authorheltai <heltai@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 17 Jul 2008 13:12:45 +0000 (13:12 +0000)
committerheltai <heltai@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 17 Jul 2008 13:12:45 +0000 (13:12 +0000)
git-svn-id: https://svn.dealii.org/trunk@16450 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/source/grid/grid_tools.cc
deal.II/doc/news/changes.h

index c4e4d402fe645154cc4fedae6790c87b652784d2..c552eaf894116bf624b172ab18ecccbc89ca602c 100644 (file)
@@ -599,7 +599,12 @@ GridTools::find_cells_adjacent_to_vertex(const Container<dim> &container,
    Assert(get_tria(container).get_used_vertices()[vertex],
           ExcVertexNotUsed(vertex));
 
-   std::vector<typename Container<dim>::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<typename Container<dim>::active_cell_iterator> adj_cells_set;
    
    typename Container<dim>::active_cell_iterator
       cell = container.begin_active(),
@@ -614,7 +619,7 @@ GridTools::find_cells_adjacent_to_vertex(const Container<dim> &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<dim> &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<typename Container<dim>::active_cell_iterator> adjacent_cells;
 
+                                       // We now produce the output vector
+                                       // from the set that we assembled above.
+   typename std::set<typename Container<dim>::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;
index c3f22bec320e5e4143fe3848147809049b87cf21..82bb232981d263918747eb93876bea36384c0b2f 100644 (file)
@@ -209,6 +209,14 @@ inconvenience this causes.
 
 <ol>
   <li>
+  <p>
+  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)
+  <li>
+
   <p>
   New: There is now a new
   Triangulation::prevent_distorted_boundary_cells function which

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.