]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Convert a lot of places to range-based loops over all active cells. 9607/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Tue, 3 Mar 2020 22:24:38 +0000 (15:24 -0700)
committerWolfgang Bangerth <bangerth@colostate.edu>
Fri, 6 Mar 2020 14:16:44 +0000 (07:16 -0700)
16 files changed:
include/deal.II/numerics/vector_tools.templates.h
source/distributed/grid_refinement.cc
source/distributed/tria.cc
source/distributed/tria_base.cc
source/dofs/dof_handler_policy.cc
source/dofs/dof_tools.cc
source/dofs/dof_tools_constraints.cc
source/grid/grid_generator.cc
source/grid/grid_in.cc
source/grid/grid_refinement.cc
source/grid/grid_tools.cc
source/grid/grid_tools_dof_handlers.cc
source/grid/tria.cc
source/hp/dof_handler.cc
source/numerics/error_estimator_1d.cc
source/numerics/solution_transfer.cc

index ce59c09993fcd5b1968cb5eda48ef8a426740a6a..229f111e82f90cedc0ea8a59c90e5287a49341be 100644 (file)
@@ -2824,10 +2824,7 @@ namespace VectorTools
       // individual vertices
       if (dim == 1)
         {
-          for (typename DoFHandlerType<dim, spacedim>::active_cell_iterator
-                 cell = dof.begin_active();
-               cell != dof.end();
-               ++cell)
+          for (const auto &cell : dof.active_cell_iterators())
             for (const unsigned int direction :
                  GeometryInfo<dim>::face_indices())
               if (cell->at_boundary(direction) &&
@@ -3532,10 +3529,7 @@ namespace VectorTools
 #ifdef DEBUG
           // Assert that there are no hanging nodes at the boundary
           int level = -1;
-          for (typename DoFHandlerType<dim, spacedim>::active_cell_iterator
-                 cell = dof.begin_active();
-               cell != dof.end();
-               ++cell)
+          for (const auto &cell : dof.active_cell_iterators())
             for (auto f : GeometryInfo<dim>::face_indices())
               {
                 if (cell->at_boundary(f))
@@ -6651,10 +6645,7 @@ namespace VectorTools
       {
         case 2:
           {
-            for (typename DoFHandler<dim>::active_cell_iterator cell =
-                   dof_handler.begin_active();
-                 cell != dof_handler.end();
-                 ++cell)
+            for (const auto &cell : dof_handler.active_cell_iterators())
               if (cell->at_boundary() && cell->is_locally_owned())
                 for (const unsigned int face :
                      GeometryInfo<dim>::face_indices())
@@ -6723,10 +6714,7 @@ namespace VectorTools
             for (unsigned int dof = 0; dof < n_dofs; ++dof)
               projected_dofs[dof] = 0;
 
-            for (typename DoFHandler<dim>::active_cell_iterator cell =
-                   dof_handler.begin_active();
-                 cell != dof_handler.end();
-                 ++cell)
+            for (const auto &cell : dof_handler.active_cell_iterators())
               if (cell->at_boundary() && cell->is_locally_owned())
                 for (const unsigned int face :
                      GeometryInfo<dim>::face_indices())
@@ -6828,10 +6816,7 @@ namespace VectorTools
       {
         case 2:
           {
-            for (typename hp::DoFHandler<dim>::active_cell_iterator cell =
-                   dof_handler.begin_active();
-                 cell != dof_handler.end();
-                 ++cell)
+            for (const auto &cell : dof_handler.active_cell_iterators())
               if (cell->at_boundary() && cell->is_locally_owned())
                 for (const unsigned int face :
                      GeometryInfo<dim>::face_indices())
@@ -6885,10 +6870,7 @@ namespace VectorTools
             for (unsigned int dof = 0; dof < n_dofs; ++dof)
               projected_dofs[dof] = 0;
 
-            for (typename hp::DoFHandler<dim>::active_cell_iterator cell =
-                   dof_handler.begin_active();
-                 cell != dof_handler.end();
-                 ++cell)
+            for (const auto &cell : dof_handler.active_cell_iterators())
               if (cell->at_boundary() && cell->is_locally_owned())
                 for (const unsigned int face :
                      GeometryInfo<dim>::face_indices())
@@ -7641,10 +7623,7 @@ namespace VectorTools
 
     std::set<types::boundary_id>::iterator                b_id;
     std::vector<std::array<types::global_dof_index, dim>> cell_vector_dofs;
-    for (typename DoFHandlerType<dim, spacedim>::active_cell_iterator cell =
-           dof_handler.begin_active();
-         cell != dof_handler.end();
-         ++cell)
+    for (const auto &cell : dof_handler.active_cell_iterators())
       if (!cell->is_artificial())
         for (const unsigned int face_no : GeometryInfo<dim>::face_indices())
           if ((b_id = boundary_ids.find(cell->face(face_no)->boundary_id())) !=
@@ -8639,10 +8618,7 @@ namespace VectorTools
                                                 update_flags);
 
       // loop over all cells
-      for (typename DoFHandlerType::active_cell_iterator cell =
-             dof.begin_active();
-           cell != dof.end();
-           ++cell)
+      for (const auto &cell : dof.active_cell_iterators())
         if (cell->is_locally_owned())
           {
             // initialize for this cell
@@ -8764,10 +8740,7 @@ namespace VectorTools
                                                           update_flags);
 
       // loop over all cells
-      for (typename DoFHandlerType::active_cell_iterator cell =
-             dof.begin_active();
-           cell != dof.end();
-           ++cell)
+      for (const auto &cell : dof.active_cell_iterators())
         if (cell->is_locally_owned())
           {
             // initialize for this cell
index e5aeeb0b21b585eade2d4a8b9a430e25d7850a13..2775af5ac2c9cbfde1a9cc5de4e0492fa6b09f23 100644 (file)
@@ -110,10 +110,7 @@ namespace
            ExcInternalError());
 
     unsigned int owned_index = 0;
-    for (typename Triangulation<dim, spacedim>::active_cell_iterator cell =
-           tria.begin_active();
-         cell != tria.end();
-         ++cell)
+    for (const auto &cell : tria.active_cell_iterators())
       if (cell->subdomain_id() == tria.locally_owned_subdomain())
         {
           locally_owned_indicators(owned_index) =
@@ -170,10 +167,7 @@ namespace
 
     // as a final good measure, delete all flags again from cells that we don't
     // locally own
-    for (typename Triangulation<dim, spacedim>::active_cell_iterator cell =
-           tria.begin_active();
-         cell != tria.end();
-         ++cell)
+    for (const auto &cell : tria.active_cell_iterators())
       if (cell->subdomain_id() != tria.locally_owned_subdomain())
         {
           cell->clear_refine_flag();
index 7a3e41e09b96f865183de0b6a1e7090f299ab0eb..035b5cca947a8616b6797b785a2282ca818f3bb9 100644 (file)
@@ -54,10 +54,7 @@ namespace
     vertex_touch_count.resize(triangulation.n_vertices());
     vertex_to_cell.resize(triangulation.n_vertices());
 
-    for (typename Triangulation<dim, spacedim>::active_cell_iterator cell =
-           triangulation.begin_active();
-         cell != triangulation.end();
-         ++cell)
+    for (const auto &cell : triangulation.active_cell_iterators())
       for (const unsigned int v : GeometryInfo<dim>::vertex_indices())
         {
           ++vertex_touch_count[cell->vertex_index(v)];
@@ -81,10 +78,7 @@ namespace
     edge_touch_count.resize(triangulation.n_active_lines());
     edge_to_cell.resize(triangulation.n_active_lines());
 
-    for (typename Triangulation<dim, spacedim>::active_cell_iterator cell =
-           triangulation.begin_active();
-         cell != triangulation.end();
-         ++cell)
+    for (const auto &cell : triangulation.active_cell_iterators())
       for (unsigned int l = 0; l < GeometryInfo<dim>::lines_per_cell; ++l)
         {
           ++edge_touch_count[cell->line(l)->index()];
@@ -652,10 +646,7 @@ namespace
   {
     // count how many flags are set and allocate that much memory
     unsigned int n_refine_flags = 0, n_coarsen_flags = 0;
-    for (typename Triangulation<dim, spacedim>::active_cell_iterator cell =
-           triangulation.begin_active();
-         cell != triangulation.end();
-         ++cell)
+    for (const auto &cell : triangulation.active_cell_iterators())
       {
         // skip cells that are not local
         if (cell->subdomain_id() != my_subdomain)
@@ -3488,10 +3479,7 @@ namespace parallel
       if (settings & mesh_reconstruction_after_repartitioning)
         while (this->begin_active()->level() > 0)
           {
-            for (typename Triangulation<dim, spacedim>::active_cell_iterator
-                   cell = this->begin_active();
-                 cell != this->end();
-                 ++cell)
+            for (const auto &cell : this->active_cell_iterators())
               {
                 cell->set_coarsen_flag();
               }
@@ -3614,10 +3602,7 @@ namespace parallel
 
           // see if any flags are still set
           mesh_changed = false;
-          for (typename Triangulation<dim, spacedim>::active_cell_iterator
-                 cell = this->begin_active();
-               cell != this->end();
-               ++cell)
+          for (const auto &cell : this->active_cell_iterators())
             if (cell->refine_flag_set() || cell->coarsen_flag_set())
               {
                 mesh_changed = true;
@@ -3645,10 +3630,7 @@ namespace parallel
       // check if correct number of ghosts is created
       unsigned int num_ghosts = 0;
 
-      for (typename Triangulation<dim, spacedim>::active_cell_iterator cell =
-             this->begin_active();
-           cell != this->end();
-           ++cell)
+      for (const auto &cell : this->active_cell_iterators())
         {
           if (cell->subdomain_id() != this->my_subdomain &&
               cell->subdomain_id() != numbers::artificial_subdomain_id)
@@ -3783,10 +3765,7 @@ namespace parallel
 
         // count the number of owned, active cells and compare with p4est.
         unsigned int n_owned = 0;
-        for (typename Triangulation<dim, spacedim>::active_cell_iterator cell =
-               this->begin_active();
-             cell != this->end();
-             ++cell)
+        for (const auto &cell : this->active_cell_iterators())
           {
             if (cell->subdomain_id() == this->my_subdomain)
               ++n_owned;
@@ -3814,10 +3793,7 @@ namespace parallel
     {
       // do not allow anisotropic refinement
 #  ifdef DEBUG
-      for (typename Triangulation<dim, spacedim>::active_cell_iterator cell =
-             this->begin_active();
-           cell != this->end();
-           ++cell)
+      for (const auto &cell : this->active_cell_iterators())
         if (cell->is_locally_owned() && cell->refine_flag_set())
           Assert(cell->refine_flag_set() ==
                    RefinementPossibilities<dim>::isotropic_refinement,
@@ -3853,10 +3829,7 @@ namespace parallel
       // now do the work we're supposed to do when we are in charge
       // make sure all flags are cleared on cells we don't own, since nothing
       // good can come of that if they are still around
-      for (typename Triangulation<dim, spacedim>::active_cell_iterator cell =
-             this->begin_active();
-           cell != this->end();
-           ++cell)
+      for (const auto &cell : this->active_cell_iterators())
         if (cell->is_ghost() || cell->is_artificial())
           {
             cell->clear_refine_flag();
@@ -3974,10 +3947,7 @@ namespace parallel
       // finally copy back from local part of tree to deal.II
       // triangulation. before doing so, make sure there are no refine or
       // coarsen flags pending
-      for (typename Triangulation<dim, spacedim>::active_cell_iterator cell =
-             this->begin_active();
-           cell != this->end();
-           ++cell)
+      for (const auto &cell : this->active_cell_iterators())
         {
           cell->clear_refine_flag();
           cell->clear_coarsen_flag();
@@ -4074,10 +4044,7 @@ namespace parallel
     Triangulation<dim, spacedim>::repartition()
     {
 #  ifdef DEBUG
-      for (typename Triangulation<dim, spacedim>::active_cell_iterator cell =
-             this->begin_active();
-           cell != this->end();
-           ++cell)
+      for (const auto &cell : this->active_cell_iterators())
         if (cell->is_locally_owned())
           Assert(
             !cell->refine_flag_set() && !cell->coarsen_flag_set(),
index d7649afc07d482ac148f499d8179def0045a43c8..7117d6f2ac8c8cf1b4e788a4e579da32b37216dd 100644 (file)
@@ -193,10 +193,7 @@ namespace parallel
 
     {
       // find ghost owners
-      for (typename Triangulation<dim, spacedim>::active_cell_iterator cell =
-             this->begin_active();
-           cell != this->end();
-           ++cell)
+      for (const auto &cell : this->active_cell_iterators())
         if (cell->is_ghost())
           number_cache.ghost_owners.insert(cell->subdomain_id());
 
@@ -206,10 +203,7 @@ namespace parallel
     }
 
     if (this->n_levels() > 0)
-      for (typename Triangulation<dim, spacedim>::active_cell_iterator cell =
-             this->begin_active();
-           cell != this->end();
-           ++cell)
+      for (const auto &cell : this->active_cell_iterators())
         if (cell->subdomain_id() == my_subdomain)
           ++number_cache.n_locally_owned_active_cells;
 
index 9306e7a96edd56d3dae0480ff991b65fd864d1e0..178ad1207dfa1ef842ee8e088eff271d64286dbd 100644 (file)
@@ -764,10 +764,7 @@ namespace internal
           dealii::Table<2, std::unique_ptr<DoFIdentities>> line_dof_identities(
             dof_handler.fe_collection.size(), dof_handler.fe_collection.size());
 
-          for (typename hp::DoFHandler<dim, spacedim>::active_cell_iterator
-                 cell = dof_handler.begin_active();
-               cell != dof_handler.end();
-               ++cell)
+          for (const auto &cell : dof_handler.active_cell_iterators())
             for (unsigned int l = 0; l < GeometryInfo<dim>::lines_per_cell; ++l)
               if (cell->line(l)->user_flag_set() == false)
                 {
@@ -1128,10 +1125,7 @@ namespace internal
           dealii::Table<2, std::unique_ptr<DoFIdentities>> quad_dof_identities(
             dof_handler.fe_collection.size(), dof_handler.fe_collection.size());
 
-          for (typename hp::DoFHandler<dim, spacedim>::active_cell_iterator
-                 cell = dof_handler.begin_active();
-               cell != dof_handler.end();
-               ++cell)
+          for (const auto &cell : dof_handler.active_cell_iterators())
             for (unsigned int q = 0; q < GeometryInfo<dim>::quads_per_cell; ++q)
               if ((cell->quad(q)->user_flag_set() == false) &&
                   (cell->quad(q)->n_active_fe_indices() == 2))
@@ -1596,10 +1590,7 @@ namespace internal
           dealii::Table<2, std::unique_ptr<DoFIdentities>> line_dof_identities(
             dof_handler.fe_collection.size(), dof_handler.fe_collection.size());
 
-          for (typename hp::DoFHandler<dim, spacedim>::active_cell_iterator
-                 cell = dof_handler.begin_active();
-               cell != dof_handler.end();
-               ++cell)
+          for (const auto &cell : dof_handler.active_cell_iterators())
             for (unsigned int l = 0; l < GeometryInfo<dim>::lines_per_cell; ++l)
               if ((cell->is_locally_owned()) &&
                   (cell->line(l)->user_flag_set() == true))
@@ -1867,10 +1858,7 @@ namespace internal
           dealii::Table<2, std::unique_ptr<DoFIdentities>> quad_dof_identities(
             dof_handler.fe_collection.size(), dof_handler.fe_collection.size());
 
-          for (typename hp::DoFHandler<dim, spacedim>::active_cell_iterator
-                 cell = dof_handler.begin_active();
-               cell != dof_handler.end();
-               ++cell)
+          for (const auto &cell : dof_handler.active_cell_iterators())
             for (unsigned int q = 0; q < GeometryInfo<dim>::quads_per_cell; ++q)
               if ((cell->is_locally_owned()) &&
                   (cell->quad(q)->user_flag_set() == true) &&
@@ -2649,10 +2637,7 @@ namespace internal
           const IndexSet &                            indices_we_care_about,
           hp::DoFHandler<dim, spacedim> &             dof_handler)
         {
-          for (typename hp::DoFHandler<dim, spacedim>::active_cell_iterator
-                 cell = dof_handler.begin_active();
-               cell != dof_handler.end();
-               ++cell)
+          for (const auto &cell : dof_handler.active_cell_iterators())
             if (!cell->is_artificial())
               {
                 const unsigned int fe_index = cell->active_fe_index();
@@ -2738,10 +2723,7 @@ namespace internal
               dof_handler.get_triangulation())
               .clear_user_flags_line();
 
-            for (typename hp::DoFHandler<dim, spacedim>::active_cell_iterator
-                   cell = dof_handler.begin_active();
-                 cell != dof_handler.end();
-                 ++cell)
+            for (const auto &cell : dof_handler.active_cell_iterators())
               if (!cell->is_artificial())
                 for (unsigned int l = 0; l < GeometryInfo<dim>::lines_per_cell;
                      ++l)
@@ -2840,10 +2822,7 @@ namespace internal
               dof_handler.get_triangulation())
               .clear_user_flags_line();
 
-            for (typename hp::DoFHandler<dim, spacedim>::active_cell_iterator
-                   cell = dof_handler.begin_active();
-                 cell != dof_handler.end();
-                 ++cell)
+            for (const auto &cell : dof_handler.active_cell_iterators())
               if (!cell->is_artificial())
                 for (unsigned int l = 0; l < GeometryInfo<dim>::lines_per_cell;
                      ++l)
@@ -2923,10 +2902,7 @@ namespace internal
               dof_handler.get_triangulation())
               .clear_user_flags_quad();
 
-            for (typename hp::DoFHandler<dim, spacedim>::active_cell_iterator
-                   cell = dof_handler.begin_active();
-                 cell != dof_handler.end();
-                 ++cell)
+            for (const auto &cell : dof_handler.active_cell_iterators())
               if (!cell->is_artificial())
                 for (unsigned int q = 0; q < GeometryInfo<dim>::quads_per_cell;
                      ++q)
index 2324dfc250ba121bb1aa0cea6e4ee44cf7edb70a..55f4c3553c670499eaf539d9585df370cedf29a8 100644 (file)
@@ -697,10 +697,7 @@ namespace DoFTools
     // do not support boundaries of dimension dim-2, and so every isolated
     // boundary line is also part of a boundary face which we will be
     // visiting sooner or later
-    for (typename DoFHandlerType::active_cell_iterator cell =
-           dof_handler.begin_active();
-         cell != dof_handler.end();
-         ++cell)
+    for (const auto &cell : dof_handler.active_cell_iterators())
 
       // only work on cells that are either locally owned or at least ghost
       // cells
@@ -805,10 +802,7 @@ namespace DoFTools
     // do not support boundaries of dimension dim-2, and so every isolated
     // boundary line is also part of a boundary face which we will be
     // visiting sooner or later
-    for (typename DoFHandlerType::active_cell_iterator cell =
-           dof_handler.begin_active();
-         cell != dof_handler.end();
-         ++cell)
+    for (const auto &cell : dof_handler.active_cell_iterators())
       for (const unsigned int face :
            GeometryInfo<DoFHandlerType::dimension>::face_indices())
         if (cell->at_boundary(face))
index 8f7a4a34aac77642519251eea095da493de9fcc1..6f3258f4adec0fef0d24a9a26f3531ea1081d9b9 100644 (file)
@@ -2964,10 +2964,7 @@ namespace DoFTools
 #ifdef DEBUG
         // if in debug mode, check whether the coarse grid is indeed coarser
         // everywhere than the fine grid
-        for (typename dealii::DoFHandler<dim, spacedim>::active_cell_iterator
-               cell = coarse_grid.begin_active();
-             cell != coarse_grid.end();
-             ++cell)
+        for (const auto &cell : coarse_grid.active_cell_iterators())
           Assert(cell->level() <= coarse_to_fine_grid_map[cell]->level(),
                  ExcGridNotCoarser());
 #endif
@@ -3022,10 +3019,7 @@ namespace DoFTools
           std::vector<types::global_dof_index> local_dof_indices(
             fine_fe.dofs_per_cell);
 
-          for (typename dealii::DoFHandler<dim, spacedim>::active_cell_iterator
-                 cell = fine_grid.begin_active();
-               cell != fine_grid.end();
-               ++cell)
+          for (const auto &cell : fine_grid.active_cell_iterators())
             if (cell->is_locally_owned())
               {
                 cell->get_dof_indices(local_dof_indices);
@@ -3052,10 +3046,7 @@ namespace DoFTools
           std::vector<types::global_dof_index> local_dof_indices(
             fine_fe.dofs_per_cell);
           unsigned int next_free_index = 0;
-          for (typename dealii::DoFHandler<dim, spacedim>::active_cell_iterator
-                 cell = fine_grid.begin_active();
-               cell != fine_grid.end();
-               ++cell)
+          for (const auto &cell : fine_grid.active_cell_iterators())
             if (cell->is_locally_owned())
               {
                 cell->get_dof_indices(local_dof_indices);
index eb6c9488c5c1e1ee8a68339ad71b6c545c9cb9c0..ca7eaed28591d2d43637d1b49e86f8ed0091adc9 100644 (file)
@@ -6100,10 +6100,7 @@ namespace GridGenerator
         intergrid_map.make_mapping(result, triangulation_2);
 
         bool any_cell_flagged = false;
-        for (typename Triangulation<dim, spacedim>::active_cell_iterator
-               result_cell = result.begin_active();
-             result_cell != result.end();
-             ++result_cell)
+        for (const auto &result_cell : result.active_cell_iterators())
           if (intergrid_map[result_cell]->has_children())
             {
               any_cell_flagged = true;
@@ -6134,10 +6131,7 @@ namespace GridGenerator
     // the loop through the cells and copy stuff, excluding
     // the ones we are to remove
     std::vector<CellData<dim>> cells;
-    for (typename Triangulation<dim, spacedim>::active_cell_iterator cell =
-           input_triangulation.begin_active();
-         cell != input_triangulation.end();
-         ++cell)
+    for (const auto &cell : input_triangulation.active_cell_iterators())
       if (cells_to_remove.find(cell) == cells_to_remove.end())
         {
           Assert(static_cast<unsigned int>(cell->level()) ==
index 810b8b03de10ccf7960071c83d5df8a5e4a37f97..cf8639fc6e6ef7398c386ce5fa953f8dc0a63dd6 100644 (file)
@@ -63,10 +63,7 @@ namespace
     Triangulation<1, spacedim> &                      triangulation)
   {
     if (boundary_ids.size() > 0)
-      for (typename Triangulation<1, spacedim>::active_cell_iterator cell =
-             triangulation.begin_active();
-           cell != triangulation.end();
-           ++cell)
+      for (const auto &cell : triangulation.active_cell_iterators())
         for (unsigned int f : GeometryInfo<1>::face_indices())
           if (boundary_ids.find(cell->vertex_index(f)) != boundary_ids.end())
             {
index 93dc2350eb41a43a571960f8c172f471a7f21672..641eb8eae5ff3371ba85fb64c4e83c03095768fc 100644 (file)
@@ -70,10 +70,7 @@ GridRefinement::refine(Triangulation<dim, spacedim> &tria,
     }
 
   unsigned int marked = 0;
-  for (typename Triangulation<dim, spacedim>::active_cell_iterator cell =
-         tria.begin_active();
-       cell != tria.end();
-       ++cell)
+  for (const auto &cell : tria.active_cell_iterators())
     if (std::fabs(criteria(cell->active_cell_index())) >= new_threshold)
       {
         if (max_to_mark != numbers::invalid_unsigned_int &&
@@ -96,10 +93,7 @@ GridRefinement::coarsen(Triangulation<dim, spacedim> &tria,
          ExcDimensionMismatch(criteria.size(), tria.n_active_cells()));
   Assert(criteria.is_non_negative(), ExcNegativeCriteria());
 
-  for (typename Triangulation<dim, spacedim>::active_cell_iterator cell =
-         tria.begin_active();
-       cell != tria.end();
-       ++cell)
+  for (const auto &cell : tria.active_cell_iterators())
     if (std::fabs(criteria(cell->active_cell_index())) <= threshold)
       if (!cell->refine_flag_set())
         cell->set_coarsen_flag();
index 8242cf17298d2a1886bd1742338ffc4a96731554..4a4cee06befefb9d40b007b12a059e15780629d0 100644 (file)
@@ -1303,10 +1303,7 @@ namespace GridTools
     const bool is_parallel_shared =
       (dynamic_cast<parallel::shared::Triangulation<dim, spacedim> *>(
          &triangulation) != nullptr);
-    for (typename Triangulation<dim, spacedim>::active_cell_iterator cell =
-           triangulation.begin_active();
-         cell != triangulation.end();
-         ++cell)
+    for (const auto &cell : triangulation.active_cell_iterators())
       if (is_parallel_shared || cell->is_locally_owned())
         {
           if (dim > 1)
@@ -1369,10 +1366,7 @@ namespace GridTools
         std::vector<bool> vertex_moved(triangulation.n_vertices(), false);
 
         // Next move vertices on locally owned cells
-        for (typename Triangulation<dim, spacedim>::active_cell_iterator cell =
-               triangulation.begin_active();
-             cell != triangulation.end();
-             ++cell)
+        for (const auto &cell : triangulation.active_cell_iterators())
           if (cell->is_locally_owned())
             {
               for (const unsigned int vertex_no :
@@ -1446,10 +1440,7 @@ namespace GridTools
           }
 
         // now do the actual move of the vertices
-        for (typename Triangulation<dim, spacedim>::active_cell_iterator cell =
-               triangulation.begin_active();
-             cell != triangulation.end();
-             ++cell)
+        for (const auto &cell : triangulation.active_cell_iterators())
           for (const unsigned int vertex_no :
                GeometryInfo<dim>::vertex_indices())
             cell->vertex(vertex_no) =
@@ -2783,10 +2774,7 @@ namespace GridTools
   {
     std::vector<std::vector<unsigned int>> vertex_to_cell(
       triangulation.n_vertices());
-    for (typename Triangulation<dim, spacedim>::active_cell_iterator cell =
-           triangulation.begin_active();
-         cell != triangulation.end();
-         ++cell)
+    for (const auto &cell : triangulation.active_cell_iterators())
       {
         for (const unsigned int v : GeometryInfo<dim>::vertex_indices())
           vertex_to_cell[cell->vertex_index(v)].push_back(
@@ -2795,10 +2783,7 @@ namespace GridTools
 
     cell_connectivity.reinit(triangulation.n_active_cells(),
                              triangulation.n_active_cells());
-    for (typename Triangulation<dim, spacedim>::active_cell_iterator cell =
-           triangulation.begin_active();
-         cell != triangulation.end();
-         ++cell)
+    for (const auto &cell : triangulation.active_cell_iterators())
       {
         for (const unsigned int v : GeometryInfo<dim>::vertex_indices())
           for (unsigned int n = 0;
@@ -3213,10 +3198,7 @@ namespace GridTools
     Assert(subdomain.size() == triangulation.n_active_cells(),
            ExcDimensionMismatch(subdomain.size(),
                                 triangulation.n_active_cells()));
-    for (typename Triangulation<dim, spacedim>::active_cell_iterator cell =
-           triangulation.begin_active();
-         cell != triangulation.end();
-         ++cell)
+    for (const auto &cell : triangulation.active_cell_iterators())
       subdomain[cell->active_cell_index()] = cell->subdomain_id();
   }
 
@@ -3229,10 +3211,7 @@ namespace GridTools
     const types::subdomain_id           subdomain)
   {
     unsigned int count = 0;
-    for (typename Triangulation<dim, spacedim>::active_cell_iterator cell =
-           triangulation.begin_active();
-         cell != triangulation.end();
-         ++cell)
+    for (const auto &cell : triangulation.active_cell_iterators())
       if (cell->subdomain_id() == subdomain)
         ++count;
 
@@ -3886,10 +3865,7 @@ namespace GridTools
     // we cannot immediately reset their boundary ids. thus, copy first
     // and reset later
     if (dim >= 3)
-      for (typename Triangulation<dim, spacedim>::active_cell_iterator cell =
-             tria.begin_active();
-           cell != tria.end();
-           ++cell)
+      for (const auto &cell : tria.active_cell_iterators())
         for (auto f : GeometryInfo<dim>::face_indices())
           if (cell->face(f)->at_boundary())
             for (unsigned int e = 0; e < GeometryInfo<dim>::lines_per_face; ++e)
@@ -3905,10 +3881,7 @@ namespace GridTools
               }
 
     // now do cells
-    for (typename Triangulation<dim, spacedim>::active_cell_iterator cell =
-           tria.begin_active();
-         cell != tria.end();
-         ++cell)
+    for (const auto &cell : tria.active_cell_iterators())
       for (auto f : GeometryInfo<dim>::face_indices())
         if (cell->face(f)->at_boundary())
           {
index 212df3ea3d75b3970af5e31ac718881345fe8191..41f794208af63c3a4b9c1f4210fe4880b6d1fe08 100644 (file)
@@ -1563,12 +1563,8 @@ namespace GridTools
     do
       {
         refinement_necessary = false;
-        for (typename Triangulation<Container::dimension,
-                                    Container::space_dimension>::
-               active_cell_iterator active_tria_cell =
-                 local_triangulation.begin_active();
-             active_tria_cell != local_triangulation.end();
-             ++active_tria_cell)
+        for (const auto &active_tria_cell :
+             local_triangulation.active_cell_iterators())
           {
             if (patch_to_global_tria_map_tmp[active_tria_cell]->has_children())
               {
index c2779e938da5e9cae178724aa10cb183936bb2dc..bce97ba2515d744d4df1caf74b4aad9ae18eda6f 100644 (file)
@@ -435,10 +435,7 @@ namespace
     std::vector<unsigned int> max_adjacent_cell_level(
       triangulation.n_vertices(), 0);
 
-    for (typename Triangulation<dim, spacedim>::active_cell_iterator cell =
-           triangulation.begin_active();
-         cell != triangulation.end();
-         ++cell)
+    for (const auto &cell : triangulation.active_cell_iterators())
       for (const unsigned int v : GeometryInfo<dim>::vertex_indices())
         {
           min_adjacent_cell_level[cell->vertex_index(v)] =
@@ -1932,10 +1929,7 @@ namespace internal
         // maps
         triangulation.vertex_to_boundary_id_map_1d->clear();
         triangulation.vertex_to_manifold_id_map_1d->clear();
-        for (typename Triangulation<dim, spacedim>::active_cell_iterator cell =
-               triangulation.begin_active();
-             cell != triangulation.end();
-             ++cell)
+        for (const auto &cell : triangulation.active_cell_iterators())
           for (auto f : GeometryInfo<dim>::face_indices())
             {
               (*triangulation.vertex_to_manifold_id_map_1d)
@@ -5550,10 +5544,7 @@ namespace internal
           // this check is very simple to implement here, since we have
           // all lines flagged if they shall be refined
 #ifdef DEBUG
-        for (typename Triangulation<dim, spacedim>::active_cell_iterator cell =
-               triangulation.begin_active();
-             cell != triangulation.end();
-             ++cell)
+        for (const auto &cell : triangulation.active_cell_iterators())
           if (!cell->refine_flag_set())
             for (unsigned int line = 0;
                  line < GeometryInfo<dim>::lines_per_cell;
index 879dad4f441b6619435eb9a1f758cf1812d68d6c..1aab77699f009ff54c84e1ae7dbcb757473a09a4 100644 (file)
@@ -173,10 +173,7 @@ namespace internal
           // first
           std::vector<bool> locally_used_vertices(
             dof_handler.tria->n_vertices(), false);
-          for (typename HpDoFHandler<dim, spacedim>::active_cell_iterator cell =
-                 dof_handler.begin_active();
-               cell != dof_handler.end();
-               ++cell)
+          for (const auto &cell : dof_handler.active_cell_iterators())
             if (!cell->is_artificial())
               for (const unsigned int v : GeometryInfo<dim>::vertex_indices())
                 locally_used_vertices[cell->vertex_index(v)] = true;
@@ -185,10 +182,7 @@ namespace internal
             dof_handler.fe_collection.size(),
             std::vector<bool>(dof_handler.tria->n_vertices(), false));
 
-          for (typename HpDoFHandler<dim, spacedim>::active_cell_iterator cell =
-                 dof_handler.begin_active();
-               cell != dof_handler.end();
-               ++cell)
+          for (const auto &cell : dof_handler.active_cell_iterators())
             if (!cell->is_artificial())
               for (const unsigned int v : GeometryInfo<dim>::vertex_indices())
                 vertex_fe_association[cell->active_fe_index()]
@@ -771,10 +765,7 @@ namespace internal
               dof_handler.fe_collection.size(),
               std::vector<bool>(dof_handler.tria->n_raw_lines(), false));
 
-            for (typename HpDoFHandler<dim, spacedim>::active_cell_iterator
-                   cell = dof_handler.begin_active();
-                 cell != dof_handler.end();
-                 ++cell)
+            for (const auto &cell : dof_handler.active_cell_iterators())
               if (!cell->is_artificial())
                 for (unsigned int l = 0; l < GeometryInfo<dim>::lines_per_cell;
                      ++l)
index 5ac42f894525e7f3e7b46d8cb592df6352f109db..b63f26045e09dede451c03bb4c45d8d10761f22f 100644 (file)
@@ -435,10 +435,7 @@ KellyErrorEstimator<1, spacedim>::estimate(
   // loop over all cells and do something on the cells which we're told to
   // work on. note that the error indicator is only a sum over the two
   // contributions from the two vertices of each cell.
-  for (typename DoFHandlerType::active_cell_iterator cell =
-         dof_handler.begin_active();
-       cell != dof_handler.end();
-       ++cell)
+  for (const auto &cell : dof_handler.active_cell_iterators())
     if (((subdomain_id == numbers::invalid_subdomain_id) ||
          (cell->subdomain_id() == subdomain_id)) &&
         ((material_id == numbers::invalid_material_id) ||
index 5e453f04cbbcf65e3604ac7f7c61835d297eddc0..87b2e313bb05a34203ec63631a52acd8824d1f12 100644 (file)
@@ -291,10 +291,7 @@ SolutionTransfer<dim, VectorType, DoFHandlerType>::
   // and that'll stay or be refined
   unsigned int n_cells_to_coarsen        = 0;
   unsigned int n_cells_to_stay_or_refine = 0;
-  for (typename DoFHandlerType::active_cell_iterator act_cell =
-         dof_handler->begin_active();
-       act_cell != dof_handler->end();
-       ++act_cell)
+  for (const auto &act_cell : dof_handler->active_cell_iterators())
     {
       if (act_cell->coarsen_flag_set())
         ++n_cells_to_coarsen;

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.