Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BlackoilWellModelGasLift: serialize last_glift_opt_time #5915

Merged
merged 3 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion opm/simulators/flow/SimulatorSerializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 9 additions & 0 deletions opm/simulators/wells/BlackoilWellModelGasLift.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
23 changes: 23 additions & 0 deletions opm/simulators/wells/BlackoilWellModelGeneric.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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,
Expand All @@ -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 &&
Expand Down Expand Up @@ -2090,6 +2093,26 @@ 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_
&& this->gen_gaslift_ == rhs.gen_gaslift_;
}

template class BlackoilWellModelGeneric<double>;

#if FLOW_INSTANTIATE_FLOAT
Expand Down
21 changes: 5 additions & 16 deletions opm/simulators/wells/BlackoilWellModelGeneric.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -91,6 +92,7 @@ class BlackoilWellModelGeneric
{
public:
BlackoilWellModelGeneric(Schedule& schedule,
BlackoilWellModelGasLiftGeneric<Scalar>& gaslift,
const SummaryState& summaryState,
const EclipseState& eclState,
const PhaseUsage& phase_usage,
Expand Down Expand Up @@ -256,24 +258,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
Expand Down Expand Up @@ -472,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_;
Expand Down
9 changes: 5 additions & 4 deletions opm/simulators/wells/BlackoilWellModel_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_)
{
Expand Down
18 changes: 15 additions & 3 deletions tests/test_RestartSerialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
Expand All @@ -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();
Expand Down