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:
parent
6e9bb4cf0b
commit
f1bdd67438
@ -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_( 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) ) )
|
||||
{
|
||||
// valid are "pid" and "pid+iteration"
|
||||
|
@ -84,29 +84,25 @@ namespace Opm
|
||||
////////////////////////////////////////////////////////
|
||||
|
||||
HardcodedTimeStepControl::
|
||||
HardcodedTimeStepControl( const std::string filename)
|
||||
HardcodedTimeStepControl( const std::string& filename)
|
||||
{
|
||||
std::ifstream infile (filename);
|
||||
double time;
|
||||
std::string::size_type sz;
|
||||
std::string line;
|
||||
std::getline(infile, line); //assumes two lines before the timing starts.
|
||||
std::getline(infile, line);
|
||||
while ( 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::
|
||||
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;
|
||||
auto nextTime = std::upper_bound(subStepTime_.begin(), subStepTime_.end(), simulationTimeElapsed);
|
||||
return (*nextTime - simulationTimeElapsed);
|
||||
}
|
||||
|
||||
|
||||
|
@ -121,21 +121,24 @@ namespace Opm
|
||||
///
|
||||
/// HardcodedTimeStepControl
|
||||
/// Input generated from summary file using the ert application:
|
||||
///
|
||||
/// ecl_summary DECK TIME > filename
|
||||
//
|
||||
///
|
||||
/// Assumes time is given in days
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
class HardcodedTimeStepControl : public TimeStepControlInterface
|
||||
{
|
||||
public:
|
||||
/// \brief constructor
|
||||
/// \param filename filename contaning the timesteps
|
||||
HardcodedTimeStepControl( const std::string filename);
|
||||
explicit 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_;
|
||||
// store the time (in days) of the substeps the simulator should use
|
||||
std::vector<double> subStepTime_;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user