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"); } diff --git a/tests/parser/integration/IOConfigIntegrationTest.cpp b/tests/parser/integration/IOConfigIntegrationTest.cpp index ea7caa3fa..eb344011c 100644 --- a/tests/parser/integration/IOConfigIntegrationTest.cpp +++ b/tests/parser/integration/IOConfigIntegrationTest.cpp @@ -144,43 +144,9 @@ BOOST_AUTO_TEST_CASE( NorneRestartConfig ) { BOOST_AUTO_TEST_CASE( RestartConfig2 ) { - std::map rptConfig{}; - - rptConfig.emplace(std::piecewise_construct, std::forward_as_tuple( 0), std::forward_as_tuple(2000,1, 1)); - rptConfig.emplace(std::piecewise_construct, std::forward_as_tuple( 8), std::forward_as_tuple(2000,7, 1)); - rptConfig.emplace(std::piecewise_construct, std::forward_as_tuple( 27), std::forward_as_tuple(2001,1, 1)); - rptConfig.emplace(std::piecewise_construct, std::forward_as_tuple( 45), std::forward_as_tuple(2001,7, 1)); - rptConfig.emplace(std::piecewise_construct, std::forward_as_tuple( 50), std::forward_as_tuple(2001,8,24)); - rptConfig.emplace(std::piecewise_construct, std::forward_as_tuple( 63), std::forward_as_tuple(2002,2, 1)); - rptConfig.emplace(std::piecewise_construct, std::forward_as_tuple( 83), std::forward_as_tuple(2002,8, 1)); - rptConfig.emplace(std::piecewise_construct, std::forward_as_tuple( 92), std::forward_as_tuple(2003,2, 1)); - rptConfig.emplace(std::piecewise_construct, std::forward_as_tuple(101), std::forward_as_tuple(2003,8, 1)); - rptConfig.emplace(std::piecewise_construct, std::forward_as_tuple(111), std::forward_as_tuple(2004,2, 1)); - rptConfig.emplace(std::piecewise_construct, std::forward_as_tuple(129), std::forward_as_tuple(2004,8, 1)); - rptConfig.emplace(std::piecewise_construct, std::forward_as_tuple(137), std::forward_as_tuple(2005,2, 1)); - rptConfig.emplace(std::piecewise_construct, std::forward_as_tuple(149), std::forward_as_tuple(2005,8, 1)); - rptConfig.emplace(std::piecewise_construct, std::forward_as_tuple(159), std::forward_as_tuple(2006,2, 1)); - rptConfig.emplace(std::piecewise_construct, std::forward_as_tuple(165), std::forward_as_tuple(2006,8, 1)); - rptConfig.emplace(std::piecewise_construct, std::forward_as_tuple(173), std::forward_as_tuple(2007,2, 1)); - rptConfig.emplace(std::piecewise_construct, std::forward_as_tuple(179), std::forward_as_tuple(2007,8, 1)); - rptConfig.emplace(std::piecewise_construct, std::forward_as_tuple(185), std::forward_as_tuple(2008,2, 1)); - rptConfig.emplace(std::piecewise_construct, std::forward_as_tuple(193), std::forward_as_tuple(2008,8, 1)); - rptConfig.emplace(std::piecewise_construct, std::forward_as_tuple(199), std::forward_as_tuple(2009,2, 1)); - rptConfig.emplace(std::piecewise_construct, std::forward_as_tuple(205), std::forward_as_tuple(2009,8, 1)); - rptConfig.emplace(std::piecewise_construct, std::forward_as_tuple(211), std::forward_as_tuple(2010,2, 1)); - rptConfig.emplace(std::piecewise_construct, std::forward_as_tuple(217), std::forward_as_tuple(2010,8, 1)); - rptConfig.emplace(std::piecewise_construct, std::forward_as_tuple(223), std::forward_as_tuple(2011,2, 1)); - rptConfig.emplace(std::piecewise_construct, std::forward_as_tuple(229), std::forward_as_tuple(2011,8, 1)); - rptConfig.emplace(std::piecewise_construct, std::forward_as_tuple(235), std::forward_as_tuple(2012,2, 1)); - rptConfig.emplace(std::piecewise_construct, std::forward_as_tuple(241), std::forward_as_tuple(2012,8, 1)); - rptConfig.emplace(std::piecewise_construct, std::forward_as_tuple(247), std::forward_as_tuple(2013,2, 1)); - rptConfig.emplace(std::piecewise_construct, std::forward_as_tuple(251), std::forward_as_tuple(2013,5, 2)); - - const auto deck = Parser{}.parseFile(path_prefix() + "IOConfig/RPT_TEST2.DATA"); const EclipseState state( deck); const Schedule schedule(deck, state, std::make_shared()); - verifyRestartConfig(schedule, rptConfig); const auto keywords0 = schedule.rst_keywords(0); const std::map expected0 = {