]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Use range-based for loops in source/hp
authorDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Sun, 6 Jan 2019 22:45:15 +0000 (23:45 +0100)
committerDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Thu, 10 Jan 2019 19:34:36 +0000 (20:34 +0100)
source/hp/dof_handler.cc
source/hp/dof_level.cc
source/hp/fe_collection.cc

index d304971601ab7beb0846d7301aa889bd9225afed..9d0e5c9e6f2b80995c83a8ff9b782c538850337a 100644 (file)
@@ -980,7 +980,7 @@ namespace internal
               // non-locally_owned cells. so we have to work around the
               // issue a little bit by accessing the underlying data
               // structures directly
-              for (auto cell : dof_handler.active_cell_iterators())
+              for (const auto &cell : dof_handler.active_cell_iterators())
                 if (cell->is_ghost())
                   dof_handler.levels[cell->level()]->set_active_fe_index(
                     cell->index(),
@@ -1579,8 +1579,8 @@ namespace hp
           Assert(*p == i, ExcNewNumbersNotConsecutive(i));
       }
     else
-      for (types::global_dof_index i = 0; i < new_numbers.size(); ++i)
-        Assert(new_numbers[i] < n_dofs(),
+      for (const auto new_number : new_numbers)
+        Assert(new_number < n_dofs(),
                ExcMessage(
                  "New DoF index is not less than the total number of dofs."));
 #endif
@@ -1754,7 +1754,7 @@ namespace hp
             const std::vector<types::subdomain_id> &true_subdomain_ids =
               shared_tria->get_true_subdomain_ids_of_cells();
 
-            for (auto &cell : active_cell_iterators())
+            for (const auto &cell : active_cell_iterators())
               {
                 const unsigned int index   = cell->active_cell_index();
                 saved_subdomain_ids[index] = cell->subdomain_id();
@@ -1815,7 +1815,7 @@ namespace hp
 
         // Finally, restore current subdomain_ids.
         if (shared_tria != nullptr && shared_tria->with_artificial_cells())
-          for (auto &cell : active_cell_iterators())
+          for (const auto &cell : active_cell_iterators())
             {
               if (cell->is_artificial())
                 cell->set_subdomain_id(numbers::invalid_subdomain_id);
index ac20643ad1c74e88127bb076efa18a65838a3c63..94982880f5a30b4f0e3084c8970e3a3c390cfd73 100644 (file)
@@ -256,10 +256,9 @@ namespace internal
     void
     DoFLevel::normalize_active_fe_indices()
     {
-      for (unsigned int i = 0; i < active_fe_indices.size(); ++i)
-        if (is_compressed_entry(active_fe_indices[i]))
-          active_fe_indices[i] =
-            get_toggled_compression_state(active_fe_indices[i]);
+      for (auto &active_fe_index : active_fe_indices)
+        if (is_compressed_entry(active_fe_index))
+          active_fe_index = get_toggled_compression_state(active_fe_index);
     }
 
 
index ce980da3b656286e7a63652048b7e25f72865b12..616359767d63148407ccad28f7656864853bdba3 100644 (file)
@@ -40,8 +40,11 @@ namespace hp
   {
     Assert(codim <= dim, ExcImpossibleInDim(dim));
 
-    for (auto it = fes.cbegin(); it != fes.cend(); ++it)
-      AssertIndexRange(*it, finite_elements.size());
+    for (const unsigned int fe_index : fes)
+      {
+        (void)fe_index;
+        AssertIndexRange(fe_index, finite_elements.size());
+      }
 
     // If the set of elements to be dominated contains only a single element X,
     // then by definition the dominating set contains this single element X
@@ -114,8 +117,11 @@ namespace hp
   {
     Assert(codim <= dim, ExcImpossibleInDim(dim));
 
-    for (auto it = fes.cbegin(); it != fes.cend(); ++it)
-      AssertIndexRange(*it, finite_elements.size());
+    for (const unsigned int fe_index : fes)
+      {
+        (void)fe_index;
+        AssertIndexRange(fe_index, finite_elements.size());
+      }
 
     // If the set of elements to be dominated contains only a single element X,
     // then by definition the dominating set contains this single element

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.