]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Replace some loops
authorDaniel Arndt <arndtd@ornl.gov>
Mon, 6 Apr 2020 17:30:26 +0000 (13:30 -0400)
committerDaniel Arndt <arndtd@ornl.gov>
Mon, 6 Apr 2020 20:28:10 +0000 (16:28 -0400)
16 files changed:
include/deal.II/differentiation/ad/ad_helpers.h
include/deal.II/lac/affine_constraints.templates.h
include/deal.II/lac/la_parallel_vector.templates.h
include/deal.II/lac/relaxation_block.templates.h
include/deal.II/lac/sparse_vanka.templates.h
include/deal.II/matrix_free/face_setup_internal.h
include/deal.II/matrix_free/matrix_free.templates.h
include/deal.II/matrix_free/operators.h
include/deal.II/meshworker/integration_info.templates.h
include/deal.II/multigrid/mg_transfer.templates.h
include/deal.II/numerics/data_out_dof_data.templates.h
source/differentiation/ad/ad_helpers.cc
source/grid/grid_in.cc
source/hp/dof_handler.cc
source/multigrid/mg_level_global_transfer.cc
source/numerics/point_value_history.cc

index f8c6ec810eaaa565578e9c8b5ba133bf5e6068a5..a7271a41e31beec11b6408f5063339b85267c7c0 100644 (file)
@@ -3794,10 +3794,10 @@ namespace Differentiation
 #    ifdef DEBUG
       const std::vector<unsigned int> index_set(
         internal::extract_field_component_indices<dim>(extractor));
