]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Modernize step-56
authorDaniel Arndt <arndtd@ornl.gov>
Wed, 8 May 2019 23:12:59 +0000 (19:12 -0400)
committerDaniel Arndt <arndtd@ornl.gov>
Wed, 8 May 2019 23:12:59 +0000 (19:12 -0400)
examples/step-56/step-56.cc

index b81f2c4564e04780416f74092767a450c523993d..1e65719b82c643170549bdb3bcbcea4c0c78824e 100644 (file)
@@ -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<dim> triangulation;
     FESystem<dim>      velocity_fe;
@@ -454,7 +450,7 @@ namespace Step56
 
   template <int dim>
   StokesProblem<dim>::StokesProblem(const unsigned int pressure_degree,
-                                    SolverType::type   solver_type)
+                                    SolverType         solver_type)
     : pressure_degree(pressure_degree)
     , solver_type(solver_type)
     , triangulation(Triangulation<dim>::maximum_smoothing)
@@ -642,10 +638,7 @@ namespace Step56
     std::vector<double>                  div_phi_u(dofs_per_cell);
     std::vector<double>                  phi_p(dofs_per_cell);
 
-    typename DoFHandler<dim>::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<dim>::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;

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.