From: Daniel Arndt Date: Mon, 6 Jan 2020 20:55:42 +0000 (+0100) Subject: Turn all for loops using "begin_active" into ranged-based ones X-Git-Tag: v9.2.0-rc1~702^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=859b78470b71a71e9460bd5314357380dac47748;p=dealii.git Turn all for loops using "begin_active" into ranged-based ones --- diff --git a/include/deal.II/fe/fe_values.h b/include/deal.II/fe/fe_values.h index 2b0e292ced..54ac66ad08 100644 --- a/include/deal.II/fe/fe_values.h +++ b/include/deal.II/fe/fe_values.h @@ -2020,9 +2020,7 @@ namespace FEValuesViews * * @code * FEValues values (mapping, finite_element, quadrature, flags); - * for (cell = dof_handler.begin_active(); - * cell != dof_handler.end(); - * ++cell) + * for (const auto &cell : dof_handler.active_cell_iterators()) * { * values.reinit(cell); * for (unsigned int q=0; q fe_eval (mapping, finite_element, * QGauss<1>(fe_degree+1), flags); - * for (cell = dof_handler.begin_active(); - * cell != dof_handler.end(); - * ++cell) + * for (const auto &cell : dof_handler.active_cell_iterators()) * { * fe_eval.reinit(cell); * for (unsigned int i=0; i::active_cell_iterator cell; - std::vector> values( + std::vector> values( quadrature.size(), Vector(dof.get_fe(0).n_components())); Number mean = Number(); typename numbers::NumberTraits::real_type area = 0.; // Compute mean value - for (cell = dof.begin_active(); cell != dof.end(); ++cell) + for (const auto &cell : dof.active_cell_iterators()) if (cell->is_locally_owned()) { fe.reinit(cell); diff --git a/source/dofs/dof_tools.cc b/source/dofs/dof_tools.cc index da3cb6402e..a266546eee 100644 --- a/source/dofs/dof_tools.cc +++ b/source/dofs/dof_tools.cc @@ -290,15 +290,13 @@ namespace DoFTools // then loop over all cells and do the work std::vector indices; - for (typename DoFHandlerType::active_cell_iterator c = dof.begin_active(); - c != dof.end(); - ++c) - if (c->is_locally_owned()) + for (const auto &cell : dof.active_cell_iterators()) + if (cell->is_locally_owned()) { - const unsigned int fe_index = c->active_fe_index(); - const unsigned int dofs_per_cell = c->get_fe().dofs_per_cell; + const unsigned int fe_index = cell->active_fe_index(); + const unsigned int dofs_per_cell = cell->get_fe().dofs_per_cell; indices.resize(dofs_per_cell); - c->get_dof_indices(indices); + cell->get_dof_indices(indices); for (unsigned int i = 0; i < dofs_per_cell; ++i) if (dof.locally_owned_dofs().is_element(indices[i])) dofs_by_block[dof.locally_owned_dofs().index_within_set( diff --git a/source/grid/grid_generator.cc b/source/grid/grid_generator.cc index 4285f5c816..2df876a43c 100644 --- a/source/grid/grid_generator.cc +++ b/source/grid/grid_generator.cc @@ -5458,9 +5458,7 @@ namespace GridGenerator // now copy the resulting level 1 cells into the new triangulation, cells.resize(tmp.n_active_cells(), CellData<3>()); - for (Triangulation<3>::active_cell_iterator cell = tmp.begin_active(); - cell != tmp.end(); - ++cell) + for (const auto &cell : tmp.active_cell_iterators()) { const unsigned int cell_index = cell->active_cell_index(); for (unsigned int v = 0; v < GeometryInfo<3>::vertices_per_cell; diff --git a/source/grid/grid_out.cc b/source/grid/grid_out.cc index 66874f19df..51704290a3 100644 --- a/source/grid/grid_out.cc +++ b/source/grid/grid_out.cc @@ -820,11 +820,6 @@ GridOut::write_dx(const Triangulation &tria, renumber[i] = new_number++; Assert(new_number == n_vertices, ExcInternalError()); - typename Triangulation::active_cell_iterator cell; - const typename Triangulation::active_cell_iterator endc = - tria.end(); - - // write the vertices out << "object \"vertices\" class array type float rank 1 shape " << dim << " items " << n_vertices << " data follows" << '\n'; @@ -850,7 +845,7 @@ GridOut::write_dx(const Triangulation &tria, << n_vertices_per_cell << " items " << n_cells << " data follows" << '\n'; - for (cell = tria.begin_active(); cell != endc; ++cell) + for (const auto &cell : tria.active_cell_iterators()) { for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; ++v) @@ -874,13 +869,13 @@ GridOut::write_dx(const Triangulation &tria, out << "object \"material\" class array type int rank 0 items " << n_cells << " data follows" << '\n'; - for (cell = tria.begin_active(); cell != endc; ++cell) + for (const auto &cell : tria.active_cell_iterators()) out << ' ' << cell->material_id(); out << '\n' << "attribute \"dep\" string \"connections\"" << '\n' << '\n'; out << "object \"level\" class array type int rank 0 items " << n_cells << " data follows" << '\n'; - for (cell = tria.begin_active(); cell != endc; ++cell) + for (const auto &cell : tria.active_cell_iterators()) out << ' ' << cell->level(); out << '\n' << "attribute \"dep\" string \"connections\"" << '\n' << '\n'; @@ -888,7 +883,7 @@ GridOut::write_dx(const Triangulation &tria, { out << "object \"measure\" class array type float rank 0 items " << n_cells << " data follows" << '\n'; - for (cell = tria.begin_active(); cell != endc; ++cell) + for (const auto &cell : tria.active_cell_iterators()) out << '\t' << cell->measure(); out << '\n' << "attribute \"dep\" string \"connections\"" << '\n' @@ -899,7 +894,7 @@ GridOut::write_dx(const Triangulation &tria, { out << "object \"diameter\" class array type float rank 0 items " << n_cells << " data follows" << '\n'; - for (cell = tria.begin_active(); cell != endc; ++cell) + for (const auto &cell : tria.active_cell_iterators()) out << '\t' << cell->diameter(); out << '\n' << "attribute \"dep\" string \"connections\"" << '\n' @@ -913,7 +908,7 @@ GridOut::write_dx(const Triangulation &tria, << n_vertices_per_face << " items " << n_faces << " data follows" << '\n'; - for (cell = tria.begin_active(); cell != endc; ++cell) + for (const auto &cell : tria.active_cell_iterators()) { for (unsigned int f = 0; f < GeometryInfo::faces_per_cell; ++f) { @@ -942,7 +937,7 @@ GridOut::write_dx(const Triangulation &tria, out << "object \"boundary\" class array type int rank 0 items " << n_faces << " data follows" << '\n'; - for (cell = tria.begin_active(); cell != endc; ++cell) + for (const auto &cell : tria.active_cell_iterators()) { // Little trick to get -1 for the interior for (unsigned int f = 0; f < GeometryInfo::faces_per_cell; ++f) @@ -959,7 +954,7 @@ GridOut::write_dx(const Triangulation &tria, { out << "object \"face measure\" class array type float rank 0 items " << n_faces << " data follows" << '\n'; - for (cell = tria.begin_active(); cell != endc; ++cell) + for (const auto &cell : tria.active_cell_iterators()) { for (unsigned int f = 0; f < GeometryInfo::faces_per_cell; ++f) @@ -973,7 +968,7 @@ GridOut::write_dx(const Triangulation &tria, { out << "object \"face diameter\" class array type float rank 0 items " << n_faces << " data follows" << '\n'; - for (cell = tria.begin_active(); cell != endc; ++cell) + for (const auto &cell : tria.active_cell_iterators()) { for (unsigned int f = 0; f < GeometryInfo::faces_per_cell; ++f) @@ -1054,11 +1049,6 @@ GridOut::write_msh(const Triangulation &tria, const unsigned int n_vertices = tria.n_used_vertices(); - typename Triangulation::active_cell_iterator cell = - tria.begin_active(); - const typename Triangulation::active_cell_iterator endc = - tria.end(); - // Write Header // The file format is: /* @@ -1148,7 +1138,7 @@ GridOut::write_msh(const Triangulation &tria, // write cells. Enumerate cells // consecutively, starting with 1 - for (cell = tria.begin_active(); cell != endc; ++cell) + for (const auto &cell : tria.active_cell_iterators()) { out << cell->active_cell_index() + 1 << ' ' << elm_type << ' ' << static_cast(cell->material_id()) << ' ' @@ -1201,11 +1191,6 @@ GridOut::write_ucd(const Triangulation &tria, const unsigned int n_vertices = tria.n_used_vertices(); - typename Triangulation::active_cell_iterator cell = - tria.begin_active(); - const typename Triangulation::active_cell_iterator endc = - tria.end(); - // write preamble if (ucd_flags.write_preamble) { @@ -1249,7 +1234,7 @@ GridOut::write_ucd(const Triangulation &tria, // write cells. Enumerate cells // consecutively, starting with 1 - for (cell = tria.begin_active(); cell != endc; ++cell) + for (const auto &cell : tria.active_cell_iterators()) { out << cell->active_cell_index() + 1 << ' ' << static_cast(cell->material_id()) << ' '; @@ -1398,10 +1383,7 @@ GridOut::write_xfig(const Triangulation<2> &tria, // on finer levels. Level 0 // corresponds to a depth of 900, // each level subtracting 1 - Triangulation::cell_iterator cell = tria.begin(); - const Triangulation::cell_iterator end = tria.end(); - - for (; cell != end; ++cell) + for (const auto &cell : tria.cell_iterators()) { // If depth is not encoded, write finest level only if (!xfig_flags.level_depth && !cell->active()) @@ -1813,9 +1795,7 @@ GridOut::write_svg(const Triangulation<2, 2> &tria, std::ostream &out) const y_max_perspective = projection_decomposition[1]; y_min_perspective = projection_decomposition[1]; - for (Triangulation<2, 2>::cell_iterator cell = tria.begin(); - cell != tria.end(); - ++cell) + for (const auto &cell : tria.cell_iterators()) { point[0] = cell->vertex(0)[0]; point[1] = cell->vertex(0)[1]; @@ -2124,10 +2104,7 @@ GridOut::write_svg(const Triangulation<2, 2> &tria, std::ostream &out) const for (unsigned int level_index = min_level; level_index <= max_level; level_index++) { - Triangulation<2, 2>::cell_iterator cell = tria.begin(level_index), - endc = tria.end(level_index); - - for (; cell != endc; ++cell) + for (const auto &cell : tria.cell_iterators_on_level(level_index)) { if (!svg_flags.convert_level_number_to_height && !cell->active()) continue; @@ -2841,12 +2818,8 @@ GridOut::write_mathgl(const Triangulation &tria, // run over all active cells and write out a list of // xyz-coordinates that correspond to vertices - typename dealii::Triangulation::active_cell_iterator - cell = tria.begin_active(), - endc = tria.end(); - // No global indices in deal.II, so we make one up here. - for (; cell != endc; ++cell) + for (const auto &cell : tria.active_cell_iterators()) { for (unsigned int i = 0; i < dim; ++i) { @@ -3341,8 +3314,7 @@ GridOut::write_mesh_per_processor_as_vtu( const unsigned int n_q_points = GeometryInfo::vertices_per_cell; - typename Triangulation::cell_iterator cell, endc; - for (cell = tria.begin(), endc = tria.end(); cell != endc; ++cell) + for (const auto &cell : tria.cell_iterators()) { if (!view_levels) { @@ -3512,8 +3484,7 @@ GridOut::n_boundary_faces(const Triangulation &tria) const typename Triangulation::active_face_iterator face, endf; unsigned int n_faces = 0; - for (face = tria.begin_active_face(), endf = tria.end_face(); face != endf; - ++face) + for (const auto &face : tria.active_face_iterators()) if ((face->at_boundary()) && (face->boundary_id() != 0)) n_faces++; @@ -3537,9 +3508,7 @@ GridOut::n_boundary_lines(const Triangulation &tria) const unsigned int n_lines = 0; - typename Triangulation::active_cell_iterator cell, endc; - - for (cell = tria.begin_active(), endc = tria.end(); cell != endc; ++cell) + for (const auto &cell : tria.active_cell_iterators()) for (unsigned int l = 0; l < GeometryInfo::lines_per_cell; ++l) if (cell->line(l)->at_boundary() && (cell->line(l)->boundary_id() != 0) && (cell->line(l)->user_flag_set() == false)) @@ -3635,10 +3604,8 @@ GridOut::write_msh_faces(const Triangulation &tria, std::ostream & out) const { unsigned int current_element_index = next_element_index; - typename Triangulation::active_face_iterator face, endf; - for (face = tria.begin_active_face(), endf = tria.end_face(); face != endf; - ++face) + for (const auto &face : tria.active_face_iterators()) if (face->at_boundary() && (face->boundary_id() != 0)) { out << current_element_index << ' '; @@ -3689,9 +3656,7 @@ GridOut::write_msh_lines(const Triangulation &tria, const_cast &>(tria) .clear_user_flags_line(); - typename Triangulation::active_cell_iterator cell, endc; - - for (cell = tria.begin_active(), endc = tria.end(); cell != endc; ++cell) + for (const auto &cell : tria.active_cell_iterators()) for (unsigned int l = 0; l < GeometryInfo::lines_per_cell; ++l) if (cell->line(l)->at_boundary() && (cell->line(l)->boundary_id() != 0) && (cell->line(l)->user_flag_set() == false)) @@ -3802,8 +3767,7 @@ GridOut::write_ucd_faces(const Triangulation &tria, unsigned int current_element_index = next_element_index; typename Triangulation::active_face_iterator face, endf; - for (face = tria.begin_active_face(), endf = tria.end_face(); face != endf; - ++face) + for (const auto &face : tria.active_face_iterators()) if (face->at_boundary() && (face->boundary_id() != 0)) { out << current_element_index << " " @@ -3853,9 +3817,7 @@ GridOut::write_ucd_lines(const Triangulation &tria, const_cast &>(tria) .clear_user_flags_line(); - typename Triangulation::active_cell_iterator cell, endc; - - for (cell = tria.begin_active(), endc = tria.end(); cell != endc; ++cell) + for (const auto &cell : tria.active_cell_iterators()) for (unsigned int l = 0; l < GeometryInfo::lines_per_cell; ++l) if (cell->line(l)->at_boundary() && (cell->line(l)->boundary_id() != 0) && (cell->line(l)->user_flag_set() == false)) @@ -3928,13 +3890,7 @@ namespace internal { AssertThrow(out, ExcIO()); - const int dim = 1; - - typename dealii::Triangulation::active_cell_iterator cell = - tria.begin_active(); - const typename dealii::Triangulation::active_cell_iterator - endc = tria.end(); - for (; cell != endc; ++cell) + for (const auto &cell : tria.active_cell_iterators()) { if (gnuplot_flags.write_cell_numbers) out << "# cell " << cell << '\n'; @@ -3970,11 +3926,6 @@ namespace internal gnuplot_flags.n_boundary_face_points; const unsigned int n_points = 2 + n_additional_points; - typename dealii::Triangulation::active_cell_iterator cell = - tria.begin_active(); - const typename dealii::Triangulation::active_cell_iterator - endc = tria.end(); - // If we need to plot curved lines then generate a quadrature formula to // place points via the mapping Quadrature * q_projector = nullptr; @@ -3994,7 +3945,7 @@ namespace internal QProjector::project_to_all_faces(quadrature)); } - for (; cell != endc; ++cell) + for (const auto &cell : tria.active_cell_iterators()) { if (gnuplot_flags.write_cell_numbers) out << "# cell " << cell << '\n'; @@ -4096,11 +4047,6 @@ namespace internal gnuplot_flags.n_boundary_face_points; const unsigned int n_points = 2 + n_additional_points; - typename dealii::Triangulation::active_cell_iterator cell = - tria.begin_active(); - const typename dealii::Triangulation::active_cell_iterator - endc = tria.end(); - // If we need to plot curved lines then generate a quadrature formula to // place points via the mapping Quadrature * q_projector = nullptr; @@ -4122,7 +4068,7 @@ namespace internal QProjector::project_to_all_faces(quadrature)); } - for (; cell != endc; ++cell) + for (const auto &cell : tria.active_cell_iterators()) { if (gnuplot_flags.write_cell_numbers) out << "# cell " << cell << '\n'; @@ -4427,10 +4373,7 @@ namespace internal case 2: { - for (typename dealii::Triangulation:: - active_cell_iterator cell = tria.begin_active(); - cell != tria.end(); - ++cell) + for (const auto &cell : tria.active_cell_iterators()) for (unsigned int line_no = 0; line_no < GeometryInfo::lines_per_cell; ++line_no) @@ -4502,10 +4445,7 @@ namespace internal // boundary faces and // generate the info from // them - for (typename dealii::Triangulation:: - active_cell_iterator cell = tria.begin_active(); - cell != tria.end(); - ++cell) + for (const auto &cell : tria.active_cell_iterators()) for (unsigned int face_no = 0; face_no < GeometryInfo::faces_per_cell; ++face_no) @@ -4558,11 +4498,6 @@ namespace internal // presently not supported Assert(mapping == nullptr, ExcNotImplemented()); - typename dealii::Triangulation::active_cell_iterator - cell = tria.begin_active(), - endc = tria.end(); - // loop over all lines and compute their // projection on the plane perpendicular // to the direction of sight @@ -4611,7 +4546,7 @@ namespace internal const Tensor<1, dim> unit_vector2 = vector2 / vector2.norm(); - for (; cell != endc; ++cell) + for (const auto &cell : tria.active_cell_iterators()) for (unsigned int line_no = 0; line_no < GeometryInfo::lines_per_cell; ++line_no) @@ -4777,10 +4712,7 @@ namespace internal { out << "(Helvetica) findfont 140 scalefont setfont" << '\n'; - typename dealii::Triangulation::active_cell_iterator - cell = tria.begin_active(), - endc = tria.end(); - for (; cell != endc; ++cell) + for (const auto &cell : tria.active_cell_iterators()) { out << (cell->center()(0) - offset(0)) * scale << ' ' << (cell->center()(1) - offset(1)) * scale << " m" << '\n' @@ -4805,10 +4737,7 @@ namespace internal // already tracked, to avoid // doing this multiply std::set treated_vertices; - typename dealii::Triangulation::active_cell_iterator - cell = tria.begin_active(), - endc = tria.end(); - for (; cell != endc; ++cell) + for (const auto &cell : tria.active_cell_iterators()) for (unsigned int vertex = 0; vertex < GeometryInfo::vertices_per_cell; ++vertex) diff --git a/source/grid/grid_tools.cc b/source/grid/grid_tools.cc index f249ca7e41..90e166de58 100644 --- a/source/grid/grid_tools.cc +++ b/source/grid/grid_tools.cc @@ -1124,9 +1124,7 @@ namespace GridTools new_points.end(); // fill these maps using the data given by new_points - typename DoFHandler::cell_iterator cell = dof_handler.begin_active(), - endc = dof_handler.end(); - for (; cell != endc; ++cell) + for (const auto &cell : dof_handler.active_cell_iterators()) { // loop over all vertices of the cell and see if it is listed in the map // given as first argument of the function @@ -1164,7 +1162,7 @@ namespace GridTools // change the coordinates of the points of the triangulation // according to the computed values std::vector vertex_touched(triangulation.n_vertices(), false); - for (cell = dof_handler.begin_active(); cell != endc; ++cell) + for (const auto &cell : dof_handler.active_cell_iterators()) for (unsigned int vertex_no = 0; vertex_no < GeometryInfo::vertices_per_cell; ++vertex_no) @@ -4076,17 +4074,13 @@ namespace GridTools unsigned int iter = 0; bool continue_refinement = true; - typename Triangulation::active_cell_iterator - cell = tria.begin_active(), - endc = tria.end(); - while (continue_refinement && (iter < max_iterations)) { if (max_iterations != numbers::invalid_unsigned_int) iter++; continue_refinement = false; - for (cell = tria.begin_active(); cell != endc; ++cell) + for (const auto &cell : tria.active_cell_iterators()) for (unsigned int j = 0; j < GeometryInfo::faces_per_cell; j++) if (cell->at_boundary(j) == false && cell->neighbor(j)->has_children()) @@ -4113,15 +4107,11 @@ namespace GridTools unsigned int iter = 0; bool continue_refinement = true; - typename Triangulation::active_cell_iterator - cell = tria.begin_active(), - endc = tria.end(); - while (continue_refinement && (iter < max_iterations)) { iter++; continue_refinement = false; - for (cell = tria.begin_active(); cell != endc; ++cell) + for (const auto &cell : tria.active_cell_iterators()) { std::pair info = GridTools::get_longest_direction(cell); diff --git a/source/grid/grid_tools_dof_handlers.cc b/source/grid/grid_tools_dof_handlers.cc index 5da7755d20..33657df523 100644 --- a/source/grid/grid_tools_dof_handlers.cc +++ b/source/grid/grid_tools_dof_handlers.cc @@ -747,9 +747,7 @@ namespace GridTools // Find the cells for which the predicate is true // These are the cells around which we wish to construct // the halo layer - for (typename MeshType::active_cell_iterator cell = mesh.begin_active(); - cell != mesh.end(); - ++cell) + for (const auto &cell : mesh.active_cell_iterators()) if (predicate(cell)) // True predicate --> Part of subdomain for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; @@ -759,9 +757,7 @@ namespace GridTools // Find the cells that do not conform to the predicate // but share a vertex with the selected subdomain // These comprise the halo layer - for (typename MeshType::active_cell_iterator cell = mesh.begin_active(); - cell != mesh.end(); - ++cell) + for (const auto &cell : mesh.active_cell_iterators()) if (!predicate(cell)) // False predicate --> Potential halo cell for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; @@ -908,9 +904,7 @@ namespace GridTools // Find the cells for which the predicate is false // These are the cells which are around the predicate subdomain - for (typename MeshType::active_cell_iterator cell = mesh.begin_active(); - cell != mesh.end(); - ++cell) + for (const auto &cell : mesh.active_cell_iterators()) if (!predicate(cell)) // Negation of predicate --> Not Part of subdomain { for (unsigned int v = 0; @@ -930,9 +924,7 @@ namespace GridTools // Find the cells that conform to the predicate // but share a vertex with the cell not in the predicate subdomain - for (typename MeshType::active_cell_iterator cell = mesh.begin_active(); - cell != mesh.end(); - ++cell) + for (const auto &cell : mesh.active_cell_iterators()) if (predicate(cell)) // True predicate --> Potential boundary cell of the // subdomain for (unsigned int v = 0; @@ -993,9 +985,7 @@ namespace GridTools // cells that are inside the extended bounding box but are not part of the // predicate subdomain are possible candidates to be within the distance to // the boundary cells of the predicate subdomain. - for (typename MeshType::active_cell_iterator cell = mesh.begin_active(); - cell != mesh.end(); - ++cell) + for (const auto &cell : mesh.active_cell_iterators()) { // Ignore all the cells that are in the predicate subdomain if (predicate(cell)) @@ -1092,9 +1082,7 @@ namespace GridTools Point maxp, minp; // initialize minp and maxp with the first predicate cell center - for (typename MeshType::active_cell_iterator cell = mesh.begin_active(); - cell != mesh.end(); - ++cell) + for (const auto &cell : mesh.active_cell_iterators()) if (predicate(cell)) { minp = cell->center(); @@ -1104,9 +1092,7 @@ namespace GridTools // Run through all the cells to check if it belongs to predicate domain, // if it belongs to the predicate domain, extend the bounding box. - for (typename MeshType::active_cell_iterator cell = mesh.begin_active(); - cell != mesh.end(); - ++cell) + for (const auto &cell : mesh.active_cell_iterators()) if (predicate(cell)) // True predicate --> Part of subdomain for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; diff --git a/source/grid/tria.cc b/source/grid/tria.cc index a2d8abfbc1..ef063853f4 100644 --- a/source/grid/tria.cc +++ b/source/grid/tria.cc @@ -10726,8 +10726,7 @@ Triangulation::create_triangulation( // is disconnected that we // still get all cells if (next_round.size() == 0) - for (active_cell_iterator cell = begin_active(); cell != end(); - ++cell) + for (const auto &cell : this->active_cell_iterators()) if (cell->user_flag_set() == false) { next_round.push_back(cell); @@ -10753,7 +10752,7 @@ Triangulation::flip_all_direction_flags() { AssertThrow(dim + 1 == spacedim, ExcMessage("Only works for dim == spacedim-1")); - for (active_cell_iterator cell = begin_active(); cell != end(); ++cell) + for (const auto &cell : this->active_cell_iterators()) cell->set_direction_flag(!cell->direction_flag()); } diff --git a/source/hp/dof_handler.cc b/source/hp/dof_handler.cc index 023d931555..357e2b27b6 100644 --- a/source/hp/dof_handler.cc +++ b/source/hp/dof_handler.cc @@ -333,10 +333,8 @@ namespace internal ++level) { types::global_dof_index counter = 0; - typename HpDoFHandler::active_cell_iterator - cell = dof_handler.begin_active(level), - endc = dof_handler.end_active(level); - for (; cell != endc; ++cell) + for (const auto &cell : + dof_handler.active_cell_iterators_on_level(level)) if (!cell->has_children() && !cell->is_artificial()) counter += cell->get_fe().template n_dofs_per_object(); @@ -348,7 +346,8 @@ namespace internal // number of active, non-artificial cells (because these are // exactly the cells on which we do something) unsigned int n_active_non_artificial_cells = 0; - for (cell = dof_handler.begin_active(level); cell != endc; ++cell) + for (const auto &cell : + dof_handler.active_cell_iterators_on_level(level)) if (!cell->has_children() && !cell->is_artificial()) ++n_active_non_artificial_cells; diff --git a/source/multigrid/mg_tools.cc b/source/multigrid/mg_tools.cc index 93a77e58df..e9cd8a6e33 100644 --- a/source/multigrid/mg_tools.cc +++ b/source/multigrid/mg_tools.cc @@ -125,11 +125,8 @@ namespace MGTools user_flags_triangulation.save_user_flags(old_flags); user_flags_triangulation.clear_user_flags(); - const typename DoFHandler::cell_iterator end = - dofs.end(level); - typename DoFHandler::active_cell_iterator cell; - std::vector cell_indices; - std::vector neighbor_indices; + std::vector cell_indices; + std::vector neighbor_indices; // We loop over cells and go from // cells to lower dimensional @@ -138,7 +135,7 @@ namespace MGTools // unknown number of cells may // share an object of dimension // smaller than dim-1. - for (cell = dofs.begin(level); cell != end; ++cell) + for (const auto &cell : dofs.cell_iterators_on_level(level)) { const FiniteElement &fe = cell->get_fe(); cell_indices.resize(fe.dofs_per_cell); @@ -310,11 +307,8 @@ namespace MGTools user_flags_triangulation.save_user_flags(old_flags); user_flags_triangulation.clear_user_flags(); - const typename DoFHandler::cell_iterator end = - dofs.end(level); - typename DoFHandler::active_cell_iterator cell; - std::vector cell_indices; - std::vector neighbor_indices; + std::vector cell_indices; + std::vector neighbor_indices; // We have to translate the // couplings from components to @@ -332,7 +326,7 @@ namespace MGTools // unknown number of cells may // share an object of dimension // smaller than dim-1. - for (cell = dofs.begin_active(); cell != end; ++cell) + for (const auto &cell : dofs.cell_iterators_on_level(level)) { const FiniteElement &fe = cell->get_fe(); const unsigned int fe_index = cell->active_fe_index(); diff --git a/source/numerics/time_dependent.cc b/source/numerics/time_dependent.cc index ee8a1853bb..99ff0ae1c0 100644 --- a/source/numerics/time_dependent.cc +++ b/source/numerics/time_dependent.cc @@ -535,12 +535,10 @@ TimeStepBase_Tria::restore_grid() // limit refinement depth if the user // desired so - // if (flags.max_refinement_level != 0) + // if (flags.max_refinement_level != 0) // { // typename Triangulation::active_cell_iterator cell, endc; - // for (cell = tria->begin_active(), - // endc = tria->end(); - // cell!=endc; ++cell) + // for (const auto &cell : tria->active_cell_iterators()) // if (static_cast(cell->level()) >= // flags.max_refinement_level) // cell->clear_refine_flag();