-      for (unsigned int i = 0; i < index_set.size(); ++i)
+      for (const unsigned int index : index_set)
         {
           Assert(
-            this->registered_independent_variable_values[index_set[i]] == false,
+            this->registered_independent_variable_values[index] == false,
             ExcMessage(
               "Overlapping indices for independent variables. "
               "One or more indices associated with the field that "
index 73460313f985990fe791f46a80cab1439078fee9..5712424ca784d98a95aa6e5598537bba1c40962e 100644 (file)
@@ -2539,14 +2539,14 @@ namespace internals
          << "Constr rows " << n_constraints() << std::endl
          << "Inhom  rows " << n_inhomogeneous_rows << std::endl
          << "Local: ";
-      for (size_type i = 0; i < total_row_indices.size(); ++i)
-        os << ' ' << std::setw(4) << total_row_indices[i].local_row;
+      for (const auto &total_row_index : total_row_indices)
+        os << ' ' << std::setw(4) << total_row_index.local_row;
       os << std::endl << "Global:";
-      for (size_type i = 0; i < total_row_indices.size(); ++i)
-        os << ' ' << std::setw(4) << total_row_indices[i].global_row;
+      for (const auto &total_row_index : total_row_indices)
+        os << ' ' << std::setw(4) << total_row_index.global_row;
       os << std::endl << "ConPos:";
-      for (size_type i = 0; i < total_row_indices.size(); ++i)
-        os << ' ' << std::setw(4) << total_row_indices[i].constraint_position;
+      for (const auto &total_row_index : total_row_indices)
+        os << ' ' << std::setw(4) << total_row_index.constraint_position;
       os << std::endl;
     }
 
index e5ad13c72064349913a4b2c2f32235c397240499..b9d8215a4aff555adeec485d17d3f33b7c3586e5 100644 (file)
@@ -381,15 +381,15 @@ namespace LinearAlgebra
     Vector<Number, MemorySpaceType>::clear_mpi_requests()
     {
 #ifdef DEAL_II_WITH_MPI
-      for (size_type j = 0; j < compress_requests.size(); j++)
+      for (auto &compress_request : compress_requests)
         {
-          const int ierr = MPI_Request_free(&compress_requests[j]);
+          const int ierr = MPI_Request_free(&compress_request);
           AssertThrowMPI(ierr);
         }
       compress_requests.clear();
-      for (size_type j = 0; j < update_ghost_values_requests.size(); j++)
+      for (auto &update_ghost_values_request : update_ghost_values_requests)
         {
-          const int ierr = MPI_Request_free(&update_ghost_values_requests[j]);
+          const int ierr = MPI_Request_free(&update_ghost_values_request);
           AssertThrowMPI(ierr);
         }
       update_ghost_values_requests.clear();
index 997ea0a4429d385d2e285173e863589e4d59f685..6f74fff16621b1abf21b75f552eea7d18f75788c 100644 (file)
@@ -49,11 +49,8 @@ inline std::size_t
 RelaxationBlock<MatrixType, InverseNumberType, VectorType>::AdditionalData::
   memory_consumption() const
 {
-  std::size_t result =
-    sizeof(*this) + block_list.memory_consumption() - sizeof(block_list);
-  for (unsigned int i = 0; i < order.size(); ++i)
-    result += MemoryConsumption::memory_consumption(order[i]);
-  return result;
+  return sizeof(*this) + block_list.memory_consumption() - sizeof(block_list) +
+         MemoryConsumption::memory_consumption(order);
 }
 
 
index 1b2f3dd564f271d70137748480be7eade904fe2a..66b721b9e9149ae721e6ff0ef688e81ddda123f7 100644 (file)
@@ -654,10 +654,8 @@ template <typename number>
 std::size_t
 SparseBlockVanka<number>::memory_consumption() const
 {
-  std::size_t mem = SparseVanka<number>::memory_consumption();
-  for (size_type i = 0; i < dof_masks.size(); ++i)
-    mem += MemoryConsumption::memory_consumption(dof_masks[i]);
-  return mem;
+  return SparseVanka<number>::memory_consumption() +
+         MemoryConsumption::memory_consumption(dof_masks);
 }
 
 
index 2ad4ab8437eb127af5a41852dbac06adae01f1ce..01c2d3145a0d7ef263c037d977cc5c9857d9446b 100644 (file)
@@ -738,9 +738,9 @@ namespace internal
                                     cells_close_to_boundary.end());
       std::vector<unsigned int> final_cells;
       final_cells.reserve(cells_close_to_boundary.size());
-      for (unsigned int i = 0; i < cells_close_to_boundary.size(); ++i)
-        if (at_processor_boundary[cells_close_to_boundary[i]] == false)
-          final_cells.push_back(cells_close_to_boundary[i]);
+      for (const unsigned int cell : cells_close_to_boundary)
+        if (at_processor_boundary[cell] == false)
+          final_cells.push_back(cell);
       cells_close_to_boundary = std::move(final_cells);
     }
 
index d2ca43976c26c7138b53f0a05b61fdde11ef1667..fc0b4670edbfe18e4b684dd752630a4dac6cbb4e 100644 (file)
@@ -1190,8 +1190,8 @@ MatrixFree<dim, Number, VectorizedArrayType>::initialize_indices(
         additional_data.cell_vectorization_categories_strict ||
         dof_handlers.active_dof_handler == DoFHandlers::hp;
       unsigned int dofs_per_cell = 0;
-      for (unsigned int no = 0; no < dof_info.size(); ++no)
-        dofs_per_cell = std::max(dofs_per_cell, dof_info[no].dofs_per_cell[0]);
+      for (const auto &info : dof_info)
+        dofs_per_cell = std::max(dofs_per_cell, info.dofs_per_cell[0]);
       task_info.create_blocks_serial(subdomain_boundary_cells,
                                      face_setup.cells_close_to_boundary,
                                      dofs_per_cell,
index b30f77691f6531a7166f9b38ef0d1dc83ab263f4..e5e771dbc1c2b7c78ad1219933177a12cca57628 100644 (file)
@@ -1101,8 +1101,8 @@ namespace MatrixFreeOperators
     Assert(data.get() != nullptr, ExcNotInitialized());
     typename Base<dim, VectorType, VectorizedArrayType>::size_type total_size =
       0;
-    for (unsigned int i = 0; i < selected_rows.size(); ++i)
-      total_size += data->get_vector_partitioner(selected_rows[i])->size();
+    for (const unsigned int selected_row : selected_rows)
+      total_size += data->get_vector_partitioner(selected_row)->size();
     return total_size;
   }
 
@@ -1115,8 +1115,8 @@ namespace MatrixFreeOperators
     Assert(data.get() != nullptr, ExcNotInitialized());
     typename Base<dim, VectorType, VectorizedArrayType>::size_type total_size =
       0;
-    for (unsigned int i = 0; i < selected_columns.size(); ++i)
-      total_size += data->get_vector_partitioner(selected_columns[i])->size();
+    for (const unsigned int selected_column : selected_columns)
+      total_size += data->get_vector_partitioner(selected_column)->size();
     return total_size;
   }
 
index c310b5629f54bf13cccf04726fcf771f141f92d6..195f3cedbf291bb47f7a5687345c6a291d13d35d 100644 (file)
@@ -38,41 +38,38 @@ namespace MeshWorker
     const unsigned int nqp = fevalv[0]->n_quadrature_points;
 
     values.resize(global_data->n_values());
-    // For all selected finite
-    // element functions
-    for (unsigned int i = 0; i < values.size(); ++i)
+    // For all selected finite element functions
+    for (auto &function_values : values)
       {
-        values[i].resize(n_components);
+        function_values.resize(n_components);
         // For all components
-        for (unsigned int j = 0; j < values[i].size(); ++j)
+        for (auto &component_values : function_values)
           {
-            values[i][j].resize(nqp);
+            component_values.resize(nqp);
           }
       }
 
     gradients.resize(global_data->n_gradients());
-    // For all selected finite
-    // element functions
-    for (unsigned int i = 0; i < gradients.size(); ++i)
+    // For all selected finite element functions
+    for (auto &function_gradients : gradients)
       {
-        gradients[i].resize(n_components);
+        function_gradients.resize(n_components);
         // For all components
-        for (unsigned int j = 0; j < gradients[i].size(); ++j)
+        for (auto &component_gradients : function_gradients)
           {
-            gradients[i][j].resize(nqp);
+            component_gradients.resize(nqp);
           }
       }
 
     hessians.resize(global_data->n_hessians());
-    // For all selected finite
-    // element functions
-    for (unsigned int i = 0; i < hessians.size(); ++i)
+    // For all selected finite element functions
+    for (auto &function_hessians : hessians)
       {
-        hessians[i].resize(n_components);
+        function_hessians.resize(n_components);
         // For all components
-        for (unsigned int j = 0; j < hessians[i].size(); ++j)
+        for (auto &component_hessians : function_hessians)
           {
-            hessians[i][j].resize(nqp);
+            component_hessians.resize(nqp);
           }
       }
   }
