From e034bbc7ad9bce362173ffb061ed8678f300763a Mon Sep 17 00:00:00 2001 From: Tor Harald Sandve Date: Wed, 28 Sep 2016 09:59:50 +0200 Subject: [PATCH] Add initalizer for adaptiveTimeStepper that uses values from TUNING Some of the tuning values from the TUNING keywords is used to tune the timestepping. --- .../timestepping/AdaptiveTimeStepping.hpp | 13 +++++++++ .../AdaptiveTimeStepping_impl.hpp | 29 +++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/opm/simulators/timestepping/AdaptiveTimeStepping.hpp b/opm/simulators/timestepping/AdaptiveTimeStepping.hpp index d722f9cfd..2c84e8500 100644 --- a/opm/simulators/timestepping/AdaptiveTimeStepping.hpp +++ b/opm/simulators/timestepping/AdaptiveTimeStepping.hpp @@ -45,6 +45,17 @@ namespace Opm { AdaptiveTimeStepping( const parameter::ParameterGroup& param, const bool terminal_output = true ); + //! \brief contructor taking parameter object + //! \param tuning Pointer to ecl TUNING keyword + //! \param time_step current report step + //! \param param The parameter object + //! \param pinfo The information about the data distribution + //! and communication for a parallel run. + AdaptiveTimeStepping( const Tuning& tuning, + size_t time_step, + const parameter::ParameterGroup& param, + const bool terminal_output = true ); + /** \brief step method that acts like the solver::step method in a sub cycle of time steps @@ -77,6 +88,8 @@ namespace Opm { Solver& solver, State& state, WellState& well_state, Output* outputWriter); + void init(const parameter::ParameterGroup& param); + typedef std::unique_ptr< TimeStepControlInterface > TimeStepControlType; TimeStepControlType timeStepControl_; //!< time step control object diff --git a/opm/simulators/timestepping/AdaptiveTimeStepping_impl.hpp b/opm/simulators/timestepping/AdaptiveTimeStepping_impl.hpp index 6cb242f0e..a79cd2937 100644 --- a/opm/simulators/timestepping/AdaptiveTimeStepping_impl.hpp +++ b/opm/simulators/timestepping/AdaptiveTimeStepping_impl.hpp @@ -30,6 +30,7 @@ #include #include #include // For MatrixBlockException +#include namespace Opm { @@ -61,6 +62,26 @@ namespace Opm { // AdaptiveTimeStepping //--------------------- + AdaptiveTimeStepping::AdaptiveTimeStepping( const Tuning& tuning, + size_t time_step, + const parameter::ParameterGroup& param, + const bool terminal_output ) + : timeStepControl_() + , restart_factor_( tuning.getTSFCNV(time_step) ) + , growth_factor_(tuning.getTFDIFF(time_step) ) + , max_growth_( tuning.getTSFMAX(time_step) ) + // default is 1 year, convert to seconds + , max_time_step_( tuning.getTSMAXZ(time_step) ) + , solver_restart_max_( param.getDefault("solver.restart", int(10) ) ) + , solver_verbose_( param.getDefault("solver.verbose", bool(true) ) && terminal_output ) + , timestep_verbose_( param.getDefault("timestep.verbose", bool(true) ) && terminal_output ) + , suggested_next_timestep_( tuning.getTSINIT(time_step) ) + , full_timestep_initially_( param.getDefault("full_timestep_initially", bool(false) ) ) + { + init(param); + + } + AdaptiveTimeStepping::AdaptiveTimeStepping( const parameter::ParameterGroup& param, const bool terminal_output ) : timeStepControl_() @@ -74,6 +95,12 @@ namespace Opm { , timestep_verbose_( param.getDefault("timestep.verbose", bool(true) ) && terminal_output ) , suggested_next_timestep_( -1.0 ) , full_timestep_initially_( param.getDefault("full_timestep_initially", bool(false) ) ) + { + init(param); + } + + void AdaptiveTimeStepping:: + init(const parameter::ParameterGroup& param) { // valid are "pid" and "pid+iteration" std::string control = param.getDefault("timestep.control", std::string("pid") ); @@ -108,6 +135,7 @@ namespace Opm { } + template void AdaptiveTimeStepping:: step( const SimulatorTimer& simulatorTimer, Solver& solver, State& state, WellState& well_state ) @@ -123,6 +151,7 @@ namespace Opm { stepImpl( simulatorTimer, solver, state, well_state, &outputWriter ); } + // implementation of the step method template void AdaptiveTimeStepping::