mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Merge pull request #4437 from akva2/singlewellstate_serialize
SingleWellState: add serialization support
This commit is contained in:
commit
e1942d145f
@ -55,6 +55,12 @@ SingleWellState::SingleWellState(const std::string& name_,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SingleWellState SingleWellState::serializationTestObject(const ParallelWellInfo& pinfo)
|
||||||
|
{
|
||||||
|
SingleWellState result("testing", pinfo, true, 1.0, {}, PhaseUsage{}, 2.0);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
void SingleWellState::init_timestep(const SingleWellState& other) {
|
void SingleWellState::init_timestep(const SingleWellState& other) {
|
||||||
if (this->producer != other.producer)
|
if (this->producer != other.producer)
|
||||||
@ -276,9 +282,27 @@ void SingleWellState::update_targets(const Well& ecl_well, const SummaryState& s
|
|||||||
this->update_injector_targets(ecl_well, st);
|
this->update_injector_targets(ecl_well, st);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SingleWellState::operator==(const SingleWellState& rhs) const
|
||||||
|
{
|
||||||
|
return this->name == rhs.name &&
|
||||||
|
this->status == rhs.status &&
|
||||||
|
this->producer == rhs.producer &&
|
||||||
|
this->bhp == rhs.bhp &&
|
||||||
|
this->thp == rhs.thp &&
|
||||||
|
this->temperature == rhs.temperature &&
|
||||||
|
this->dissolved_gas_rate == rhs.dissolved_gas_rate &&
|
||||||
|
this->dissolved_gas_rate_in_water == rhs.dissolved_gas_rate_in_water &&
|
||||||
|
this->vaporized_oil_rate == rhs.vaporized_oil_rate &&
|
||||||
|
this->vaporized_wat_rate == rhs.vaporized_wat_rate &&
|
||||||
|
this->well_potentials == rhs.well_potentials &&
|
||||||
|
this->productivity_index == rhs.productivity_index &&
|
||||||
|
this->surface_rates == rhs.surface_rates &&
|
||||||
|
this->reservoir_rates == rhs.reservoir_rates &&
|
||||||
|
this->trivial_target == rhs.trivial_target &&
|
||||||
|
this->segments == rhs.segments &&
|
||||||
|
this->events == rhs.events &&
|
||||||
|
this->injection_cmode == rhs.injection_cmode &&
|
||||||
|
this->production_cmode == rhs.production_cmode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -47,6 +47,34 @@ public:
|
|||||||
const PhaseUsage& pu,
|
const PhaseUsage& pu,
|
||||||
double temp);
|
double temp);
|
||||||
|
|
||||||
|
static SingleWellState serializationTestObject(const ParallelWellInfo& pinfo);
|
||||||
|
|
||||||
|
template<class Serializer>
|
||||||
|
void serializeOp(Serializer& serializer)
|
||||||
|
{
|
||||||
|
serializer(name);
|
||||||
|
serializer(status);
|
||||||
|
serializer(producer);
|
||||||
|
serializer(bhp);
|
||||||
|
serializer(thp);
|
||||||
|
serializer(temperature);
|
||||||
|
serializer(dissolved_gas_rate);
|
||||||
|
serializer(dissolved_gas_rate_in_water);
|
||||||
|
serializer(vaporized_oil_rate);
|
||||||
|
serializer(vaporized_wat_rate);
|
||||||
|
serializer(well_potentials);
|
||||||
|
serializer(productivity_index);
|
||||||
|
serializer(surface_rates);
|
||||||
|
serializer(reservoir_rates);
|
||||||
|
serializer(trivial_target);
|
||||||
|
serializer(segments);
|
||||||
|
serializer(events);
|
||||||
|
serializer(injection_cmode);
|
||||||
|
serializer(production_cmode);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator==(const SingleWellState&) const;
|
||||||
|
|
||||||
std::string name;
|
std::string name;
|
||||||
std::reference_wrapper<const ParallelWellInfo> parallel_info;
|
std::reference_wrapper<const ParallelWellInfo> parallel_info;
|
||||||
|
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
#include <opm/simulators/timestepping/TimeStepControl.hpp>
|
#include <opm/simulators/timestepping/TimeStepControl.hpp>
|
||||||
#include <opm/simulators/utils/SerializationPackers.hpp>
|
#include <opm/simulators/utils/SerializationPackers.hpp>
|
||||||
#include <opm/simulators/wells/SegmentState.hpp>
|
#include <opm/simulators/wells/SegmentState.hpp>
|
||||||
|
#include <opm/simulators/wells/SingleWellState.hpp>
|
||||||
|
|
||||||
#define BOOST_TEST_MODULE TestRestartSerialization
|
#define BOOST_TEST_MODULE TestRestartSerialization
|
||||||
#define BOOST_TEST_NO_MAIN
|
#define BOOST_TEST_NO_MAIN
|
||||||
@ -97,6 +98,21 @@ namespace Opm {
|
|||||||
}
|
}
|
||||||
TEST_FOR_TYPE_NAMED(BVec, BlockVectorWrapper)
|
TEST_FOR_TYPE_NAMED(BVec, BlockVectorWrapper)
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(SingleWellState)
|
||||||
|
{
|
||||||
|
Opm::ParallelWellInfo dummy;
|
||||||
|
auto data_out = Opm::SingleWellState::serializationTestObject(dummy);
|
||||||
|
Opm::Serialization::MemPacker packer;
|
||||||
|
Opm::Serializer ser(packer);
|
||||||
|
ser.pack(data_out);
|
||||||
|
const size_t pos1 = ser.position();
|
||||||
|
decltype(data_out) data_in("", dummy, false, 0.0, {}, Opm::PhaseUsage{}, 0.0);
|
||||||
|
ser.unpack(data_in);
|
||||||
|
const size_t pos2 = ser.position();
|
||||||
|
BOOST_CHECK_MESSAGE(pos1 == pos2, "Packed size differ from unpack size for SingleWellState");
|
||||||
|
BOOST_CHECK_MESSAGE(data_out == data_in, "Deserialized SingleWellState differ");
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(EclGenericVanguard)
|
BOOST_AUTO_TEST_CASE(EclGenericVanguard)
|
||||||
{
|
{
|
||||||
auto in_params = Opm::EclGenericVanguard::serializationTestParams();
|
auto in_params = Opm::EclGenericVanguard::serializationTestParams();
|
||||||
|
Loading…
Reference in New Issue
Block a user