From: David Wells Date: Tue, 7 May 2019 00:28:07 +0000 (-0400) Subject: step-28: use ranged-for loops. X-Git-Tag: v9.1.0-rc1~118^2~3 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=500075b50c78622accbf25c1ba3652f0f00e8fc8;p=dealii.git step-28: use ranged-for loops. --- diff --git a/examples/step-28/step-28.cc b/examples/step-28/step-28.cc index 5e6bed8f42..b45df6eb6a 100644 --- a/examples/step-28/step-28.cc +++ b/examples/step-28/step-28.cc @@ -668,11 +668,7 @@ namespace Step28 std::vector local_dof_indices(dofs_per_cell); - typename DoFHandler::active_cell_iterator cell = - dof_handler.begin_active(), - endc = dof_handler.end(); - - for (; cell != endc; ++cell) + for (const auto &cell : dof_handler.active_cell_iterators()) { cell_matrix = 0; @@ -743,11 +739,7 @@ namespace Step28 std::vector local_dof_indices(dofs_per_cell); - typename DoFHandler::active_cell_iterator cell = - dof_handler.begin_active(), - endc = dof_handler.end(); - - for (; cell != endc; ++cell) + for (const auto &cell : dof_handler.active_cell_iterators()) { cell_rhs = 0; @@ -803,18 +795,14 @@ namespace Step28 cell_list = GridTools::get_finest_common_cells(dof_handler, g_prime.dof_handler); - typename std::list::cell_iterator, - typename DoFHandler::cell_iterator>>:: - const_iterator cell_iter = cell_list.begin(); - - for (; cell_iter != cell_list.end(); ++cell_iter) + for (const auto &cell_pair : cell_list) { FullMatrix unit_matrix(fe.dofs_per_cell); for (unsigned int i = 0; i < unit_matrix.m(); ++i) unit_matrix(i, i) = 1; assemble_cross_group_rhs_recursive(g_prime, - cell_iter->first, - cell_iter->second, + cell_pair.first, + cell_pair.second, unit_matrix); } } @@ -993,10 +981,7 @@ namespace Step28 double fission_source = 0; - typename DoFHandler::active_cell_iterator cell = - dof_handler.begin_active(), - endc = dof_handler.end(); - for (; cell != endc; ++cell) + for (const auto &cell : dof_handler.active_cell_iterators()) { fe_values.reinit(cell); @@ -1080,12 +1065,7 @@ namespace Step28 const double refine_threshold, const double coarsen_threshold) { - typename Triangulation::active_cell_iterator cell = triangulation - .begin_active(), - endc = - triangulation.end(); - - for (; cell != endc; ++cell) + for (const auto &cell : triangulation.active_cell_iterators()) if (error_indicators(cell->active_cell_index()) > refine_threshold) cell->set_refine_flag(); else if (error_indicators(cell->active_cell_index()) < coarsen_threshold) @@ -1456,10 +1436,7 @@ namespace Step28 // add a few checks to see that the locations we compute are within the // bounds of the arrays in which we have to look up materials.) At the end // of the loop, we set material identifiers accordingly: - for (typename Triangulation::active_cell_iterator cell = - coarse_grid.begin_active(); - cell != coarse_grid.end(); - ++cell) + for (auto &cell : coarse_grid.active_cell_iterators()) { const Point cell_center = cell->center();