]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Indent step-20 and modernize
authorDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Wed, 20 Jun 2018 13:11:33 +0000 (15:11 +0200)
committerDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Wed, 20 Jun 2018 13:14:58 +0000 (15:14 +0200)
examples/step-20/doc/intro.dox
examples/step-20/step-20.cc

index f791e4d94483222a6f42f777367fbc2de09fa504..85e53f467f4737a3725d554258e3083f6899568f 100644 (file)
@@ -262,10 +262,7 @@ see step-22 for a realization of that approach).
 The final result then looks like this, working in every space dimension:
 
 @code
-  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;
index 17eda9bb4e3e4b532d323358f51e3dec25b4ac63..c4ec3c888e9b5d780549713208ab07c777b34181 100644 (file)
@@ -473,16 +473,13 @@ namespace Step20
     // refer to the velocities (a set of <code>dim</code> components starting
     // at component zero) or the pressure (a scalar component located at
     // position <code>dim</code>):
-    const FEValuesExtractors::Vector velocities(0);
-    const FEValuesExtractors::Scalar pressure(dim);
+    const FEValuesExtractors::Vector u(0);
+    const FEValuesExtractors::Scalar p(dim);
 
     // With all this in place, we can go on with the loop over all cells. The
     // body of this loop has been discussed in the introduction, and will not
     // be commented any further here:
-    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;
@@ -496,22 +493,21 @@ namespace Step20
         for (unsigned int q = 0; q < n_q_points; ++q)
           for (unsigned int i = 0; i < dofs_per_cell; ++i)
             {
-              const Tensor<1, dim> phi_i_u = fe_values[velocities].value(i, q);
-              const double div_phi_i_u = fe_values[velocities].divergence(i, q);
-              const double phi_i_p     = fe_values[pressure].value(i, q);
+              const Tensor<1, dim> phi_i_u     = fe_values[u].value(i, q);
+              const double         div_phi_i_u = fe_values[u].divergence(i, q);
+              const double         phi_i_p     = fe_values[p].value(i, q);
 
               for (unsigned int j = 0; j < dofs_per_cell; ++j)
                 {
-                  const Tensor<1, dim> phi_j_u =
-                    fe_values[velocities].value(j, q);
-                  const double div_phi_j_u =
-                    fe_values[velocities].divergence(j, q);
-                  const double phi_j_p = fe_values[pressure].value(j, q);
+                  const Tensor<1, dim> phi_j_u = fe_values[u].value(j, q);
+                  const double div_phi_j_u     = fe_values[u].divergence(j, q);
+                  const double phi_j_p         = fe_values[p].value(j, q);
 
                   local_matrix(i, j) +=
-                    (phi_i_u * k_inverse_values[q] * phi_j_u -
-                     div_phi_i_u * phi_j_p - phi_i_p * div_phi_j_u) *
-                    fe_values.JxW(q);
+                    (phi_i_u * k_inverse_values[q] * phi_j_u //
+                     - phi_i_p * div_phi_j_u                 //
+                     - div_phi_i_u * phi_j_p)                //
+                    * fe_values.JxW(q);
                 }
 
               local_rhs(i) += -phi_i_p * rhs_values[q] * fe_values.JxW(q);
@@ -529,9 +525,10 @@ namespace Step20
 
               for (unsigned int q = 0; q < n_face_q_points; ++q)
                 for (unsigned int i = 0; i < dofs_per_cell; ++i)
-                  local_rhs(i) += -(fe_face_values[velocities].value(i, q) *
-                                    fe_face_values.normal_vector(q) *
-                                    boundary_values[q] * fe_face_values.JxW(q));
+                  local_rhs(i) += -(fe_face_values[u].value(i, q) *   //
+                                    fe_face_values.normal_vector(q) * //
+                                    boundary_values[q] *              //
+                                    fe_face_values.JxW(q));
             }
 
         // The final step in the loop over all cells is to transfer local

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.