From 5aae0bfae2907f718f437317ff3ac48fb928e113 Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Sun, 12 May 2019 05:03:39 +0200 Subject: [PATCH] Modernize step-33 --- examples/step-33/step-33.cc | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/examples/step-33/step-33.cc b/examples/step-33/step-33.cc index a24a5665fc..f95b93fb8e 100644 --- a/examples/step-33/step-33.cc +++ b/examples/step-33/step-33.cc @@ -355,9 +355,9 @@ namespace Step33 // go with the pragmatic, even if not pretty, solution shown here: template static void - compute_Wminus(const BoundaryKind (&boundary_kind)[n_components], - const Tensor<1, dim> &normal_vector, - const DataVector & Wplus, + compute_Wminus(const std::array &boundary_kind, + const Tensor<1, dim> & normal_vector, + const DataVector & Wplus, const Vector &boundary_values, const DataVector & Wminus) { @@ -460,11 +460,9 @@ namespace Step33 std::vector>> dU( 1, std::vector>(n_components)); - typename DoFHandler::active_cell_iterator cell = dof_handler - .begin_active(), - endc = dof_handler.end(); - for (unsigned int cell_no = 0; cell != endc; ++cell, ++cell_no) + for (const auto &cell : dof_handler.active_cell_iterators()) { + const unsigned int cell_no = cell->active_cell_index(); fe_v.reinit(cell); fe_v.get_function_gradients(solution, dU); @@ -1061,8 +1059,9 @@ namespace Step33 struct BoundaryConditions { - typename EulerEquations::BoundaryKind - kind[EulerEquations::n_components]; + std::array::BoundaryKind, + EulerEquations::n_components> + kind; FunctionParser values; @@ -1093,8 +1092,9 @@ namespace Step33 AllParameters::BoundaryConditions::BoundaryConditions() : values(EulerEquations::n_components) { - for (unsigned int c = 0; c < EulerEquations::n_components; ++c) - kind[c] = EulerEquations::no_penetration_boundary; + std::fill(kind.begin(), + kind.end(), + EulerEquations::no_penetration_boundary); } @@ -1472,10 +1472,7 @@ namespace Step33 // Then loop over all cells, initialize the FEValues object for the // current cell and call the function that assembles the problem on this // 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()) { fe_v.reinit(cell); cell->get_dof_indices(dof_indices); @@ -2250,12 +2247,9 @@ namespace Step33 void ConservationLaw::refine_grid(const Vector &refinement_indicators) { - typename DoFHandler::active_cell_iterator cell = - dof_handler.begin_active(), - endc = dof_handler.end(); - - for (unsigned int cell_no = 0; cell != endc; ++cell, ++cell_no) + for (const auto &cell : dof_handler.active_cell_iterators()) { + const unsigned int cell_no = cell->active_cell_index(); cell->clear_coarsen_flag(); cell->clear_refine_flag(); -- 2.39.5