Merge pull request #2661 from joakim-hove/save-correct-report-step
Assign SAVE keyword to previous report step
This commit is contained in:
commit
0da931a7e6
@ -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<double>& 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<int> m_save_step;
|
||||
bool m_save_step{false};
|
||||
|
||||
Tuning m_tuning;
|
||||
Nupcol m_nupcol;
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
@ -49,9 +49,19 @@ std::pair<std::size_t, std::size_t> 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 &&
|
||||
|
@ -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");
|
||||
}
|
||||
|
||||
|
||||
|
@ -144,43 +144,9 @@ BOOST_AUTO_TEST_CASE( NorneRestartConfig ) {
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE( RestartConfig2 ) {
|
||||
std::map<int, boost::gregorian::date> 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<Python>());
|
||||
verifyRestartConfig(schedule, rptConfig);
|
||||
|
||||
const auto keywords0 = schedule.rst_keywords(0);
|
||||
const std::map<std::string, int> expected0 = {
|
||||
|
Loading…
Reference in New Issue
Block a user