From 2b930ca51c8d53718f6940098206e98a1a39a24c Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving <arne.morten.kvarving@sintef.no> Date: Fri, 24 Jan 2025 08:23:55 +0100 Subject: [PATCH 1/3] SimulatorSerializer: add LoadFile to ignore list --- opm/simulators/flow/SimulatorSerializer.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/opm/simulators/flow/SimulatorSerializer.cpp b/opm/simulators/flow/SimulatorSerializer.cpp index bb899db1967..5b6c28baedb 100644 --- a/opm/simulators/flow/SimulatorSerializer.cpp +++ b/opm/simulators/flow/SimulatorSerializer.cpp @@ -198,9 +198,10 @@ void SimulatorSerializer::checkSerializedCmdLine(const std::string& current, [](const std::string& line) { return line.compare(0, 11, "EclDeckFile") != 0 && - line.compare(0, 8, "LoadStep") != 0 && line.compare(0, 9, "OutputDir") != 0 && + line.compare(0, 8, "LoadFile") != 0 && line.compare(0, 8, "SaveFile") != 0 && + line.compare(0, 8, "LoadStep") != 0 && line.compare(0, 8, "SaveStep") != 0; }); return output; From da22efb6234a84f913868ace4ef81826cb2aa16d Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving <arne.morten.kvarving@sintef.no> Date: Fri, 24 Jan 2025 14:35:52 +0100 Subject: [PATCH 2/3] BlackoilWellModelGeneric: move operator== to translation unit --- .../wells/BlackoilWellModelGeneric.cpp | 19 +++++++++++++++++++ .../wells/BlackoilWellModelGeneric.hpp | 18 ++---------------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/opm/simulators/wells/BlackoilWellModelGeneric.cpp b/opm/simulators/wells/BlackoilWellModelGeneric.cpp index ec92e97faa1..5324a7aa4f9 100644 --- a/opm/simulators/wells/BlackoilWellModelGeneric.cpp +++ b/opm/simulators/wells/BlackoilWellModelGeneric.cpp @@ -2090,6 +2090,25 @@ reportGroupSwitching(DeferredLogger& local_deferredLogger) const } } +template<class Scalar> +bool BlackoilWellModelGeneric<Scalar>:: +operator==(const BlackoilWellModelGeneric& rhs) const +{ + return this->initial_step_ == rhs.initial_step_ + && this->report_step_starts_ == rhs.report_step_starts_ + && this->last_run_wellpi_ == rhs.last_run_wellpi_ + && this->local_shut_wells_ == rhs.local_shut_wells_ + && this->closed_this_step_ == rhs.closed_this_step_ + && this->node_pressures_ == rhs.node_pressures_ + && this->prev_inj_multipliers_ == rhs.prev_inj_multipliers_ + && this->active_wgstate_ == rhs.active_wgstate_ + && this->last_valid_wgstate_ == rhs.last_valid_wgstate_ + && this->nupcol_wgstate_ == rhs.nupcol_wgstate_ + && this->switched_prod_groups_ == rhs.switched_prod_groups_ + && this->switched_inj_groups_ == rhs.switched_inj_groups_ + && this->closed_offending_wells_ == rhs.closed_offending_wells_; +} + template class BlackoilWellModelGeneric<double>; #if FLOW_INSTANTIATE_FLOAT diff --git a/opm/simulators/wells/BlackoilWellModelGeneric.hpp b/opm/simulators/wells/BlackoilWellModelGeneric.hpp index 1eb7c44371a..e490fcfd74f 100644 --- a/opm/simulators/wells/BlackoilWellModelGeneric.hpp +++ b/opm/simulators/wells/BlackoilWellModelGeneric.hpp @@ -256,24 +256,10 @@ class BlackoilWellModelGeneric serializer(switched_prod_groups_); serializer(switched_inj_groups_); serializer(closed_offending_wells_); + serializer(gen_gaslift_); } - bool operator==(const BlackoilWellModelGeneric& rhs) const - { - return this->initial_step_ == rhs.initial_step_ && - this->report_step_starts_ == rhs.report_step_starts_ && - this->last_run_wellpi_ == rhs.last_run_wellpi_ && - this->local_shut_wells_ == rhs.local_shut_wells_ && - this->closed_this_step_ == rhs.closed_this_step_ && - this->node_pressures_ == rhs.node_pressures_ && - this->prev_inj_multipliers_ == rhs.prev_inj_multipliers_ && - this->active_wgstate_ == rhs.active_wgstate_ && - this->last_valid_wgstate_ == rhs.last_valid_wgstate_ && - this->nupcol_wgstate_ == rhs.nupcol_wgstate_ && - this->switched_prod_groups_ == rhs.switched_prod_groups_ && - this->switched_inj_groups_ == rhs.switched_inj_groups_ && - this->closed_offending_wells_ == rhs.closed_offending_wells_; - } + bool operator==(const BlackoilWellModelGeneric& rhs) const; const ParallelWellInfo<Scalar>& parallelWellInfo(const std::size_t idx) const From b41f5122142a4de3489acfb4d1e6971efb5632c4 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving <arne.morten.kvarving@sintef.no> Date: Fri, 24 Jan 2025 14:37:00 +0100 Subject: [PATCH 3/3] BlackoilWellModelGasLift: serialize last_glift_opt_time --- .../wells/BlackoilWellModelGasLift.hpp | 9 +++++++++ .../wells/BlackoilWellModelGeneric.cpp | 6 +++++- .../wells/BlackoilWellModelGeneric.hpp | 3 +++ .../wells/BlackoilWellModel_impl.hpp | 9 +++++---- tests/test_RestartSerialization.cpp | 18 +++++++++++++++--- 5 files changed, 37 insertions(+), 8 deletions(-) diff --git a/opm/simulators/wells/BlackoilWellModelGasLift.hpp b/opm/simulators/wells/BlackoilWellModelGasLift.hpp index 126e9880cc9..13edca77d3a 100644 --- a/opm/simulators/wells/BlackoilWellModelGasLift.hpp +++ b/opm/simulators/wells/BlackoilWellModelGasLift.hpp @@ -57,6 +57,15 @@ class BlackoilWellModelGasLiftGeneric bool terminalOutput() const { return terminal_output_; } + template<class Serializer> + void serializeOp(Serializer& serializer) + { + serializer(last_glift_opt_time_); + } + + bool operator==(const BlackoilWellModelGasLiftGeneric& that) const + { return this->last_glift_opt_time_ == that.last_glift_opt_time_; } + protected: void gliftDebugShowALQ(const std::vector<WellInterfaceGeneric<Scalar>*>& well_container, const WellState<Scalar>& wellState, diff --git a/opm/simulators/wells/BlackoilWellModelGeneric.cpp b/opm/simulators/wells/BlackoilWellModelGeneric.cpp index 5324a7aa4f9..baaa63328f7 100644 --- a/opm/simulators/wells/BlackoilWellModelGeneric.cpp +++ b/opm/simulators/wells/BlackoilWellModelGeneric.cpp @@ -54,6 +54,7 @@ #include <opm/simulators/utils/DeferredLogger.hpp> #include <opm/simulators/wells/BlackoilWellModelConstraints.hpp> +#include <opm/simulators/wells/BlackoilWellModelGasLift.hpp> #include <opm/simulators/wells/BlackoilWellModelGuideRates.hpp> #include <opm/simulators/wells/BlackoilWellModelRestart.hpp> #include <opm/simulators/wells/GasLiftStage2.hpp> @@ -87,6 +88,7 @@ namespace Opm { template<class Scalar> BlackoilWellModelGeneric<Scalar>:: BlackoilWellModelGeneric(Schedule& schedule, + BlackoilWellModelGasLiftGeneric<Scalar>& gaslift, const SummaryState& summaryState, const EclipseState& eclState, const PhaseUsage& phase_usage, @@ -95,6 +97,7 @@ BlackoilWellModelGeneric(Schedule& schedule, , summaryState_(summaryState) , eclState_(eclState) , comm_(comm) + , gen_gaslift_(gaslift) , wbp_(*this) , phase_usage_(phase_usage) , terminal_output_(comm_.rank() == 0 && @@ -2106,7 +2109,8 @@ operator==(const BlackoilWellModelGeneric& rhs) const && this->nupcol_wgstate_ == rhs.nupcol_wgstate_ && this->switched_prod_groups_ == rhs.switched_prod_groups_ && this->switched_inj_groups_ == rhs.switched_inj_groups_ - && this->closed_offending_wells_ == rhs.closed_offending_wells_; + && this->closed_offending_wells_ == rhs.closed_offending_wells_ + && this->gen_gaslift_ == rhs.gen_gaslift_; } template class BlackoilWellModelGeneric<double>; diff --git a/opm/simulators/wells/BlackoilWellModelGeneric.hpp b/opm/simulators/wells/BlackoilWellModelGeneric.hpp index e490fcfd74f..0d0040851e8 100644 --- a/opm/simulators/wells/BlackoilWellModelGeneric.hpp +++ b/opm/simulators/wells/BlackoilWellModelGeneric.hpp @@ -55,6 +55,7 @@ namespace Opm { class DeferredLogger; class EclipseState; + template<class Scalar> class BlackoilWellModelGasLiftGeneric; template<class Scalar> class GasLiftGroupInfo; template<class Scalar> class GasLiftSingleWellGeneric; template<class Scalar> class GasLiftWellState; @@ -91,6 +92,7 @@ class BlackoilWellModelGeneric { public: BlackoilWellModelGeneric(Schedule& schedule, + BlackoilWellModelGasLiftGeneric<Scalar>& gaslift, const SummaryState& summaryState, const EclipseState& eclState, const PhaseUsage& phase_usage, @@ -458,6 +460,7 @@ class BlackoilWellModelGeneric const SummaryState& summaryState_; const EclipseState& eclState_; const Parallel::Communication& comm_; + BlackoilWellModelGasLiftGeneric<Scalar>& gen_gaslift_; BlackoilWellModelWBP<Scalar> wbp_; PhaseUsage phase_usage_; diff --git a/opm/simulators/wells/BlackoilWellModel_impl.hpp b/opm/simulators/wells/BlackoilWellModel_impl.hpp index 0852c8245c8..2111dc5128f 100644 --- a/opm/simulators/wells/BlackoilWellModel_impl.hpp +++ b/opm/simulators/wells/BlackoilWellModel_impl.hpp @@ -71,10 +71,11 @@ namespace Opm { BlackoilWellModel(Simulator& simulator, const PhaseUsage& phase_usage) : WellConnectionModule(*this, simulator.gridView().comm()) , BlackoilWellModelGeneric<Scalar>(simulator.vanguard().schedule(), - simulator.vanguard().summaryState(), - simulator.vanguard().eclState(), - phase_usage, - simulator.gridView().comm()) + gaslift_, + simulator.vanguard().summaryState(), + simulator.vanguard().eclState(), + phase_usage, + simulator.gridView().comm()) , simulator_(simulator) , gaslift_(this->terminal_output_, this->phase_usage_) { diff --git a/tests/test_RestartSerialization.cpp b/tests/test_RestartSerialization.cpp index 3dd32cad338..f1c48eeadd6 100644 --- a/tests/test_RestartSerialization.cpp +++ b/tests/test_RestartSerialization.cpp @@ -297,12 +297,13 @@ class BlackoilWellModelGenericTest : public BlackoilWellModelGeneric<double> { public: BlackoilWellModelGenericTest(Schedule& schedule, + BlackoilWellModelGasLiftGeneric<double>& gaslift, const SummaryState& summaryState, const EclipseState& eclState, const PhaseUsage& phase_usage, const Parallel::Communication& comm, bool deserialize) - : BlackoilWellModelGeneric<double>(schedule, summaryState, + : BlackoilWellModelGeneric<double>(schedule, gaslift, summaryState, eclState, phase_usage, comm) { if (deserialize) { @@ -366,6 +367,16 @@ class BlackoilWellModelGenericTest : public BlackoilWellModelGeneric<double> ParallelWellInfo<double> dummy; }; +class BlackoilWellModelGasLiftGenericTest : public BlackoilWellModelGasLiftGeneric<double> +{ +public: + BlackoilWellModelGasLiftGenericTest() + : BlackoilWellModelGasLiftGeneric<double>(false) + { + this->last_glift_opt_time_ = 1234.5; + } +}; + } BOOST_AUTO_TEST_CASE(BlackoilWellModelGeneric) @@ -375,14 +386,15 @@ BOOST_AUTO_TEST_CASE(BlackoilWellModelGeneric) Opm::EclipseState eclState{}; Opm::PhaseUsage phase_usage{}; Opm::Parallel::Communication comm{}; - Opm::BlackoilWellModelGenericTest data_out(schedule, summaryState, + Opm::BlackoilWellModelGasLiftGenericTest gaslift; + Opm::BlackoilWellModelGenericTest data_out(schedule, gaslift, summaryState, eclState, phase_usage, comm, false); data_out.setSerializationTestData(); Opm::Serialization::MemPacker packer; Opm::Serializer ser(packer); ser.pack(data_out); const size_t pos1 = ser.position(); - Opm::BlackoilWellModelGenericTest data_in(schedule, summaryState, + Opm::BlackoilWellModelGenericTest data_in(schedule, gaslift, summaryState, eclState, phase_usage, comm, true); ser.unpack(data_in); const size_t pos2 = ser.position();