]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Simplify some more 16967/head
authorTimo Heister <timo.heister@gmail.com>
Mon, 6 May 2024 13:25:24 +0000 (09:25 -0400)
committerTimo Heister <timo.heister@gmail.com>
Tue, 7 May 2024 10:43:55 +0000 (06:43 -0400)
examples/step-77/step-77.cc

index 95cc12f236a94f449dfbf1889cc883f657bef50f..30fc66af84adfee0e2ffadab108de4b720a8125e 100644 (file)
@@ -164,6 +164,9 @@ namespace Step77
   {
     TimerOutput::Scope t(computing_timer, "set up");
 
+    dof_handler.distribute_dofs(fe);
+    current_solution.reinit(dof_handler.n_dofs());
+
     zero_constraints.clear();
     VectorTools::interpolate_boundary_values(dof_handler,
                                              0,
@@ -370,8 +373,6 @@ namespace Step77
                                                     residual);
       }
 
-    zero_constraints.set_zero(residual);
-
     std::cout << " norm=" << residual.l2_norm() << std::endl;
   }
 
@@ -433,18 +434,15 @@ namespace Step77
     triangulation.prepare_coarsening_and_refinement();
 
     SolutionTransfer<dim> solution_transfer(dof_handler);
-    solution_transfer.prepare_for_coarsening_and_refinement(current_solution);
+    const Vector<double>  coarse_solution = current_solution;
+    solution_transfer.prepare_for_coarsening_and_refinement(coarse_solution);
 
     triangulation.execute_coarsening_and_refinement();
 
-    dof_handler.distribute_dofs(fe);
-
-    Vector<double> tmp(dof_handler.n_dofs());
-    solution_transfer.interpolate(current_solution, tmp);
-    current_solution = std::move(tmp);
-
     setup_system();
 
+    solution_transfer.interpolate(coarse_solution, current_solution);
+
     nonzero_constraints.distribute(current_solution);
   }
 
@@ -494,9 +492,6 @@ namespace Step77
     GridGenerator::hyper_ball(triangulation);
     triangulation.refine_global(2);
 
-    dof_handler.distribute_dofs(fe);
-    current_solution.reinit(dof_handler.n_dofs());
-
     setup_system();
     nonzero_constraints.distribute(current_solution);
 

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.