fix problem with solver reastart, variable was not reset.

Also, the time step does only grow moderately after a solver restart.
This commit is contained in:
Robert K 2014-10-24 12:32:00 +02:00
parent 16624f6f4e
commit f16f4a2e98
2 changed files with 16 additions and 3 deletions

View File

@ -38,6 +38,7 @@ namespace Opm {
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 double growth_factor_; //!< factor to multiply time step when solver recovered from failed convergence
const int solver_restart_max_; //!< how many restart of solver are allowed
const bool solver_verbose_; //!< solver verbosity
const bool timestep_verbose_; //!< timestep verbosity

View File

@ -17,6 +17,7 @@ namespace Opm {
: timeStepControl_()
, initial_fraction_( param.getDefault("solver.initialfraction", double(0.25) ) )
, restart_factor_( param.getDefault("solver.restartfactor", double(0.1) ) )
, growth_factor_( param.getDefault("solver.growthfactor", double(1.25) ) )
, 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) ) )
@ -36,6 +37,9 @@ namespace Opm {
}
else
OPM_THROW(std::runtime_error,"Unsupported time step control selected "<< control );
// make sure growth factor is something reasonable
assert( growth_factor_ >= 1.0 );
}
@ -78,11 +82,11 @@ namespace Opm {
std::cout << "Overall linear iterations used: " << linearIterations << std::endl;
}
}
catch (Opm::NumericalProblem e) {
catch (const Opm::NumericalProblem& e) {
std::cerr << e.what() << std::endl;
// since linearIterations is < 0 this will restart the solver
}
catch (std::runtime_error e) {
catch (const std::runtime_error& e) {
std::cerr << e.what() << std::endl;
// also catch linear solver not converged
}
@ -94,8 +98,16 @@ namespace Opm {
++timer;
// compute new time step estimate
const double dtEstimate =
double dtEstimate =
timeStepControl_->computeTimeStepSize( dt, linearIterations, state );
// avoid time step size growth
if( restarts > 0 ) {
dtEstimate = std::min( growth_factor_ * dt, dtEstimate );
// solver converged, reset restarts counter
restarts = 0;
}
if( timestep_verbose_ )
std::cout << "Suggested time step size = " << unit::convert::to(dtEstimate, unit::day) << " (days)" << std::endl;