From 6b7c0e630aeb8e7ba5e1a4016e8d08ad0fe4847d Mon Sep 17 00:00:00 2001 From: Tor Harald Sandve Date: Thu, 10 Dec 2020 13:39:01 +0100 Subject: [PATCH] report pre/post time --- opm/simulators/flow/BlackoilModelEbos.hpp | 15 +++++++++++++-- opm/simulators/flow/NonlinearSolverEbos.hpp | 4 ++-- opm/simulators/timestepping/SimulatorReport.cpp | 10 ++++++++++ opm/simulators/timestepping/SimulatorReport.hpp | 1 + 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/opm/simulators/flow/BlackoilModelEbos.hpp b/opm/simulators/flow/BlackoilModelEbos.hpp index 7da4276c0..d3cbba5a3 100644 --- a/opm/simulators/flow/BlackoilModelEbos.hpp +++ b/opm/simulators/flow/BlackoilModelEbos.hpp @@ -226,8 +226,11 @@ namespace Opm { /// Called once before each time step. /// \param[in] timer simulation timer - void prepareStep(const SimulatorTimerInterface& timer) + SimulatorReportSingle prepareStep(const SimulatorTimerInterface& timer) { + SimulatorReportSingle report; + Dune::Timer perfTimer; + perfTimer.start(); // update the solution variables in ebos if ( timer.lastStepFailed() ) { ebosSimulator_.model().updateFailed(); @@ -251,6 +254,9 @@ namespace Opm { std::cout << "equation scaling not suported yet" << std::endl; //updateEquationsScaling(); } + report.pre_post_time += perfTimer.stop(); + + return report; } @@ -394,9 +400,14 @@ namespace Opm { /// Called once after each time step. /// In this class, this function does nothing. /// \param[in] timer simulation timer - void afterStep(const SimulatorTimerInterface& timer OPM_UNUSED) + SimulatorReportSingle afterStep(const SimulatorTimerInterface& timer OPM_UNUSED) { + SimulatorReportSingle report; + Dune::Timer perfTimer; + perfTimer.start(); ebosSimulator_.problem().endTimeStep(); + report.pre_post_time += perfTimer.stop(); + return report; } /// Assemble the residual and Jacobian of the nonlinear system. diff --git a/opm/simulators/flow/NonlinearSolverEbos.hpp b/opm/simulators/flow/NonlinearSolverEbos.hpp index 7f2547178..2bb128720 100644 --- a/opm/simulators/flow/NonlinearSolverEbos.hpp +++ b/opm/simulators/flow/NonlinearSolverEbos.hpp @@ -183,7 +183,7 @@ namespace Opm { report.timestep_length = timer.currentStepLength(); // Do model-specific once-per-step calculations. - model_->prepareStep(timer); + report += model_->prepareStep(timer); int iteration = 0; @@ -224,7 +224,7 @@ namespace Opm { } // Do model-specific post-step actions. - model_->afterStep(timer); + report += model_->afterStep(timer); report.converged = true; return report; } diff --git a/opm/simulators/timestepping/SimulatorReport.cpp b/opm/simulators/timestepping/SimulatorReport.cpp index f7016d6d6..9c16dbe10 100644 --- a/opm/simulators/timestepping/SimulatorReport.cpp +++ b/opm/simulators/timestepping/SimulatorReport.cpp @@ -36,6 +36,7 @@ namespace Opm total_time(0.0), solver_time(0.0), assemble_time(0.0), + pre_post_time(0.0), assemble_time_well(0.0), linear_solve_setup_time(0.0), linear_solve_time(0.0), @@ -60,6 +61,7 @@ namespace Opm linear_solve_time += sr.linear_solve_time; solver_time += sr.solver_time; assemble_time += sr.assemble_time; + pre_post_time += sr.pre_post_time; assemble_time_well += sr.assemble_time_well; update_time += sr.update_time; output_write_time += sr.output_write_time; @@ -139,6 +141,14 @@ namespace Opm 100*failureReport->update_time/t); } os << std::endl; + t = pre_post_time + (failureReport ? failureReport->pre_post_time : 0.0); + os << fmt::format(" Pre/post step (seconds): {:7.2f}", t); + if (failureReport) { + os << fmt::format(" (Failed: {:2.1f}; {:2.1f}%)", + failureReport->pre_post_time, + 100*failureReport->pre_post_time/t); + } + os << std::endl; os << fmt::format(" Output write time (seconds): {:7.2f}", output_write_time + (failureReport ? failureReport->output_write_time : 0.0)); diff --git a/opm/simulators/timestepping/SimulatorReport.hpp b/opm/simulators/timestepping/SimulatorReport.hpp index b505a8fd3..6eadc34b2 100644 --- a/opm/simulators/timestepping/SimulatorReport.hpp +++ b/opm/simulators/timestepping/SimulatorReport.hpp @@ -34,6 +34,7 @@ namespace Opm double total_time; double solver_time; double assemble_time; + double pre_post_time; double assemble_time_well; double linear_solve_setup_time; double linear_solve_time;