]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Refactor common code into a function of its own.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Mon, 13 Apr 2015 22:55:28 +0000 (17:55 -0500)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Mon, 13 Apr 2015 22:55:28 +0000 (17:55 -0500)
include/deal.II/grid/tria.h
source/grid/tria.cc

index c6dc8f031488e8b452fc75bb1909bd0ec9e9a1e2..2cbb45722595484d830ed0857f57a81f2ea86115 100644 (file)
@@ -3025,6 +3025,14 @@ private:
    */
   void clear_despite_subscriptions ();
 
+  /**
+   * For all cells, set the active cell indices so that active cells know
+   * the how many-th active cell they are, and all other cells have an invalid
+   * value. This function is called after mesh creation, refinement, and
+   * serialization.
+   */
+  void reset_active_cell_indices ();
+
   /**
    * Refine all cells on all levels which were previously flagged for
    * refinement.
@@ -3321,18 +3329,7 @@ Triangulation<dim,spacedim>::load (Archive &ar,
   {
     for (unsigned int l=0; l<levels.size(); ++l)
       levels[l]->active_cell_indices.resize (levels[l]->refine_flags.size());
-
-    unsigned int active_cell_index = 0;
-    for (cell_iterator cell=begin(); cell!=end(); ++cell)
-      if (cell->has_children())
-        cell->set_active_cell_index (numbers::invalid_unsigned_int);
-      else
-        {
-          cell->set_active_cell_index (active_cell_index);
-          ++active_cell_index;
-        }
-
-    Assert (active_cell_index == n_active_cells(), ExcInternalError());
+    reset_active_cell_indices ();
   }
 
 
index b10c57b73dcb6102e1ef92d373f59a3110817119..c7d2bb8fe003eff5a8fd13d5d36cd052bf81defb 100644 (file)
@@ -9073,6 +9073,7 @@ create_triangulation_compatibility (const std::vector<Point<spacedim> > &v,
 }
 
 
+
 template <int dim, int spacedim>
 void
 Triangulation<dim,spacedim>::
@@ -9105,19 +9106,7 @@ create_triangulation (const std::vector<Point<spacedim> >    &v,
   // active_cell_indices of all cells
   internal::Triangulation::Implementation
   ::compute_number_cache (*this, levels.size(), number_cache);
-  {
-    unsigned int active_cell_index = 0;
-    for (cell_iterator cell=begin(); cell!=end(); ++cell)
-      if (cell->has_children())
-        cell->set_active_cell_index (numbers::invalid_unsigned_int);
-      else
-        {
-          cell->set_active_cell_index (active_cell_index);
-          ++active_cell_index;
-        }
-
-    Assert (active_cell_index == n_active_cells(), ExcInternalError());
-  }
+  reset_active_cell_indices ();
 
   // now verify that there are indeed no distorted cells. as per the
   // documentation of this class, we first collect all distorted cells
@@ -11515,19 +11504,7 @@ Triangulation<dim, spacedim>::execute_coarsening_and_refinement ()
   // finally build up neighbor connectivity information, and set
   // active cell indices
   update_neighbors(*this);
-  {
-    unsigned int active_cell_index = 0;
-    for (cell_iterator cell=begin(); cell!=end(); ++cell)
-      if (cell->has_children())
-        cell->set_active_cell_index (numbers::invalid_unsigned_int);
-      else
-        {
-          cell->set_active_cell_index (active_cell_index);
-          ++active_cell_index;
-        }
-
-    Assert (active_cell_index == n_active_cells(), ExcInternalError());
-  }
+  reset_active_cell_indices ();
 
   // Inform all listeners about end of refinement.
   signals.post_refinement();
@@ -11537,6 +11514,26 @@ Triangulation<dim, spacedim>::execute_coarsening_and_refinement ()
 }
 
 
+
+template <int dim, int spacedim>
+void
+Triangulation<dim,spacedim>::reset_active_cell_indices ()
+{
+  unsigned int active_cell_index = 0;
+  for (raw_cell_iterator cell=begin_raw(); cell!=end(); ++cell)
+    if ((cell->used() == false) || cell->has_children())
+      cell->set_active_cell_index (numbers::invalid_unsigned_int);
+    else
+      {
+        cell->set_active_cell_index (active_cell_index);
+        ++active_cell_index;
+      }
+
+  Assert (active_cell_index == n_active_cells(), ExcInternalError());
+}
+
+
+
 template<int dim, int spacedim>
 void
 Triangulation<dim, spacedim>::clear_despite_subscriptions()

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.