From: Daniel Arndt Date: Wed, 9 Jan 2019 08:51:21 +0000 (+0100) Subject: Use range-based for loops in source/grid X-Git-Tag: v9.1.0-rc1~445^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=123bbd9509c449785192db0141937ccdb1f43dc2;p=dealii.git Use range-based for loops in source/grid --- diff --git a/source/grid/cell_id.cc b/source/grid/cell_id.cc index c995495da0..7941bccaf9 100644 --- a/source/grid/cell_id.cc +++ b/source/grid/cell_id.cc @@ -28,8 +28,9 @@ CellId::CellId() // initialize the child indices to invalid values // (the only allowed values are between zero and // GeometryInfo::max_children_per_cell) - for (unsigned int i = 0; i < child_indices.size(); ++i) - child_indices[i] = std::numeric_limits::max(); + std::fill(child_indices.begin(), + child_indices.end(), + std::numeric_limits::max()); } diff --git a/source/grid/grid_generator.cc b/source/grid/grid_generator.cc index a51cbe29a3..b6a71f3490 100644 --- a/source/grid/grid_generator.cc +++ b/source/grid/grid_generator.cc @@ -2088,7 +2088,7 @@ namespace GridGenerator static constexpr double tol = std::numeric_limits::epsilon() * 10000; if (colorize) - for (auto &cell : tria.active_cell_iterators()) + for (const auto &cell : tria.active_cell_iterators()) for (unsigned int face_n = 0; face_n < GeometryInfo<2>::faces_per_cell; ++face_n) { @@ -2257,7 +2257,7 @@ namespace GridGenerator // The bulk cells are not quite squares, so we need to move the left // and right sides of cylinder_tria inwards so that it fits in // bulk_tria: - for (auto &cell : cylinder_tria.active_cell_iterators()) + for (const auto &cell : cylinder_tria.active_cell_iterators()) for (unsigned int vertex_n = 0; vertex_n < GeometryInfo<2>::vertices_per_cell; ++vertex_n) @@ -2269,7 +2269,7 @@ namespace GridGenerator } // Assign interior manifold ids to be the TFI id. - for (auto &cell : cylinder_tria.active_cell_iterators()) + for (const auto &cell : cylinder_tria.active_cell_iterators()) { cell->set_manifold_id(tfi_manifold_id); for (unsigned int face_n = 0; face_n < GeometryInfo<2>::faces_per_cell; @@ -2317,7 +2317,7 @@ namespace GridGenerator // Ensure that all manifold ids on a polar cell really are set to the // polar manifold id: - for (auto &cell : tria.active_cell_iterators()) + for (const auto &cell : tria.active_cell_iterators()) if (cell->manifold_id() == polar_manifold_id) cell->set_all_manifold_ids(polar_manifold_id); @@ -2360,7 +2360,7 @@ namespace GridGenerator tria.set_manifold(tfi_manifold_id, inner_manifold); if (colorize) - for (auto &face : tria.active_face_iterators()) + for (const auto &face : tria.active_face_iterators()) if (face->at_boundary()) { const Point<2> center = face->center(); @@ -2418,7 +2418,7 @@ namespace GridGenerator // 3, the bottom boundary id is 4 and the top is 5: both are walls, so set // them to 3 if (colorize) - for (auto &face : tria.active_face_iterators()) + for (const auto &face : tria.active_face_iterators()) if (face->boundary_id() == 4 || face->boundary_id() == 5) face->set_boundary_id(3); } @@ -2633,9 +2633,9 @@ namespace GridGenerator coords[3] = right + thickness; unsigned int k = 0; - for (unsigned int i0 = 0; i0 < 4; ++i0) - for (unsigned int i1 = 0; i1 < 4; ++i1) - vertices[k++] = Point<2>(coords[i1], coords[i0]); + for (const double y : coords) + for (const double x : coords) + vertices[k++] = Point<2>(x, y); const types::material_id materials[9] = {5, 4, 6, 1, 0, 2, 9, 8, 10}; @@ -3318,10 +3318,10 @@ namespace GridGenerator coords[3] = right + thickness; unsigned int k = 0; - for (unsigned int z = 0; z < 4; ++z) - for (unsigned int y = 0; y < 4; ++y) - for (unsigned int x = 0; x < 4; ++x) - vertices[k++] = Point<3>(coords[x], coords[y], coords[z]); + for (const double z : coords) + for (const double y : coords) + for (const double x : coords) + vertices[k++] = Point<3>(x, y, z); const types::material_id materials[27] = {21, 20, 22, 17, 16, 18, 25, 24, 26, 5, 4, 6, 1, 0, @@ -3388,7 +3388,7 @@ namespace GridGenerator // Set boundary ids at -half_length to 1 and at half_length to 2. Set the // manifold id on hull faces (i.e., faces not on either end) to 0. - for (auto face : triangulation.active_face_iterators()) + for (const auto &face : triangulation.active_face_iterators()) if (face->at_boundary()) { if (std::abs(face->center()[0] - -half_length) < 1e-8 * half_length) @@ -3596,11 +3596,11 @@ namespace GridGenerator Point<3>(d, half_length, d), }; // Turn cylinder such that y->x - for (unsigned int i = 0; i < 24; ++i) + for (auto &vertex : vertices) { - const double h = vertices[i](1); - vertices[i](1) = -vertices[i](0); - vertices[i](0) = h; + const double h = vertex(1); + vertex(1) = -vertex(0); + vertex(0) = h; } int cell_vertices[10][8] = {{0, 1, 8, 9, 2, 3, 10, 11}, @@ -4741,10 +4741,8 @@ namespace GridGenerator quads.push_back(quad); quad.boundary_id = top_boundary_id; - for (unsigned int vertex_n = 0; - vertex_n < GeometryInfo<3>::vertices_per_face; - ++vertex_n) - quad.vertices[vertex_n] += (n_slices - 1) * input.n_vertices(); + for (unsigned int &vertex : quad.vertices) + vertex += (n_slices - 1) * input.n_vertices(); if (copy_manifold_ids) quad.manifold_id = cell->manifold_id(); quads.push_back(quad); @@ -4763,7 +4761,7 @@ namespace GridGenerator for (auto manifold_id_it = priorities.rbegin(); manifold_id_it != priorities.rend(); ++manifold_id_it) - for (auto &face : result.active_face_iterators()) + for (const auto &face : result.active_face_iterators()) if (face->manifold_id() == *manifold_id_it) for (unsigned int line_n = 0; line_n < GeometryInfo<3>::lines_per_face; @@ -5347,20 +5345,18 @@ namespace GridGenerator // orientation. if so, skip it. { bool edge_found = false; - for (unsigned int i = 0; - i < subcell_data.boundary_lines.size(); - ++i) - if (((subcell_data.boundary_lines[i].vertices[0] == + for (auto &boundary_line : subcell_data.boundary_lines) + if (((boundary_line.vertices[0] == map_vert_index[face->line(e)->vertex_index(0)]) && - (subcell_data.boundary_lines[i].vertices[1] == + (boundary_line.vertices[1] == map_vert_index[face->line(e)->vertex_index( 1)])) || - ((subcell_data.boundary_lines[i].vertices[0] == + ((boundary_line.vertices[0] == map_vert_index[face->line(e)->vertex_index(1)]) && - (subcell_data.boundary_lines[i].vertices[1] == + (boundary_line.vertices[1] == map_vert_index[face->line(e)->vertex_index(0)]))) { - subcell_data.boundary_lines[i].boundary_id = + boundary_line.boundary_id = numbers::internal_face_boundary_id; edge_found = true; break; diff --git a/source/grid/grid_in.cc b/source/grid/grid_in.cc index 2f4afa4168..21d848abe7 100644 --- a/source/grid/grid_in.cc +++ b/source/grid/grid_in.cc @@ -426,32 +426,28 @@ GridIn::read_vtk(std::istream &in) if (dim == 3) { - for (unsigned int i = 0; - i < subcelldata.boundary_quads.size(); - i++) + for (auto &boundary_quad : subcelldata.boundary_quads) { double id; in >> id; if (set == "MaterialID") - subcelldata.boundary_quads[i].material_id = + boundary_quad.material_id = static_cast(id); else if (set == "ManifoldID") - subcelldata.boundary_quads[i].manifold_id = + boundary_quad.manifold_id = static_cast(id); else Assert(false, ExcInternalError()); } - for (unsigned int i = 0; - i < subcelldata.boundary_lines.size(); - i++) + for (auto &boundary_line : subcelldata.boundary_lines) { double id; in >> id; if (set == "MaterialID") - subcelldata.boundary_lines[i].material_id = + boundary_line.material_id = static_cast(id); else if (set == "ManifoldID") - subcelldata.boundary_lines[i].manifold_id = + boundary_line.manifold_id = static_cast(id); else Assert(false, ExcInternalError()); @@ -459,17 +455,15 @@ GridIn::read_vtk(std::istream &in) } else if (dim == 2) { - for (unsigned int i = 0; - i < subcelldata.boundary_lines.size(); - i++) + for (auto &boundary_line : subcelldata.boundary_lines) { double id; in >> id; if (set == "MaterialID") - subcelldata.boundary_lines[i].material_id = + boundary_line.material_id = static_cast(id); else if (set == "ManifoldID") - subcelldata.boundary_lines[i].manifold_id = + boundary_line.manifold_id = static_cast(id); else Assert(false, ExcInternalError()); @@ -624,14 +618,15 @@ GridIn::read_unv(std::istream &in) subcelldata.boundary_lines.emplace_back(); AssertThrow(in, ExcIO()); - for (unsigned int v = 0; v < 2; v++) - in >> subcelldata.boundary_lines.back().vertices[v]; + for (unsigned int &vertex : + subcelldata.boundary_lines.back().vertices) + in >> vertex; subcelldata.boundary_lines.back().material_id = 0; - for (unsigned int v = 0; v < 2; v++) - subcelldata.boundary_lines.back().vertices[v] = - vertex_indices[subcelldata.boundary_lines.back().vertices[v]]; + for (unsigned int &vertex : + subcelldata.boundary_lines.back().vertices) + vertex = vertex_indices[vertex]; line_indices[no] = no_line; @@ -642,14 +637,15 @@ GridIn::read_unv(std::istream &in) subcelldata.boundary_quads.emplace_back(); AssertThrow(in, ExcIO()); - for (unsigned int v = 0; v < 4; v++) - in >> subcelldata.boundary_quads.back().vertices[v]; + for (unsigned int &vertex : + subcelldata.boundary_quads.back().vertices) + in >> vertex; subcelldata.boundary_quads.back().material_id = 0; - for (unsigned int v = 0; v < 4; v++) - subcelldata.boundary_quads.back().vertices[v] = - vertex_indices[subcelldata.boundary_quads.back().vertices[v]]; + for (unsigned int &vertex : + subcelldata.boundary_quads.back().vertices) + vertex = vertex_indices[vertex]; quad_indices[no] = no_quad; @@ -900,22 +896,16 @@ GridIn::read_ucd(std::istream &in, // transform from ucd to // consecutive numbering - for (unsigned int i = 0; i < 2; ++i) - if (vertex_indices.find( - subcelldata.boundary_lines.back().vertices[i]) != - vertex_indices.end()) + for (unsigned int &vertex : + subcelldata.boundary_lines.back().vertices) + if (vertex_indices.find(vertex) != vertex_indices.end()) // vertex with this index exists - subcelldata.boundary_lines.back().vertices[i] = - vertex_indices[subcelldata.boundary_lines.back().vertices[i]]; + vertex = vertex_indices[vertex]; else { // no such vertex index - AssertThrow(false, - ExcInvalidVertexIndex( - cell, - subcelldata.boundary_lines.back().vertices[i])); - subcelldata.boundary_lines.back().vertices[i] = - numbers::invalid_unsigned_int; + AssertThrow(false, ExcInvalidVertexIndex(cell, vertex)); + vertex = numbers::invalid_unsigned_int; }; } else if ((cell_type == "quad") && (dim == 3)) @@ -960,21 +950,16 @@ GridIn::read_ucd(std::istream &in, // transform from ucd to // consecutive numbering - for (unsigned int i = 0; i < 4; ++i) - if (vertex_indices.find( - subcelldata.boundary_quads.back().vertices[i]) != - vertex_indices.end()) + for (unsigned int &vertex : + subcelldata.boundary_quads.back().vertices) + if (vertex_indices.find(vertex) != vertex_indices.end()) // vertex with this index exists - subcelldata.boundary_quads.back().vertices[i] = - vertex_indices[subcelldata.boundary_quads.back().vertices[i]]; + vertex = vertex_indices[vertex]; else { // no such vertex index - Assert(false, - ExcInvalidVertexIndex( - cell, subcelldata.boundary_quads.back().vertices[i])); - subcelldata.boundary_quads.back().vertices[i] = - numbers::invalid_unsigned_int; + Assert(false, ExcInvalidVertexIndex(cell, vertex)); + vertex = numbers::invalid_unsigned_int; }; } else @@ -1303,8 +1288,8 @@ GridIn<2>::read_xda(std::istream &in) AssertThrow(in, ExcIO()); Assert(GeometryInfo<2>::vertices_per_cell == 4, ExcInternalError()); - for (unsigned int i = 0; i < 4; ++i) - in >> cells[cell].vertices[i]; + for (unsigned int &vertex : cells[cell].vertices) + in >> vertex; }; @@ -1378,8 +1363,8 @@ GridIn<3>::read_xda(std::istream &in) unsigned int xda_ordered_nodes[8]; - for (unsigned int i = 0; i < 8; ++i) - in >> xda_ordered_nodes[i]; + for (unsigned int &xda_ordered_node : xda_ordered_nodes) + in >> xda_ordered_node; for (unsigned int i = 0; i < 8; i++) cells[cell].vertices[i] = xda_ordered_nodes[xda_to_dealII_map[i]]; @@ -1778,24 +1763,18 @@ GridIn::read_msh(std::istream &in) // transform from ucd to // consecutive numbering - for (unsigned int i = 0; i < 2; ++i) - if (vertex_indices.find( - subcelldata.boundary_lines.back().vertices[i]) != - vertex_indices.end()) + for (unsigned int &vertex : + subcelldata.boundary_lines.back().vertices) + if (vertex_indices.find(vertex) != vertex_indices.end()) // vertex with this index exists - subcelldata.boundary_lines.back().vertices[i] = - vertex_indices[subcelldata.boundary_lines.back() - .vertices[i]]; + vertex = vertex_indices[vertex]; else { // no such vertex index - AssertThrow( - false, - ExcInvalidVertexIndex( - cell_per_entity, - subcelldata.boundary_lines.back().vertices[i])); - subcelldata.boundary_lines.back().vertices[i] = - numbers::invalid_unsigned_int; + AssertThrow(false, + ExcInvalidVertexIndex(cell_per_entity, + vertex)); + vertex = numbers::invalid_unsigned_int; }; } else if ((cell_type == 3) && (dim == 3)) @@ -1826,23 +1805,17 @@ GridIn::read_msh(std::istream &in) // transform from gmsh to // consecutive numbering - for (unsigned int i = 0; i < 4; ++i) - if (vertex_indices.find( - subcelldata.boundary_quads.back().vertices[i]) != - vertex_indices.end()) + for (unsigned int &vertex : + subcelldata.boundary_quads.back().vertices) + if (vertex_indices.find(vertex) != vertex_indices.end()) // vertex with this index exists - subcelldata.boundary_quads.back().vertices[i] = - vertex_indices[subcelldata.boundary_quads.back() - .vertices[i]]; + vertex = vertex_indices[vertex]; else { // no such vertex index Assert(false, - ExcInvalidVertexIndex( - cell_per_entity, - subcelldata.boundary_quads.back().vertices[i])); - subcelldata.boundary_quads.back().vertices[i] = - numbers::invalid_unsigned_int; + ExcInvalidVertexIndex(cell_per_entity, vertex)); + vertex = numbers::invalid_unsigned_int; } } else if (cell_type == 15) @@ -2842,9 +2815,8 @@ GridIn<2>::read_tecplot(std::istream &in) // get the connectivity from the // input file. the vertices are // ordered like in the ucd format - for (unsigned int j = 0; j < GeometryInfo::vertices_per_cell; - ++j) - in >> cells[i].vertices[j]; + for (unsigned int &vertex : cells[i].vertices) + in >> vertex; } // do some clean-up on vertices GridTools::delete_unused_vertices(vertices, cells, subcelldata); @@ -3115,9 +3087,9 @@ GridIn<2>::debug_output_grid(const std::vector> &cells, for (unsigned int i = 0; i < cells.size(); ++i) { - for (unsigned int v = 0; v < 4; ++v) + for (const auto vertex : cells[i].vertices) { - const Point<2> &p = vertices[cells[i].vertices[v]]; + const Point<2> &p = vertices[vertex]; if (p(0) < min_x) min_x = p(0); @@ -3131,8 +3103,8 @@ GridIn<2>::debug_output_grid(const std::vector> &cells, out << "# cell " << i << std::endl; Point<2> center; - for (unsigned int f = 0; f < 4; ++f) - center += vertices[cells[i].vertices[f]]; + for (const auto vertex : cells[i].vertices) + center += vertices[vertex]; center /= 4; out << "set label \"" << i << "\" at " << center(0) << ',' << center(1) @@ -3169,66 +3141,66 @@ GridIn<3>::debug_output_grid(const std::vector> &cells, const std::vector> & vertices, std::ostream & out) { - for (unsigned int cell = 0; cell < cells.size(); ++cell) + for (const auto &cell : cells) { // line 0 - out << vertices[cells[cell].vertices[0]] << std::endl - << vertices[cells[cell].vertices[1]] << std::endl + out << vertices[cell.vertices[0]] << std::endl + << vertices[cell.vertices[1]] << std::endl << std::endl << std::endl; // line 1 - out << vertices[cells[cell].vertices[1]] << std::endl - << vertices[cells[cell].vertices[2]] << std::endl + out << vertices[cell.vertices[1]] << std::endl + << vertices[cell.vertices[2]] << std::endl << std::endl << std::endl; // line 2 - out << vertices[cells[cell].vertices[3]] << std::endl - << vertices[cells[cell].vertices[2]] << std::endl + out << vertices[cell.vertices[3]] << std::endl + << vertices[cell.vertices[2]] << std::endl << std::endl << std::endl; // line 3 - out << vertices[cells[cell].vertices[0]] << std::endl - << vertices[cells[cell].vertices[3]] << std::endl + out << vertices[cell.vertices[0]] << std::endl + << vertices[cell.vertices[3]] << std::endl << std::endl << std::endl; // line 4 - out << vertices[cells[cell].vertices[4]] << std::endl - << vertices[cells[cell].vertices[5]] << std::endl + out << vertices[cell.vertices[4]] << std::endl + << vertices[cell.vertices[5]] << std::endl << std::endl << std::endl; // line 5 - out << vertices[cells[cell].vertices[5]] << std::endl - << vertices[cells[cell].vertices[6]] << std::endl + out << vertices[cell.vertices[5]] << std::endl + << vertices[cell.vertices[6]] << std::endl << std::endl << std::endl; // line 6 - out << vertices[cells[cell].vertices[7]] << std::endl - << vertices[cells[cell].vertices[6]] << std::endl + out << vertices[cell.vertices[7]] << std::endl + << vertices[cell.vertices[6]] << std::endl << std::endl << std::endl; // line 7 - out << vertices[cells[cell].vertices[4]] << std::endl - << vertices[cells[cell].vertices[7]] << std::endl + out << vertices[cell.vertices[4]] << std::endl + << vertices[cell.vertices[7]] << std::endl << std::endl << std::endl; // line 8 - out << vertices[cells[cell].vertices[0]] << std::endl - << vertices[cells[cell].vertices[4]] << std::endl + out << vertices[cell.vertices[0]] << std::endl + << vertices[cell.vertices[4]] << std::endl << std::endl << std::endl; // line 9 - out << vertices[cells[cell].vertices[1]] << std::endl - << vertices[cells[cell].vertices[5]] << std::endl + out << vertices[cell.vertices[1]] << std::endl + << vertices[cell.vertices[5]] << std::endl << std::endl << std::endl; // line 10 - out << vertices[cells[cell].vertices[2]] << std::endl - << vertices[cells[cell].vertices[6]] << std::endl + out << vertices[cell.vertices[2]] << std::endl + << vertices[cell.vertices[6]] << std::endl << std::endl << std::endl; // line 11 - out << vertices[cells[cell].vertices[3]] << std::endl - << vertices[cells[cell].vertices[7]] << std::endl + out << vertices[cell.vertices[3]] << std::endl + << vertices[cell.vertices[7]] << std::endl << std::endl << std::endl; }; @@ -3460,11 +3432,11 @@ namespace extract_int(const std::string &s) { std::string tmp; - for (unsigned int i = 0; i < s.size(); ++i) + for (const char c : s) { - if (isdigit(s[i])) + if (isdigit(c)) { - tmp += s[i]; + tmp += c; } } @@ -3636,9 +3608,9 @@ namespace iss >> stmp >> temp >> face_number; const std::vector cells = elsets_list[elset_name]; - for (unsigned int i = 0; i < cells.size(); ++i) + for (const int cell : cells) { - el_idx = cells[i]; + el_idx = cell; quad_node_list = get_global_node_numbers(el_idx, face_number); quad_node_list.insert(quad_node_list.begin(), @@ -3806,9 +3778,9 @@ namespace // Assign material id to cells const std::vector &elset_cells = elsets_list[elset_name]; - for (unsigned int i = 0; i < elset_cells.size(); ++i) + for (const int elset_cell : elset_cells) { - const int cell_id = elset_cells[i] - 1; + const int cell_id = elset_cell - 1; cell_list[cell_id][0] = material_id; } } diff --git a/source/grid/grid_out.cc b/source/grid/grid_out.cc index 325e78dbae..9e22f390ae 100644 --- a/source/grid/grid_out.cc +++ b/source/grid/grid_out.cc @@ -1331,9 +1331,7 @@ GridOut::write_xfig(const Triangulation<2> &tria, const int dim = 2; const int spacedim = 2; - const unsigned int nv = GeometryInfo::vertices_per_cell; - const unsigned int nf = GeometryInfo::faces_per_cell; - const unsigned int nvf = GeometryInfo::vertices_per_face; + const unsigned int nv = GeometryInfo::vertices_per_cell; // The following text was copied // from an existing XFig file. @@ -1463,10 +1461,9 @@ GridOut::write_xfig(const Triangulation<2> &tria, // Now write boundary edges static const unsigned int face_reorder[4] = {2, 1, 3, 0}; if (xfig_flags.draw_boundary) - for (unsigned int f = 0; f < nf; ++f) + for (const unsigned int f : face_reorder) { - Triangulation::face_iterator face = - cell->face(face_reorder[f]); + Triangulation::face_iterator face = cell->face(f); const types::boundary_id bi = face->boundary_id(); if (bi != numbers::internal_face_boundary_id) { @@ -1485,14 +1482,16 @@ GridOut::write_xfig(const Triangulation<2> &tria, // some style parameters << " 0 0 -1 0 0 " // number of points - << nvf << std::endl; + << GeometryInfo::vertices_per_face << std::endl; // For each point, write scaled // and shifted coordinates // multiplied by 1200 // (dots/inch) - for (unsigned int k = 0; k < nvf; ++k) + for (unsigned int k = 0; + k < GeometryInfo::vertices_per_face; + ++k) { const Point &p = face->vertex(k % nv); for (unsigned int d = 0; d < static_cast(dim); @@ -1530,11 +1529,6 @@ GridOut::write_svg(const Triangulation &, void GridOut::write_svg(const Triangulation<2, 2> &tria, std::ostream &out) const { - unsigned int n_materials = 0; - unsigned int n_levels = 0; - unsigned int n_subdomains = 0; - unsigned int n_level_subdomains = 0; - unsigned int n = 0; unsigned int min_level, max_level; @@ -1587,26 +1581,16 @@ GridOut::write_svg(const Triangulation<2, 2> &tria, std::ostream &out) const min_level = max_level = tria.begin()->level(); // auxiliary array for the materials being used (material ids 255 max.) - unsigned int materials[256]; - for (unsigned int material_index = 0; material_index < 256; material_index++) - materials[material_index] = 0; + std::array materials{}; // auxiliary array for the levels being used (level number 255 max.) - unsigned int levels[256]; - for (unsigned int level_index = 0; level_index < 256; level_index++) - levels[level_index] = 0; + std::array levels{}; // auxiliary array for the subdomains being used (subdomain id 255 max.) - unsigned int subdomains[256]; - for (unsigned int subdomain_index = 0; subdomain_index < 256; - subdomain_index++) - subdomains[subdomain_index] = 0; + std::array subdomains{}; // auxiliary array for the level subdomains being used - int level_subdomains[256]; - for (int level_subdomain_index = 0; level_subdomain_index < 256; - level_subdomain_index++) - level_subdomains[level_subdomain_index] = 0; + std::array level_subdomains{}; // We use an active cell iterator to determine the // bounding box of the given triangulation and check @@ -1643,34 +1627,30 @@ GridOut::write_svg(const Triangulation<2, 2> &tria, std::ostream &out) const y_dimension = y_max - y_min; // count the materials being used - for (unsigned int material_index = 0; material_index < 256; material_index++) - { - if (materials[material_index]) - n_materials++; - } + const unsigned int n_materials = + std::count_if(materials.begin(), + materials.end(), + [](const unsigned int material) { return material != 0; }); // count the levels being used - for (unsigned int level_index = 0; level_index < 256; level_index++) - { - if (levels[level_index]) - n_levels++; - } + const unsigned int n_levels = + std::count_if(levels.begin(), levels.end(), [](const unsigned int level) { + return level != 0; + }); // count the subdomains being used - for (unsigned int subdomain_index = 0; subdomain_index < 256; - subdomain_index++) - { - if (subdomains[subdomain_index]) - n_subdomains++; - } + const unsigned int n_subdomains = + std::count_if(subdomains.begin(), + subdomains.end(), + [](const unsigned int subdomain) { return subdomain != 0; }); // count the level subdomains being used - for (int level_subdomain_index = 0; level_subdomain_index < 256; - level_subdomain_index++) - { - if (level_subdomains[level_subdomain_index]) - n_level_subdomains++; - } + const unsigned int n_level_subdomains = + std::count_if(level_subdomains.begin(), + level_subdomains.end(), + [](const int level_subdomain) { + return level_subdomain != 0; + }); switch (svg_flags.coloring) { @@ -3042,7 +3022,7 @@ GridOut::write_vtk(const Triangulation &tria, << "POINTS " << n_vertices << " double\n"; // actually write the vertices. - for (auto v : vertices) + for (const auto &v : vertices) { out << v; for (unsigned int d = spacedim + 1; d <= 3; ++d) @@ -3083,7 +3063,7 @@ GridOut::write_vtk(const Triangulation &tria, const int co_face_type = (dim == 1 ? -1 : dim == 2 ? -1 : 3); // write cells. - for (auto cell : tria.active_cell_iterators()) + for (const auto &cell : tria.active_cell_iterators()) { out << GeometryInfo::vertices_per_cell; for (unsigned int i = 0; i < GeometryInfo::vertices_per_cell; ++i) @@ -3092,7 +3072,7 @@ GridOut::write_vtk(const Triangulation &tria, } out << '\n'; } - for (auto face : faces) + for (const auto &face : faces) { out << GeometryInfo::vertices_per_face; for (unsigned int i = 0; i < GeometryInfo::vertices_per_face; ++i) @@ -3103,7 +3083,7 @@ GridOut::write_vtk(const Triangulation &tria, } out << '\n'; } - for (auto co_face : co_faces) + for (const auto &co_face : co_faces) { out << 2; for (unsigned int i = 0; i < 2; ++i) @@ -3132,21 +3112,21 @@ GridOut::write_vtk(const Triangulation &tria, << "LOOKUP_TABLE default\n"; // Now material id and boundary id - for (auto cell : tria.active_cell_iterators()) + for (const auto &cell : tria.active_cell_iterators()) { out << static_cast::type>( cell->material_id()) << ' '; } out << '\n'; - for (auto face : faces) + for (const auto &face : faces) { out << static_cast::type>( face->boundary_id()) << ' '; } out << '\n'; - for (auto co_face : co_faces) + for (const auto &co_face : co_faces) { out << static_cast::type>( co_face->boundary_id()) @@ -3157,21 +3137,21 @@ GridOut::write_vtk(const Triangulation &tria, << "LOOKUP_TABLE default\n"; // Now material id and boundary id - for (auto cell : tria.active_cell_iterators()) + for (const auto &cell : tria.active_cell_iterators()) { out << static_cast::type>( cell->manifold_id()) << ' '; } out << '\n'; - for (auto face : faces) + for (const auto &face : faces) { out << static_cast::type>( face->manifold_id()) << ' '; } out << '\n'; - for (auto co_face : co_faces) + for (const auto &co_face : co_faces) { out << static_cast::type>( co_face->manifold_id()) diff --git a/source/grid/grid_reordering.cc b/source/grid/grid_reordering.cc index 3030f6678a..70f34fdf25 100644 --- a/source/grid/grid_reordering.cc +++ b/source/grid/grid_reordering.cc @@ -1027,20 +1027,20 @@ namespace void reorder_new_to_old_style(std::vector> &cells) { - for (unsigned int cell = 0; cell < cells.size(); ++cell) - std::swap(cells[cell].vertices[2], cells[cell].vertices[3]); + for (auto &cell : cells) + std::swap(cell.vertices[2], cell.vertices[3]); } void reorder_new_to_old_style(std::vector> &cells) { unsigned int tmp[GeometryInfo<3>::vertices_per_cell]; - for (unsigned int cell = 0; cell < cells.size(); ++cell) + for (auto &cell : cells) { for (unsigned int i = 0; i < GeometryInfo<3>::vertices_per_cell; ++i) - tmp[i] = cells[cell].vertices[i]; + tmp[i] = cell.vertices[i]; for (unsigned int i = 0; i < GeometryInfo<3>::vertices_per_cell; ++i) - cells[cell].vertices[i] = tmp[GeometryInfo<3>::ucd_to_deal[i]]; + cell.vertices[i] = tmp[GeometryInfo<3>::ucd_to_deal[i]]; } } @@ -1063,12 +1063,12 @@ namespace { // undo the ordering above unsigned int tmp[GeometryInfo<3>::vertices_per_cell]; - for (unsigned int cell = 0; cell < cells.size(); ++cell) + for (auto &cell : cells) { for (unsigned int i = 0; i < GeometryInfo<3>::vertices_per_cell; ++i) - tmp[i] = cells[cell].vertices[i]; + tmp[i] = cell.vertices[i]; for (unsigned int i = 0; i < GeometryInfo<3>::vertices_per_cell; ++i) - cells[cell].vertices[GeometryInfo<3>::ucd_to_deal[i]] = tmp[i]; + cell.vertices[GeometryInfo<3>::ucd_to_deal[i]] = tmp[i]; } } } // namespace @@ -1154,18 +1154,17 @@ GridReordering<2>::invert_all_cells_of_negative_grid( { unsigned int vertices_lex[GeometryInfo<2>::vertices_per_cell]; unsigned int n_negative_cells = 0; - for (unsigned int cell_no = 0; cell_no < cells.size(); ++cell_no) + for (auto &cell : cells) { // GridTools::cell_measure // requires the vertices to be // in lexicographic ordering for (unsigned int i = 0; i < GeometryInfo<2>::vertices_per_cell; ++i) - vertices_lex[GeometryInfo<2>::ucd_to_deal[i]] = - cells[cell_no].vertices[i]; + vertices_lex[GeometryInfo<2>::ucd_to_deal[i]] = cell.vertices[i]; if (GridTools::cell_measure<2>(all_vertices, vertices_lex) < 0) { ++n_negative_cells; - std::swap(cells[cell_no].vertices[1], cells[cell_no].vertices[3]); + std::swap(cell.vertices[1], cell.vertices[3]); // check whether the // resulting cell is now ok. @@ -1174,8 +1173,7 @@ GridReordering<2>::invert_all_cells_of_negative_grid( // should be sticked into the // bin for (unsigned int i = 0; i < GeometryInfo<2>::vertices_per_cell; ++i) - vertices_lex[GeometryInfo<2>::ucd_to_deal[i]] = - cells[cell_no].vertices[i]; + vertices_lex[GeometryInfo<2>::ucd_to_deal[i]] = cell.vertices[i]; AssertThrow(GridTools::cell_measure<2>(all_vertices, vertices_lex) > 0, ExcInternalError()); @@ -1226,21 +1224,19 @@ GridReordering<3>::invert_all_cells_of_negative_grid( { unsigned int vertices_lex[GeometryInfo<3>::vertices_per_cell]; unsigned int n_negative_cells = 0; - for (unsigned int cell_no = 0; cell_no < cells.size(); ++cell_no) + for (auto &cell : cells) { // GridTools::cell_measure // requires the vertices to be // in lexicographic ordering for (unsigned int i = 0; i < GeometryInfo<3>::vertices_per_cell; ++i) - vertices_lex[GeometryInfo<3>::ucd_to_deal[i]] = - cells[cell_no].vertices[i]; + vertices_lex[GeometryInfo<3>::ucd_to_deal[i]] = cell.vertices[i]; if (GridTools::cell_measure<3>(all_vertices, vertices_lex) < 0) { ++n_negative_cells; // reorder vertices: swap front and back face for (unsigned int i = 0; i < 4; ++i) - std::swap(cells[cell_no].vertices[i], - cells[cell_no].vertices[i + 4]); + std::swap(cell.vertices[i], cell.vertices[i + 4]); // check whether the // resulting cell is now ok. @@ -1249,8 +1245,7 @@ GridReordering<3>::invert_all_cells_of_negative_grid( // should be sticked into the // bin for (unsigned int i = 0; i < GeometryInfo<3>::vertices_per_cell; ++i) - vertices_lex[GeometryInfo<3>::ucd_to_deal[i]] = - cells[cell_no].vertices[i]; + vertices_lex[GeometryInfo<3>::ucd_to_deal[i]] = cell.vertices[i]; AssertThrow(GridTools::cell_measure<3>(all_vertices, vertices_lex) > 0, ExcInternalError()); diff --git a/source/grid/grid_tools.cc b/source/grid/grid_tools.cc index e48689f582..5cd5d14e08 100644 --- a/source/grid/grid_tools.cc +++ b/source/grid/grid_tools.cc @@ -655,7 +655,8 @@ namespace GridTools cells[c].vertices[v] = new_vertex_numbers[cells[c].vertices[v]]; // same for boundary data - for (unsigned int c = 0; c < subcelldata.boundary_lines.size(); ++c) + for (unsigned int c = 0; c < subcelldata.boundary_lines.size(); // NOLINT + ++c) for (unsigned int v = 0; v < GeometryInfo<1>::vertices_per_cell; ++v) { Assert(subcelldata.boundary_lines[c].vertices[v] < @@ -674,7 +675,8 @@ namespace GridTools new_vertex_numbers[subcelldata.boundary_lines[c].vertices[v]]; } - for (unsigned int c = 0; c < subcelldata.boundary_quads.size(); ++c) + for (unsigned int c = 0; c < subcelldata.boundary_quads.size(); // NOLINT + ++c) for (unsigned int v = 0; v < GeometryInfo<2>::vertices_per_cell; ++v) { Assert(subcelldata.boundary_quads[c].vertices[v] < @@ -3643,7 +3645,7 @@ namespace GridTools const auto src_boundary_ids = tria.get_boundary_ids(); std::vector dst_manifold_ids(src_boundary_ids.size()); auto m_it = dst_manifold_ids.begin(); - for (auto b : src_boundary_ids) + for (const auto b : src_boundary_ids) { *m_it = static_cast(b); ++m_it; @@ -3886,7 +3888,7 @@ namespace GridTools { has_cells_with_more_than_dim_faces_on_boundary = false; - for (auto cell : tria.active_cell_iterators()) + for (const auto &cell : tria.active_cell_iterators()) { unsigned int boundary_face_counter = 0; for (unsigned int f = 0; f < GeometryInfo::faces_per_cell; ++f) @@ -3916,7 +3918,7 @@ namespace GridTools { while (refinement_cycles > 0) { - for (auto cell : tria.active_cell_iterators()) + for (const auto &cell : tria.active_cell_iterators()) cell->set_coarsen_flag(); tria.execute_coarsening_and_refinement(); refinement_cycles--; @@ -3936,7 +3938,7 @@ namespace GridTools const unsigned int v0 = 0, v1 = 1, v2 = (dim > 1 ? 2 : 0), v3 = (dim > 1 ? 3 : 0); - for (auto cell : tria.active_cell_iterators()) + for (const auto &cell : tria.active_cell_iterators()) { double angle_fraction = 0; unsigned int vertex_at_corner = numbers::invalid_unsigned_int; @@ -4085,7 +4087,7 @@ namespace GridTools { while (refinement_cycles > 0) { - for (auto cell : tria.active_cell_iterators()) + for (const auto &cell : tria.active_cell_iterators()) cell->set_coarsen_flag(); tria.execute_coarsening_and_refinement(); refinement_cycles--; @@ -4094,7 +4096,7 @@ namespace GridTools } // add the cells that were not marked as skipped - for (auto cell : tria.active_cell_iterators()) + for (const auto &cell : tria.active_cell_iterators()) { if (cells_to_remove[cell->active_cell_index()] == false) { @@ -4161,7 +4163,7 @@ namespace GridTools std::map>> manifolds; // Set manifolds in new Triangulation - for (auto manifold_id : manifold_ids) + for (const auto manifold_id : manifold_ids) if (manifold_id != numbers::flat_manifold_id) manifolds[manifold_id] = tria.get_manifold(manifold_id).clone(); @@ -4170,7 +4172,7 @@ namespace GridTools tria.create_triangulation(vertices, cells_to_add, subcelldata_to_add); // Restore manifolds - for (auto manifold_id : manifold_ids) + for (const auto manifold_id : manifold_ids) if (manifold_id != numbers::flat_manifold_id) tria.set_manifold(manifold_id, *manifolds[manifold_id]); } @@ -4535,7 +4537,7 @@ namespace GridTools // Alayzing the output discarding artificial cell // and storing in the proper container locally owned and ghost cells - for (auto const &cell_tuples : cpt_loc_pts) + for (const auto &cell_tuples : cpt_loc_pts) { auto &cell_loc = cell_tuples.first; auto &q_loc = std::get<0>(cell_tuples.second); @@ -4621,7 +4623,7 @@ namespace GridTools // rank and points is a pair: first rank, then a pair of vectors // (points, indices) - for (auto const &rank_and_points : map_pts) + for (const auto &rank_and_points : map_pts) { // Rewriting the contents of the map in human readable format const auto &received_process = rank_and_points.first; @@ -4849,11 +4851,11 @@ namespace GridTools point_idx)) // The point wasn't found in ghost or locally owned cells: adding it // to the map - for (unsigned int i = 0; i < probable_owners_rks.size(); ++i) - if (probable_owners_rks[i] != my_rank) + for (const unsigned int probable_owners_rk : probable_owners_rks) + if (probable_owners_rk != my_rank) { // add to the data for process probable_owners_rks[i] - auto ¤t_pts = other_check_pts[probable_owners_rks[i]]; + auto ¤t_pts = other_check_pts[probable_owners_rk]; // The point local_points[point_idx] current_pts.first.emplace_back(local_points[point_idx]); // and its index in the current process diff --git a/source/grid/grid_tools_cache.cc b/source/grid/grid_tools_cache.cc index 96219c9996..5899540f87 100644 --- a/source/grid/grid_tools_cache.cc +++ b/source/grid/grid_tools_cache.cc @@ -127,7 +127,7 @@ namespace GridTools typename Triangulation::active_cell_iterator>> boxes(tria->n_active_cells()); unsigned int i = 0; - for (auto cell : tria->active_cell_iterators()) + for (const auto &cell : tria->active_cell_iterators()) boxes[i++] = std::make_pair(cell->bounding_box(), cell); cell_bounding_boxes_rtree = pack_rtree(boxes); } diff --git a/source/grid/grid_tools_dof_handlers.cc b/source/grid/grid_tools_dof_handlers.cc index 1882e6e985..16012d59e5 100644 --- a/source/grid/grid_tools_dof_handlers.cc +++ b/source/grid/grid_tools_dof_handlers.cc @@ -704,7 +704,7 @@ namespace GridTools const double original_distance_to_unit_cell = GeometryInfo::distance_to_unit_cell(unit_point); - for (auto cell : cells_to_add) + for (const auto &cell : cells_to_add) { if (cell != my_cell) try diff --git a/source/grid/manifold_lib.cc b/source/grid/manifold_lib.cc index 7387e35f89..99ea39747b 100644 --- a/source/grid/manifold_lib.cc +++ b/source/grid/manifold_lib.cc @@ -1804,10 +1804,7 @@ namespace // identify the weights for the lines to be accumulated (vertex // weights are set outside and coincide with the flat manifold case) - double weights_lines[GeometryInfo<3>::lines_per_cell]; - for (unsigned int line = 0; line < GeometryInfo<3>::lines_per_cell; - ++line) - weights_lines[line] = 0; + std::array::lines_per_cell> weights_lines{}; // start with the contributions of the faces std::array::vertices_per_cell> weights; diff --git a/source/grid/tria.cc b/source/grid/tria.cc index 3f1da7e211..b730503da0 100644 --- a/source/grid/tria.cc +++ b/source/grid/tria.cc @@ -501,8 +501,8 @@ namespace void reorder_compatibility(std::vector> &cells, const SubCellData &) { - for (unsigned int cell = 0; cell < cells.size(); ++cell) - std::swap(cells[cell].vertices[2], cells[cell].vertices[3]); + for (auto &cell : cells) + std::swap(cell.vertices[2], cell.vertices[3]); } @@ -510,12 +510,12 @@ namespace SubCellData & subcelldata) { unsigned int tmp[GeometryInfo<3>::vertices_per_cell]; - for (unsigned int cell = 0; cell < cells.size(); ++cell) + for (auto &cell : cells) { for (unsigned int i = 0; i < GeometryInfo<3>::vertices_per_cell; ++i) - tmp[i] = cells[cell].vertices[i]; + tmp[i] = cell.vertices[i]; for (unsigned int i = 0; i < GeometryInfo<3>::vertices_per_cell; ++i) - cells[cell].vertices[GeometryInfo<3>::ucd_to_deal[i]] = tmp[i]; + cell.vertices[GeometryInfo<3>::ucd_to_deal[i]] = tmp[i]; } // now points in boundary quads @@ -1779,8 +1779,8 @@ namespace internal // some security tests { unsigned int boundary_nodes = 0; - for (unsigned int i = 0; i < lines_at_vertex.size(); ++i) - switch (lines_at_vertex[i].size()) + for (const auto &line : lines_at_vertex) + switch (line.size()) { case 1: // this vertex has only @@ -1958,11 +1958,10 @@ namespace internal needed_lines; for (unsigned int cell = 0; cell < cells.size(); ++cell) { - for (unsigned int vertex = 0; vertex < 4; ++vertex) - AssertThrow(cells[cell].vertices[vertex] < - triangulation.vertices.size(), + for (const auto vertex : cells[cell].vertices) + AssertThrow(vertex < triangulation.vertices.size(), ExcInvalidVertexIndex(cell, - cells[cell].vertices[vertex], + vertex, triangulation.vertices.size())); for (unsigned int line = 0; @@ -2105,10 +2104,8 @@ namespace internal // note that this cell is // adjacent to the four // lines - for (unsigned int line = 0; - line < GeometryInfo::lines_per_cell; - ++line) - adjacent_cells[lines[line]->index()].push_back(cell); + for (const auto &line : lines) + adjacent_cells[line->index()].push_back(cell); } } @@ -2343,13 +2340,10 @@ namespace internal { // check whether vertex indices // are valid ones - for (unsigned int vertex = 0; - vertex < GeometryInfo::vertices_per_cell; - ++vertex) - AssertThrow(cells[cell].vertices[vertex] < - triangulation.vertices.size(), + for (const auto vertex : cells[cell].vertices) + AssertThrow(vertex < triangulation.vertices.size(), ExcInvalidVertexIndex(cell, - cells[cell].vertices[vertex], + vertex, triangulation.vertices.size())); for (unsigned int line = 0; @@ -2472,7 +2466,7 @@ namespace internal std::array::lines_per_face>>, QuadComparator> needed_quads; - for (unsigned int cell = 0; cell < cells.size(); ++cell) + for (const auto &cell : cells) { // the faces are quads which // consist of four numbers @@ -2507,15 +2501,15 @@ namespace internal ++line) { line_list[line] = std::pair( - cells[cell].vertices[GeometryInfo::line_to_cell_vertices( - line, 0)], - cells[cell].vertices[GeometryInfo::line_to_cell_vertices( - line, 1)]); + cell.vertices[GeometryInfo::line_to_cell_vertices(line, + 0)], + cell.vertices[GeometryInfo::line_to_cell_vertices(line, + 1)]); inverse_line_list[line] = std::pair( - cells[cell].vertices[GeometryInfo::line_to_cell_vertices( - line, 1)], - cells[cell].vertices[GeometryInfo::line_to_cell_vertices( - line, 0)]); + cell.vertices[GeometryInfo::line_to_cell_vertices(line, + 1)], + cell.vertices[GeometryInfo::line_to_cell_vertices(line, + 0)]); } for (unsigned int face = 0; @@ -2933,10 +2927,8 @@ namespace internal // note that this cell is // adjacent to the six // quads - for (unsigned int quad = 0; - quad < GeometryInfo::faces_per_cell; - ++quad) - adjacent_cells[face_iterator[quad]->index()].push_back(cell); + for (const auto &quad : face_iterator) + adjacent_cells[quad->index()].push_back(cell); #ifdef DEBUG // make some checks on the @@ -5869,22 +5861,21 @@ namespace internal quad->line_index(3))); } - for (unsigned int i = 0; i < 2; ++i) + for (const auto &new_quad : new_quads) { - new_quads[i]->set_used_flag(); - new_quads[i]->clear_user_flag(); - new_quads[i]->clear_user_data(); - new_quads[i]->clear_children(); - new_quads[i]->set_boundary_id_internal( - quad->boundary_id()); - new_quads[i]->set_manifold_id(quad->manifold_id()); + new_quad->set_used_flag(); + new_quad->clear_user_flag(); + new_quad->clear_user_data(); + new_quad->clear_children(); + new_quad->set_boundary_id_internal(quad->boundary_id()); + new_quad->set_manifold_id(quad->manifold_id()); // set all line orientations to true, change // this after the loop, as we have to consider // different lines for each child for (unsigned int j = 0; j < GeometryInfo::lines_per_face; ++j) - new_quads[i]->set_line_orientation(j, true); + new_quad->set_line_orientation(j, true); } // now set the line orientation of children of // outer lines correctly, the lines in the @@ -6446,15 +6437,14 @@ namespace internal internal::TriangulationImplementation::TriaObject<1>( vertex_indices[4], vertex_indices[1])); - for (unsigned int i = 0; i < 4; ++i) + for (const auto &new_line : new_lines) { - new_lines[i]->set_used_flag(); - new_lines[i]->clear_user_flag(); - new_lines[i]->clear_user_data(); - new_lines[i]->clear_children(); - new_lines[i]->set_boundary_id_internal( - quad->boundary_id()); - new_lines[i]->set_manifold_id(quad->manifold_id()); + new_line->set_used_flag(); + new_line->clear_user_flag(); + new_line->clear_user_data(); + new_line->clear_children(); + new_line->set_boundary_id_internal(quad->boundary_id()); + new_line->set_manifold_id(quad->manifold_id()); } // now for the quads. again, first collect some @@ -6582,22 +6572,21 @@ namespace internal line_indices[3], line_indices[11], line_indices[7])); - for (unsigned int i = 0; i < 4; ++i) + for (const auto &new_quad : new_quads) { - new_quads[i]->set_used_flag(); - new_quads[i]->clear_user_flag(); - new_quads[i]->clear_user_data(); - new_quads[i]->clear_children(); - new_quads[i]->set_boundary_id_internal( - quad->boundary_id()); - new_quads[i]->set_manifold_id(quad->manifold_id()); + new_quad->set_used_flag(); + new_quad->clear_user_flag(); + new_quad->clear_user_data(); + new_quad->clear_children(); + new_quad->set_boundary_id_internal(quad->boundary_id()); + new_quad->set_manifold_id(quad->manifold_id()); // set all line orientations to true, change // this after the loop, as we have to consider // different lines for each child for (unsigned int j = 0; j < GeometryInfo::lines_per_face; ++j) - new_quads[i]->set_line_orientation(j, true); + new_quad->set_line_orientation(j, true); } // now set the line orientation of children of // outer lines correctly, the lines in the @@ -6972,7 +6961,7 @@ namespace internal // and fill it with the respective values bool line_orientation[4]; - // the middle vertice marked as m0 above is the + // the middle vertex marked as m0 above is the // start vertex for lines 0 and 2 in standard // orientation, whereas m1 is the end vertex of // lines 1 and 3 in standard orientation @@ -7202,7 +7191,7 @@ namespace internal // and fill it with the respective values bool line_orientation[4]; - // the middle vertice marked as m0 above is the + // the middle vertex marked as m0 above is the // start vertex for lines 0 and 2 in standard // orientation, whereas m1 is the end vertex of // lines 1 and 3 in standard orientation @@ -10989,8 +10978,8 @@ namespace &levels, internal::TriangulationImplementation::TriaFaces<1> *) { - for (unsigned int level = 0; level < levels.size(); ++level) - levels[level]->cells.clear_user_flags(); + for (const auto &level : levels) + level->cells.clear_user_flags(); } template @@ -11030,8 +11019,8 @@ namespace &levels, internal::TriangulationImplementation::TriaFaces<2> *) { - for (unsigned int level = 0; level < levels.size(); ++level) - levels[level]->cells.clear_user_flags(); + for (const auto &level : levels) + level->cells.clear_user_flags(); } template @@ -11080,8 +11069,8 @@ namespace &levels, internal::TriangulationImplementation::TriaFaces<3> *) { - for (unsigned int level = 0; level < levels.size(); ++level) - levels[level]->cells.clear_user_flags(); + for (const auto &level : levels) + level->cells.clear_user_flags(); } } // namespace