mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Merge ecbe713c9b
into 4b688e5945
This commit is contained in:
commit
5b7573cb88
@ -54,6 +54,7 @@ namespace Opm::Parameters {
|
||||
// Do not merge parallel output files or warn about them
|
||||
struct EnableLoggingFalloutWarning { static constexpr bool value = false; };
|
||||
struct OutputInterval { static constexpr int value = 1; };
|
||||
struct EndStep { static constexpr int value = std::numeric_limits<int>::max(); };
|
||||
|
||||
} // namespace Opm::Parameters
|
||||
|
||||
@ -103,6 +104,7 @@ namespace Opm {
|
||||
("Developer option to see whether logging was on non-root processors. "
|
||||
"In that case it will be appended to the *.DBG or *.PRT files");
|
||||
|
||||
Parameters::Register<Parameters::EndStep>("End step for simulation");
|
||||
// register the base parameters
|
||||
registerAllParameters_<TypeTag>(/*finalizeRegistration=*/false);
|
||||
|
||||
@ -421,7 +423,8 @@ namespace Opm {
|
||||
|
||||
// initialize variables
|
||||
const auto& initConfig = eclState().getInitConfig();
|
||||
simtimer_->init(schedule, static_cast<std::size_t>(initConfig.getRestartStep()));
|
||||
int end_step = Parameters::Get<Parameters::EndStep>();
|
||||
simtimer_->init(schedule, static_cast<std::size_t>(initConfig.getRestartStep()), end_step);
|
||||
|
||||
if (this->output_cout_) {
|
||||
std::ostringstream oss;
|
||||
|
@ -29,7 +29,7 @@
|
||||
#include <cstddef>
|
||||
#include <numeric>
|
||||
#include <ostream>
|
||||
|
||||
#include <limits>
|
||||
namespace Opm
|
||||
{
|
||||
|
||||
@ -37,6 +37,7 @@ namespace Opm
|
||||
SimulatorTimer::SimulatorTimer()
|
||||
: current_step_(0),
|
||||
current_time_(0.0),
|
||||
end_step_(std::numeric_limits<int>::max()),
|
||||
start_date_(2012,1,1) // A really arbitrary default starting value?!
|
||||
{
|
||||
}
|
||||
@ -48,33 +49,21 @@ namespace Opm
|
||||
res.current_step_ = 4;
|
||||
res.current_time_ = 5.0;
|
||||
res.total_time_ = 6.0;
|
||||
res.end_step_ = 8;
|
||||
res.start_date_ = boost::gregorian::date(2023,1,31);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/// Initialize from parameters. Accepts the following:
|
||||
/// num_psteps (default 1)
|
||||
/// stepsize_days (default 1)
|
||||
void SimulatorTimer::init(const ParameterGroup& param)
|
||||
{
|
||||
const int num_psteps = param.getDefault("num_psteps", 1);
|
||||
const double stepsize_days = param.getDefault("stepsize_days", 1.0);
|
||||
const double stepsize = Opm::unit::convert::from(stepsize_days, Opm::unit::day);
|
||||
timesteps_.clear();
|
||||
timesteps_.resize(num_psteps, stepsize);
|
||||
total_time_ = num_psteps*stepsize;
|
||||
}
|
||||
|
||||
/// Use the SimulatorTimer as a shim around opm-parser's Opm::TimeMap
|
||||
void SimulatorTimer::init(const Schedule& schedule, std::size_t report_step)
|
||||
void SimulatorTimer::init(const Schedule& schedule, std::size_t report_step, std::size_t end_step)
|
||||
{
|
||||
total_time_ = schedule.seconds( schedule.size() - 1 );
|
||||
timesteps_.resize(schedule.size() - 1);
|
||||
for (std::size_t i = 0; i < schedule.size() - 1; ++i) {
|
||||
timesteps_[i] = schedule.stepLength(i);
|
||||
}
|
||||
|
||||
end_step_ = end_step;
|
||||
setCurrentStepNum(report_step);
|
||||
start_date_ = boost::posix_time::from_time_t(schedule.getStartTime()).date();
|
||||
}
|
||||
@ -167,7 +156,11 @@ namespace Opm
|
||||
/// Return true if op++() has been called numSteps() times.
|
||||
bool SimulatorTimer::done() const
|
||||
{
|
||||
return int(timesteps_.size()) == current_step_;
|
||||
if (current_step_ < end_step_) {
|
||||
return int(timesteps_.size()) == current_step_;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/// return copy of object
|
||||
@ -183,6 +176,7 @@ namespace Opm
|
||||
this->current_step_ == rhs.current_step_ &&
|
||||
this->current_time_ == rhs.current_time_ &&
|
||||
this->total_time_ == rhs.total_time_ &&
|
||||
this->end_step_ == rhs.end_step_ &&
|
||||
this->start_date_ == rhs.start_date_;
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ namespace Opm
|
||||
void init(const ParameterGroup& param);
|
||||
|
||||
/// Use the SimulatorTimer as a shim around opm-commons Schedule class
|
||||
void init(const Schedule& schedule, std::size_t report_step = 0);
|
||||
void init(const Schedule& schedule, std::size_t report_step, int end_step);
|
||||
|
||||
/// Whether the current step is the first step.
|
||||
bool initialStep() const override;
|
||||
@ -127,6 +127,7 @@ namespace Opm
|
||||
serializer(current_step_);
|
||||
serializer(current_time_);
|
||||
serializer(total_time_);
|
||||
serializer(end_step_);
|
||||
serializer(start_date_);
|
||||
}
|
||||
|
||||
@ -137,6 +138,7 @@ namespace Opm
|
||||
int current_step_;
|
||||
double current_time_;
|
||||
double total_time_;
|
||||
int end_step_;
|
||||
boost::gregorian::date start_date_;
|
||||
};
|
||||
|
||||
|
@ -55,7 +55,7 @@ BOOST_AUTO_TEST_CASE(CreateTimer)
|
||||
boost::gregorian::date defaultStartDate( 2012, 1, 1);
|
||||
BOOST_CHECK_EQUAL( boost::posix_time::ptime(defaultStartDate), simtimer.currentDateTime() );
|
||||
|
||||
simtimer.init(schedule);
|
||||
simtimer.init(schedule, 0, std::numeric_limits<int>::max());
|
||||
boost::gregorian::date startDate( 2014, 3, 26);
|
||||
BOOST_CHECK_EQUAL( boost::posix_time::ptime(startDate), simtimer.currentDateTime() );
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user