From 7c9dab1a6444f0824bf2bd9fc817f1e5c148a81d Mon Sep 17 00:00:00 2001 From: Tor Harald Sandve Date: Mon, 12 Mar 2018 14:48:34 +0100 Subject: [PATCH] Add reportStep method in SimulatorReport and use it --- .../SimulatorFullyImplicitBlackoilEbos.hpp | 13 +++---------- opm/core/simulator/SimulatorReport.cpp | 18 ++++++++++++++++++ opm/core/simulator/SimulatorReport.hpp | 1 + .../timestepping/AdaptiveTimeStepping_impl.hpp | 10 +--------- 4 files changed, 23 insertions(+), 19 deletions(-) diff --git a/opm/autodiff/SimulatorFullyImplicitBlackoilEbos.hpp b/opm/autodiff/SimulatorFullyImplicitBlackoilEbos.hpp index 5416354ed..00180c198 100644 --- a/opm/autodiff/SimulatorFullyImplicitBlackoilEbos.hpp +++ b/opm/autodiff/SimulatorFullyImplicitBlackoilEbos.hpp @@ -251,16 +251,9 @@ public: if( terminal_output_ ) { - //stepReport.briefReport(); - std::ostringstream iter_msg; - iter_msg << "Stepsize " << (double)unit::convert::to(timer.currentStepLength(), unit::day); - if (solver->wellIterations() != 0) { - iter_msg << " days well iterations = " << solver->wellIterations() << ", "; - } - iter_msg << "non-linear iterations = " << solver->nonlinearIterations() - << ", total linear iterations = " << solver->linearIterations() - << "\n"; - OpmLog::info(iter_msg.str()); + std::ostringstream ss; + stepReport.reportStep(ss); + OpmLog::info(ss.str()); } } diff --git a/opm/core/simulator/SimulatorReport.cpp b/opm/core/simulator/SimulatorReport.cpp index 2f99a410b..e7fc2eb9a 100644 --- a/opm/core/simulator/SimulatorReport.cpp +++ b/opm/core/simulator/SimulatorReport.cpp @@ -20,6 +20,8 @@ #include "config.h" #include #include +#include + namespace Opm { @@ -70,6 +72,22 @@ namespace Opm } } + void SimulatorReport::reportStep(std::ostringstream& ss) + { + if ( verbose_ ) + { + ss << "Time step summary: "; + if (total_well_iterations != 0) { + ss << "well its = " << std::setw(2) << total_well_iterations << ", "; + } + ss << "newton its = " << std::setw(2) << total_newton_iterations << ", " + << "linearizations = " << std::setw(2) << total_linearizations + << " (" << std::fixed << std::setprecision(3) << std::setw(6) << assemble_time << " sec), " + << "linear its = " << std::setw(3) << total_linear_iterations + << " (" << std::fixed << std::setprecision(3) << std::setw(6) << linear_solve_time << " sec)"; + } + } + void SimulatorReport::reportFullyImplicit(std::ostream& os, const SimulatorReport* failureReport) { if ( verbose_ ) diff --git a/opm/core/simulator/SimulatorReport.hpp b/opm/core/simulator/SimulatorReport.hpp index 8b1194570..696f9bca1 100644 --- a/opm/core/simulator/SimulatorReport.hpp +++ b/opm/core/simulator/SimulatorReport.hpp @@ -52,6 +52,7 @@ namespace Opm void operator+=(const SimulatorReport& sr); /// Print a report to the given stream. void report(std::ostream& os); + void reportStep(std::ostringstream& os); /// Print a report, leaving out the transport time. void reportFullyImplicit(std::ostream& os, const SimulatorReport* failedReport = nullptr); void reportParam(std::ostream& os); diff --git a/opm/simulators/timestepping/AdaptiveTimeStepping_impl.hpp b/opm/simulators/timestepping/AdaptiveTimeStepping_impl.hpp index 4d38768db..42fba4286 100644 --- a/opm/simulators/timestepping/AdaptiveTimeStepping_impl.hpp +++ b/opm/simulators/timestepping/AdaptiveTimeStepping_impl.hpp @@ -309,15 +309,7 @@ namespace Opm { if( timestep_verbose_ ) { std::ostringstream ss; - ss << "Time step summary: "; - if (substepReport.total_well_iterations != 0) { - ss << "well its = " << std::setw(2) << substepReport.total_well_iterations << ", "; - } - ss << "newton its = " << std::setw(2) << substepReport.total_newton_iterations << ", " - << "linearizations = " << std::setw(2) << substepReport.total_linearizations - << " (" << std::fixed << std::setprecision(3) << std::setw(6) << substepReport.assemble_time << " sec), " - << "linear its = " << std::setw(3) << substepReport.total_linear_iterations - << " (" << std::fixed << std::setprecision(3) << std::setw(6) << substepReport.linear_solve_time << " sec)"; + substepReport.reportStep(ss); OpmLog::info(ss.str()); }