From 9a4faba5c153940d4a07cd435cd4497fac98a105 Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Wed, 8 May 2019 19:12:59 -0400 Subject: [PATCH] Modernize step-56 --- examples/step-56/step-56.cc | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/examples/step-56/step-56.cc b/examples/step-56/step-56.cc index b81f2c4564..1e65719b82 100644 --- a/examples/step-56/step-56.cc +++ b/examples/step-56/step-56.cc @@ -81,14 +81,11 @@ namespace Step56 // In order to make it easy to switch between the different solvers that are // being used, we declare an enum that can be passed as an argument to the // constructor of the main class. - struct SolverType + enum class SolverType { - enum type - { - FGMRES_ILU, - FGMRES_GMG, - UMFPACK - }; + FGMRES_ILU, + FGMRES_GMG, + UMFPACK }; // @sect3{Functions for Solution and Righthand side} @@ -412,8 +409,7 @@ namespace Step56 class StokesProblem { public: - StokesProblem(const unsigned int pressure_degree, - SolverType::type solver_type); + StokesProblem(const unsigned int pressure_degree, SolverType solver_type); void run(); private: @@ -425,7 +421,7 @@ namespace Step56 void output_results(const unsigned int refinement_cycle) const; const unsigned int pressure_degree; - SolverType::type solver_type; + SolverType solver_type; Triangulation triangulation; FESystem velocity_fe; @@ -454,7 +450,7 @@ namespace Step56 template StokesProblem::StokesProblem(const unsigned int pressure_degree, - SolverType::type solver_type) + SolverType solver_type) : pressure_degree(pressure_degree) , solver_type(solver_type) , triangulation(Triangulation::maximum_smoothing) @@ -642,10 +638,7 @@ namespace Step56 std::vector div_phi_u(dofs_per_cell); std::vector phi_p(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()) { fe_values.reinit(cell); local_matrix = 0; @@ -755,10 +748,7 @@ namespace Step56 } // This iterator goes over all cells (not just active) - typename DoFHandler::cell_iterator cell = velocity_dof_handler.begin(), - endc = velocity_dof_handler.end(); - - for (; cell != endc; ++cell) + for (const auto &cell : velocity_dof_handler.active_cell_iterators()) { fe_values.reinit(cell); cell_matrix = 0; -- 2.39.5