Add member sim_step to ScheduleState

This commit is contained in:
Joakim Hove 2021-03-10 08:01:51 +01:00
parent 69c198271f
commit 34ddba52d7
4 changed files with 28 additions and 1 deletions

View File

@ -271,6 +271,11 @@ namespace Opm {
time_point end_time() const;
ScheduleState next(const time_point& next_start);
// The sim_step() is the report step we are currently simulating on. The
// results when we have completed sim_step=N are stored in report_step
// N+1.
std::size_t sim_step() const;
bool operator==(const ScheduleState& other) const;
static ScheduleState serializeObject();
@ -424,6 +429,7 @@ namespace Opm {
void serializeOp(Serializer& serializer) {
serializer(m_start_time);
serializer(m_end_time);
serializer(m_sim_step);
m_tuning.serializeOp(serializer);
serializer(m_nupcol);
m_oilvap.serializeOp(serializer);
@ -440,6 +446,7 @@ namespace Opm {
time_point m_start_time;
std::optional<time_point> m_end_time;
std::size_t m_sim_step = 0;
Tuning m_tuning;
int m_nupcol;
OilVaporizationProperties m_oilvap;

View File

@ -60,7 +60,7 @@ ScheduleState::ScheduleState(const ScheduleState& src, const time_point& start_t
{
this->m_start_time = clamp_time(start_time);
this->m_end_time = std::nullopt;
this->m_sim_step = src.sim_step() + 1;
this->m_events.reset();
this->m_wellgroup_events.reset();
this->m_geo_keywords.clear();
@ -86,6 +86,10 @@ time_point ScheduleState::end_time() const {
return this->m_end_time.value();
}
std::size_t ScheduleState::sim_step() const {
return this->m_sim_step;
}
void ScheduleState::update_nupcol(int nupcol) {
this->m_nupcol = nupcol;
}
@ -142,6 +146,7 @@ bool ScheduleState::operator==(const ScheduleState& other) const {
return this->m_start_time == other.m_start_time &&
this->m_oilvap == other.m_oilvap &&
this->m_sim_step == other.m_sim_step &&
this->target_wellpi == other.target_wellpi &&
this->m_tuning == other.m_tuning &&
this->m_end_time == other.m_end_time &&
@ -175,6 +180,7 @@ ScheduleState ScheduleState::serializeObject() {
auto t1 = TimeService::now();
auto t2 = t1 + std::chrono::hours(48);
ScheduleState ts(t1, t2);
ts.m_sim_step = 123;
ts.vfpprod = map_member<int, VFPProdTable>::serializeObject();
ts.vfpinj = map_member<int, VFPInjTable>::serializeObject();
ts.groups = map_member<std::string, Group>::serializeObject();

View File

@ -8054,4 +8054,8 @@ VFPPROD
/
TSTEP
1 2 3 4 5 6 /
END

View File

@ -3586,6 +3586,11 @@ BOOST_AUTO_TEST_CASE(SKIPREST_VFP) {
const auto& rst = Opm::RestartIO::RstState::load(rst_file, report_step);
const auto sched = Schedule{ deck, es, python , {}, &rst};
BOOST_CHECK_NO_THROW( sched[3].vfpprod(5) );
for (std::size_t index = 0; index < sched.size(); index++) {
const auto& state = sched[index];
BOOST_CHECK_EQUAL(index, state.sim_step());
}
}
@ -4133,6 +4138,11 @@ BOOST_AUTO_TEST_CASE(VFPPROD_SCALING) {
cmp_vector(wfr, vfp_table.getWFRAxis());
cmp_vector(gfr, vfp_table.getGFRAxis());
cmp_vector(alq, vfp_table.getALQAxis());
for (std::size_t index = 0; index < sched.size(); index++) {
const auto& state = sched[index];
BOOST_CHECK_EQUAL(index, state.sim_step());
}
}