Timestepper based on userInput
A new timestepper that reads timesteps from a file generated using ecl_summary "DECK" TIME and applies it to the simulator Also a parameter timestep.initial_step_length (default 1 day) is added to controll the frist timestep.
This commit is contained in:
parent
cf16b0affe
commit
6e9bb4cf0b
@ -72,7 +72,7 @@ namespace Opm {
|
||||
, 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_( -1.0 )
|
||||
, suggested_next_timestep_( unit::convert::from(param.getDefault("timestep.initial_step_length", double(1.0) ), unit::day) )
|
||||
, full_timestep_initially_( param.getDefault("full_timestep_initially", bool(false) ) )
|
||||
{
|
||||
// valid are "pid" and "pid+iteration"
|
||||
@ -95,6 +95,10 @@ namespace Opm {
|
||||
const double decayrate = param.getDefault("timestep.control.decayrate", double(0.75) );
|
||||
const double growthrate = param.getDefault("timestep.control.growthrate", double(1.25) );
|
||||
timeStepControl_ = TimeStepControlType( new SimpleIterationCountTimeStepControl( iterations, decayrate, growthrate ) );
|
||||
} else if ( control == "hardcoded") {
|
||||
const std::string filename = param.getDefault("timestep.control.filename", std::string("timesteps"));
|
||||
timeStepControl_ = TimeStepControlType( new HardcodedTimeStepControl( filename ) );
|
||||
|
||||
}
|
||||
else
|
||||
OPM_THROW(std::runtime_error,"Unsupported time step control selected "<< control );
|
||||
@ -202,7 +206,7 @@ namespace Opm {
|
||||
|
||||
// compute new time step estimate
|
||||
double dtEstimate =
|
||||
timeStepControl_->computeTimeStepSize( dt, linearIterations, relativeChange );
|
||||
timeStepControl_->computeTimeStepSize( dt, linearIterations, relativeChange, substepTimer.simulationTimeElapsed());
|
||||
|
||||
// limit the growth of the timestep size by the growth factor
|
||||
dtEstimate = std::min( dtEstimate, double(max_growth_ * dt) );
|
||||
|
@ -23,6 +23,9 @@
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
#include <opm/common/ErrorMacros.hpp>
|
||||
#include <opm/core/utility/Units.hpp>
|
||||
@ -55,7 +58,7 @@ namespace Opm
|
||||
}
|
||||
|
||||
double SimpleIterationCountTimeStepControl::
|
||||
computeTimeStepSize( const double dt, const int iterations, const RelativeChangeInterface& /* relativeChange */ ) const
|
||||
computeTimeStepSize( const double dt, const int iterations, const RelativeChangeInterface& /* relativeChange */, const double /*simulationTimeElapsed */) const
|
||||
{
|
||||
double dtEstimate = dt ;
|
||||
|
||||
@ -74,6 +77,38 @@ namespace Opm
|
||||
return dtEstimate;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
//
|
||||
// HardcodedTimeStepControl Implementation
|
||||
//
|
||||
////////////////////////////////////////////////////////
|
||||
|
||||
HardcodedTimeStepControl::
|
||||
HardcodedTimeStepControl( const std::string filename)
|
||||
{
|
||||
std::ifstream infile (filename);
|
||||
double time;
|
||||
std::string line;
|
||||
std::getline(infile, line); //assumes two lines before the timing starts.
|
||||
std::getline(infile, line);
|
||||
|
||||
while (!infile.eof() ) {
|
||||
infile >> time; // read the time in days
|
||||
std::string line;
|
||||
std::getline(infile, line); // skip the rest of the line
|
||||
timesteps_.push_back( time * unit::day );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
double HardcodedTimeStepControl::
|
||||
computeTimeStepSize( const double /*dt */, const int /*iterations */, const RelativeChangeInterface& /* relativeChange */ , const double simulationTimeElapsed) const
|
||||
{
|
||||
auto nextTime = std::upper_bound(timesteps_.begin(), timesteps_.end(), simulationTimeElapsed);
|
||||
double dtEstimate = (*nextTime - simulationTimeElapsed);
|
||||
return dtEstimate;
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
@ -90,7 +125,7 @@ namespace Opm
|
||||
{}
|
||||
|
||||
double PIDTimeStepControl::
|
||||
computeTimeStepSize( const double dt, const int /* iterations */, const RelativeChangeInterface& relChange ) const
|
||||
computeTimeStepSize( const double dt, const int /* iterations */, const RelativeChangeInterface& relChange, const double /*simulationTimeElapsed */) const
|
||||
{
|
||||
// shift errors
|
||||
for( int i=0; i<2; ++i ) {
|
||||
@ -141,9 +176,9 @@ namespace Opm
|
||||
{}
|
||||
|
||||
double PIDAndIterationCountTimeStepControl::
|
||||
computeTimeStepSize( const double dt, const int iterations, const RelativeChangeInterface& relChange ) const
|
||||
computeTimeStepSize( const double dt, const int iterations, const RelativeChangeInterface& relChange, const double simulationTimeElapsed ) const
|
||||
{
|
||||
double dtEstimate = BaseType :: computeTimeStepSize( dt, iterations, relChange );
|
||||
double dtEstimate = BaseType :: computeTimeStepSize( dt, iterations, relChange, simulationTimeElapsed);
|
||||
|
||||
// further reduce step size if to many iterations were used
|
||||
if( iterations > target_iterations_ )
|
||||
|
@ -48,7 +48,7 @@ namespace Opm
|
||||
const bool verbose = false);
|
||||
|
||||
/// \brief \copydoc TimeStepControlInterface::computeTimeStepSize
|
||||
double computeTimeStepSize( const double dt, const int iterations, const RelativeChangeInterface& /* relativeChange */ ) const;
|
||||
double computeTimeStepSize( const double dt, const int iterations, const RelativeChangeInterface& /* relativeChange */, const double /*simulationTimeElapsed */ ) const;
|
||||
|
||||
protected:
|
||||
const int target_iterations_;
|
||||
@ -82,7 +82,7 @@ namespace Opm
|
||||
const bool verbose = false );
|
||||
|
||||
/// \brief \copydoc TimeStepControlInterface::computeTimeStepSize
|
||||
double computeTimeStepSize( const double dt, const int /* iterations */, const RelativeChangeInterface& relativeChange ) const;
|
||||
double computeTimeStepSize( const double dt, const int /* iterations */, const RelativeChangeInterface& relativeChange, const double /*simulationTimeElapsed */ ) const;
|
||||
|
||||
protected:
|
||||
const double tol_;
|
||||
@ -111,12 +111,33 @@ namespace Opm
|
||||
const bool verbose = false);
|
||||
|
||||
/// \brief \copydoc TimeStepControlInterface::computeTimeStepSize
|
||||
double computeTimeStepSize( const double dt, const int iterations, const RelativeChangeInterface& relativeChange ) const;
|
||||
double computeTimeStepSize( const double dt, const int iterations, const RelativeChangeInterface& relativeChange, const double /*simulationTimeElapsed */ ) const;
|
||||
|
||||
protected:
|
||||
const int target_iterations_;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///
|
||||
/// HardcodedTimeStepControl
|
||||
/// Input generated from summary file using the ert application:
|
||||
/// ecl_summary DECK TIME > filename
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
class HardcodedTimeStepControl : public TimeStepControlInterface
|
||||
{
|
||||
public:
|
||||
/// \brief constructor
|
||||
/// \param filename filename contaning the timesteps
|
||||
HardcodedTimeStepControl( const std::string filename);
|
||||
|
||||
/// \brief \copydoc TimeStepControlInterface::computeTimeStepSize
|
||||
double computeTimeStepSize( const double dt, const int /* iterations */, const RelativeChangeInterface& /*relativeChange */, const double simulationTimeElapsed) const;
|
||||
|
||||
protected:
|
||||
std::vector<double> timesteps_;
|
||||
};
|
||||
|
||||
|
||||
} // end namespace Opm
|
||||
#endif
|
||||
|
@ -56,7 +56,7 @@ namespace Opm
|
||||
/// \param timeError object to compute || u^n+1 - u^n || / || u^n+1 ||
|
||||
///
|
||||
/// \return suggested time step size for the next step
|
||||
virtual double computeTimeStepSize( const double dt, const int iterations, const RelativeChangeInterface& relativeChange ) const = 0;
|
||||
virtual double computeTimeStepSize( const double dt, const int iterations, const RelativeChangeInterface& relativeChange , const double simulationTimeElapsed) const = 0;
|
||||
|
||||
/// virtual destructor (empty)
|
||||
virtual ~TimeStepControlInterface () {}
|
||||
|
Loading…
Reference in New Issue
Block a user