From f424aba75d441dff47b0b59e006241f0fc1acd09 Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Thu, 7 Jan 2021 08:23:07 +0100 Subject: [PATCH] Internalize nupcol in ScheduleState --- opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp | 3 --- .../eclipse/EclipseState/Schedule/ScheduleState.hpp | 5 +++++ .../eclipse/EclipseState/Schedule/KeywordHandlers.cpp | 2 +- .../parser/eclipse/EclipseState/Schedule/Schedule.cpp | 7 ------- .../eclipse/EclipseState/Schedule/ScheduleState.cpp | 11 ++++++++++- tests/parser/ScheduleTests.cpp | 6 +++--- 6 files changed, 19 insertions(+), 15 deletions(-) diff --git a/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp b/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp index da530e26d..d0218722e 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp +++ b/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp @@ -283,7 +283,6 @@ namespace Opm void applyAction(std::size_t reportStep, const Action::ActionX& action, const Action::Result& result); void applyWellProdIndexScaling(const std::string& well_name, const std::size_t reportStep, const double scalingFactor); - int getNupcol(std::size_t reportStep) const; const Network::ExtNetwork& network(std::size_t report_step) const; @@ -342,7 +341,6 @@ namespace Opm m_network.serializeOp(serializer); m_glo.serializeOp(serializer); rft_config.serializeOp(serializer); - m_nupcol.template serializeOp(serializer); restart_config.serializeOp(serializer); serializer.map(wellgroup_events); if (!serializer.isSerializing()) { @@ -381,7 +379,6 @@ namespace Opm DynamicState> m_network; DynamicState> m_glo; RFTConfig rft_config; - DynamicState m_nupcol; RestartConfig restart_config; UnitSystem unit_system; std::optional exit_status; diff --git a/opm/parser/eclipse/EclipseState/Schedule/ScheduleState.hpp b/opm/parser/eclipse/EclipseState/Schedule/ScheduleState.hpp index 293f5ef6e..e24215015 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/ScheduleState.hpp +++ b/opm/parser/eclipse/EclipseState/Schedule/ScheduleState.hpp @@ -59,6 +59,9 @@ namespace Opm { void tuning(Tuning tuning); const Tuning& tuning() const; + void nupcol(int nupcol); + int nupcol() const; + template void serializeOp(Serializer& serializer) { @@ -66,6 +69,7 @@ namespace Opm { serializer(m_end_time); serializer(m_pavg); m_tuning.serializeOp(serializer); + serializer(m_nupcol); } private: @@ -74,6 +78,7 @@ namespace Opm { std::shared_ptr m_pavg; Tuning m_tuning; + int m_nupcol; }; } diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/KeywordHandlers.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/KeywordHandlers.cpp index 8c3fd6f8e..2f7898592 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/KeywordHandlers.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/KeywordHandlers.cpp @@ -736,7 +736,7 @@ namespace { OpmLog::note(msg); } - this->m_nupcol.update(handlerContext.currentStep, nupcol); + this->snapshots.back().nupcol(nupcol); } void Schedule::handleRPTSCHED(const HandlerContext& handlerContext, const ParseContext&, ErrorGuard&) { diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp index 0515718f1..5c5dae632 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp @@ -128,7 +128,6 @@ namespace { m_network(this->m_timeMap, std::make_shared()), m_glo(this->m_timeMap, std::make_shared()), rft_config(this->m_timeMap), - m_nupcol(this->m_timeMap, runspec.nupcol()), restart_config(m_timeMap, deck, parseContext, errors), unit_system(deck.getActiveUnitSystem()), rpt_config(this->m_timeMap, std::make_shared()) @@ -284,7 +283,6 @@ namespace { result.global_whistctl_mode = {{Well::ProducerCMode::CRAT}, 1}; result.m_actions = {{std::make_shared(Action::Actions::serializeObject())}, 1}; result.rft_config = RFTConfig::serializeObject(); - result.m_nupcol = {{1}, 1}; result.restart_config = RestartConfig::serializeObject(); result.wellgroup_events = {{"test", Events::serializeObject()}}; result.unit_system = UnitSystem::newFIELD(); @@ -1612,10 +1610,6 @@ private: return this->restart_config; } - int Schedule::getNupcol(std::size_t reportStep) const { - return this->m_nupcol.get(reportStep); - } - bool Schedule::operator==(const Schedule& data) const { auto&& comparePtr = [](const auto& t1, const auto& t2) { if ((t1 && !t2) || (!t1 && t2)) @@ -1671,7 +1665,6 @@ private: compareDynState(this->m_actions, data.m_actions) && compareDynState(this->rpt_config, data.rpt_config) && rft_config == data.rft_config && - this->m_nupcol == data.m_nupcol && this->restart_config == data.restart_config && this->unit_system == data.unit_system && this->wellgroup_events == data.wellgroup_events; diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/ScheduleState.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/ScheduleState.cpp index 2c849fc25..cf624165b 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/ScheduleState.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/ScheduleState.cpp @@ -65,17 +65,26 @@ const PAvg& ScheduleState::pavg() const { return *this->m_pavg; } +void ScheduleState::nupcol(int nupcol) { + this->m_nupcol = nupcol; +} + +int ScheduleState::nupcol() const { + return this->m_nupcol; +} bool ScheduleState::operator==(const ScheduleState& other) const { return this->m_start_time == other.m_start_time && this->m_tuning == other.m_tuning && - this->m_end_time == other.m_end_time; + this->m_end_time == other.m_end_time && + this->m_nupcol == other.m_nupcol; } ScheduleState ScheduleState::serializeObject() { auto t1 = std::chrono::system_clock::now(); auto t2 = t1 + std::chrono::hours(48); ScheduleState ts(t1, t2); + ts.nupcol(77); return ts; } diff --git a/tests/parser/ScheduleTests.cpp b/tests/parser/ScheduleTests.cpp index 573d230ca..24385ecdb 100644 --- a/tests/parser/ScheduleTests.cpp +++ b/tests/parser/ScheduleTests.cpp @@ -3447,9 +3447,9 @@ DATES -- 1 const auto& schedule = make_schedule(input); { // Flow uses 12 as default - BOOST_CHECK_EQUAL(schedule.getNupcol(0),20); - BOOST_CHECK_EQUAL(schedule.getNupcol(1),12); - BOOST_CHECK_EQUAL(schedule.getNupcol(2),10); + BOOST_CHECK_EQUAL(schedule[0].nupcol(),20); + BOOST_CHECK_EQUAL(schedule[1].nupcol(),12); + BOOST_CHECK_EQUAL(schedule[2].nupcol(),10); } }