]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Use range-based for loops 8096/head
authorDaniel Arndt <arndtd@ornl.gov>
Sat, 11 May 2019 16:32:03 +0000 (12:32 -0400)
committerDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Sat, 11 May 2019 16:54:06 +0000 (18:54 +0200)
examples/step-43/step-43.cc

index c6546c8e18c12d2158cd73847d30cd0cdba83410..14e458f20a16d0b4a43b2d9b89aee42590b33f96 100644 (file)
@@ -881,12 +881,9 @@ namespace Step43
     const FEValuesExtractors::Vector velocities(0);
     const FEValuesExtractors::Scalar pressure(dim);
 
-    typename DoFHandler<dim>::active_cell_iterator cell = darcy_dof_handler
-                                                            .begin_active(),
-                                                   endc =
-                                                     darcy_dof_handler.end();
-    typename DoFHandler<dim>::active_cell_iterator saturation_cell =
-      saturation_dof_handler.begin_active();
+    auto       cell            = darcy_dof_handler.begin_active();
+    const auto endc            = darcy_dof_handler.end();
+    auto       saturation_cell = saturation_dof_handler.begin_active();
 
     for (; cell != endc; ++cell, ++saturation_cell)
       {
@@ -1083,12 +1080,9 @@ namespace Step43
     // AffineConstraints class do the insertion of the cell matrix
     // elements to the global matrix, which already condenses the hanging node
     // constraints.
-    typename DoFHandler<dim>::active_cell_iterator cell = darcy_dof_handler
-                                                            .begin_active(),
-                                                   endc =
-                                                     darcy_dof_handler.end();
-    typename DoFHandler<dim>::active_cell_iterator saturation_cell =
-      saturation_dof_handler.begin_active();
+    auto       cell            = darcy_dof_handler.begin_active();
+    const auto endc            = darcy_dof_handler.end();
+    auto       saturation_cell = saturation_dof_handler.begin_active();
 
     for (; cell != endc; ++cell, ++saturation_cell)
       {
@@ -1216,10 +1210,7 @@ namespace Step43
 
     std::vector<types::global_dof_index> local_dof_indices(dofs_per_cell);
 
-    typename DoFHandler<dim>::active_cell_iterator
-      cell = saturation_dof_handler.begin_active(),
-      endc = saturation_dof_handler.end();
-    for (; cell != endc; ++cell)
+    for (const auto &cell : saturation_dof_handler.active_cell_iterators())
       {
         saturation_fe_values.reinit(cell);
         local_matrix = 0;
@@ -1303,11 +1294,9 @@ namespace Step43
     const double global_S_variation =
       global_S_range.second - global_S_range.first;
 
-    typename DoFHandler<dim>::active_cell_iterator
-      cell = saturation_dof_handler.begin_active(),
-      endc = saturation_dof_handler.end();
-    typename DoFHandler<dim>::active_cell_iterator darcy_cell =
-      darcy_dof_handler.begin_active();
+    auto       cell       = saturation_dof_handler.begin_active();
+    const auto endc       = saturation_dof_handler.end();
+    auto       darcy_cell = darcy_dof_handler.begin_active();
     for (; cell != endc; ++cell, ++darcy_cell)
       {
         saturation_fe_values.reinit(cell);
@@ -1662,11 +1651,9 @@ namespace Step43
                                               time_step / old_time_step,
                                               old_saturation_solution);
 
-      typename DoFHandler<dim>::active_cell_iterator
-        cell = saturation_dof_handler.begin_active(),
-        endc = saturation_dof_handler.end();
-      for (unsigned int cell_no = 0; cell != endc; ++cell, ++cell_no)
+      for (const auto &cell : saturation_dof_handler.active_cell_iterators())
         {
+          const unsigned int cell_no = cell->active_cell_index();
           fe_values.reinit(cell);
           fe_values.get_function_gradients(extrapolated_saturation_solution,
                                            grad_saturation);
@@ -1676,12 +1663,9 @@ namespace Step43
     }
 
     {
-      typename DoFHandler<dim>::active_cell_iterator
-        cell = saturation_dof_handler.begin_active(),
-        endc = saturation_dof_handler.end();
-
-      for (unsigned int cell_no = 0; cell != endc; ++cell, ++cell_no)
+      for (const auto &cell : saturation_dof_handler.active_cell_iterators())
         {
+          const unsigned int cell_no = cell->active_cell_index();
           cell->clear_coarsen_flag();
           cell->clear_refine_flag();
 
@@ -1780,11 +1764,10 @@ namespace Step43
       std::vector<types::global_dof_index> local_saturation_dof_indices(
         saturation_fe.dofs_per_cell);
 
-      typename DoFHandler<dim>::active_cell_iterator
-        joint_cell      = joint_dof_handler.begin_active(),
-        joint_endc      = joint_dof_handler.end(),
-        darcy_cell      = darcy_dof_handler.begin_active(),
-        saturation_cell = saturation_dof_handler.begin_active();
+      auto       joint_cell      = joint_dof_handler.begin_active();
+      const auto joint_endc      = joint_dof_handler.end();
+      auto       darcy_cell      = darcy_dof_handler.begin_active();
+      auto       saturation_cell = saturation_dof_handler.begin_active();
 
       for (; joint_cell != joint_endc;
            ++joint_cell, ++darcy_cell, ++saturation_cell)
@@ -1887,10 +1870,7 @@ namespace Step43
 
     double max_global_aop_indicator = 0.0;
 
-    typename DoFHandler<dim>::active_cell_iterator
-      cell = saturation_dof_handler.begin_active(),
-      endc = saturation_dof_handler.end();
-    for (; cell != endc; ++cell)
+    for (const auto &cell : saturation_dof_handler.active_cell_iterators())
       {
         double max_local_mobility_reciprocal_difference = 0.0;
         double max_local_permeability_inverse_l1_norm   = 0.0;
@@ -1978,12 +1958,9 @@ namespace Step43
 
     double max_velocity_times_dF_dS = 0;
 
-    typename DoFHandler<dim>::active_cell_iterator cell = darcy_dof_handler
-                                                            .begin_active(),
-                                                   endc =
-                                                     darcy_dof_handler.end();
-    typename DoFHandler<dim>::active_cell_iterator saturation_cell =
-      saturation_dof_handler.begin_active();
+    auto       cell            = darcy_dof_handler.begin_active();
+    const auto endc            = darcy_dof_handler.end();
+    auto       saturation_cell = saturation_dof_handler.begin_active();
     for (; cell != endc; ++cell, ++saturation_cell)
       {
         darcy_fe_values.reinit(cell);
@@ -2038,10 +2015,7 @@ namespace Step43
         double min_saturation = std::numeric_limits<double>::max(),
                max_saturation = -std::numeric_limits<double>::max();
 
-        typename DoFHandler<dim>::active_cell_iterator
-          cell = saturation_dof_handler.begin_active(),
-          endc = saturation_dof_handler.end();
-        for (; cell != endc; ++cell)
+        for (const auto &cell : saturation_dof_handler.active_cell_iterators())
           {
             fe_values.reinit(cell);
             fe_values.get_function_values(old_saturation_solution,
@@ -2067,10 +2041,7 @@ namespace Step43
         double min_saturation = std::numeric_limits<double>::max(),
                max_saturation = -std::numeric_limits<double>::max();
 
-        typename DoFHandler<dim>::active_cell_iterator
-          cell = saturation_dof_handler.begin_active(),
-          endc = saturation_dof_handler.end();
-        for (; cell != endc; ++cell)
+        for (const auto &cell : saturation_dof_handler.active_cell_iterators())
           {
             fe_values.reinit(cell);
             fe_values.get_function_values(old_saturation_solution,

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.