From 9b2c0308c7123ce31e3a169f8800500c9ae4dae1 Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Sun, 6 Jan 2019 23:45:15 +0100 Subject: [PATCH] Use range-based for loops in source/hp --- source/hp/dof_handler.cc | 10 +++++----- source/hp/dof_level.cc | 7 +++---- source/hp/fe_collection.cc | 14 ++++++++++---- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/source/hp/dof_handler.cc b/source/hp/dof_handler.cc index d304971601..9d0e5c9e6f 100644 --- a/source/hp/dof_handler.cc +++ b/source/hp/dof_handler.cc @@ -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 &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); diff --git a/source/hp/dof_level.cc b/source/hp/dof_level.cc index ac20643ad1..94982880f5 100644 --- a/source/hp/dof_level.cc +++ b/source/hp/dof_level.cc @@ -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); } diff --git a/source/hp/fe_collection.cc b/source/hp/fe_collection.cc index ce980da3b6..616359767d 100644 --- a/source/hp/fe_collection.cc +++ b/source/hp/fe_collection.cc @@ -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 -- 2.39.5