From 609c4c57924301d7ee7d1f4aeb2121d53fed3d72 Mon Sep 17 00:00:00 2001 From: Matthias Maier Date: Sat, 11 May 2019 23:18:32 -0500 Subject: [PATCH] examples: favor auto & cell --- examples/step-1/doc/results.dox | 2 +- examples/step-1/step-1.cc | 2 +- examples/step-18/step-18.cc | 10 +++++----- examples/step-2/step-2.cc | 2 +- examples/step-49/doc/results.dox | 6 +++--- examples/step-49/step-49.cc | 2 +- examples/step-60/step-60.cc | 2 +- examples/step-62/step-62.cc | 2 +- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/examples/step-1/doc/results.dox b/examples/step-1/doc/results.dox index 438b1473c3..adde1a4d30 100644 --- a/examples/step-1/doc/results.dox +++ b/examples/step-1/doc/results.dox @@ -35,7 +35,7 @@ places where you can play with it. For example, you could modify the criterion by which we decide which cells to refine. An example would be to change the condition to this: @code - for (auto cell: triangulation.active_cell_iterators()) + for (auto & cell: triangulation.active_cell_iterators()) if (cell->center()[1] > 0) cell->set_refine_flag (); @endcode diff --git a/examples/step-1/step-1.cc b/examples/step-1/step-1.cc index a753e1859b..f9f77369be 100644 --- a/examples/step-1/step-1.cc +++ b/examples/step-1/step-1.cc @@ -192,7 +192,7 @@ void second_grid() // range- // based for loops, which wrap up all of the syntax shown above into a // much shorter form: - for (auto cell : triangulation.active_cell_iterators()) + for (auto &cell : triangulation.active_cell_iterators()) { // @note See @ref Iterators for more information about the iterator // classes used in deal.II, and @ref CPP11 for more information about diff --git a/examples/step-18/step-18.cc b/examples/step-18/step-18.cc index 50feb3f2a7..cb6ba6df8a 100644 --- a/examples/step-18/step-18.cc +++ b/examples/step-18/step-18.cc @@ -774,7 +774,7 @@ namespace Step18 { const double inner_radius = 0.8, outer_radius = 1; GridGenerator::cylinder_shell(triangulation, 3, inner_radius, outer_radius); - for (auto cell : triangulation.active_cell_iterators()) + for (auto &cell : triangulation.active_cell_iterators()) for (unsigned int f = 0; f < GeometryInfo::faces_per_cell; ++f) if (cell->face(f)->at_boundary()) { @@ -1228,7 +1228,7 @@ namespace Step18 Vector norm_of_stress(triangulation.n_active_cells()); { // Loop over all the cells... - for (auto cell : triangulation.active_cell_iterators()) + for (auto &cell : triangulation.active_cell_iterators()) if (cell->is_locally_owned()) { // On these cells, add up the stresses over all quadrature @@ -1573,7 +1573,7 @@ namespace Step18 pcout << " Moving mesh..." << std::endl; std::vector vertex_touched(triangulation.n_vertices(), false); - for (auto cell : dof_handler.active_cell_iterators()) + for (auto &cell : dof_handler.active_cell_iterators()) for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; ++v) if (vertex_touched[cell->vertex_index(v)] == false) { @@ -1641,7 +1641,7 @@ namespace Step18 // quadrature point objects corresponding to this cell in the vector of // such objects: unsigned int history_index = 0; - for (auto cell : triangulation.active_cell_iterators()) + for (auto &cell : triangulation.active_cell_iterators()) if (cell->is_locally_owned()) { cell->set_user_pointer(&quadrature_point_history[history_index]); @@ -1724,7 +1724,7 @@ namespace Step18 // Then loop over all cells and do the job in the cells that belong to our // subdomain: - for (auto cell : dof_handler.active_cell_iterators()) + for (auto &cell : dof_handler.active_cell_iterators()) if (cell->is_locally_owned()) { // Next, get a pointer to the quadrature point history data local to diff --git a/examples/step-2/step-2.cc b/examples/step-2/step-2.cc index bf602061d3..13984151c1 100644 --- a/examples/step-2/step-2.cc +++ b/examples/step-2/step-2.cc @@ -75,7 +75,7 @@ void make_grid(Triangulation<2> &triangulation) for (unsigned int step = 0; step < 3; ++step) { - for (auto cell : triangulation.active_cell_iterators()) + for (auto &cell : triangulation.active_cell_iterators()) for (unsigned int v = 0; v < GeometryInfo<2>::vertices_per_cell; ++v) { const double distance_from_center = diff --git a/examples/step-49/doc/results.dox b/examples/step-49/doc/results.dox index 1340bd6449..47eda4cfa0 100644 --- a/examples/step-49/doc/results.dox +++ b/examples/step-49/doc/results.dox @@ -271,7 +271,7 @@ Triangulation<3> triangulation; create_3d_grid(triangulation); triangulation.set_manifold(cylinder_id, cylinder); -for (auto cell : triangulation.active_cell_iterators()) +for (auto & cell : triangulation.active_cell_iterators()) if (cell->center()[1] >= 3.0) cell->set_all_manifold_ids(cylinder_id); @@ -300,11 +300,11 @@ Triangulation<3> triangulation; create_3d_grid(triangulation); triangulation.set_manifold(cylinder_id, cylinder); -for (auto cell : triangulation.active_cell_iterators()) +for (auto & cell : triangulation.active_cell_iterators()) if (cell->center()[1] >= 3.0) cell->set_all_manifold_ids(cylinder_id); -for (auto cell : triangulation.active_cell_iterators()) +for (auto & cell : triangulation.active_cell_iterators()) for (unsigned int face_n = 0; face_n < GeometryInfo<3>::faces_per_cell; ++face_n) { diff --git a/examples/step-49/step-49.cc b/examples/step-49/step-49.cc index c99e66a0e3..8508831963 100644 --- a/examples/step-49/step-49.cc +++ b/examples/step-49/step-49.cc @@ -72,7 +72,7 @@ void print_mesh_info(const Triangulation &triangulation, // we then increment it): { std::map boundary_count; - for (auto cell : triangulation.active_cell_iterators()) + for (auto &cell : triangulation.active_cell_iterators()) { for (unsigned int face = 0; face < GeometryInfo::faces_per_cell; ++face) diff --git a/examples/step-60/step-60.cc b/examples/step-60/step-60.cc index 49b8629f49..4cc7af9fbe 100644 --- a/examples/step-60/step-60.cc +++ b/examples/step-60/step-60.cc @@ -769,7 +769,7 @@ namespace Step60 GridTools::compute_point_locations(*space_grid_tools_cache, support_points); const auto &cells = std::get<0>(point_locations); - for (auto cell : cells) + for (auto &cell : cells) { cell->set_refine_flag(); for (unsigned int face_no = 0; diff --git a/examples/step-62/step-62.cc b/examples/step-62/step-62.cc index c448b476e2..9993acf5fd 100644 --- a/examples/step-62/step-62.cc +++ b/examples/step-62/step-62.cc @@ -1133,7 +1133,7 @@ namespace step62 dim, Vector(triangulation.n_active_cells())); Vector rho(triangulation.n_active_cells()); - for (auto cell : triangulation.active_cell_iterators()) + for (auto &cell : triangulation.active_cell_iterators()) { if (cell->is_locally_owned()) { -- 2.39.5