mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
WellState: add serialization support
This commit is contained in:
@@ -21,6 +21,8 @@
|
||||
#ifndef OPM_WELLSTATEFULLYIMPLICITBLACKOIL_HEADER_INCLUDED
|
||||
#define OPM_WELLSTATEFULLYIMPLICITBLACKOIL_HEADER_INCLUDED
|
||||
|
||||
#include <opm/common/ErrorMacros.hpp>
|
||||
|
||||
#include <opm/core/props/BlackoilPhases.hpp>
|
||||
|
||||
#include <opm/simulators/wells/ALQState.hpp>
|
||||
@@ -58,18 +60,19 @@ class WellState
|
||||
{
|
||||
public:
|
||||
static const uint64_t event_mask = ScheduleEvents::WELL_STATUS_CHANGE + ScheduleEvents::PRODUCTION_UPDATE + ScheduleEvents::INJECTION_UPDATE;
|
||||
|
||||
virtual ~WellState() = default;
|
||||
|
||||
// TODO: same definition with WellInterface, eventually they should go to a common header file.
|
||||
static const int Water = BlackoilPhases::Aqua;
|
||||
static const int Oil = BlackoilPhases::Liquid;
|
||||
static const int Gas = BlackoilPhases::Vapour;
|
||||
|
||||
// Only usable for testing purposes
|
||||
explicit WellState(const ParallelWellInfo& pinfo);
|
||||
|
||||
explicit WellState(const PhaseUsage& pu)
|
||||
{
|
||||
this->phase_usage_ = pu;
|
||||
}
|
||||
: phase_usage_(pu)
|
||||
{}
|
||||
|
||||
static WellState serializationTestObject(const ParallelWellInfo& pinfo);
|
||||
|
||||
std::size_t size() const {
|
||||
return this->wells_.size();
|
||||
@@ -275,6 +278,27 @@ public:
|
||||
return this->wells_.has(well_name);
|
||||
}
|
||||
|
||||
bool operator==(const WellState&) const;
|
||||
|
||||
template<class Serializer>
|
||||
void serializeOp(Serializer& serializer)
|
||||
{
|
||||
serializer(alq_state);
|
||||
serializer(well_rates);
|
||||
if (serializer.isSerializing()) {
|
||||
serializer(wells_.size());
|
||||
} else {
|
||||
std::size_t size = 0;
|
||||
serializer(size);
|
||||
if (size != wells_.size()) {
|
||||
OPM_THROW(std::runtime_error, "Error deserializing WellState: size mismatch");
|
||||
}
|
||||
}
|
||||
for (auto& w : wells_) {
|
||||
serializer(w);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
PhaseUsage phase_usage_;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user