From f65f5d2c3b2083f3a7d3864384036ded82326794 Mon Sep 17 00:00:00 2001 From: Tor Harald Sandve Date: Mon, 5 Dec 2016 09:37:30 +0100 Subject: [PATCH] Store whether timestep failed or not Used in flow ebos to tell the simulator to recalculate the cached quantities for failed timesteps. --- opm/simulators/timestepping/AdaptiveSimulatorTimer.cpp | 1 + opm/simulators/timestepping/AdaptiveSimulatorTimer.hpp | 8 ++++++++ opm/simulators/timestepping/AdaptiveTimeStepping_impl.hpp | 3 ++- opm/simulators/timestepping/SimulatorTimer.hpp | 4 ++++ opm/simulators/timestepping/SimulatorTimerInterface.hpp | 3 +++ 5 files changed, 18 insertions(+), 1 deletion(-) diff --git a/opm/simulators/timestepping/AdaptiveSimulatorTimer.cpp b/opm/simulators/timestepping/AdaptiveSimulatorTimer.cpp index 927b06419..6fd59d3f1 100644 --- a/opm/simulators/timestepping/AdaptiveSimulatorTimer.cpp +++ b/opm/simulators/timestepping/AdaptiveSimulatorTimer.cpp @@ -42,6 +42,7 @@ namespace Opm , dt_( 0.0 ) , current_step_( 0 ) , steps_() + , lastStepFailed_( false ) { // reserve memory for sub steps steps_.reserve( 10 ); diff --git a/opm/simulators/timestepping/AdaptiveSimulatorTimer.hpp b/opm/simulators/timestepping/AdaptiveSimulatorTimer.hpp index be93f3047..31af15b83 100644 --- a/opm/simulators/timestepping/AdaptiveSimulatorTimer.hpp +++ b/opm/simulators/timestepping/AdaptiveSimulatorTimer.hpp @@ -93,6 +93,12 @@ namespace Opm /// \brief start date time of simulation boost::posix_time::ptime startDateTime() const; + /// \brief Return true if last time step failed + bool lastStepFailed() const {return lastStepFailed_;} + + /// \brief tell the timestepper whether timestep failed or not + void setLastStepFailed(bool lastStepFailed) {lastStepFailed_ = lastStepFailed;} + /// return copy of object virtual std::unique_ptr< SimulatorTimerInterface > clone() const; @@ -108,6 +114,8 @@ namespace Opm int current_step_; std::vector< double > steps_; + bool lastStepFailed_; + }; } // namespace Opm diff --git a/opm/simulators/timestepping/AdaptiveTimeStepping_impl.hpp b/opm/simulators/timestepping/AdaptiveTimeStepping_impl.hpp index 03c16e0e0..12d31dec9 100644 --- a/opm/simulators/timestepping/AdaptiveTimeStepping_impl.hpp +++ b/opm/simulators/timestepping/AdaptiveTimeStepping_impl.hpp @@ -295,12 +295,13 @@ namespace Opm { last_well_state = well_state; report.converged = substepTimer.done(); + substepTimer.setLastStepFailed(false); } else // in case of no convergence (linearIterations < 0) { report.converged = false; - + substepTimer.setLastStepFailed(true); // increase restart counter if( restarts >= solver_restart_max_ ) { const auto msg = std::string("Solver failed to converge after ") diff --git a/opm/simulators/timestepping/SimulatorTimer.hpp b/opm/simulators/timestepping/SimulatorTimer.hpp index ada0cc049..8b920192c 100644 --- a/opm/simulators/timestepping/SimulatorTimer.hpp +++ b/opm/simulators/timestepping/SimulatorTimer.hpp @@ -110,6 +110,10 @@ namespace Opm /// Return true if op++() has been called numSteps() times. bool done() const; + /// Always return false. Timestep failures is handled in the + /// substepTimer + bool lastStepFailed() const {return false;} + /// return copy of object virtual std::unique_ptr< SimulatorTimerInterface > clone() const; diff --git a/opm/simulators/timestepping/SimulatorTimerInterface.hpp b/opm/simulators/timestepping/SimulatorTimerInterface.hpp index c9e28471e..ae30d381c 100644 --- a/opm/simulators/timestepping/SimulatorTimerInterface.hpp +++ b/opm/simulators/timestepping/SimulatorTimerInterface.hpp @@ -101,6 +101,9 @@ namespace Opm return std::mktime(&t); } + /// Return true if last time step failed + virtual bool lastStepFailed() const = 0; + /// return copy of current timer instance virtual std::unique_ptr< SimulatorTimerInterface > clone () const = 0; };