From: Wolfgang Bangerth Date: Tue, 3 Mar 2020 22:24:38 +0000 (-0700) Subject: Convert a lot of places to range-based loops over all active cells. X-Git-Tag: v9.2.0-rc1~446^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F9607%2Fhead;p=dealii.git Convert a lot of places to range-based loops over all active cells. --- diff --git a/include/deal.II/numerics/vector_tools.templates.h b/include/deal.II/numerics/vector_tools.templates.h index ce59c09993..229f111e82 100644 --- a/include/deal.II/numerics/vector_tools.templates.h +++ b/include/deal.II/numerics/vector_tools.templates.h @@ -2824,10 +2824,7 @@ namespace VectorTools // individual vertices if (dim == 1) { - for (typename DoFHandlerType::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::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::active_cell_iterator - cell = dof.begin_active(); - cell != dof.end(); - ++cell) + for (const auto &cell : dof.active_cell_iterators()) for (auto f : GeometryInfo::face_indices()) { if (cell->at_boundary(f)) @@ -6651,10 +6645,7 @@ namespace VectorTools { case 2: { - for (typename DoFHandler::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::face_indices()) @@ -6723,10 +6714,7 @@ namespace VectorTools for (unsigned int dof = 0; dof < n_dofs; ++dof) projected_dofs[dof] = 0; - for (typename DoFHandler::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::face_indices()) @@ -6828,10 +6816,7 @@ namespace VectorTools { case 2: { - for (typename hp::DoFHandler::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::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::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::face_indices()) @@ -7641,10 +7623,7 @@ namespace VectorTools std::set::iterator b_id; std::vector> cell_vector_dofs; - 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 (!cell->is_artificial()) for (const unsigned int face_no : GeometryInfo::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 diff --git a/source/distributed/grid_refinement.cc b/source/distributed/grid_refinement.cc index e5aeeb0b21..2775af5ac2 100644 --- a/source/distributed/grid_refinement.cc +++ b/source/distributed/grid_refinement.cc @@ -110,10 +110,7 @@ namespace ExcInternalError()); unsigned int owned_index = 0; - for (typename Triangulation::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::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(); diff --git a/source/distributed/tria.cc b/source/distributed/tria.cc index 7a3e41e09b..035b5cca94 100644 --- a/source/distributed/tria.cc +++ b/source/distributed/tria.cc @@ -54,10 +54,7 @@ namespace vertex_touch_count.resize(triangulation.n_vertices()); vertex_to_cell.resize(triangulation.n_vertices()); - for (typename Triangulation::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::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::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::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::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::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::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::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::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::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::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::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::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::repartition() { # ifdef DEBUG - for (typename Triangulation::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(), diff --git a/source/distributed/tria_base.cc b/source/distributed/tria_base.cc index d7649afc07..7117d6f2ac 100644 --- a/source/distributed/tria_base.cc +++ b/source/distributed/tria_base.cc @@ -193,10 +193,7 @@ namespace parallel { // find ghost owners - for (typename Triangulation::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::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; diff --git a/source/dofs/dof_handler_policy.cc b/source/dofs/dof_handler_policy.cc index 9306e7a96e..178ad1207d 100644 --- a/source/dofs/dof_handler_policy.cc +++ b/source/dofs/dof_handler_policy.cc @@ -764,10 +764,7 @@ namespace internal dealii::Table<2, std::unique_ptr> line_dof_identities( dof_handler.fe_collection.size(), dof_handler.fe_collection.size()); - for (typename hp::DoFHandler::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::lines_per_cell; ++l) if (cell->line(l)->user_flag_set() == false) { @@ -1128,10 +1125,7 @@ namespace internal dealii::Table<2, std::unique_ptr> quad_dof_identities( dof_handler.fe_collection.size(), dof_handler.fe_collection.size()); - for (typename hp::DoFHandler::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::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> line_dof_identities( dof_handler.fe_collection.size(), dof_handler.fe_collection.size()); - for (typename hp::DoFHandler::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::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> quad_dof_identities( dof_handler.fe_collection.size(), dof_handler.fe_collection.size()); - for (typename hp::DoFHandler::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::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 & dof_handler) { - for (typename hp::DoFHandler::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::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::lines_per_cell; ++l) @@ -2840,10 +2822,7 @@ namespace internal dof_handler.get_triangulation()) .clear_user_flags_line(); - for (typename hp::DoFHandler::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::lines_per_cell; ++l) @@ -2923,10 +2902,7 @@ namespace internal dof_handler.get_triangulation()) .clear_user_flags_quad(); - for (typename hp::DoFHandler::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::quads_per_cell; ++q) diff --git a/source/dofs/dof_tools.cc b/source/dofs/dof_tools.cc index 2324dfc250..55f4c3553c 100644 --- a/source/dofs/dof_tools.cc +++ b/source/dofs/dof_tools.cc @@ -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::face_indices()) if (cell->at_boundary(face)) diff --git a/source/dofs/dof_tools_constraints.cc b/source/dofs/dof_tools_constraints.cc index 8f7a4a34aa..6f3258f4ad 100644 --- a/source/dofs/dof_tools_constraints.cc +++ b/source/dofs/dof_tools_constraints.cc @@ -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::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 local_dof_indices( fine_fe.dofs_per_cell); - for (typename dealii::DoFHandler::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 local_dof_indices( fine_fe.dofs_per_cell); unsigned int next_free_index = 0; - for (typename dealii::DoFHandler::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); diff --git a/source/grid/grid_generator.cc b/source/grid/grid_generator.cc index eb6c9488c5..ca7eaed285 100644 --- a/source/grid/grid_generator.cc +++ b/source/grid/grid_generator.cc @@ -6100,10 +6100,7 @@ namespace GridGenerator intergrid_map.make_mapping(result, triangulation_2); bool any_cell_flagged = false; - for (typename Triangulation::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> cells; - for (typename Triangulation::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(cell->level()) == diff --git a/source/grid/grid_in.cc b/source/grid/grid_in.cc index 810b8b03de..cf8639fc6e 100644 --- a/source/grid/grid_in.cc +++ b/source/grid/grid_in.cc @@ -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()) { diff --git a/source/grid/grid_refinement.cc b/source/grid/grid_refinement.cc index 93dc2350eb..641eb8eae5 100644 --- a/source/grid/grid_refinement.cc +++ b/source/grid/grid_refinement.cc @@ -70,10 +70,7 @@ GridRefinement::refine(Triangulation &tria, } unsigned int marked = 0; - for (typename Triangulation::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 &tria, ExcDimensionMismatch(criteria.size(), tria.n_active_cells())); Assert(criteria.is_non_negative(), ExcNegativeCriteria()); - for (typename Triangulation::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(); diff --git a/source/grid/grid_tools.cc b/source/grid/grid_tools.cc index 8242cf1729..4a4cee06be 100644 --- a/source/grid/grid_tools.cc +++ b/source/grid/grid_tools.cc @@ -1303,10 +1303,7 @@ namespace GridTools const bool is_parallel_shared = (dynamic_cast *>( &triangulation) != nullptr); - for (typename Triangulation::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 vertex_moved(triangulation.n_vertices(), false); // Next move vertices on locally owned cells - for (typename Triangulation::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::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::vertex_indices()) cell->vertex(vertex_no) = @@ -2783,10 +2774,7 @@ namespace GridTools { std::vector> vertex_to_cell( triangulation.n_vertices()); - for (typename Triangulation::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::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::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::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::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::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::active_cell_iterator cell = - tria.begin_active(); - cell != tria.end(); - ++cell) + for (const auto &cell : tria.active_cell_iterators()) for (auto f : GeometryInfo::face_indices()) if (cell->face(f)->at_boundary()) for (unsigned int e = 0; e < GeometryInfo::lines_per_face; ++e) @@ -3905,10 +3881,7 @@ namespace GridTools } // now do cells - for (typename Triangulation::active_cell_iterator cell = - tria.begin_active(); - cell != tria.end(); - ++cell) + for (const auto &cell : tria.active_cell_iterators()) for (auto f : GeometryInfo::face_indices()) if (cell->face(f)->at_boundary()) { diff --git a/source/grid/grid_tools_dof_handlers.cc b/source/grid/grid_tools_dof_handlers.cc index 212df3ea3d..41f794208a 100644 --- a/source/grid/grid_tools_dof_handlers.cc +++ b/source/grid/grid_tools_dof_handlers.cc @@ -1563,12 +1563,8 @@ namespace GridTools do { refinement_necessary = false; - for (typename Triangulation:: - 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()) { diff --git a/source/grid/tria.cc b/source/grid/tria.cc index c2779e938d..bce97ba251 100644 --- a/source/grid/tria.cc +++ b/source/grid/tria.cc @@ -435,10 +435,7 @@ namespace std::vector max_adjacent_cell_level( triangulation.n_vertices(), 0); - for (typename Triangulation::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::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::active_cell_iterator cell = - triangulation.begin_active(); - cell != triangulation.end(); - ++cell) + for (const auto &cell : triangulation.active_cell_iterators()) for (auto f : GeometryInfo::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::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::lines_per_cell; diff --git a/source/hp/dof_handler.cc b/source/hp/dof_handler.cc index 879dad4f44..1aab77699f 100644 --- a/source/hp/dof_handler.cc +++ b/source/hp/dof_handler.cc @@ -173,10 +173,7 @@ namespace internal // first std::vector locally_used_vertices( dof_handler.tria->n_vertices(), false); - for (typename HpDoFHandler::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::vertex_indices()) locally_used_vertices[cell->vertex_index(v)] = true; @@ -185,10 +182,7 @@ namespace internal dof_handler.fe_collection.size(), std::vector(dof_handler.tria->n_vertices(), false)); - for (typename HpDoFHandler::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::vertex_indices()) vertex_fe_association[cell->active_fe_index()] @@ -771,10 +765,7 @@ namespace internal dof_handler.fe_collection.size(), std::vector(dof_handler.tria->n_raw_lines(), false)); - for (typename HpDoFHandler::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::lines_per_cell; ++l) diff --git a/source/numerics/error_estimator_1d.cc b/source/numerics/error_estimator_1d.cc index 5ac42f8945..b63f26045e 100644 --- a/source/numerics/error_estimator_1d.cc +++ b/source/numerics/error_estimator_1d.cc @@ -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) || diff --git a/source/numerics/solution_transfer.cc b/source/numerics/solution_transfer.cc index 5e453f04cb..87b2e313bb 100644 --- a/source/numerics/solution_transfer.cc +++ b/source/numerics/solution_transfer.cc @@ -291,10 +291,7 @@ SolutionTransfer:: // 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;