From a90acfabcd585c9aefbebf5f85ae8b3debe870c2 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Fri, 14 Sep 2018 16:46:55 -0600 Subject: [PATCH] Deal better with boundary values in step-52. --- examples/step-52/step-52.cc | 41 +++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/examples/step-52/step-52.cc b/examples/step-52/step-52.cc index 77ef88d5e1..a9f3e8d1c0 100644 --- a/examples/step-52/step-52.cc +++ b/examples/step-52/step-52.cc @@ -466,12 +466,23 @@ namespace Step52 // @sect4{Diffusion::explicit_method} // - // This function is the driver for all the explicit methods. It calls - // evolve_one_time_step which performs one time step. For - // explicit methods, evolve_one_time_step needs to evaluate - // $M^{-1}(f(t,y))$, i.e, it needs evaluate_diffusion. Because - // evaluate_diffusion is a member function, it needs to be bound - // to this. Finally, the solution is output every 10 time steps. + // This function is the driver for all the explicit methods. At the + // top it initializes the time stepping and the solution (by setting + // it to zero and then ensuring that boundary value and hanging node + // constraints are respected; of course, with the mesh we use here, + // hanging node constraints are not in fact an issue). It then calls + // evolve_one_time_step which performs one time step. + // + // For explicit methods, evolve_one_time_step needs to + // evaluate $M^{-1}(f(t,y))$, i.e, it needs + // evaluate_diffusion. Because + // evaluate_diffusion is a member function, it needs to + // be bound to this. After each evolution step, we + // again apply the correct boundary values and hanging node + // constraints. + // + // Finally, the solution is output + // every 10 time steps. void Diffusion::explicit_method(const TimeStepping::runge_kutta_method method, const unsigned int n_time_steps, const double initial_time, @@ -480,7 +491,9 @@ namespace Step52 const double time_step = (final_time - initial_time) / static_cast(n_time_steps); double time = initial_time; - solution = 0.; + + solution = 0.; + constraint_matrix.distribute(solution); TimeStepping::ExplicitRungeKutta> explicit_runge_kutta( method); @@ -496,6 +509,8 @@ namespace Step52 time_step, solution); + constraint_matrix.distribute(solution); + if ((i + 1) % 10 == 0) output_results(i + 1, method); } @@ -517,7 +532,9 @@ namespace Step52 const double time_step = (final_time - initial_time) / static_cast(n_time_steps); double time = initial_time; - solution = 0.; + + solution = 0.; + constraint_matrix.distribute(solution); TimeStepping::ImplicitRungeKutta> implicit_runge_kutta( method); @@ -538,6 +555,8 @@ namespace Step52 time_step, solution); + constraint_matrix.distribute(solution); + if ((i + 1) % 10 == 0) output_results(i + 1, method); } @@ -576,7 +595,9 @@ namespace Step52 const double max_delta = 10 * time_step; const double refine_tol = 1e-1; const double coarsen_tol = 1e-5; - solution = 0.; + + solution = 0.; + constraint_matrix.distribute(solution); TimeStepping::EmbeddedExplicitRungeKutta> embedded_explicit_runge_kutta(method, @@ -605,6 +626,8 @@ namespace Step52 time_step, solution); + constraint_matrix.distribute(solution); + if ((n_steps + 1) % 10 == 0) output_results(n_steps + 1, method); -- 2.39.5