added initial fraction to initialize last_timestep.

This commit is contained in:
Robert Kloefkorn 2014-10-13 11:17:37 +02:00
parent 3b58ad9aa4
commit 1bda36b251
2 changed files with 9 additions and 2 deletions

View File

@ -36,6 +36,7 @@ namespace Opm {
typedef std::unique_ptr< TimeStepControlInterface > TimeStepControlType;
TimeStepControlType timeStepControl_; //!< time step control object
const double initial_fraction_; //!< fraction to take as a guess for initial time interval
const double restart_factor_; //!< factor to multiply time step with when solver fails to converge
const int solver_restart_max_; //!< how many restart of solver are allowed
const bool solver_verbose_; //!< solver verbosity

View File

@ -15,11 +15,12 @@ namespace Opm {
AdaptiveTimeStepping::AdaptiveTimeStepping( const parameter::ParameterGroup& param )
: timeStepControl_()
, initial_fraction_( param.getDefault("solver.initialfraction", double(0.25) ) )
, restart_factor_( param.getDefault("solver.restartfactor", double(0.1) ) )
, solver_restart_max_( param.getDefault("solver.restart", int(3) ) )
, solver_verbose_( param.getDefault("solver.verbose", bool(false) ) )
, timestep_verbose_( param.getDefault("timestep.verbose", bool(false) ) )
, last_timestep_( std::numeric_limits< double >::max() )
, last_timestep_( -1.0 )
{
// valid are "pid" and "pid+iteration"
std::string control = param.getDefault("timestep.control", std::string("pid") );
@ -42,6 +43,10 @@ namespace Opm {
step( Solver& solver, State& state, WellState& well_state,
const double time, const double timestep )
{
// init last time step as a fraction of the given time step
if( last_timestep_ < 0 )
last_timestep_ = initial_fraction_ * timestep ;
// create adaptive step timer with previously used sub step size
AdaptiveSimulatorTimer timer( time, time+timestep, last_timestep_ );
@ -106,7 +111,8 @@ namespace Opm {
// we need to revise this
timer.provideTimeStepEstimate( newTimeStep );
if( solver_verbose_ )
std::cerr << "Solver convergence failed, restarting solver with new time step ("<< newTimeStep <<" days)." << std::endl;
std::cerr << "Solver convergence failed, restarting solver with new time step ("
<< unit::convert::to( newTimeStep, unit::day ) <<" days)." << std::endl;
// reset states
state = last_state;