From efe1e202d5779cbae0f2aa6b85ddd43ce27d30c3 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Wed, 4 Mar 2020 18:46:38 -0700 Subject: [PATCH] Use GeometryInfo::vertex_indices() in include/ and source/. --- include/deal.II/dofs/dof_accessor.templates.h | 25 ++-- include/deal.II/fe/fe_tools.templates.h | 15 +-- include/deal.II/fe/mapping_manifold.h | 4 +- include/deal.II/grid/grid_tools.h | 28 ++--- .../deal.II/grid/tria_accessor.templates.h | 8 +- include/deal.II/numerics/data_out_dof_data.h | 3 +- source/base/data_out_base.cc | 8 +- source/distributed/tria.cc | 53 ++++---- source/distributed/tria_base.cc | 5 +- source/dofs/dof_handler.cc | 12 +- source/dofs/dof_handler_policy.cc | 42 ++----- source/dofs/dof_tools.cc | 10 +- source/fe/fe_enriched.cc | 6 +- source/fe/fe_q_hierarchical.cc | 4 +- source/fe/mapping.cc | 2 +- source/fe/mapping_fe_field.cc | 5 +- source/fe/mapping_manifold.cc | 7 +- source/fe/mapping_q1_eulerian.cc | 4 +- source/fe/mapping_q_generic.cc | 15 ++- source/grid/grid_generator.cc | 47 +++----- source/grid/grid_in.cc | 25 ++-- source/grid/grid_out.cc | 26 ++-- source/grid/grid_reordering.cc | 24 ++-- source/grid/grid_tools.cc | 114 +++++++----------- source/grid/grid_tools_dof_handlers.cc | 50 +++----- source/grid/manifold.cc | 6 +- source/grid/manifold_lib.cc | 20 ++- source/grid/tria.cc | 76 +++++------- source/grid/tria_accessor.cc | 16 ++- source/grid/tria_description.cc | 42 ++----- source/hp/dof_handler.cc | 6 +- source/numerics/data_out.cc | 5 +- source/numerics/data_out_rotation.cc | 5 +- source/particles/particle_handler.cc | 6 +- 34 files changed, 271 insertions(+), 453 deletions(-) diff --git a/include/deal.II/dofs/dof_accessor.templates.h b/include/deal.II/dofs/dof_accessor.templates.h index 269f454547..aa30251af7 100644 --- a/include/deal.II/dofs/dof_accessor.templates.h +++ b/include/deal.II/dofs/dof_accessor.templates.h @@ -1407,9 +1407,7 @@ namespace internal std::vector::const_iterator next = dof_indices.begin(); - for (unsigned int vertex = 0; - vertex < GeometryInfo<1>::vertices_per_cell; - ++vertex) + for (const unsigned int vertex : GeometryInfo<1>::vertex_indices()) for (unsigned int dof = 0; dof < fe.dofs_per_vertex; ++dof) accessor.set_mg_vertex_dof_index( level, vertex, dof, *next++, fe_index); @@ -1435,9 +1433,7 @@ namespace internal std::vector::const_iterator next = dof_indices.begin(); - for (unsigned int vertex = 0; - vertex < GeometryInfo<2>::vertices_per_cell; - ++vertex) + for (const unsigned int vertex : GeometryInfo<2>::vertex_indices()) for (unsigned int dof = 0; dof < fe.dofs_per_vertex; ++dof) accessor.set_mg_vertex_dof_index( level, vertex, dof, *next++, fe_index); @@ -1470,9 +1466,7 @@ namespace internal std::vector::const_iterator next = dof_indices.begin(); - for (unsigned int vertex = 0; - vertex < GeometryInfo<3>::vertices_per_cell; - ++vertex) + for (const unsigned int vertex : GeometryInfo<3>::vertex_indices()) for (unsigned int dof = 0; dof < fe.dofs_per_vertex; ++dof) accessor.set_mg_vertex_dof_index( level, vertex, dof, *next++, fe_index); @@ -1950,8 +1944,7 @@ namespace internal handler.get_fe(fe_index); std::vector::iterator next = dof_indices.begin(); - for (unsigned int vertex = 0; vertex < GeometryInfo<1>::vertices_per_cell; - ++vertex) + for (const unsigned int vertex : GeometryInfo<1>::vertex_indices()) for (unsigned int dof = 0; dof < fe.dofs_per_vertex; ++dof) *next++ = accessor.mg_vertex_dof_index(level, vertex, dof); @@ -1978,8 +1971,7 @@ namespace internal handler.get_fe(fe_index); std::vector::iterator next = dof_indices.begin(); - for (unsigned int vertex = 0; vertex < GeometryInfo<2>::vertices_per_cell; - ++vertex) + for (const unsigned int vertex : GeometryInfo<2>::vertex_indices()) for (unsigned int dof = 0; dof < fe.dofs_per_vertex; ++dof) *next++ = accessor.mg_vertex_dof_index(level, vertex, dof); @@ -2011,8 +2003,7 @@ namespace internal handler.get_fe(fe_index); std::vector::iterator next = dof_indices.begin(); - for (unsigned int vertex = 0; vertex < GeometryInfo<3>::vertices_per_cell; - ++vertex) + for (const unsigned int vertex : GeometryInfo<3>::vertex_indices()) for (unsigned int dof = 0; dof < fe.dofs_per_vertex; ++dof) *next++ = accessor.mg_vertex_dof_index(level, vertex, dof); @@ -2990,9 +2981,7 @@ namespace internal unsigned int index = 0; - for (unsigned int vertex = 0; - vertex < GeometryInfo::vertices_per_cell; - ++vertex) + for (const unsigned int vertex : GeometryInfo::vertex_indices()) for (unsigned int d = 0; d < dofs_per_vertex; ++d, ++index) accessor.set_vertex_dof_index(vertex, d, diff --git a/include/deal.II/fe/fe_tools.templates.h b/include/deal.II/fe/fe_tools.templates.h index 0a7d0d6375..d8f4c374b4 100644 --- a/include/deal.II/fe/fe_tools.templates.h +++ b/include/deal.II/fe/fe_tools.templates.h @@ -227,9 +227,8 @@ namespace FETools // for each shape function, copy the flags from the base element to this // one, taking into account multiplicities, and other complications unsigned int total_index = 0; - for (unsigned int vertex_number = 0; - vertex_number < GeometryInfo::vertices_per_cell; - ++vertex_number) + for (const unsigned int vertex_number : + GeometryInfo::vertex_indices()) { for (unsigned int base = 0; base < fes.size(); ++base) for (unsigned int m = 0; m < multiplicities[base]; ++m) @@ -419,9 +418,8 @@ namespace FETools // to this one, taking into account multiplicities, multiple components in // base elements, and other complications unsigned int total_index = 0; - for (unsigned int vertex_number = 0; - vertex_number < GeometryInfo::vertices_per_cell; - ++vertex_number) + for (const unsigned int vertex_number : + GeometryInfo::vertex_indices()) { unsigned int comp_start = 0; for (unsigned int base = 0; base < fes.size(); ++base) @@ -663,9 +661,8 @@ namespace FETools // the first vertex in the order of the base elements, then of the second // vertex, etc total_index = 0; - for (unsigned int vertex_number = 0; - vertex_number < GeometryInfo::vertices_per_cell; - ++vertex_number) + for (const unsigned int vertex_number : + GeometryInfo::vertex_indices()) { unsigned int comp_start = 0; for (unsigned int base = 0; base < fe.n_base_elements(); ++base) diff --git a/include/deal.II/fe/mapping_manifold.h b/include/deal.II/fe/mapping_manifold.h index 828f74d011..7dd5a81adc 100644 --- a/include/deal.II/fe/mapping_manifold.h +++ b/include/deal.II/fe/mapping_manifold.h @@ -400,7 +400,7 @@ MappingManifold::InternalData::store_vertices( const typename Triangulation::cell_iterator &cell) const { vertices.resize(GeometryInfo::vertices_per_cell); - for (unsigned int i = 0; i < GeometryInfo::vertices_per_cell; ++i) + for (const unsigned int i : GeometryInfo::vertex_indices()) vertices[i] = cell->vertex(i); this->cell = cell; } @@ -415,7 +415,7 @@ MappingManifold::InternalData:: quad.size(), std::vector(GeometryInfo::vertices_per_cell)); for (unsigned int q = 0; q < quad.size(); ++q) { - for (unsigned int i = 0; i < GeometryInfo::vertices_per_cell; ++i) + for (const unsigned int i : GeometryInfo::vertex_indices()) { cell_manifold_quadrature_weights[q][i] = GeometryInfo::d_linear_shape_function(quad.point(q), i); diff --git a/include/deal.II/grid/grid_tools.h b/include/deal.II/grid/grid_tools.h index d891ea3bdd..4369210a60 100644 --- a/include/deal.II/grid/grid_tools.h +++ b/include/deal.II/grid/grid_tools.h @@ -3145,7 +3145,7 @@ namespace GridTools cell = triangulation.begin_active(), endc = triangulation.end(); for (; cell != endc; ++cell) - for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; ++v) + for (const unsigned int v : GeometryInfo::vertex_indices()) if (treated_vertices[cell->vertex_index(v)] == false) { // transform this vertex @@ -3464,29 +3464,25 @@ namespace GridTools xi[d] = 0.5; Point x_k; - for (unsigned int i = 0; i < GeometryInfo::vertices_per_cell; - ++i) + for (const unsigned int i : GeometryInfo::vertex_indices()) x_k += object->vertex(i) * GeometryInfo::d_linear_shape_function(xi, i); do { Tensor<1, structdim> F_k; - for (unsigned int i = 0; - i < GeometryInfo::vertices_per_cell; - ++i) + for (const unsigned int i : + GeometryInfo::vertex_indices()) F_k += (x_k - trial_point) * object->vertex(i) * GeometryInfo::d_linear_shape_function_gradient(xi, i); Tensor<2, structdim> H_k; - for (unsigned int i = 0; - i < GeometryInfo::vertices_per_cell; - ++i) - for (unsigned int j = 0; - j < GeometryInfo::vertices_per_cell; - ++j) + for (const unsigned int i : + GeometryInfo::vertex_indices()) + for (const unsigned int j : + GeometryInfo::vertex_indices()) { Tensor<2, structdim> tmp = outer_product( GeometryInfo::d_linear_shape_function_gradient( @@ -3500,9 +3496,8 @@ namespace GridTools xi += delta_xi; x_k = Point(); - for (unsigned int i = 0; - i < GeometryInfo::vertices_per_cell; - ++i) + for (const unsigned int i : + GeometryInfo::vertex_indices()) x_k += object->vertex(i) * GeometryInfo::d_linear_shape_function(xi, i); @@ -3920,8 +3915,7 @@ namespace GridTools if (cell->is_locally_owned()) { std::set send_to; - for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; - ++v) + for (const unsigned int v : GeometryInfo::vertex_indices()) { const std::map>:: diff --git a/include/deal.II/grid/tria_accessor.templates.h b/include/deal.II/grid/tria_accessor.templates.h index 572cfde36a..a4b5d33003 100644 --- a/include/deal.II/grid/tria_accessor.templates.h +++ b/include/deal.II/grid/tria_accessor.templates.h @@ -2166,7 +2166,7 @@ TriaAccessor::enclosing_ball() const // For each vertex that is found to be geometrically outside the ball // enlarge the ball so that the new ball contains both the previous ball // and the given vertex. - for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; ++v) + for (const unsigned int v : GeometryInfo::vertex_indices()) if (!is_initial_guess_vertex[v]) { const double distance = center.distance(this->vertex(v)); @@ -2188,7 +2188,7 @@ TriaAccessor::enclosing_ball() const // Set all_vertices_within_ball false if any of the vertices of the object // are geometrically outside the ball - for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; ++v) + for (const unsigned int v : GeometryInfo::vertex_indices()) if (center.distance(this->vertex(v)) > radius + 100. * std::numeric_limits::epsilon()) { @@ -2214,9 +2214,7 @@ TriaAccessor::minimum_vertex_distance() const case 3: { double min = std::numeric_limits::max(); - for (unsigned int i = 0; - i < GeometryInfo::vertices_per_cell; - ++i) + for (const unsigned int i : GeometryInfo::vertex_indices()) for (unsigned int j = i + 1; j < GeometryInfo::vertices_per_cell; ++j) diff --git a/include/deal.II/numerics/data_out_dof_data.h b/include/deal.II/numerics/data_out_dof_data.h index 2164aa86bf..6bd54c4e95 100644 --- a/include/deal.II/numerics/data_out_dof_data.h +++ b/include/deal.II/numerics/data_out_dof_data.h @@ -1185,8 +1185,7 @@ DataOut_DoFData::merge_patches( // perform shift, if so desired if (shift != Point()) for (unsigned int i = old_n_patches; i < patches.size(); ++i) - for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; - ++v) + for (const unsigned int v : GeometryInfo::vertex_indices()) patches[i].vertices[v] += shift; // adjust patch numbers diff --git a/source/base/data_out_base.cc b/source/base/data_out_base.cc index a210f67e74..cb2873f3dd 100644 --- a/source/base/data_out_base.cc +++ b/source/base/data_out_base.cc @@ -1772,7 +1772,7 @@ namespace DataOutBase { // TODO: make tolerance relative const double epsilon = 3e-16; - for (unsigned int i = 0; i < GeometryInfo::vertices_per_cell; ++i) + for (const unsigned int i : GeometryInfo::vertex_indices()) if (vertices[i].distance(patch.vertices[i]) > epsilon) return false; @@ -1868,7 +1868,7 @@ namespace DataOutBase // TODO: make tolerance relative const double epsilon = 3e-16; - for (unsigned int i = 0; i < GeometryInfo::vertices_per_cell; ++i) + for (const unsigned int i : GeometryInfo::vertex_indices()) if (vertices[i].distance(patch.vertices[i]) > epsilon) return false; @@ -8594,7 +8594,7 @@ namespace DataOutBase << '\n'; // then write all the data that is in this patch - for (unsigned int i = 0; i < GeometryInfo::vertices_per_cell; ++i) + for (const unsigned int i : GeometryInfo::vertex_indices()) out << patch.vertices[GeometryInfo::ucd_to_deal[i]] << ' '; out << '\n'; @@ -8643,7 +8643,7 @@ namespace DataOutBase // then read all the data that is in this patch - for (unsigned int i = 0; i < GeometryInfo::vertices_per_cell; ++i) + for (const unsigned int i : GeometryInfo::vertex_indices()) in >> patch.vertices[GeometryInfo::ucd_to_deal[i]]; for (unsigned int i : GeometryInfo::face_indices()) diff --git a/source/distributed/tria.cc b/source/distributed/tria.cc index 2477b09b0c..7a3e41e09b 100644 --- a/source/distributed/tria.cc +++ b/source/distributed/tria.cc @@ -58,7 +58,7 @@ namespace triangulation.begin_active(); cell != triangulation.end(); ++cell) - for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; ++v) + for (const unsigned int v : GeometryInfo::vertex_indices()) { ++vertex_touch_count[cell->vertex_index(v)]; vertex_to_cell[cell->vertex_index(v)].emplace_back(cell, v); @@ -147,7 +147,7 @@ namespace const unsigned int index = coarse_cell_to_p4est_tree_permutation[cell->index()]; - for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; ++v) + for (const unsigned int v : GeometryInfo::vertex_indices()) { if (set_vertex_info == true) connectivity @@ -349,7 +349,7 @@ namespace // important: only assign the level_subdomain_id if it is a ghost cell // even though we could fill in all. bool used = false; - for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; ++v) + for (const unsigned int v : GeometryInfo::vertex_indices()) { if (marked_vertices[dealii_cell->level()] [dealii_cell->vertex_index(v)]) @@ -375,8 +375,7 @@ namespace dealii_cell->is_artificial() == false && dealii_cell->level() + 1 < static_cast(marked_vertices.size())) { - for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; - ++v) + for (const unsigned int v : GeometryInfo::vertex_indices()) { if (marked_vertices[dealii_cell->level() + 1] [dealii_cell->vertex_index(v)]) @@ -391,8 +390,7 @@ namespace if (!used && dealii_cell->is_active() && dealii_cell->is_artificial() == false && dealii_cell->level() > 0) { - for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; - ++v) + for (const unsigned int v : GeometryInfo::vertex_indices()) { if (marked_vertices[dealii_cell->level() - 1] [dealii_cell->vertex_index(v)]) @@ -2442,8 +2440,7 @@ namespace parallel if (dealii_cell->is_locally_owned()) { std::set send_to; - for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; - ++v) + for (const unsigned int v : GeometryInfo::vertex_indices()) { const std::map>:: @@ -2466,9 +2463,8 @@ namespace parallel { std::vector vertex_indices; std::vector> local_vertices; - for (unsigned int v = 0; - v < GeometryInfo::vertices_per_cell; - ++v) + for (const unsigned int v : + GeometryInfo::vertex_indices()) if (vertex_locally_moved[dealii_cell->vertex_index(v)]) { vertex_indices.push_back(v); @@ -3305,18 +3301,16 @@ namespace parallel for (; cell != endc; ++cell) { if (cell->refine_flag_set()) - for (unsigned int vertex = 0; - vertex < GeometryInfo::vertices_per_cell; - ++vertex) + for (const unsigned int vertex : + GeometryInfo::vertex_indices()) vertex_level[topological_vertex_numbering [cell->vertex_index(vertex)]] = std::max(vertex_level[topological_vertex_numbering [cell->vertex_index(vertex)]], cell->level() + 1); else if (!cell->coarsen_flag_set()) - for (unsigned int vertex = 0; - vertex < GeometryInfo::vertices_per_cell; - ++vertex) + for (const unsigned int vertex : + GeometryInfo::vertex_indices()) vertex_level[topological_vertex_numbering [cell->vertex_index(vertex)]] = std::max(vertex_level[topological_vertex_numbering @@ -3331,9 +3325,8 @@ namespace parallel // to correct this by iterating over the entire // process until we are converged Assert(cell->coarsen_flag_set(), ExcInternalError()); - for (unsigned int vertex = 0; - vertex < GeometryInfo::vertices_per_cell; - ++vertex) + for (const unsigned int vertex : + GeometryInfo::vertex_indices()) vertex_level[topological_vertex_numbering [cell->vertex_index(vertex)]] = std::max(vertex_level[topological_vertex_numbering @@ -3356,9 +3349,8 @@ namespace parallel for (cell = tria.last_active(); cell != endc; --cell) if (cell->refine_flag_set() == false) { - for (unsigned int vertex = 0; - vertex < GeometryInfo::vertices_per_cell; - ++vertex) + for (const unsigned int vertex : + GeometryInfo::vertex_indices()) if (vertex_level[topological_vertex_numbering [cell->vertex_index(vertex)]] >= cell->level() + 1) @@ -3376,9 +3368,8 @@ namespace parallel cell->set_refine_flag(); continue_iterating = true; - for (unsigned int v = 0; - v < GeometryInfo::vertices_per_cell; - ++v) + for (const unsigned int v : + GeometryInfo::vertex_indices()) vertex_level[topological_vertex_numbering [cell->vertex_index(v)]] = std::max( @@ -4050,9 +4041,8 @@ namespace parallel (cell->level_subdomain_id() == numbers::artificial_subdomain_id); bool need_to_know = false; - for (unsigned int vertex = 0; - vertex < GeometryInfo::vertices_per_cell; - ++vertex) + for (const unsigned int vertex : + GeometryInfo::vertex_indices()) if (active_verts[cell->vertex_index(vertex)]) { need_to_know = true; @@ -4509,8 +4499,7 @@ namespace parallel cell_iterator cell = this->begin(level), endc = this->end(level); for (; cell != endc; ++cell) if (cell->level_subdomain_id() == this->locally_owned_subdomain()) - for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; - ++v) + for (const unsigned int v : GeometryInfo::vertex_indices()) marked_vertices[cell->vertex_index(v)] = true; /** diff --git a/source/distributed/tria_base.cc b/source/distributed/tria_base.cc index 189be2a997..97a3718aec 100644 --- a/source/distributed/tria_base.cc +++ b/source/distributed/tria_base.cc @@ -376,7 +376,7 @@ namespace parallel std::vector vertex_of_own_cell(this->n_vertices(), false); for (const auto &cell : this->active_cell_iterators()) if (cell->is_locally_owned()) - for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; ++v) + for (const unsigned int v : GeometryInfo::vertex_indices()) vertex_of_own_cell[cell->vertex_index(v)] = true; // 3) for each vertex belonging to a locally owned cell all ghost @@ -390,8 +390,7 @@ namespace parallel const types::subdomain_id owner = cell->subdomain_id(); // loop over all its vertices - for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; - ++v) + for (const unsigned int v : GeometryInfo::vertex_indices()) { // set owner if vertex belongs to a local cell if (vertex_of_own_cell[cell->vertex_index(v)]) diff --git a/source/dofs/dof_handler.cc b/source/dofs/dof_handler.cc index b5efafe0bf..69133d732d 100644 --- a/source/dofs/dof_handler.cc +++ b/source/dofs/dof_handler.cc @@ -427,9 +427,7 @@ namespace internal { const unsigned int level = cell->level(); - for (unsigned int vertex = 0; - vertex < GeometryInfo<1>::vertices_per_cell; - ++vertex) + for (const unsigned int vertex : GeometryInfo<1>::vertex_indices()) { const unsigned int vertex_index = cell->vertex_index(vertex); @@ -503,9 +501,7 @@ namespace internal { const unsigned int level = cell->level(); - for (unsigned int vertex = 0; - vertex < GeometryInfo<2>::vertices_per_cell; - ++vertex) + for (const unsigned int vertex : GeometryInfo<2>::vertex_indices()) { const unsigned int vertex_index = cell->vertex_index(vertex); @@ -580,9 +576,7 @@ namespace internal { const unsigned int level = cell->level(); - for (unsigned int vertex = 0; - vertex < GeometryInfo<3>::vertices_per_cell; - ++vertex) + for (const unsigned int vertex : GeometryInfo<3>::vertex_indices()) { const unsigned int vertex_index = cell->vertex_index(vertex); diff --git a/source/dofs/dof_handler_policy.cc b/source/dofs/dof_handler_policy.cc index cde3c40aa8..9306e7a96e 100644 --- a/source/dofs/dof_handler_policy.cc +++ b/source/dofs/dof_handler_policy.cc @@ -235,8 +235,7 @@ namespace internal { // distribute dofs of vertices if (dof_handler.get_fe().dofs_per_vertex > 0) - for (unsigned int v = 0; v < GeometryInfo<1>::vertices_per_cell; - ++v) + for (const unsigned int v : GeometryInfo<1>::vertex_indices()) { if (cell->vertex_dof_index(v, 0) == numbers::invalid_dof_index) for (unsigned int d = 0; @@ -275,9 +274,7 @@ namespace internal { if (dof_handler.get_fe().dofs_per_vertex > 0) // number dofs on vertices - for (unsigned int vertex = 0; - vertex < GeometryInfo<2>::vertices_per_cell; - ++vertex) + for (const unsigned int vertex : GeometryInfo<2>::vertex_indices()) // check whether dofs for this vertex have been distributed // (checking the first dof should be good enough) if (cell->vertex_dof_index(vertex, 0) == @@ -326,9 +323,7 @@ namespace internal { if (dof_handler.get_fe().dofs_per_vertex > 0) // number dofs on vertices - for (unsigned int vertex = 0; - vertex < GeometryInfo<3>::vertices_per_cell; - ++vertex) + for (const unsigned int vertex : GeometryInfo<3>::vertex_indices()) // check whether dofs for this vertex have been distributed // (checking the first dof should be good enough) if (cell->vertex_dof_index(vertex, 0) == @@ -404,9 +399,7 @@ namespace internal // (only check the first dof), and if this isn't the case // distribute new ones there if (fe.dofs_per_vertex > 0) - for (unsigned int vertex = 0; - vertex < GeometryInfo<1>::vertices_per_cell; - ++vertex) + for (const unsigned int vertex : GeometryInfo<1>::vertex_indices()) if (cell->vertex_dof_index(vertex, 0, fe_index) == numbers::invalid_dof_index) for (unsigned int d = 0; d < fe.dofs_per_vertex; @@ -454,9 +447,7 @@ namespace internal // (only check the first dof), and if this isn't the case // distribute new ones there if (fe.dofs_per_vertex > 0) - for (unsigned int vertex = 0; - vertex < GeometryInfo<2>::vertices_per_cell; - ++vertex) + for (const unsigned int vertex : GeometryInfo<2>::vertex_indices()) if (cell->vertex_dof_index(vertex, 0, fe_index) == numbers::invalid_dof_index) for (unsigned int d = 0; d < fe.dofs_per_vertex; @@ -520,9 +511,7 @@ namespace internal // (only check the first dof), and if this isn't the case // distribute new ones there if (fe.dofs_per_vertex > 0) - for (unsigned int vertex = 0; - vertex < GeometryInfo<3>::vertices_per_cell; - ++vertex) + for (const unsigned int vertex : GeometryInfo<3>::vertex_indices()) if (cell->vertex_dof_index(vertex, 0, fe_index) == numbers::invalid_dof_index) for (unsigned int d = 0; d < fe.dofs_per_vertex; @@ -1439,9 +1428,7 @@ namespace internal &dof_handler.get_triangulation()) != nullptr) for (const auto &cell : dof_handler.active_cell_iterators()) if (cell->is_ghost()) - for (unsigned int v = 0; - v < GeometryInfo::vertices_per_cell; - ++v) + for (const unsigned int v : GeometryInfo::vertex_indices()) include_vertex[cell->vertex_index(v)] = true; // loop over all vertices and see which one we need to work on @@ -2117,8 +2104,7 @@ namespace internal { // distribute dofs of vertices if (cell->get_fe().dofs_per_vertex > 0) - for (unsigned int v = 0; v < GeometryInfo<1>::vertices_per_cell; - ++v) + for (const unsigned int v : GeometryInfo<1>::vertex_indices()) { typename DoFHandler::level_cell_iterator neighbor = cell->neighbor(v); @@ -2190,9 +2176,7 @@ namespace internal { if (cell->get_fe().dofs_per_vertex > 0) // number dofs on vertices - for (unsigned int vertex = 0; - vertex < GeometryInfo<2>::vertices_per_cell; - ++vertex) + for (const unsigned int vertex : GeometryInfo<2>::vertex_indices()) // check whether dofs for this // vertex have been distributed // (only check the first dof) @@ -2246,9 +2230,7 @@ namespace internal { if (cell->get_fe().dofs_per_vertex > 0) // number dofs on vertices - for (unsigned int vertex = 0; - vertex < GeometryInfo<3>::vertices_per_cell; - ++vertex) + for (const unsigned int vertex : GeometryInfo<3>::vertex_indices()) // check whether dofs for this vertex have been distributed // (only check the first dof) if (cell->mg_vertex_dof_index(cell->level(), vertex, 0) == @@ -4932,9 +4914,7 @@ namespace internal for (const auto &cell : dof_handler->active_cell_iterators()) if (cell->is_locally_owned()) { - for (unsigned int v = 0; - v < GeometryInfo::vertices_per_cell; - ++v) + for (const unsigned int v : GeometryInfo::vertex_indices()) if (vertices_with_ghost_neighbors.find(cell->vertex_index( v)) != vertices_with_ghost_neighbors.end()) { diff --git a/source/dofs/dof_tools.cc b/source/dofs/dof_tools.cc index 0044ee5520..2324dfc250 100644 --- a/source/dofs/dof_tools.cc +++ b/source/dofs/dof_tools.cc @@ -2720,9 +2720,8 @@ namespace DoFTools // Identify all vertices active on this level and remember some data // about them for (cell = dof_handler.begin(level); cell != endc; ++cell) - for (unsigned int v = 0; - v < GeometryInfo::vertices_per_cell; - ++v) + for (const unsigned int v : + GeometryInfo::vertex_indices()) { const unsigned int vg = cell->vertex_index(v); vertex_dof_count[vg] += cell->get_fe().dofs_per_cell; @@ -2777,9 +2776,8 @@ namespace DoFTools indices.resize(fe.dofs_per_cell); cell->get_mg_dof_indices(indices); - for (unsigned int v = 0; - v < GeometryInfo::vertices_per_cell; - ++v) + for (const unsigned int v : + GeometryInfo::vertex_indices()) { const unsigned int vg = cell->vertex_index(v); const unsigned int block = vertex_mapping[vg]; diff --git a/source/fe/fe_enriched.cc b/source/fe/fe_enriched.cc index a41a54ade3..214d86ea5b 100644 --- a/source/fe/fe_enriched.cc +++ b/source/fe/fe_enriched.cc @@ -1076,15 +1076,13 @@ namespace ColorEnriched // Mark vertices that belong to cells in subdomain 1 for (const auto &cell : dof_handler.active_cell_iterators()) if (predicate_1(cell)) // True ==> part of subdomain 1 - for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; - ++v) + for (const unsigned int v : GeometryInfo::vertex_indices()) vertices_subdomain_1[cell->vertex_index(v)] = true; // Find if cells in subdomain 2 and subdomain 1 share vertices. for (const auto &cell : dof_handler.active_cell_iterators()) if (predicate_2(cell)) // True ==> part of subdomain 2 - for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; - ++v) + for (const unsigned int v : GeometryInfo::vertex_indices()) if (vertices_subdomain_1[cell->vertex_index(v)] == true) { return true; diff --git a/source/fe/fe_q_hierarchical.cc b/source/fe/fe_q_hierarchical.cc index 1ba13b069b..d77f389ad5 100644 --- a/source/fe/fe_q_hierarchical.cc +++ b/source/fe/fe_q_hierarchical.cc @@ -2261,7 +2261,7 @@ FE_Q_Hierarchical::get_embedding_dofs(const unsigned int sub_degree) const { std::vector embedding_dofs( GeometryInfo::vertices_per_cell); - for (unsigned int i = 0; i < GeometryInfo::vertices_per_cell; ++i) + for (const unsigned int i : GeometryInfo::vertex_indices()) embedding_dofs[i] = i; return embedding_dofs; @@ -2386,7 +2386,7 @@ std::pair, std::vector> FE_Q_Hierarchical::get_constant_modes() const { Table<2, bool> constant_modes(1, this->dofs_per_cell); - for (unsigned int i = 0; i < GeometryInfo::vertices_per_cell; ++i) + for (const unsigned int i : GeometryInfo::vertex_indices()) constant_modes(0, i) = true; for (unsigned int i = GeometryInfo::vertices_per_cell; i < this->dofs_per_cell; diff --git a/source/fe/mapping.cc b/source/fe/mapping.cc index 1ac3f4997f..d00b05df83 100644 --- a/source/fe/mapping.cc +++ b/source/fe/mapping.cc @@ -29,7 +29,7 @@ Mapping::get_vertices( const typename Triangulation::cell_iterator &cell) const { std::array, GeometryInfo::vertices_per_cell> vertices; - for (unsigned int i = 0; i < GeometryInfo::vertices_per_cell; ++i) + for (const unsigned int i : GeometryInfo::vertex_indices()) { vertices[i] = cell->vertex(i); } diff --git a/source/fe/mapping_fe_field.cc b/source/fe/mapping_fe_field.cc index f01bd9cdb6..da952eb2bc 100644 --- a/source/fe/mapping_fe_field.cc +++ b/source/fe/mapping_fe_field.cc @@ -201,7 +201,7 @@ namespace if (quad.size() == 0) { std::vector> points(GeometryInfo::vertices_per_cell); - for (unsigned int i = 0; i < GeometryInfo::vertices_per_cell; ++i) + for (const unsigned int i : GeometryInfo::vertex_indices()) points[i] = GeometryInfo::unit_cell_vertex(i); quad = Quadrature(points); } @@ -405,8 +405,7 @@ MappingFEField::get_vertices( typename VectorType::value_type value = internal::ElementAccess::get(vector, dof_indices[i]); if (euler_dof_handler->get_fe().is_primitive(i)) - for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; - ++v) + for (const unsigned int v : GeometryInfo::vertex_indices()) vertices[v][comp] += fe_values.shape_value(i, v) * value; else Assert(false, ExcNotImplemented()); diff --git a/source/fe/mapping_manifold.cc b/source/fe/mapping_manifold.cc index 5a2c5ee830..73276788ff 100644 --- a/source/fe/mapping_manifold.cc +++ b/source/fe/mapping_manifold.cc @@ -178,7 +178,7 @@ MappingManifold::transform_unit_to_real_cell( std::array, GeometryInfo::vertices_per_cell> vertices; std::array::vertices_per_cell> weights; - for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; ++v) + for (const unsigned int v : GeometryInfo::vertex_indices()) { vertices[v] = cell->vertex(v); weights[v] = GeometryInfo::d_linear_shape_function(p, v); @@ -416,9 +416,8 @@ namespace internal const Point np(p + L * ei); // Get the weights to compute the np point in real space - for (unsigned int j = 0; - j < GeometryInfo::vertices_per_cell; - ++j) + for (const unsigned int j : + GeometryInfo::vertex_indices()) data.vertex_weights[j] = GeometryInfo::d_linear_shape_function(np, j); diff --git a/source/fe/mapping_q1_eulerian.cc b/source/fe/mapping_q1_eulerian.cc index 7d7d381c20..ca0483c886 100644 --- a/source/fe/mapping_q1_eulerian.cc +++ b/source/fe/mapping_q1_eulerian.cc @@ -81,7 +81,7 @@ MappingQ1Eulerian::get_vertices( shiftmap_dof_handler->get_fe().dofs_per_cell); dof_cell->get_dof_values(*euler_transform_vectors, mapping_values); - for (unsigned int i = 0; i < GeometryInfo::vertices_per_cell; ++i) + for (const unsigned int i : GeometryInfo::vertex_indices()) { Point shift_vector; @@ -109,7 +109,7 @@ MappingQ1Eulerian::compute_mapping_support_points( vertices = this->get_vertices(cell); std::vector> a(GeometryInfo::vertices_per_cell); - for (unsigned int i = 0; i < GeometryInfo::vertices_per_cell; ++i) + for (const unsigned int i : GeometryInfo::vertex_indices()) a[i] = vertices[i]; return a; diff --git a/source/fe/mapping_q_generic.cc b/source/fe/mapping_q_generic.cc index ed7d7ce4d4..d2156ba6f3 100644 --- a/source/fe/mapping_q_generic.cc +++ b/source/fe/mapping_q_generic.cc @@ -1101,7 +1101,7 @@ namespace internal output[0].reinit(polynomial_degree - 1, GeometryInfo<1>::vertices_per_cell); for (unsigned int q = 0; q < polynomial_degree - 1; ++q) - for (unsigned int i = 0; i < GeometryInfo<1>::vertices_per_cell; ++i) + for (const unsigned int i : GeometryInfo<1>::vertex_indices()) output[0](q, i) = GeometryInfo<1>::d_linear_shape_function(quadrature.point(q + 1), i); @@ -1135,8 +1135,7 @@ namespace internal GeometryInfo::vertices_per_cell, GeometryInfo::vertices_per_cell); for (unsigned int q = 0; q < output.size(0); ++q) - for (unsigned int i = 0; i < GeometryInfo::vertices_per_cell; - ++i) + for (const unsigned int i : GeometryInfo::vertex_indices()) output(q, i) = GeometryInfo::d_linear_shape_function( quadrature.point(h2l[q + GeometryInfo::vertices_per_cell]), i); @@ -2598,7 +2597,7 @@ MappingQGeneric::transform_real_to_unit_cell( this->compute_mapping_support_points(cell); a.resize(GeometryInfo::vertices_per_cell); std::vector> cells(1); - for (unsigned int i = 0; i < GeometryInfo::vertices_per_cell; ++i) + for (const unsigned int i : GeometryInfo::vertex_indices()) cells[0].vertices[i] = i; Triangulation tria; tria.create_triangulation(a, cells, SubCellData()); @@ -3951,7 +3950,7 @@ MappingQGeneric<3, 3>::add_quad_support_points( boost::container::small_vector, 200> tmp_points( GeometryInfo<2>::vertices_per_cell + GeometryInfo<2>::lines_per_cell * (polynomial_degree - 1)); - for (unsigned int v = 0; v < GeometryInfo<2>::vertices_per_cell; ++v) + for (const unsigned int v : GeometryInfo<2>::vertex_indices()) tmp_points[v] = a[GeometryInfo<3>::face_to_cell_vertices(face_no, v)]; if (polynomial_degree > 1) for (unsigned int line = 0; line < GeometryInfo<2>::lines_per_cell; @@ -3983,7 +3982,7 @@ MappingQGeneric<2, 3>::add_quad_support_points( std::vector> & a) const { std::array, GeometryInfo<2>::vertices_per_cell> vertices; - for (unsigned int i = 0; i < GeometryInfo<2>::vertices_per_cell; ++i) + for (const unsigned int i : GeometryInfo<2>::vertex_indices()) vertices[i] = cell->vertex(i); Table<2, double> weights(Utilities::fixed_power<2>(polynomial_degree - 1), @@ -3993,7 +3992,7 @@ MappingQGeneric<2, 3>::add_quad_support_points( { Point<2> point(line_support_points.point(q1 + 1)[0], line_support_points.point(q2 + 1)[0]); - for (unsigned int i = 0; i < GeometryInfo<2>::vertices_per_cell; ++i) + for (const unsigned int i : GeometryInfo<2>::vertex_indices()) weights(q, i) = GeometryInfo<2>::d_linear_shape_function(point, i); } @@ -4025,7 +4024,7 @@ MappingQGeneric::compute_mapping_support_points( // get the vertices first std::vector> a; a.reserve(Utilities::fixed_power(polynomial_degree + 1)); - for (unsigned int i = 0; i < GeometryInfo::vertices_per_cell; ++i) + for (const unsigned int i : GeometryInfo::vertex_indices()) a.push_back(cell->vertex(i)); if (this->polynomial_degree > 1) diff --git a/source/grid/grid_generator.cc b/source/grid/grid_generator.cc index 1474276e91..eb6c9488c5 100644 --- a/source/grid/grid_generator.cc +++ b/source/grid/grid_generator.cc @@ -961,8 +961,7 @@ namespace GridGenerator // loop over vertices of all cells for (auto &cell : tria) - for (unsigned int v = 0; v < GeometryInfo<2>::vertices_per_cell; - ++v) + for (const unsigned int v : GeometryInfo<2>::vertex_indices()) { // vertex has been already processed: nothing to do if (vertex_processed[cell.vertex_index(v)]) @@ -1567,7 +1566,7 @@ namespace GridGenerator // Prepare cell data std::vector> cells(1); - for (unsigned int i = 0; i < GeometryInfo::vertices_per_cell; ++i) + for (const unsigned int i : GeometryInfo::vertex_indices()) cells[0].vertices[i] = i; cells[0].material_id = 0; @@ -2064,7 +2063,7 @@ namespace GridGenerator typename Triangulation::active_cell_iterator cell = tria.begin_active(); - for (unsigned int i = 0; i < GeometryInfo::vertices_per_cell; ++i) + for (const unsigned int i : GeometryInfo::vertex_indices()) cell->vertex(i) = vertices[i]; // Check that the order of the vertices makes sense, i.e., the volume of the @@ -3535,9 +3534,8 @@ namespace GridGenerator if (cylinder_triangulation_offset == Tensor<1, 2>()) { - for (unsigned int vertex_n = 0; - vertex_n < GeometryInfo<2>::vertices_per_cell; - ++vertex_n) + for (const unsigned int vertex_n : + GeometryInfo<2>::vertex_indices()) if (cell->vertex(vertex_n) == Point<2>()) { // cylinder_tria is centered at zero, so we need to @@ -3563,9 +3561,7 @@ namespace GridGenerator // and right sides of cylinder_tria inwards so that it fits in // bulk_tria: for (const auto &cell : cylinder_tria.active_cell_iterators()) - for (unsigned int vertex_n = 0; - vertex_n < GeometryInfo<2>::vertices_per_cell; - ++vertex_n) + for (const unsigned int vertex_n : GeometryInfo<2>::vertex_indices()) { if (std::abs(cell->vertex(vertex_n)[0] - -0.41 / 4.0) < 1e-10) cell->vertex(vertex_n)[0] = -0.1; @@ -3633,7 +3629,7 @@ namespace GridGenerator const double shift = std::min(0.125 + shell_region_width * 0.5, 0.1 * 4. / 3.); for (const auto &cell : tria.active_cell_iterators()) - for (unsigned int v = 0; v < GeometryInfo<2>::vertices_per_cell; ++v) + for (const unsigned int v : GeometryInfo<2>::vertex_indices()) if (cell->vertex(v).distance(Point<2>(0.1, 0.205)) < 1e-10) cell->vertex(v) = Point<2>(0.2 - shift, 0.205); else if (cell->vertex(v).distance(Point<2>(0.3, 0.205)) < 1e-10) @@ -3777,7 +3773,7 @@ namespace GridGenerator std::vector> cells(n_cells); // Vertices of the center cell - for (unsigned int i = 0; i < GeometryInfo::vertices_per_cell; ++i) + for (const unsigned int i : GeometryInfo::vertex_indices()) { Point p; for (unsigned int d = 0; d < dim; ++d) @@ -4048,12 +4044,12 @@ namespace GridGenerator std::end(vertices_tmp)); unsigned int cell_vertices[1][GeometryInfo<2>::vertices_per_cell]; - for (unsigned int i = 0; i < GeometryInfo<2>::vertices_per_cell; ++i) + for (const unsigned int i : GeometryInfo<2>::vertex_indices()) cell_vertices[0][i] = i; std::vector> cells(1, CellData<2>()); - for (unsigned int i = 0; i < GeometryInfo<2>::vertices_per_cell; ++i) + for (const unsigned int i : GeometryInfo<2>::vertex_indices()) cells[0].vertices[i] = cell_vertices[0][i]; cells[0].material_id = 0; @@ -4976,7 +4972,7 @@ namespace GridGenerator for (unsigned int i = 0; i < n_cells; ++i) { - for (unsigned int j = 0; j < GeometryInfo<3>::vertices_per_cell; ++j) + for (const unsigned int j : GeometryInfo<3>::vertex_indices()) cells[i].vertices[j] = cell_vertices[i][j]; cells[i].material_id = 0; cells[i].manifold_id = i == 0 ? numbers::flat_manifold_id : 1; @@ -5380,8 +5376,7 @@ namespace GridGenerator for (unsigned int i = 0; i < n_cells; ++i) { - for (unsigned int j = 0; j < GeometryInfo<3>::vertices_per_cell; - ++j) + for (const unsigned int j : GeometryInfo<3>::vertex_indices()) cells[i].vertices[j] = cell_vertices[i][j]; cells[i].material_id = 0; } @@ -5454,8 +5449,7 @@ namespace GridGenerator 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; - ++v) + for (const unsigned int v : GeometryInfo<3>::vertex_indices()) cells[cell_index].vertices[v] = cell->vertex_index(v); cells[cell_index].material_id = 0; } @@ -6155,8 +6149,7 @@ namespace GridGenerator "all cells are on the same refinement level.")); CellData this_cell; - for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; - ++v) + for (const unsigned int v : GeometryInfo::vertex_indices()) this_cell.vertices[v] = cell->vertex_index(v); this_cell.material_id = cell->material_id(); cells.push_back(this_cell); @@ -6313,9 +6306,8 @@ namespace GridGenerator for (std::size_t slice_n = 0; slice_n < n_slices - 1; ++slice_n) { CellData<3> this_cell; - for (unsigned int vertex_n = 0; - vertex_n < GeometryInfo<2>::vertices_per_cell; - ++vertex_n) + for (const unsigned int vertex_n : + GeometryInfo<2>::vertex_indices()) { this_cell.vertices[vertex_n] = cell->vertex_index(vertex_n) + slice_n * input.n_vertices(); @@ -6819,7 +6811,7 @@ namespace GridGenerator for (unsigned int id = 0; cell != endc; ++cell, ++id) { - for (unsigned int i = 0; i < GeometryInfo::vertices_per_cell; ++i) + for (const unsigned int i : GeometryInfo::vertex_indices()) cells[id].vertices[i] = cell->vertex_index(i); cells[id].material_id = cell->material_id(); cells[id].manifold_id = cell->manifold_id(); @@ -6978,9 +6970,8 @@ namespace GridGenerator { CellData c_data; - for (unsigned int j = 0; - j < GeometryInfo::vertices_per_cell; - ++j) + for (const unsigned int j : + GeometryInfo::vertex_indices()) { const unsigned int v_index = face->vertex_index(j); diff --git a/source/grid/grid_in.cc b/source/grid/grid_in.cc index a046132edf..810b8b03de 100644 --- a/source/grid/grid_in.cc +++ b/source/grid/grid_in.cc @@ -595,14 +595,12 @@ GridIn::read_unv(std::istream &in) cells.emplace_back(); AssertThrow(in, ExcIO()); - for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; - v++) + for (const unsigned int v : GeometryInfo::vertex_indices()) in >> cells.back().vertices[v]; cells.back().material_id = 0; - for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; - v++) + for (const unsigned int v : GeometryInfo::vertex_indices()) cells.back().vertices[v] = vertex_indices[cells.back().vertices[v]]; cell_indices[no] = no_cell; @@ -820,8 +818,7 @@ GridIn::read_ucd(std::istream &in, { // allocate and read indices cells.emplace_back(); - for (unsigned int i = 0; i < GeometryInfo::vertices_per_cell; - ++i) + for (const unsigned int i : GeometryInfo::vertex_indices()) in >> cells.back().vertices[i]; // to make sure that the cast won't fail @@ -841,8 +838,7 @@ GridIn::read_ucd(std::istream &in, // transform from ucd to // consecutive numbering - for (unsigned int i = 0; i < GeometryInfo::vertices_per_cell; - ++i) + for (const unsigned int i : GeometryInfo::vertex_indices()) if (vertex_indices.find(cells.back().vertices[i]) != vertex_indices.end()) // vertex with this index exists @@ -1188,7 +1184,7 @@ GridIn::read_dbmesh(std::istream &in) // read in vertex numbers. they // are 1-based, so subtract one cells.emplace_back(); - for (unsigned int i = 0; i < GeometryInfo::vertices_per_cell; ++i) + for (const unsigned int i : GeometryInfo::vertex_indices()) { in >> cells.back().vertices[i]; @@ -1832,9 +1828,7 @@ GridIn::read_msh(std::istream &in) // allocate and read indices cells.emplace_back(); - for (unsigned int i = 0; - i < GeometryInfo::vertices_per_cell; - ++i) + for (const unsigned int i : GeometryInfo::vertex_indices()) in >> cells.back().vertices[i]; // to make sure that the cast won't fail @@ -1853,9 +1847,7 @@ GridIn::read_msh(std::istream &in) // transform from ucd to // consecutive numbering - for (unsigned int i = 0; - i < GeometryInfo::vertices_per_cell; - ++i) + for (const unsigned int i : GeometryInfo::vertex_indices()) { AssertThrow( vertex_indices.find(cells.back().vertices[i]) != @@ -3058,8 +3050,7 @@ GridIn::read_assimp(const std::string &filename, { if (mFaces[i].mNumIndices == GeometryInfo::vertices_per_cell) { - for (unsigned int f = 0; f < GeometryInfo::vertices_per_cell; - ++f) + for (const unsigned int f : GeometryInfo::vertex_indices()) { cells[valid_cell].vertices[f] = mFaces[i].mIndices[f] + v_offset; diff --git a/source/grid/grid_out.cc b/source/grid/grid_out.cc index 7df2c15a09..5532c7b8e3 100644 --- a/source/grid/grid_out.cc +++ b/source/grid/grid_out.cc @@ -849,8 +849,7 @@ GridOut::write_dx(const Triangulation &tria, for (const auto &cell : tria.active_cell_iterators()) { - for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; - ++v) + for (const unsigned int v : GeometryInfo::vertex_indices()) out << '\t' << renumber[cell->vertex_index(GeometryInfo::dx_to_deal[v])]; @@ -1147,9 +1146,7 @@ GridOut::write_msh(const Triangulation &tria, // Vertex numbering follows UCD conventions. - for (unsigned int vertex = 0; - vertex < GeometryInfo::vertices_per_cell; - ++vertex) + for (const unsigned int vertex : GeometryInfo::vertex_indices()) out << cell->vertex_index(GeometryInfo::ucd_to_deal[vertex]) + 1 << ' '; out << '\n'; @@ -1268,9 +1265,7 @@ GridOut::write_ucd(const Triangulation &tria, // May, 1992, p. E6 // // note: vertex numbers are 1-base - for (unsigned int vertex = 0; - vertex < GeometryInfo::vertices_per_cell; - ++vertex) + for (const unsigned int vertex : GeometryInfo::vertex_indices()) out << cell->vertex_index(GeometryInfo::ucd_to_deal[vertex]) + 1 << ' '; out << '\n'; @@ -2924,8 +2919,7 @@ GridOut::write_mathgl(const Triangulation &tria, // out << "\nfalse"; out << "\nlist " << axes[i] << cell->active_cell_index() << " "; - for (unsigned int j = 0; j < GeometryInfo::vertices_per_cell; - ++j) + for (const unsigned int j : GeometryInfo::vertex_indices()) out << cell->vertex(j)[i] << " "; } out << '\n'; @@ -2981,7 +2975,7 @@ namespace patch.n_subdivisions = 1; patch.data.reinit(5, GeometryInfo::vertices_per_cell); - for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; ++v) + for (const unsigned int v : GeometryInfo::vertex_indices()) { patch.vertices[v] = cell->vertex(v); patch.data(0, v) = cell->level(); @@ -3231,7 +3225,7 @@ GridOut::write_vtk(const Triangulation &tria, for (const auto &cell : tria.active_cell_iterators()) { out << GeometryInfo::vertices_per_cell; - for (unsigned int i = 0; i < GeometryInfo::vertices_per_cell; ++i) + for (const unsigned int i : GeometryInfo::vertex_indices()) { out << ' ' << cell->vertex_index(GeometryInfo::ucd_to_deal[i]); } @@ -4055,8 +4049,7 @@ namespace internal // write out the four sides of this cell by putting the four // points (+ the initial point again) in a row and lifting the // drawing pencil at the end - for (unsigned int i = 0; i < GeometryInfo::vertices_per_cell; - ++i) + for (const unsigned int i : GeometryInfo::vertex_indices()) out << cell->vertex(GeometryInfo::ucd_to_deal[i]) << ' ' << cell->level() << ' ' << static_cast(cell->material_id()) << '\n'; @@ -4830,9 +4823,8 @@ namespace internal // doing this multiply std::set treated_vertices; for (const auto &cell : tria.active_cell_iterators()) - for (unsigned int vertex = 0; - vertex < GeometryInfo::vertices_per_cell; - ++vertex) + for (const unsigned int vertex : + GeometryInfo::vertex_indices()) if (treated_vertices.find(cell->vertex_index(vertex)) == treated_vertices.end()) { diff --git a/source/grid/grid_reordering.cc b/source/grid/grid_reordering.cc index 05106492d1..f0a4c0b36c 100644 --- a/source/grid/grid_reordering.cc +++ b/source/grid/grid_reordering.cc @@ -386,7 +386,7 @@ namespace */ Cell(const CellData &c, const std::vector> &edge_list) { - for (unsigned int i = 0; i < GeometryInfo::vertices_per_cell; ++i) + for (const unsigned int i : GeometryInfo::vertex_indices()) vertex_indices[i] = c.vertices[i]; // now for each of the edges of this cell, find the location inside the @@ -922,13 +922,11 @@ namespace unsigned int temp_vertex_indices[GeometryInfo::vertices_per_cell]; - for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; - ++v) + for (const unsigned int v : GeometryInfo::vertex_indices()) temp_vertex_indices[v] = raw_cells[cell_index] .vertices[cube_permutations[origin_vertex_of_cell][v]]; - for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; - ++v) + for (const unsigned int v : GeometryInfo::vertex_indices()) raw_cells[cell_index].vertices[v] = temp_vertex_indices[v]; break; @@ -1037,9 +1035,9 @@ namespace unsigned int tmp[GeometryInfo<3>::vertices_per_cell]; for (auto &cell : cells) { - for (unsigned int i = 0; i < GeometryInfo<3>::vertices_per_cell; ++i) + for (const unsigned int i : GeometryInfo<3>::vertex_indices()) tmp[i] = cell.vertices[i]; - for (unsigned int i = 0; i < GeometryInfo<3>::vertices_per_cell; ++i) + for (const unsigned int i : GeometryInfo<3>::vertex_indices()) cell.vertices[i] = tmp[GeometryInfo<3>::ucd_to_deal[i]]; } } @@ -1065,9 +1063,9 @@ namespace unsigned int tmp[GeometryInfo<3>::vertices_per_cell]; for (auto &cell : cells) { - for (unsigned int i = 0; i < GeometryInfo<3>::vertices_per_cell; ++i) + for (const unsigned int i : GeometryInfo<3>::vertex_indices()) tmp[i] = cell.vertices[i]; - for (unsigned int i = 0; i < GeometryInfo<3>::vertices_per_cell; ++i) + for (const unsigned int i : GeometryInfo<3>::vertex_indices()) cell.vertices[GeometryInfo<3>::ucd_to_deal[i]] = tmp[i]; } } @@ -1159,7 +1157,7 @@ GridReordering<2>::invert_all_cells_of_negative_grid( // GridTools::cell_measure // requires the vertices to be // in lexicographic ordering - for (unsigned int i = 0; i < GeometryInfo<2>::vertices_per_cell; ++i) + for (const unsigned int i : GeometryInfo<2>::vertex_indices()) vertices_lex[GeometryInfo<2>::ucd_to_deal[i]] = cell.vertices[i]; if (GridTools::cell_measure<2>(all_vertices, vertices_lex) < 0) { @@ -1169,7 +1167,7 @@ GridReordering<2>::invert_all_cells_of_negative_grid( // Check whether the resulting cell is now ok. // If not, then the grid is seriously broken and // we just give up. - for (unsigned int i = 0; i < GeometryInfo<2>::vertices_per_cell; ++i) + for (const unsigned int i : GeometryInfo<2>::vertex_indices()) vertices_lex[GeometryInfo<2>::ucd_to_deal[i]] = cell.vertices[i]; AssertThrow(GridTools::cell_measure<2>(all_vertices, vertices_lex) > 0, @@ -1225,7 +1223,7 @@ GridReordering<3>::invert_all_cells_of_negative_grid( // GridTools::cell_measure // requires the vertices to be // in lexicographic ordering - for (unsigned int i = 0; i < GeometryInfo<3>::vertices_per_cell; ++i) + for (const unsigned int i : GeometryInfo<3>::vertex_indices()) vertices_lex[GeometryInfo<3>::ucd_to_deal[i]] = cell.vertices[i]; if (GridTools::cell_measure<3>(all_vertices, vertices_lex) < 0) { @@ -1237,7 +1235,7 @@ GridReordering<3>::invert_all_cells_of_negative_grid( // Check whether the resulting cell is now ok. // If not, then the grid is seriously broken and // we just give up. - for (unsigned int i = 0; i < GeometryInfo<3>::vertices_per_cell; ++i) + for (const unsigned int i : GeometryInfo<3>::vertex_indices()) vertices_lex[GeometryInfo<3>::ucd_to_deal[i]] = cell.vertices[i]; AssertThrow(GridTools::cell_measure<3>(all_vertices, vertices_lex) > 0, diff --git a/source/grid/grid_tools.cc b/source/grid/grid_tools.cc index daa42cc498..8242cf1729 100644 --- a/source/grid/grid_tools.cc +++ b/source/grid/grid_tools.cc @@ -650,9 +650,8 @@ namespace GridTools unsigned int max_level_0_vertex_n = 0; for (const auto &cell : tria.cell_iterators_on_level(0)) - for (unsigned int cell_vertex_n = 0; - cell_vertex_n < GeometryInfo::vertices_per_cell; - ++cell_vertex_n) + for (const unsigned int cell_vertex_n : + GeometryInfo::vertex_indices()) max_level_0_vertex_n = std::max(cell->vertex_index(cell_vertex_n), max_level_0_vertex_n); vertices.resize(max_level_0_vertex_n + 1); @@ -664,9 +663,8 @@ namespace GridTools { // Save cell data CellData cell_data; - for (unsigned int cell_vertex_n = 0; - cell_vertex_n < GeometryInfo::vertices_per_cell; - ++cell_vertex_n) + for (const unsigned int cell_vertex_n : + GeometryInfo::vertex_indices()) { Assert(cell->vertex_index(cell_vertex_n) < vertices.size(), ExcInternalError()); @@ -712,9 +710,8 @@ namespace GridTools { std::vector used_vertices(vertices.size()); for (const CellData &cell_data : cells) - for (unsigned int cell_vertex_n = 0; - cell_vertex_n < GeometryInfo::vertices_per_cell; - ++cell_vertex_n) + for (const unsigned int cell_vertex_n : + GeometryInfo::vertex_indices()) used_vertices[cell_data.vertices[cell_vertex_n]] = true; Assert(std::find(used_vertices.begin(), used_vertices.end(), false) == used_vertices.end(), @@ -753,7 +750,7 @@ namespace GridTools // first check which vertices are actually used std::vector vertex_used(vertices.size(), false); for (unsigned int c = 0; c < cells.size(); ++c) - for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; ++v) + for (const unsigned int v : GeometryInfo::vertex_indices()) { Assert(cells[c].vertices[v] < vertices.size(), ExcMessage("Invalid vertex index encountered! cells[" + @@ -782,13 +779,13 @@ namespace GridTools // next replace old vertex numbers by the new ones for (unsigned int c = 0; c < cells.size(); ++c) - for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; ++v) + for (const unsigned int v : GeometryInfo::vertex_indices()) 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(); // NOLINT ++c) - for (unsigned int v = 0; v < GeometryInfo<1>::vertices_per_cell; ++v) + for (const unsigned int v : GeometryInfo<1>::vertex_indices()) { Assert(subcelldata.boundary_lines[c].vertices[v] < new_vertex_numbers.size(), @@ -808,7 +805,7 @@ namespace GridTools for (unsigned int c = 0; c < subcelldata.boundary_quads.size(); // NOLINT ++c) - for (unsigned int v = 0; v < GeometryInfo<2>::vertices_per_cell; ++v) + for (const unsigned int v : GeometryInfo<2>::vertex_indices()) { Assert(subcelldata.boundary_quads[c].vertices[v] < new_vertex_numbers.size(), @@ -1183,9 +1180,7 @@ namespace GridTools { // loop over all vertices of the cell and see if it is listed in the map // given as first argument of the function - for (unsigned int vertex_no = 0; - vertex_no < GeometryInfo::vertices_per_cell; - ++vertex_no) + for (const unsigned int vertex_no : GeometryInfo::vertex_indices()) { const unsigned int vertex_index = cell->vertex_index(vertex_no); const Point & vertex_point = cell->vertex(vertex_no); @@ -1218,9 +1213,7 @@ namespace GridTools // according to the computed values std::vector vertex_touched(triangulation.n_vertices(), false); for (const auto &cell : dof_handler.active_cell_iterators()) - for (unsigned int vertex_no = 0; - vertex_no < GeometryInfo::vertices_per_cell; - ++vertex_no) + for (const unsigned int vertex_no : GeometryInfo::vertex_indices()) if (vertex_touched[cell->vertex_index(vertex_no)] == false) { Point &v = cell->vertex(vertex_no); @@ -1382,9 +1375,8 @@ namespace GridTools ++cell) if (cell->is_locally_owned()) { - for (unsigned int vertex_no = 0; - vertex_no < GeometryInfo::vertices_per_cell; - ++vertex_no) + for (const unsigned int vertex_no : + GeometryInfo::vertex_indices()) { const unsigned global_vertex_no = cell->vertex_index(vertex_no); @@ -1458,9 +1450,8 @@ namespace GridTools triangulation.begin_active(); cell != triangulation.end(); ++cell) - for (unsigned int vertex_no = 0; - vertex_no < GeometryInfo::vertices_per_cell; - ++vertex_no) + for (const unsigned int vertex_no : + GeometryInfo::vertex_indices()) cell->vertex(vertex_no) = new_vertex_locations[cell->vertex_index(vertex_no)]; } @@ -1700,7 +1691,7 @@ namespace GridTools // list, but std::set throws out those cells already entered for (const auto &cell : mesh.active_cell_iterators()) { - for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; v++) + for (const unsigned int v : GeometryInfo::vertex_indices()) if (cell->vertex_index(v) == vertex) { // OK, we found a cell that contains @@ -2070,9 +2061,8 @@ namespace GridTools for (; i < active_cells.size(); ++i) if (predicate(active_cells[i])) - for (unsigned int v = 0; - v < GeometryInfo::vertices_per_cell; - ++v) + for (const unsigned int v : + GeometryInfo::vertex_indices()) for (unsigned int d = 0; d < spacedim; ++d) { minp[d] = std::min(minp[d], active_cells[i]->vertex(v)[d]); @@ -2344,7 +2334,7 @@ namespace GridTools cell = triangulation.begin_active(), endc = triangulation.end(); for (; cell != endc; ++cell) - for (unsigned int i = 0; i < GeometryInfo::vertices_per_cell; ++i) + for (const unsigned int i : GeometryInfo::vertex_indices()) vertex_to_cell_map[cell->vertex_index(i)].insert(cell); // Take care of hanging nodes @@ -2429,8 +2419,7 @@ namespace GridTools { if (cell->is_locally_owned()) { - for (unsigned int i = 0; i < GeometryInfo::vertices_per_cell; - ++i) + for (const unsigned int i : GeometryInfo::vertex_indices()) { types::subdomain_id lowest_subdomain_id = cell->subdomain_id(); typename std::set::iterator @@ -2799,7 +2788,7 @@ namespace GridTools cell != triangulation.end(); ++cell) { - for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; ++v) + for (const unsigned int v : GeometryInfo::vertex_indices()) vertex_to_cell[cell->vertex_index(v)].push_back( cell->active_cell_index()); } @@ -2811,7 +2800,7 @@ namespace GridTools cell != triangulation.end(); ++cell) { - for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; ++v) + for (const unsigned int v : GeometryInfo::vertex_indices()) for (unsigned int n = 0; n < vertex_to_cell[cell->vertex_index(v)].size(); ++n) @@ -2835,7 +2824,7 @@ namespace GridTools cell != triangulation.end(level); ++cell) { - for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; ++v) + for (const unsigned int v : GeometryInfo::vertex_indices()) vertex_to_cell[cell->vertex_index(v)].push_back(cell->index()); } @@ -2846,7 +2835,7 @@ namespace GridTools cell != triangulation.end(level); ++cell) { - for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; ++v) + for (const unsigned int v : GeometryInfo::vertex_indices()) for (unsigned int n = 0; n < vertex_to_cell[cell->vertex_index(v)].size(); ++n) @@ -3271,8 +3260,7 @@ namespace GridTools if (cell->is_artificial() || (cell->is_ghost() && (cell->subdomain_id() < tr->locally_owned_subdomain()))) - for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; - ++v) + for (const unsigned int v : GeometryInfo::vertex_indices()) locally_owned_vertices[cell->vertex_index(v)] = false; return locally_owned_vertices; @@ -3412,8 +3400,7 @@ namespace GridTools Tensor parent_alternating_forms[GeometryInfo::vertices_per_cell]; - for (unsigned int i = 0; i < GeometryInfo::vertices_per_cell; - ++i) + for (const unsigned int i : GeometryInfo::vertex_indices()) parent_vertices[i] = object->vertex(i); GeometryInfo::alternating_form_at_vertices( @@ -3441,9 +3428,7 @@ namespace GridTools [GeometryInfo::vertices_per_cell]; for (unsigned int c = 0; c < object->n_children(); ++c) - for (unsigned int i = 0; - i < GeometryInfo::vertices_per_cell; - ++i) + for (const unsigned int i : GeometryInfo::vertex_indices()) child_vertices[c][i] = object->child(c)->vertex(i); // replace mid-object @@ -3472,9 +3457,7 @@ namespace GridTools // objective function double objective = 0; for (unsigned int c = 0; c < object->n_children(); ++c) - for (unsigned int i = 0; - i < GeometryInfo::vertices_per_cell; - ++i) + for (const unsigned int i : GeometryInfo::vertex_indices()) objective += (child_alternating_forms[c][i] - average_parent_alternating_form / std::pow(2., 1. * structdim)) @@ -3689,8 +3672,7 @@ namespace GridTools Point parent_vertices[GeometryInfo::vertices_per_cell]; - for (unsigned int i = 0; i < GeometryInfo::vertices_per_cell; - ++i) + for (const unsigned int i : GeometryInfo::vertex_indices()) parent_vertices[i] = object->vertex(i); Tensor @@ -3703,9 +3685,7 @@ namespace GridTools [GeometryInfo::vertices_per_cell]; for (unsigned int c = 0; c < object->n_children(); ++c) - for (unsigned int i = 0; - i < GeometryInfo::vertices_per_cell; - ++i) + for (const unsigned int i : GeometryInfo::vertex_indices()) child_vertices[c][i] = object->child(c)->vertex(i); Tensor child_alternating_forms @@ -3719,12 +3699,9 @@ namespace GridTools old_min_product = child_alternating_forms[0][0] * parent_alternating_forms[0]; for (unsigned int c = 0; c < object->n_children(); ++c) - for (unsigned int i = 0; - i < GeometryInfo::vertices_per_cell; - ++i) - for (unsigned int j = 0; - j < GeometryInfo::vertices_per_cell; - ++j) + for (const unsigned int i : GeometryInfo::vertex_indices()) + for (const unsigned int j : + GeometryInfo::vertex_indices()) old_min_product = std::min(old_min_product, child_alternating_forms[c][i] * parent_alternating_forms[j]); @@ -3746,12 +3723,9 @@ namespace GridTools new_min_product = child_alternating_forms[0][0] * parent_alternating_forms[0]; for (unsigned int c = 0; c < object->n_children(); ++c) - for (unsigned int i = 0; - i < GeometryInfo::vertices_per_cell; - ++i) - for (unsigned int j = 0; - j < GeometryInfo::vertices_per_cell; - ++j) + for (const unsigned int i : GeometryInfo::vertex_indices()) + for (const unsigned int j : + GeometryInfo::vertex_indices()) new_min_product = std::min(new_min_product, child_alternating_forms[c][i] * parent_alternating_forms[j]); @@ -4414,8 +4388,7 @@ namespace GridTools if (cells_to_remove[cell->active_cell_index()] == false) { CellData c; - for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; - ++v) + for (const unsigned int v : GeometryInfo::vertex_indices()) c.vertices[v] = cell->vertex_index(v); c.manifold_id = cell->manifold_id(); c.material_id = cell->material_id(); @@ -4437,18 +4410,14 @@ namespace GridTools CellData<1> line; if (dim == 2) { - for (unsigned int v = 0; - v < GeometryInfo<1>::vertices_per_cell; - ++v) + for (const unsigned int v : GeometryInfo<1>::vertex_indices()) line.vertices[v] = face->vertex_index(v); line.boundary_id = face->boundary_id(); line.manifold_id = face->manifold_id(); } else { - for (unsigned int v = 0; - v < GeometryInfo<1>::vertices_per_cell; - ++v) + for (const unsigned int v : GeometryInfo<1>::vertex_indices()) line.vertices[v] = face->line(l)->vertex_index(v); line.boundary_id = face->line(l)->boundary_id(); line.manifold_id = face->line(l)->manifold_id(); @@ -4458,8 +4427,7 @@ namespace GridTools if (dim == 3) { CellData<2> quad; - for (unsigned int v = 0; v < GeometryInfo<2>::vertices_per_cell; - ++v) + for (const unsigned int v : GeometryInfo<2>::vertex_indices()) quad.vertices[v] = face->vertex_index(v); quad.boundary_id = face->boundary_id(); quad.manifold_id = face->manifold_id(); diff --git a/source/grid/grid_tools_dof_handlers.cc b/source/grid/grid_tools_dof_handlers.cc index 46a3ad2b05..212df3ea3d 100644 --- a/source/grid/grid_tools_dof_handlers.cc +++ b/source/grid/grid_tools_dof_handlers.cc @@ -253,7 +253,7 @@ namespace GridTools // list, but std::set throws out those cells already entered for (; cell != endc; ++cell) { - for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; v++) + for (const unsigned int v : GeometryInfo::vertex_indices()) if (cell->vertex_index(v) == vertex) { // OK, we found a cell that contains @@ -748,9 +748,8 @@ namespace GridTools // the halo layer 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; - ++v) + for (const unsigned int v : + GeometryInfo::vertex_indices()) locally_active_vertices_on_subdomain[cell->vertex_index(v)] = true; // Find the cells that do not conform to the predicate @@ -758,9 +757,8 @@ namespace GridTools // These comprise the halo layer 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; - ++v) + for (const unsigned int v : + GeometryInfo::vertex_indices()) if (locally_active_vertices_on_subdomain[cell->vertex_index(v)] == true) { @@ -792,9 +790,8 @@ namespace GridTools cell != mesh.end(level); ++cell) if (predicate(cell)) // True predicate --> Part of subdomain - for (unsigned int v = 0; - v < GeometryInfo::vertices_per_cell; - ++v) + for (const unsigned int v : + GeometryInfo::vertex_indices()) locally_active_vertices_on_level_subdomain[cell->vertex_index(v)] = true; @@ -805,9 +802,8 @@ namespace GridTools cell != mesh.end(level); ++cell) if (!predicate(cell)) // False predicate --> Potential halo cell - for (unsigned int v = 0; - v < GeometryInfo::vertices_per_cell; - ++v) + for (const unsigned int v : + GeometryInfo::vertex_indices()) if (locally_active_vertices_on_level_subdomain[cell->vertex_index( v)] == true) { @@ -906,9 +902,8 @@ namespace GridTools for (const auto &cell : mesh.active_cell_iterators()) if (!predicate(cell)) // Negation of predicate --> Not Part of subdomain { - for (unsigned int v = 0; - v < GeometryInfo::vertices_per_cell; - ++v) + for (const unsigned int v : + GeometryInfo::vertex_indices()) vertices_outside_subdomain[cell->vertex_index(v)] = true; n_non_predicate_cells++; } @@ -926,9 +921,8 @@ namespace GridTools for (const auto &cell : mesh.active_cell_iterators()) if (predicate(cell)) // True predicate --> Potential boundary cell of the // subdomain - for (unsigned int v = 0; - v < GeometryInfo::vertices_per_cell; - ++v) + for (const unsigned int v : + GeometryInfo::vertex_indices()) if (vertices_outside_subdomain[cell->vertex_index(v)] == true) { subdomain_boundary_cells.push_back(cell); @@ -1093,9 +1087,8 @@ namespace GridTools // if it belongs to the predicate domain, extend the bounding box. 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; - ++v) + for (const unsigned int v : + GeometryInfo::vertex_indices()) if (locally_active_vertices_on_subdomain[cell->vertex_index(v)] == false) { @@ -1238,7 +1231,7 @@ namespace GridTools mesh_2.begin(0), endc = mesh_1.end(0); for (; cell_1 != endc; ++cell_1, ++cell_2) - for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; ++v) + for (const unsigned int v : GeometryInfo::vertex_indices()) if (cell_1->vertex(v) != cell_2->vertex(v)) return false; @@ -1513,9 +1506,8 @@ namespace GridTools uniform_cell != uniform_cells.end(); ++uniform_cell) { - for (unsigned int v = 0; - v < GeometryInfo::vertices_per_cell; - ++v) + for (const unsigned int v : + GeometryInfo::vertex_indices()) { Point position = (*uniform_cell)->vertex(v); @@ -1594,10 +1586,8 @@ namespace GridTools { // adjust the cell vertices of the local_triangulation to // match cell vertices of the global triangulation - for (unsigned int v = 0; - v < GeometryInfo< - Container::dimension>::vertices_per_cell; - ++v) + for (const unsigned int v : + GeometryInfo::vertex_indices()) active_tria_cell->vertex(v) = patch[i]->vertex(v); Assert(active_tria_cell->center().distance( diff --git a/source/grid/manifold.cc b/source/grid/manifold.cc index 155d34e7f8..e2d75590c9 100644 --- a/source/grid/manifold.cc +++ b/source/grid/manifold.cc @@ -902,16 +902,14 @@ FlatManifold::normal_vector( while (true) { Point F; - for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; - ++v) + for (const unsigned int v : GeometryInfo::vertex_indices()) F += face->vertex(v) * GeometryInfo::d_linear_shape_function(xi, v); for (unsigned int i = 0; i < facedim; ++i) { grad_F[i] = 0; - for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; - ++v) + for (const unsigned int v : GeometryInfo::vertex_indices()) grad_F[i] += face->vertex(v) * GeometryInfo::d_linear_shape_function_gradient(xi, v)[i]; diff --git a/source/grid/manifold_lib.cc b/source/grid/manifold_lib.cc index c63ebc8c34..df41f41960 100644 --- a/source/grid/manifold_lib.cc +++ b/source/grid/manifold_lib.cc @@ -1740,7 +1740,7 @@ namespace Point new_point; if (cell_is_flat) - for (unsigned int v = 0; v < GeometryInfo<2>::vertices_per_cell; ++v) + for (const unsigned int v : GeometryInfo<2>::vertex_indices()) new_point += weights_vertices[v] * vertices[v]; else { @@ -1798,7 +1798,7 @@ namespace } // subtract contribution from the vertices (second line in formula) - for (unsigned int v = 0; v < GeometryInfo<2>::vertices_per_cell; ++v) + for (const unsigned int v : GeometryInfo<2>::vertex_indices()) new_point -= weights_vertices[v] * vertices[v]; } @@ -1932,8 +1932,7 @@ namespace } else { - for (unsigned int v = 0; v < GeometryInfo<2>::vertices_per_cell; - ++v) + for (const unsigned int v : GeometryInfo<2>::vertex_indices()) points[v] = vertices[face_to_cell_vertices_3d[face][v]]; weights[0] = linear_shapes[face_even + 2] * linear_shapes[face_even + 4]; @@ -2000,7 +1999,7 @@ namespace } // finally add the contribution of the - for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; ++v) + for (const unsigned int v : GeometryInfo::vertex_indices()) new_point += weights_vertices[v] * vertices[v]; } return new_point; @@ -2243,9 +2242,7 @@ TransfiniteInterpolationManifold:: std::array, GeometryInfo::vertices_per_cell> vertices; - for (unsigned int vertex_n = 0; - vertex_n < GeometryInfo::vertices_per_cell; - ++vertex_n) + for (const unsigned int vertex_n : GeometryInfo::vertex_indices()) { vertices[vertex_n] = cell->vertex(vertex_n); } @@ -2254,11 +2251,11 @@ TransfiniteInterpolationManifold:: // center of the loop, we can skip the expensive part below (this assumes // that the manifold does not deform the grid too much) Point center; - for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; ++v) + for (const unsigned int v : GeometryInfo::vertex_indices()) center += vertices[v]; center *= 1. / GeometryInfo::vertices_per_cell; double radius_square = 0.; - for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; ++v) + for (const unsigned int v : GeometryInfo::vertex_indices()) radius_square = std::max(radius_square, (center - vertices[v]).norm_square()); bool inside_circle = true; @@ -2531,8 +2528,7 @@ TransfiniteInterpolationManifold::compute_chart_points( triangulation, level_coarse, nearby_cells[b]); message << "Looking at cell " << cell->id() << " with vertices: " << std::endl; - for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; - ++v) + for (const unsigned int v : GeometryInfo::vertex_indices()) message << cell->vertex(v) << " "; message << std::endl; message << "Transformation to chart coordinates: " << std::endl; diff --git a/source/grid/tria.cc b/source/grid/tria.cc index 354fb50985..96465678a1 100644 --- a/source/grid/tria.cc +++ b/source/grid/tria.cc @@ -60,7 +60,7 @@ template bool CellData::operator==(const CellData &other) const { - for (unsigned int i = 0; i < GeometryInfo::vertices_per_cell; i++) + for (const unsigned int i : GeometryInfo::vertex_indices()) if (vertices[i] != other.vertices[i]) return false; @@ -439,7 +439,7 @@ namespace triangulation.begin_active(); cell != triangulation.end(); ++cell) - for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; ++v) + for (const unsigned int v : GeometryInfo::vertex_indices()) { min_adjacent_cell_level[cell->vertex_index(v)] = std::min( @@ -547,9 +547,9 @@ namespace unsigned int tmp[GeometryInfo<3>::vertices_per_cell]; for (auto &cell : cells) { - for (unsigned int i = 0; i < GeometryInfo<3>::vertices_per_cell; ++i) + for (const unsigned int i : GeometryInfo<3>::vertex_indices()) tmp[i] = cell.vertices[i]; - for (unsigned int i = 0; i < GeometryInfo<3>::vertices_per_cell; ++i) + for (const unsigned int i : GeometryInfo<3>::vertex_indices()) cell.vertices[GeometryInfo<3>::ucd_to_deal[i]] = tmp[i]; } @@ -691,13 +691,13 @@ namespace ++cell) { Point vertices[GeometryInfo::vertices_per_cell]; - for (unsigned int i = 0; i < GeometryInfo::vertices_per_cell; ++i) + for (const unsigned int i : GeometryInfo::vertex_indices()) vertices[i] = cell->vertex(i); Tensor<0, dim> determinants[GeometryInfo::vertices_per_cell]; GeometryInfo::alternating_form_at_vertices(vertices, determinants); - for (unsigned int i = 0; i < GeometryInfo::vertices_per_cell; ++i) + for (const unsigned int i : GeometryInfo::vertex_indices()) if (determinants[i] <= 1e-9 * std::pow(cell->diameter(), 1. * dim)) { distorted_cells.distorted_cells.push_back(cell); @@ -727,13 +727,13 @@ namespace for (unsigned int c = 0; c < cell->n_children(); ++c) { Point vertices[GeometryInfo::vertices_per_cell]; - for (unsigned int i = 0; i < GeometryInfo::vertices_per_cell; ++i) + for (const unsigned int i : GeometryInfo::vertex_indices()) vertices[i] = cell->child(c)->vertex(i); Tensor<0, dim> determinants[GeometryInfo::vertices_per_cell]; GeometryInfo::alternating_form_at_vertices(vertices, determinants); - for (unsigned int i = 0; i < GeometryInfo::vertices_per_cell; ++i) + for (const unsigned int i : GeometryInfo::vertex_indices()) if (determinants[i] <= 1e-9 * std::pow(cell->child(c)->diameter(), 1. * dim)) return true; @@ -1894,9 +1894,7 @@ namespace internal // for all lines for (; line != triangulation.end(); ++line) // for each of the two vertices - for (unsigned int vertex = 0; - vertex < GeometryInfo::vertices_per_cell; - ++vertex) + for (const unsigned int vertex : GeometryInfo::vertex_indices()) // if first cell adjacent to // this vertex is the present // one, then the neighbor is @@ -13318,8 +13316,7 @@ Triangulation::max_adjacent_cells() const // vertices used on level 0 unsigned int max_vertex_index = 0; for (; cell != endc; ++cell) - for (unsigned int vertex = 0; vertex < GeometryInfo::vertices_per_cell; - ++vertex) + for (const unsigned int vertex : GeometryInfo::vertex_indices()) if (cell->vertex_index(vertex) > max_vertex_index) max_vertex_index = cell->vertex_index(vertex); @@ -13332,8 +13329,7 @@ Triangulation::max_adjacent_cells() const // every time we find an adjacent // element for (cell = begin(); cell != endc; ++cell) - for (unsigned int vertex = 0; vertex < GeometryInfo::vertices_per_cell; - ++vertex) + for (const unsigned int vertex : GeometryInfo::vertex_indices()) ++usage_count[cell->vertex_index(vertex)]; return std::max(GeometryInfo::vertices_per_cell, @@ -13684,16 +13680,14 @@ Triangulation::fix_coarsen_flags() for (; cell != endc; ++cell) { if (cell->refine_flag_set()) - for (unsigned int vertex = 0; - vertex < GeometryInfo::vertices_per_cell; - ++vertex) + for (const unsigned int vertex : + GeometryInfo::vertex_indices()) vertex_level[cell->vertex_index(vertex)] = std::max(vertex_level[cell->vertex_index(vertex)], cell->level() + 1); else if (!cell->coarsen_flag_set()) - for (unsigned int vertex = 0; - vertex < GeometryInfo::vertices_per_cell; - ++vertex) + for (const unsigned int vertex : + GeometryInfo::vertex_indices()) vertex_level[cell->vertex_index(vertex)] = std::max(vertex_level[cell->vertex_index(vertex)], cell->level()); @@ -13706,9 +13700,8 @@ Triangulation::fix_coarsen_flags() // to correct this by iterating over the entire // process until we are converged Assert(cell->coarsen_flag_set(), ExcInternalError()); - for (unsigned int vertex = 0; - vertex < GeometryInfo::vertices_per_cell; - ++vertex) + for (const unsigned int vertex : + GeometryInfo::vertex_indices()) vertex_level[cell->vertex_index(vertex)] = std::max(vertex_level[cell->vertex_index(vertex)], cell->level() - 1); @@ -13728,9 +13721,8 @@ Triangulation::fix_coarsen_flags() for (cell = last_active(); cell != endc; --cell) if (cell->refine_flag_set() == false) { - for (unsigned int vertex = 0; - vertex < GeometryInfo::vertices_per_cell; - ++vertex) + for (const unsigned int vertex : + GeometryInfo::vertex_indices()) if (vertex_level[cell->vertex_index(vertex)] >= cell->level() + 1) { @@ -13745,9 +13737,8 @@ Triangulation::fix_coarsen_flags() { cell->set_refine_flag(); - for (unsigned int v = 0; - v < GeometryInfo::vertices_per_cell; - ++v) + for (const unsigned int v : + GeometryInfo::vertex_indices()) vertex_level[cell->vertex_index(v)] = std::max(vertex_level[cell->vertex_index(v)], cell->level() + 1); @@ -14356,16 +14347,14 @@ Triangulation::prepare_coarsening_and_refinement() for (const auto &cell : active_cell_iterators()) { if (cell->refine_flag_set()) - for (unsigned int vertex = 0; - vertex < GeometryInfo::vertices_per_cell; - ++vertex) + for (const unsigned int vertex : + GeometryInfo::vertex_indices()) vertex_level[cell->vertex_index(vertex)] = std::max(vertex_level[cell->vertex_index(vertex)], cell->level() + 1); else if (!cell->coarsen_flag_set()) - for (unsigned int vertex = 0; - vertex < GeometryInfo::vertices_per_cell; - ++vertex) + for (const unsigned int vertex : + GeometryInfo::vertex_indices()) vertex_level[cell->vertex_index(vertex)] = std::max(vertex_level[cell->vertex_index(vertex)], cell->level()); @@ -14376,9 +14365,8 @@ Triangulation::prepare_coarsening_and_refinement() // always true (the coarsen flag could be removed // again) and so we may make an error here Assert(cell->coarsen_flag_set(), ExcInternalError()); - for (unsigned int vertex = 0; - vertex < GeometryInfo::vertices_per_cell; - ++vertex) + for (const unsigned int vertex : + GeometryInfo::vertex_indices()) vertex_level[cell->vertex_index(vertex)] = std::max(vertex_level[cell->vertex_index(vertex)], cell->level() - 1); @@ -14398,9 +14386,8 @@ Triangulation::prepare_coarsening_and_refinement() for (active_cell_iterator cell = last_active(); cell != end(); --cell) if (cell->refine_flag_set() == false) { - for (unsigned int vertex = 0; - vertex < GeometryInfo::vertices_per_cell; - ++vertex) + for (const unsigned int vertex : + GeometryInfo::vertex_indices()) if (vertex_level[cell->vertex_index(vertex)] >= cell->level() + 1) { @@ -14415,9 +14402,8 @@ Triangulation::prepare_coarsening_and_refinement() { cell->set_refine_flag(); - for (unsigned int v = 0; - v < GeometryInfo::vertices_per_cell; - ++v) + for (const unsigned int v : + GeometryInfo::vertex_indices()) vertex_level[cell->vertex_index(v)] = std::max(vertex_level[cell->vertex_index(v)], cell->level() + 1); diff --git a/source/grid/tria_accessor.cc b/source/grid/tria_accessor.cc index efc1c01a62..7e85fd1f7f 100644 --- a/source/grid/tria_accessor.cc +++ b/source/grid/tria_accessor.cc @@ -1265,7 +1265,7 @@ namespace measure(const TriaAccessor<2, 2, 2> &accessor) { unsigned int vertex_indices[GeometryInfo<2>::vertices_per_cell]; - for (unsigned int i = 0; i < GeometryInfo<2>::vertices_per_cell; ++i) + for (const unsigned int i : GeometryInfo<2>::vertex_indices()) vertex_indices[i] = accessor.vertex_index(i); return GridTools::cell_measure<2>( @@ -1277,7 +1277,7 @@ namespace measure(const TriaAccessor<3, 3, 3> &accessor) { unsigned int vertex_indices[GeometryInfo<3>::vertices_per_cell]; - for (unsigned int i = 0; i < GeometryInfo<3>::vertices_per_cell; ++i) + for (const unsigned int i : GeometryInfo<3>::vertex_indices()) vertex_indices[i] = accessor.vertex_index(i); return GridTools::cell_measure<3>( @@ -1570,7 +1570,7 @@ TriaAccessor::intermediate_point( std::array, GeometryInfo::vertices_per_cell> p; std::array::vertices_per_cell> w; - for (unsigned int i = 0; i < GeometryInfo::vertices_per_cell; ++i) + for (const unsigned int i : GeometryInfo::vertex_indices()) { p[i] = this->vertex(i); w[i] = GeometryInfo::d_linear_shape_function(coordinates, i); @@ -1690,17 +1690,16 @@ TriaAccessor::real_to_unit_cell_affine_approximation( // copy vertices to avoid expensive resolution of vertex index inside loop std::array, GeometryInfo::vertices_per_cell> vertices; - for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; ++v) + for (const unsigned int v : GeometryInfo::vertex_indices()) vertices[v] = this->vertex(v); for (unsigned int d = 0; d < spacedim; ++d) - for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; - ++v) + for (const unsigned int v : GeometryInfo::vertex_indices()) for (unsigned int e = 0; e < structdim; ++e) A[d][e] += vertices[v][d] * TransformR2UAffine::KA[v][e]; // b = vertex * Kb Tensor<1, spacedim> b = point; - for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; ++v) + for (const unsigned int v : GeometryInfo::vertex_indices()) b -= vertices[v] * TransformR2UAffine::Kb[v]; DerivativeForm<1, spacedim, structdim> A_inv = A.covariant_form().transpose(); @@ -1718,8 +1717,7 @@ TriaAccessor::center( { Assert(use_interpolation == false, ExcNotImplemented()); Point p; - for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; - ++v) + for (const unsigned int v : GeometryInfo::vertex_indices()) p += vertex(v); return p / GeometryInfo::vertices_per_cell; } diff --git a/source/grid/tria_description.cc b/source/grid/tria_description.cc index 5d34c7d913..541d684624 100644 --- a/source/grid/tria_description.cc +++ b/source/grid/tria_description.cc @@ -164,8 +164,7 @@ namespace TriangulationDescription TriaIterator> &cell, std::vector &vertices_owned_by_locally_owned_cells) { // add local vertices - for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; - ++v) + for (const unsigned int v : GeometryInfo::vertex_indices()) { vertices_owned_by_locally_owned_cells[cell->vertex_index(v)] = true; @@ -204,8 +203,7 @@ namespace TriangulationDescription auto is_locally_relevant = [&]( TriaIterator> &cell) { - for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; - ++v) + for (const unsigned int v : GeometryInfo::vertex_indices()) if (vertices_owned_by_locally_owned_cells[cell->vertex_index(v)]) return true; return false; @@ -228,16 +226,12 @@ namespace TriangulationDescription dealii::CellData cell_data; cell_data.material_id = cell->material_id(); cell_data.manifold_id = cell->manifold_id(); - for (unsigned int v = 0; - v < GeometryInfo::vertices_per_cell; - ++v) + for (const unsigned int v : GeometryInfo::vertex_indices()) cell_data.vertices[v] = cell->vertex_index(v); construction_data.coarse_cells.push_back(cell_data); // b) save indices of each vertex of this cell - for (unsigned int v = 0; - v < GeometryInfo::vertices_per_cell; - ++v) + for (const unsigned int v : GeometryInfo::vertex_indices()) vertices_locally_relevant[cell->vertex_index(v)] = numbers::invalid_unsigned_int; @@ -304,8 +298,7 @@ namespace TriangulationDescription // 4) correct vertices of cells (make them local) for (auto &cell : construction_data.coarse_cells) - for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; - ++v) + for (const unsigned int v : GeometryInfo::vertex_indices()) cell.vertices[v] = vertices_locally_relevant[cell.vertices[v]]; } else @@ -347,9 +340,8 @@ namespace TriangulationDescription // owned cell) auto is_locally_relevant_on_level = [&](TriaIterator> &cell) { - for (unsigned int v = 0; - v < GeometryInfo::vertices_per_cell; - ++v) + for (const unsigned int v : + GeometryInfo::vertex_indices()) if (vertices_owned_by_locally_owned_cells_on_level [cell->vertex_index(v)]) return true; @@ -376,16 +368,12 @@ namespace TriangulationDescription dealii::CellData cell_data; cell_data.material_id = cell->material_id(); cell_data.manifold_id = cell->manifold_id(); - for (unsigned int v = 0; - v < GeometryInfo::vertices_per_cell; - ++v) + for (const unsigned int v : GeometryInfo::vertex_indices()) cell_data.vertices[v] = cell->vertex_index(v); construction_data.coarse_cells.push_back(cell_data); // save indices of each vertex of this cell - for (unsigned int v = 0; - v < GeometryInfo::vertices_per_cell; - ++v) + for (const unsigned int v : GeometryInfo::vertex_indices()) vertices_locally_relevant[cell->vertex_index(v)] = numbers::invalid_unsigned_int; @@ -405,8 +393,7 @@ namespace TriangulationDescription // c) correct vertices of cells (make them local) for (auto &cell : construction_data.coarse_cells) - for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; - ++v) + for (const unsigned int v : GeometryInfo::vertex_indices()) cell.vertices[v] = vertices_locally_relevant[cell.vertices[v]]; } @@ -428,9 +415,7 @@ namespace TriangulationDescription auto is_locally_relevant_on_active_level = [&](TriaIterator> &cell) { if (cell->active()) - for (unsigned int v = 0; - v < GeometryInfo::vertices_per_cell; - ++v) + for (const unsigned int v : GeometryInfo::vertex_indices()) if (vertices_owned_by_locally_owned_active_cells [cell->vertex_index(v)]) return true; @@ -454,9 +439,8 @@ namespace TriangulationDescription // on level auto is_locally_relevant_on_level = [&](TriaIterator> &cell) { - for (unsigned int v = 0; - v < GeometryInfo::vertices_per_cell; - ++v) + for (const unsigned int v : + GeometryInfo::vertex_indices()) if (vertices_owned_by_locally_owned_cells_on_level [cell->vertex_index(v)]) return true; diff --git a/source/hp/dof_handler.cc b/source/hp/dof_handler.cc index 5723a253fa..879dad4f44 100644 --- a/source/hp/dof_handler.cc +++ b/source/hp/dof_handler.cc @@ -178,8 +178,7 @@ namespace internal cell != dof_handler.end(); ++cell) if (!cell->is_artificial()) - for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; - ++v) + for (const unsigned int v : GeometryInfo::vertex_indices()) locally_used_vertices[cell->vertex_index(v)] = true; std::vector> vertex_fe_association( @@ -191,8 +190,7 @@ namespace internal cell != dof_handler.end(); ++cell) if (!cell->is_artificial()) - for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; - ++v) + for (const unsigned int v : GeometryInfo::vertex_indices()) vertex_fe_association[cell->active_fe_index()] [cell->vertex_index(v)] = true; diff --git a/source/numerics/data_out.cc b/source/numerics/data_out.cc index b33264a4f0..b3e92e3cb3 100644 --- a/source/numerics/data_out.cc +++ b/source/numerics/data_out.cc @@ -102,9 +102,8 @@ DataOut::build_one_patch( // set the vertices of the patch. if the mapping does not preserve locations // (e.g. MappingQEulerian), we need to compute the offset of the vertex for // the graphical output. Otherwise, we can just use the vertex info. - for (unsigned int vertex = 0; - vertex < GeometryInfo::vertices_per_cell; - ++vertex) + for (const unsigned int vertex : + GeometryInfo::vertex_indices()) if (scratch_data.mapping_collection[0].preserves_vertex_locations()) patch.vertices[vertex] = cell_and_index->first->vertex(vertex); else diff --git a/source/numerics/data_out_rotation.cc b/source/numerics/data_out_rotation.cc index 6db2d3448c..8930c8af76 100644 --- a/source/numerics/data_out_rotation.cc +++ b/source/numerics/data_out_rotation.cc @@ -159,9 +159,8 @@ DataOutRotation::build_one_patch( case 2: { - for (unsigned int vertex = 0; - vertex < GeometryInfo::vertices_per_cell; - ++vertex) + for (const unsigned int vertex : + GeometryInfo::vertex_indices()) { const Point v = (*cell)->vertex(vertex); diff --git a/source/particles/particle_handler.cc b/source/particles/particle_handler.cc index f470a83534..c0ed663d28 100644 --- a/source/particles/particle_handler.cc +++ b/source/particles/particle_handler.cc @@ -1106,8 +1106,7 @@ namespace Particles for (const auto &cell : triangulation->active_cell_iterators()) { if (cell->is_ghost()) - for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; - ++v) + for (const unsigned int v : GeometryInfo::vertex_indices()) vertex_to_neighbor_subdomain[cell->vertex_index(v)].insert( cell->subdomain_id()); } @@ -1117,8 +1116,7 @@ namespace Particles if (!cell->is_ghost()) { std::set cell_to_neighbor_subdomain; - for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; - ++v) + for (const unsigned int v : GeometryInfo::vertex_indices()) { cell_to_neighbor_subdomain.insert( vertex_to_neighbor_subdomain[cell->vertex_index(v)].begin(), -- 2.39.5