diff --git a/opm/parser/eclipse/EclipseState/Schedule/ScheduleState.hpp b/opm/parser/eclipse/EclipseState/Schedule/ScheduleState.hpp index 88c8e4779..803235b6d 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/ScheduleState.hpp +++ b/opm/parser/eclipse/EclipseState/Schedule/ScheduleState.hpp @@ -329,7 +329,8 @@ namespace Opm { bool rst_file(const RSTConfig& rst_config, const time_point& previous_restart_output_time) const; void update_date(const time_point& prev_time); - void handleSAVE(); + void updateSAVE(bool save); + bool save() const; const std::optional& sumthin() const; void update_sumthin(double sumthin); @@ -497,7 +498,7 @@ namespace Opm { std::size_t m_year_num = 0; bool m_first_in_month; bool m_first_in_year; - std::optional m_save_step; + bool m_save_step{false}; Tuning m_tuning; Nupcol m_nupcol; diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/KeywordHandlers.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/KeywordHandlers.cpp index 690df6830..be0dc3074 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/KeywordHandlers.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/KeywordHandlers.cpp @@ -814,10 +814,8 @@ namespace { We do not really handle the SAVE keyword, we just interpret it as: Write a normal restart file at this report step. */ - void Schedule::handleSAVE(const HandlerContext&, const ParseContext&, ErrorGuard&) { - auto rst_config = this->snapshots.back().rst_config(); - rst_config.save = true; - this->snapshots.back().rst_config.update(std::move(rst_config)); + void Schedule::handleSAVE(const HandlerContext& handlerContext, const ParseContext&, ErrorGuard&) { + this->snapshots[handlerContext.currentStep].updateSAVE(true); } diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp index d24b5afb0..93efa91c4 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp @@ -1264,7 +1264,7 @@ void Schedule::iterateScheduleSection(std::size_t load_start, std::size_t load_e bool Schedule::write_rst_file(const std::size_t report_step) const { - return this->restart_output.writeRestartFile(report_step); + return this->restart_output.writeRestartFile(report_step) || this->operator[](report_step).save(); } bool Schedule::must_write_rst_file(const std::size_t report_step) const diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/ScheduleState.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/ScheduleState.cpp index dafa9d034..0c9ef24b1 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/ScheduleState.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/ScheduleState.cpp @@ -49,9 +49,19 @@ std::pair date_diff(const time_point& t2, const time_p return { year_diff, month_diff }; } - } +void ScheduleState::updateSAVE(bool save) { + this->m_save_step = save; +} + +bool ScheduleState::save() const { + return this->m_save_step; +} + + + + ScheduleState::ScheduleState(const time_point& t1): @@ -92,6 +102,7 @@ ScheduleState::ScheduleState(const ScheduleState& src, const time_point& start_t this->m_wellgroup_events.reset(); this->m_geo_keywords.clear(); this->target_wellpi.clear(); + this->m_save_step = false; auto next_rft = this->rft_config().next(); if (next_rft.has_value()) @@ -224,6 +235,7 @@ bool ScheduleState::operator==(const ScheduleState& other) const { this->m_oilvap == other.m_oilvap && this->m_sim_step == other.m_sim_step && this->m_month_num == other.m_month_num && + this->m_save_step == other.m_save_step && this->m_first_in_month == other.m_first_in_month && this->m_first_in_year == other.m_first_in_year && this->m_year_num == other.m_year_num && diff --git a/tests/parser/RestartConfigTests.cpp b/tests/parser/RestartConfigTests.cpp index 43a786961..a36f63537 100644 --- a/tests/parser/RestartConfigTests.cpp +++ b/tests/parser/RestartConfigTests.cpp @@ -1501,8 +1501,11 @@ TSTEP BOOST_CHECK_MESSAGE( !sched.write_rst_file(ts), "Must NOT write restart for report step " << ts); - BOOST_CHECK_MESSAGE( sched.write_rst_file( 12 ), - "Must write restart for report step 12"); + BOOST_CHECK_MESSAGE( sched.write_rst_file(11), + "Must write restart for report step 11"); + + BOOST_CHECK_MESSAGE( !sched.write_rst_file( 12 ), + "Must NOT write restart for report step 12"); }