mirror of
https://github.com/OPM/opm-simulators.git
synced 2024-12-01 21:39:09 -06:00
Merge pull request #4415 from GitPaean/time_step_nochange
fix the running when solution does not change between time steps
This commit is contained in:
commit
b598c27605
@ -27,11 +27,15 @@
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <limits>
|
||||
|
||||
#include <opm/common/ErrorMacros.hpp>
|
||||
#include <opm/common/OpmLog/OpmLog.hpp>
|
||||
#include <opm/input/eclipse/Units/Units.hpp>
|
||||
#include <opm/simulators/timestepping/TimeStepControl.hpp>
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
namespace Opm
|
||||
{
|
||||
////////////////////////////////////////////////////////
|
||||
@ -141,17 +145,22 @@ namespace Opm
|
||||
errors_[ 2 ] = error;
|
||||
for( int i=0; i<2; ++i ) {
|
||||
assert(std::isfinite(errors_[i]));
|
||||
assert(errors_[i]>0);
|
||||
}
|
||||
|
||||
if( error > tol_ )
|
||||
if( errors_[2] > tol_ )
|
||||
{
|
||||
// adjust dt by given tolerance
|
||||
const double newDt = dt * tol_ / error;
|
||||
if( verbose_ )
|
||||
std::cout << "Computed step size (tol): " << unit::convert::to( newDt, unit::day ) << " (days)" << std::endl;
|
||||
if ( verbose_ )
|
||||
OpmLog::info(fmt::format("Computed step size (tol): {} days", unit::convert::to( newDt, unit::day )));
|
||||
return newDt;
|
||||
}
|
||||
else if (errors_[1] == 0 || errors_[2] == 0.)
|
||||
{
|
||||
if ( verbose_ )
|
||||
OpmLog::info("The solution between time steps does not change, there is no time step constraint from the PID time step control ");
|
||||
return std::numeric_limits<double>::max();
|
||||
}
|
||||
else
|
||||
{
|
||||
// values taking from turek time stepping paper
|
||||
@ -162,7 +171,7 @@ namespace Opm
|
||||
std::pow( tol_ / errors_[ 2 ], kI ) *
|
||||
std::pow( errors_[0]*errors_[0]/errors_[ 1 ]/errors_[ 2 ], kD ));
|
||||
if( verbose_ )
|
||||
std::cout << "Computed step size (pow): " << unit::convert::to( newDt, unit::day ) << " (days)" << std::endl;
|
||||
OpmLog::info(fmt::format("Computed step size (pow): {} days", unit::convert::to( newDt, unit::day )));
|
||||
return newDt;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user