index 0158b6310b03b3a98fd9a448b3b4fa72dd38e63a..df58561dfe2068cc6d9c5c259c0105cf526a68bd 100644 (file)
@@ -247,17 +247,13 @@ MGLevelGlobalTransfer<VectorType>::copy_to_mg(
       VectorType &dst_level = dst[level];
 
       // first copy local unknowns
-      for (dof_pair_iterator i = copy_indices[level].begin();
-           i != copy_indices[level].end();
-           ++i)
-        dst_level(i->second) = src(i->first);
+      for (const auto &copy_index : copy_indices[level])
+        dst_level(copy_index.second) = src(copy_index.first);
 
       // Do the same for the indices where the global index is local, but the
       // local index is not
-      for (dof_pair_iterator i = copy_indices_global_mine[level].begin();
-           i != copy_indices_global_mine[level].end();
-           ++i)
-        dst_level(i->second) = src(i->first);
+      for (const auto &copy_index : copy_indices_global_mine[level])
+        dst_level(copy_index.second) = src(copy_index.first);
 
       dst_level.compress(VectorOperation::insert);
 
@@ -314,17 +310,13 @@ MGLevelGlobalTransfer<VectorType>::copy_from_mg(
       const VectorType &src_level = src[level];
 
       // First copy all indices local to this process
-      for (dof_pair_iterator i = copy_indices[level].begin();
-           i != copy_indices[level].end();
-           ++i)
-        dst(i->first) = src_level(i->second);
+      for (const auto &copy_index : copy_indices[level])
+        dst(copy_index.first) = src_level(copy_index.second);
 
       // Do the same for the indices where the level index is local, but the
       // global index is not
-      for (dof_pair_iterator i = copy_indices_level_mine[level].begin();
-           i != copy_indices_level_mine[level].end();
-           ++i)
-        dst(i->first) = src_level(i->second);
+      for (const auto &copy_index : copy_indices_level_mine[level])
+        dst(copy_index.first) = src_level(copy_index.second);
 
 #ifdef DEBUG_OUTPUT
       {
@@ -366,17 +358,13 @@ MGLevelGlobalTransfer<VectorType>::copy_from_mg_add(
       const VectorType &src_level = src[level];
 
       // First add all indices local to this process
-      for (dof_pair_iterator i = copy_indices[level].begin();
-           i != copy_indices[level].end();
-           ++i)
-        dst(i->first) += src_level(i->second);
+      for (const auto &copy_index : copy_indices[level])
+        dst(copy_index.first) += src_level(copy_index.second);
 
       // Do the same for the indices where the level index is local, but the
       // global index is not
-      for (dof_pair_iterator i = copy_indices_level_mine[level].begin();
-           i != copy_indices_level_mine[level].end();
-           ++i)
-        dst(i->first) += src_level(i->second);
+      for (const auto &copy_index : copy_indices_level_mine[level])
+        dst(copy_index.first) += src_level(copy_index.second);
     }
   dst.compress(VectorOperation::add);
 }
index d9d4a3071e2aa73f039644e1b188486ee0d18330..6ad298b399dc350750160edcd5edb3909fd3ddad 100644 (file)
@@ -493,16 +493,15 @@ namespace internal
                                   names.size()));
 
       // check that the names use only allowed characters
