From a98b70200e5bb0921f5a1e76902799384688e3bd Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Sat, 6 Apr 2024 10:19:39 -0600 Subject: [PATCH] In step-40, move timer section into the function being timed. --- examples/step-40/step-40.cc | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/examples/step-40/step-40.cc b/examples/step-40/step-40.cc index 2b353a75c1..5291257e07 100644 --- a/examples/step-40/step-40.cc +++ b/examples/step-40/step-40.cc @@ -166,7 +166,7 @@ namespace Step40 void assemble_system(); void solve(); void refine_grid(); - void output_results(const unsigned int cycle) const; + void output_results(const unsigned int cycle); MPI_Comm mpi_communicator; @@ -483,7 +483,8 @@ namespace Step40 void LaplaceProblem::solve() { TimerOutput::Scope t(computing_timer, "solve"); - LA::MPI::Vector completely_distributed_solution(locally_owned_dofs, + + LA::MPI::Vector completely_distributed_solution(locally_owned_dofs, mpi_communicator); SolverControl solver_control(dof_handler.n_dofs(), 1e-12); @@ -584,8 +585,10 @@ namespace Step40 // to locally owned cells, while providing the wrong value for all other // elements -- but these are then ignored anyway. template - void LaplaceProblem::output_results(const unsigned int cycle) const + void LaplaceProblem::output_results(const unsigned int cycle) { + TimerOutput::Scope t(computing_timer, "output"); + DataOut data_out; data_out.attach_dof_handler(dof_handler); data_out.add_data_vector(locally_relevant_solution, "u"); @@ -652,11 +655,7 @@ namespace Step40 assemble_system(); solve(); - - { - TimerOutput::Scope t(computing_timer, "output"); - output_results(cycle); - } + output_results(cycle); computing_timer.print_summary(); computing_timer.reset(); -- 2.39.5