mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Small fixes hardcodedTimestepControl
-- avoid using eof() -- add comments -- no longer assumes two lines of comments. -- revert change to default value for timestep.initial_step_length -- make contructer explicit -- pass reference
This commit is contained in:
@@ -72,7 +72,7 @@ namespace Opm {
|
|||||||
, solver_restart_max_( param.getDefault("solver.restart", int(10) ) )
|
, solver_restart_max_( param.getDefault("solver.restart", int(10) ) )
|
||||||
, solver_verbose_( param.getDefault("solver.verbose", bool(true) ) && terminal_output )
|
, solver_verbose_( param.getDefault("solver.verbose", bool(true) ) && terminal_output )
|
||||||
, timestep_verbose_( param.getDefault("timestep.verbose", bool(true) ) && terminal_output )
|
, timestep_verbose_( param.getDefault("timestep.verbose", bool(true) ) && terminal_output )
|
||||||
, suggested_next_timestep_( unit::convert::from(param.getDefault("timestep.initial_step_length", double(1.0) ), unit::day) )
|
, suggested_next_timestep_( -1.0 )
|
||||||
, full_timestep_initially_( param.getDefault("full_timestep_initially", bool(false) ) )
|
, full_timestep_initially_( param.getDefault("full_timestep_initially", bool(false) ) )
|
||||||
{
|
{
|
||||||
// valid are "pid" and "pid+iteration"
|
// valid are "pid" and "pid+iteration"
|
||||||
|
|||||||
@@ -84,29 +84,25 @@ namespace Opm
|
|||||||
////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////
|
||||||
|
|
||||||
HardcodedTimeStepControl::
|
HardcodedTimeStepControl::
|
||||||
HardcodedTimeStepControl( const std::string filename)
|
HardcodedTimeStepControl( const std::string& filename)
|
||||||
{
|
{
|
||||||
std::ifstream infile (filename);
|
std::ifstream infile (filename);
|
||||||
double time;
|
std::string::size_type sz;
|
||||||
std::string line;
|
std::string line;
|
||||||
std::getline(infile, line); //assumes two lines before the timing starts.
|
while ( std::getline(infile, line)) {
|
||||||
std::getline(infile, line);
|
if( line[0] != '-') { // ignore lines starting with '-'
|
||||||
|
const double time = std::stod(line,&sz); // read the first number i.e. the actual substep time
|
||||||
|
subStepTime_.push_back( time * unit::day );
|
||||||
|
}
|
||||||
|
|
||||||
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::
|
double HardcodedTimeStepControl::
|
||||||
computeTimeStepSize( const double /*dt */, const int /*iterations */, const RelativeChangeInterface& /* relativeChange */ , const double simulationTimeElapsed) const
|
computeTimeStepSize( const double /*dt */, const int /*iterations */, const RelativeChangeInterface& /* relativeChange */ , const double simulationTimeElapsed) const
|
||||||
{
|
{
|
||||||
auto nextTime = std::upper_bound(timesteps_.begin(), timesteps_.end(), simulationTimeElapsed);
|
auto nextTime = std::upper_bound(subStepTime_.begin(), subStepTime_.end(), simulationTimeElapsed);
|
||||||
double dtEstimate = (*nextTime - simulationTimeElapsed);
|
return (*nextTime - simulationTimeElapsed);
|
||||||
return dtEstimate;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -121,21 +121,24 @@ namespace Opm
|
|||||||
///
|
///
|
||||||
/// HardcodedTimeStepControl
|
/// HardcodedTimeStepControl
|
||||||
/// Input generated from summary file using the ert application:
|
/// Input generated from summary file using the ert application:
|
||||||
|
///
|
||||||
/// ecl_summary DECK TIME > filename
|
/// ecl_summary DECK TIME > filename
|
||||||
//
|
///
|
||||||
|
/// Assumes time is given in days
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
class HardcodedTimeStepControl : public TimeStepControlInterface
|
class HardcodedTimeStepControl : public TimeStepControlInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// \brief constructor
|
/// \brief constructor
|
||||||
/// \param filename filename contaning the timesteps
|
/// \param filename filename contaning the timesteps
|
||||||
HardcodedTimeStepControl( const std::string filename);
|
explicit HardcodedTimeStepControl( const std::string& filename);
|
||||||
|
|
||||||
/// \brief \copydoc TimeStepControlInterface::computeTimeStepSize
|
/// \brief \copydoc TimeStepControlInterface::computeTimeStepSize
|
||||||
double computeTimeStepSize( const double dt, const int /* iterations */, const RelativeChangeInterface& /*relativeChange */, const double simulationTimeElapsed) const;
|
double computeTimeStepSize( const double dt, const int /* iterations */, const RelativeChangeInterface& /*relativeChange */, const double simulationTimeElapsed) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::vector<double> timesteps_;
|
// store the time (in days) of the substeps the simulator should use
|
||||||
|
std::vector<double> subStepTime_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user