AdaptiveSimulatorTimer: initialization of first time step size follows the same rule as

for later steps.
PIDTimeStepControl: added maxgrowth factor which indicates the maximum allow groth of
                    the time step from one to the next value.
This commit is contained in:
Robert K 2015-01-16 14:56:37 +01:00
parent aa66a4304f
commit 04e8533cee
3 changed files with 8 additions and 18 deletions

View File

@ -36,7 +36,7 @@ namespace Opm
, total_time_( start_time_ + timer.currentStepLength() )
, report_step_( timer.reportStepNum() )
, current_time_( start_time_ )
, dt_( computeInitialTimeStep( lastStepTaken ) )
, dt_( 0.0 )
, current_step_( 0 )
, steps_()
, suggestedMax_( 0.0 )
@ -44,6 +44,9 @@ namespace Opm
{
// reserve memory for sub steps
steps_.reserve( 10 );
// set appropriate value for dt_
provideTimeStepEstimate( lastStepTaken );
}
AdaptiveSimulatorTimer& AdaptiveSimulatorTimer::operator++ ()
@ -161,16 +164,4 @@ namespace Opm
return start_date_time_;
}
double AdaptiveSimulatorTimer::
computeInitialTimeStep( const double lastDt ) const
{
const double maxTimeStep = total_time_ - start_time_;
const double fraction = (lastDt / maxTimeStep);
// when lastDt and maxTimeStep are close together, choose the max time step
if( fraction > 0.95 ) return maxTimeStep;
// otherwise choose lastDt
return std::min( lastDt, maxTimeStep );
}
} // namespace Opm

View File

@ -105,8 +105,6 @@ namespace Opm
std::vector< double > steps_;
double suggestedMax_;
double suggestedAverage_;
double computeInitialTimeStep( const double lastDt ) const;
};
} // namespace Opm

View File

@ -51,8 +51,9 @@ namespace Opm {
}
else if ( control == "pid+iteration" )
{
const int iterations = param.getDefault("timestep.control.targetiteration", int(25) );
timeStepControl_ = TimeStepControlType( new PIDAndIterationCountTimeStepControl( iterations, tol ) );
const int iterations = param.getDefault("timestep.control.targetiteration", int(25) );
const double maxgrowth = param.getDefault("timestep.control.maxgrowth", double(3.0) );
timeStepControl_ = TimeStepControlType( new PIDAndIterationCountTimeStepControl( iterations, tol, maxgrowth ) );
}
else
OPM_THROW(std::runtime_error,"Unsupported time step control selected "<< control );
@ -150,7 +151,7 @@ namespace Opm {
{
std::cout << std::endl
<<"Substep( " << substepTimer.currentStepNum()
<< " ): Current time (days) " << unit::convert::to(substepTimer.simulationTimeElapsed(),unit::day) << std::endl
<< " ): Current time (days) " << unit::convert::to(substepTimer.simulationTimeElapsed(),unit::day) << std::endl
<< " Current stepsize est (days) " << unit::convert::to(dtEstimate, unit::day) << std::endl;
}