-      for (unsigned int i = 0; i < names.size(); ++i)
-        Assert(names[i].find_first_not_of("abcdefghijklmnopqrstuvwxyz"
-                                          "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
-                                          "0123456789_<>()") ==
-                 std::string::npos,
+      for (const auto &name : names)
+        Assert(name.find_first_not_of("abcdefghijklmnopqrstuvwxyz"
+                                      "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+                                      "0123456789_<>()") == std::string::npos,
                Exceptions::DataOutImplementation::ExcInvalidCharacter(
-                 names[i],
-                 names[i].find_first_not_of("abcdefghijklmnopqrstuvwxyz"
-                                            "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
-                                            "0123456789_<>()")));
+                 name,
+                 name.find_first_not_of("abcdefghijklmnopqrstuvwxyz"
+                                        "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+                                        "0123456789_<>()")));
     }
 
 
@@ -531,16 +530,15 @@ namespace internal
                data_postprocessor->get_data_component_interpretation().size()));
 
       // check that the names use only allowed characters
-      for (unsigned int i = 0; i < names.size(); ++i)
-        Assert(names[i].find_first_not_of("abcdefghijklmnopqrstuvwxyz"
-                                          "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
-                                          "0123456789_<>()") ==
-                 std::string::npos,
+      for (const auto &name : names)
+        Assert(name.find_first_not_of("abcdefghijklmnopqrstuvwxyz"
+                                      "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+                                      "0123456789_<>()") == std::string::npos,
                Exceptions::DataOutImplementation::ExcInvalidCharacter(
-                 names[i],
-                 names[i].find_first_not_of("abcdefghijklmnopqrstuvwxyz"
-                                            "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
-                                            "0123456789_<>()")));
+                 name,
+                 name.find_first_not_of("abcdefghijklmnopqrstuvwxyz"
+                                        "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+                                        "0123456789_<>()")));
     }
 
 
index 2fea29d658c6c7a51baeb2292e1c902180d12846..392fa59555b1afa033c3b4632222212ca671c30e 100644 (file)
@@ -81,11 +81,9 @@ namespace Differentiation
     HelperBase<ADNumberTypeCode,
                ScalarType>::reset_registered_independent_variables()
     {
-      for (typename std::vector<bool>::iterator it =
-             registered_independent_variable_values.begin();
-           it != registered_independent_variable_values.end();
-           ++it)
-        *it = false;
+      for (auto &&registered_independent_variable_value :
+           registered_independent_variable_values)
+        registered_independent_variable_value = false;
     }
 
 
@@ -95,11 +93,9 @@ namespace Differentiation
     HelperBase<ADNumberTypeCode, ScalarType>::
       reset_registered_dependent_variables(const bool flag)
     {
-      for (typename std::vector<bool>::iterator it =
-             registered_marked_dependent_variables.begin();
-           it != registered_marked_dependent_variables.end();
-           ++it)
-        *it = flag;
+      for (auto &&registered_marked_dependent_variable :
+           registered_marked_dependent_variables)
+        registered_marked_dependent_variable = flag;
     }
 
 
index cf8639fc6e6ef7398c386ce5fa953f8dc0a63dd6..cdc599a05f02a1c18a5552f1e6fe06c3e79bbae0 100644 (file)
@@ -4032,18 +4032,18 @@ namespace
 
     // Write out node numbers
     // Loop over all nodes
-    for (unsigned int ii = 0; ii < node_list.size(); ++ii)
+    for (const auto &node : node_list)
       {
         // Node number
-        output << node_list[ii][0] << "\t";
+        output << node[0] << "\t";
 
         // Node coordinates
         output.setf(std::ios::scientific, std::ios::floatfield);
         for (unsigned int jj = 1; jj < spacedim + 1; ++jj)
           {
             // invoke tolerance -> set points close to zero equal to zero
-            if (std::abs(node_list[ii][jj]) > tolerance)
-              output << static_cast<double>(node_list[ii][jj]) << "\t";
+            if (std::abs(node[jj]) > tolerance)
+              output << static_cast<double>(node[jj]) << "\t";
             else
               output << 0.0 << "\t";
           }
index fb2ced901c7e4fbb90977a237d36f4aed8992e2c..2431997e41096e3cfbdf5de45e7dda09fcb04dfd 100644 (file)
@@ -1520,8 +1520,8 @@ namespace hp
        MemoryConsumption::memory_consumption(number_cache) +
        MemoryConsumption::memory_consumption(vertex_dofs) +
        MemoryConsumption::memory_consumption(vertex_dof_offsets));
-    for (unsigned int i = 0; i < levels.size(); ++i)
-      mem += MemoryConsumption::memory_consumption(*levels[i]);
+    for (const auto &level : levels)
+      mem += MemoryConsumption::memory_consumption(*level);
     mem += MemoryConsumption::memory_consumption(*faces);
 
     return mem;
index 964f1a9d13efd4bb74c643eb287eb8531cd29989..db089eaabe26529a5e67fab4883baac7e21358b6 100644 (file)
@@ -73,8 +73,8 @@ MGLevelGlobalTransfer<VectorType>::fill_and_communicate_copy_indices(
       // check whether there is a renumbering of degrees of freedom on
       // either the finest level or the global dofs, which means that we
       // cannot apply a plain copy
-      for (unsigned int i = 0; i < copy_indices.back().size(); ++i)
-        if (copy_indices.back()[i].first != copy_indices.back()[i].second)
+      for (const auto &copy_index : copy_indices.back())
+        if (copy_index.first != copy_index.second)
           {
             my_perform_plain_copy = false;
             break;
index 89445ff029d153143adb54aaa682ab05684c86bd..fe0cd668f3dcf79e80b6271a6c5b51c2720af8b1 100644 (file)
@@ -304,17 +304,13 @@ PointValueHistory<dim>::add_point(const Point<dim> &location)
     new_point_geometry_data(location, current_points, new_solution_indices);
   point_geometry_data.push_back(new_point_geometry_data);
 
-  std::map<std::string, std::vector<std::vector<double>>>::iterator
-    data_store_begin = data_store.begin();
-  for (; data_store_begin != data_store.end(); ++data_store_begin)
+  for (auto &data_entry : data_store)
     {
-      // add an extra row to each vector
-      // entry
+      // add an extra row to each vector entry
       const ComponentMask &current_mask =
-        (component_mask.find(data_store_begin->first))->second;
+        (component_mask.find(data_entry.first))->second;
       unsigned int n_stored = current_mask.n_selected_components();
-      data_store_begin->second.resize(data_store_begin->second.size() +
-                                      n_stored);
+      data_entry.second.resize(data_entry.second.size() + n_stored);
     }
 }
 
@@ -444,17 +440,13 @@ PointValueHistory<dim>::add_points(const std::vector<Point<dim>> &locations)
 
       point_geometry_data.push_back(new_point_geometry_data);
 
-      std::map<std::string, std::vector<std::vector<double>>>::iterator
-        data_store_begin = data_store.begin();
-      for (; data_store_begin != data_store.end(); ++data_store_begin)
+      for (auto &data_entry : data_store)
         {
-          // add an extra row to each vector
-          // entry
+          // add an extra row to each vector entry
           const ComponentMask current_mask =
-            (component_mask.find(data_store_begin->first))->second;
+            (component_mask.find(data_entry.first))->second;
           unsigned int n_stored = current_mask.n_selected_components();
-          data_store_begin->second.resize(data_store_begin->second.size() +
-                                          n_stored);
+          data_entry.second.resize(data_entry.second.size() + n_stored);
         }
     }
 }
@@ -1023,9 +1015,9 @@ PointValueHistory<dim>::write_gnuplot(
 
       if (indep_names.size() > 0)
         {
-          for (unsigned int name = 0; name < indep_names.size(); name++)
+          for (const auto &indep_name : indep_names)
             {
-              to_gnuplot << "<" << indep_names[name] << "> ";
+              to_gnuplot << "<" << indep_name << "> ";
             }
           to_gnuplot << "\n";
         }
@@ -1127,9 +1119,9 @@ PointValueHistory<dim>::write_gnuplot(
 
           if (indep_names.size() > 0)
             {
-              for (unsigned int name = 0; name < indep_names.size(); name++)
+              for (const auto &indep_name : indep_names)
                 {
-                  to_gnuplot << "<" << indep_names[name] << "> ";
+                  to_gnuplot << "<" << indep_name << "> ";
                 }
             }
           else
@@ -1140,16 +1132,13 @@ PointValueHistory<dim>::write_gnuplot(
                 }
             }
 
-          for (std::map<std::string, std::vector<std::vector<double>>>::iterator
-                 data_store_begin = data_store.begin();
-               data_store_begin != data_store.end();
-               ++data_store_begin)
+          for (const auto &data_entry : data_store)
             {
               typename std::map<std::string, ComponentMask>::iterator mask =
-                component_mask.find(data_store_begin->first);
+                component_mask.find(data_entry.first);
               unsigned int n_stored = mask->second.n_selected_components();
               std::vector<std::string> names =
-                (component_names_map.find(data_store_begin->first))->second;
+                (component_names_map.find(data_entry.first))->second;
 
               if (names.size() > 0)
                 {
@@ -1165,8 +1154,8 @@ PointValueHistory<dim>::write_gnuplot(
                   for (unsigned int component = 0; component < n_stored;
                        component++)
                     {
-                      to_gnuplot << "<" << data_store_begin->first << "_"
-                                 << component << "> ";
+                      to_gnuplot << "<" << data_entry.first << "_" << component
+                                 << "> ";
                     }
                 }
             }
@@ -1182,14 +1171,10 @@ PointValueHistory<dim>::write_gnuplot(
                   to_gnuplot << " " << independent_values[component][key];
                 }
 
-              for (std::map<std::string,
-                            std::vector<std::vector<double>>>::iterator
-                     data_store_begin = data_store.begin();
-                   data_store_begin != data_store.end();
-                   ++data_store_begin)
+              for (const auto &data_entry : data_store)
                 {
                   typename std::map<std::string, ComponentMask>::iterator mask =
-                    component_mask.find(data_store_begin->first);
+                    component_mask.find(data_entry.first);
                   unsigned int n_stored = mask->second.n_selected_components();
 
                   for (unsigned int component = 0; component < n_stored;
@@ -1197,9 +1182,8 @@ PointValueHistory<dim>::write_gnuplot(
                     {
                       to_gnuplot
                         << " "
-                        << (data_store_begin
-                              ->second)[data_store_index * n_stored + component]
-                                       [key];
+                        << (data_entry.second)[data_store_index * n_stored +
+                                               component][key];
                     }
                 }
               to_gnuplot << "\n";
@@ -1377,9 +1361,9 @@ PointValueHistory<dim>::status(std::ostream &out)
       if (indep_names.size() > 0)
         {
           out << "Names: ";
-          for (unsigned int name = 0; name < indep_names.size(); name++)
+          for (const auto &indep_name : indep_names)
             {
-              out << "<" << indep_names[name] << "> ";
+              out << "<" << indep_name << "> ";
             }
           out << "\n";
         }
@@ -1389,17 +1373,15 @@ PointValueHistory<dim>::status(std::ostream &out)
       out << "No independent values stored\n";
     }
 
-  std::map<std::string, std::vector<std::vector<double>>>::iterator
-    data_store_begin = data_store.begin();
-  if (data_store_begin != data_store.end())
+  if (data_store.begin() != data_store.end())
     {
       out
         << "Mnemonic: data set size (mask size, n true components) : n data sets\n";
     }
-  for (; data_store_begin != data_store.end(); ++data_store_begin)
+  for (const auto &data_entry : data_store)
     {
       // Find field mnemonic
-      std::string vector_name = data_store_begin->first;
+      std::string vector_name = data_entry.first;
       typename std::map<std::string, ComponentMask>::iterator mask =
         component_mask.find(vector_name);
       Assert(mask != component_mask.end(),
@@ -1409,18 +1391,16 @@ PointValueHistory<dim>::status(std::ostream &out)
       Assert(component_names != component_names_map.end(),
              ExcMessage("vector_name not in class"));
 
-      if (data_store_begin->second.size() != 0)
+      if (data_entry.second.size() != 0)
         {
-          out << data_store_begin->first << ": "
-              << data_store_begin->second.size() << " (";
+          out << data_entry.first << ": " << data_entry.second.size() << " (";
           out << mask->second.size() << ", "
               << mask->second.n_selected_components() << ") : ";
-          out << (data_store_begin->second)[0].size() << "\n";
+          out << (data_entry.second)[0].size() << "\n";
         }
       else
         {
-          out << data_store_begin->first << ": "
-              << data_store_begin->second.size() << " (";
+          out << data_entry.first << ": " << data_entry.second.size() << " (";
           out << mask->second.size() << ", "
               << mask->second.n_selected_components() << ") : ";
           out << "No points added"
@@ -1457,14 +1437,12 @@ PointValueHistory<dim>::deep_check(const bool strict)
               return false;
             }
         }
-      std::map<std::string, std::vector<std::vector<double>>>::iterator
-        data_store_begin = data_store.begin();
       if (have_dof_handler)
         {
-          for (; data_store_begin != data_store.end(); ++data_store_begin)
+          for (const auto &data_entry : data_store)
             {
-              Assert(data_store_begin->second.size() > 0, ExcInternalError());
-              if ((data_store_begin->second)[0].size() != dataset_key.size())
+              Assert(data_entry.second.size() > 0, ExcInternalError());
+              if ((data_entry.second)[0].size() != dataset_key.size())
                 return false;
               // this loop only tests one
               // member for each name,
@@ -1487,13 +1465,11 @@ PointValueHistory<dim>::deep_check(const bool strict)
 
   if (have_dof_handler)
     {
-      std::map<std::string, std::vector<std::vector<double>>>::iterator
-        data_store_begin = data_store.begin();
-      for (; data_store_begin != data_store.end(); ++data_store_begin)
+      for (const auto &data_entry : data_store)
         {
-          Assert(data_store_begin->second.size() > 0, ExcInternalError());
+          Assert(data_entry.second.size() > 0, ExcInternalError());
 
-          if (std::abs(static_cast<int>((data_store_begin->second)[0].size()) -
+          if (std::abs(static_cast<int>((data_entry.second)[0].size()) -
                        static_cast<int>(dataset_key.size())) >= 2)
             return false;
           // this loop only tests one member

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.