diff --git a/opm/simulators/timestepping/AdaptiveTimeStepping_impl.hpp b/opm/simulators/timestepping/AdaptiveTimeStepping_impl.hpp index 0ac481ac2..33d92d904 100644 --- a/opm/simulators/timestepping/AdaptiveTimeStepping_impl.hpp +++ b/opm/simulators/timestepping/AdaptiveTimeStepping_impl.hpp @@ -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" diff --git a/opm/simulators/timestepping/TimeStepControl.cpp b/opm/simulators/timestepping/TimeStepControl.cpp index 0c01b24e3..91cb478c0 100644 --- a/opm/simulators/timestepping/TimeStepControl.cpp +++ b/opm/simulators/timestepping/TimeStepControl.cpp @@ -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); } diff --git a/opm/simulators/timestepping/TimeStepControl.hpp b/opm/simulators/timestepping/TimeStepControl.hpp index 40f5db6e0..00a82d743 100644 --- a/opm/simulators/timestepping/TimeStepControl.hpp +++ b/opm/simulators/timestepping/TimeStepControl.hpp @@ -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 timesteps_; + // store the time (in days) of the substeps the simulator should use + std::vector subStepTime_; };