GroupState: add serialization support

This commit is contained in:
Arne Morten Kvarving 2023-02-02 11:52:08 +01:00
parent 1a5ae624b1
commit b87bf2b3ae
3 changed files with 43 additions and 1 deletions

View File

@ -33,6 +33,25 @@ GroupState::GroupState(std::size_t np) :
num_phases(np)
{}
GroupState GroupState::serializationTestObject()
{
GroupState result(3);
result.m_production_rates = {{"test1", {1.0, 2.0}}};
result.production_controls = {{"test2", Group::ProductionCMode::LRAT}};
result.prod_red_rates = {{"test3", {3.0, 4.0, 5.0}}};
result.inj_red_rates = {{"test4", {6.0, 7.0}}};
result.inj_surface_rates = {{"test5", {8.0}}};
result.inj_resv_rates = {{"test6", {9.0, 10.0}}};
result.inj_rein_rates = {{"test7", {11.0}}};
result.inj_vrep_rate = {{"test8", 12.0}, {"test9", 13.0}};
result.m_grat_sales_target = {{"test10", 14.0}};
result.m_gpmaint_target = {{"test11", 15.0}};
result.injection_controls = {{{Phase::FOAM, "test12"}, Group::InjectionCMode::REIN}};
result.gpmaint_state.add("foo", GPMaint::State::serializationTestObject());
return result;
}
bool GroupState::operator==(const GroupState& other) const {
return this->m_production_rates == other.m_production_rates &&
this->production_controls == other.production_controls &&

View File

@ -33,7 +33,11 @@ namespace Opm {
class GroupState {
public:
GroupState() = default;
explicit GroupState(std::size_t num_phases);
static GroupState serializationTestObject();
bool operator==(const GroupState& other) const;
bool has_production_rates(const std::string& gname) const;
@ -159,9 +163,26 @@ public:
throw std::logic_error("Internal size mismatch when distributing groupData");
}
template<class Serializer>
void serializeOp(Serializer& serializer)
{
serializer(num_phases);
serializer(m_production_rates);
serializer(production_controls);
serializer(prod_red_rates);
serializer(inj_red_rates);
serializer(inj_surface_rates);
serializer(inj_resv_rates);
serializer(inj_rein_rates);
serializer(inj_vrep_rate);
serializer(m_grat_sales_target);
serializer(m_gpmaint_target);
serializer(injection_controls);
serializer(gpmaint_state);
}
private:
std::size_t num_phases;
std::size_t num_phases{};
std::map<std::string, std::vector<double>> m_production_rates;
std::map<std::string, Group::ProductionCMode> production_controls;
std::map<std::string, std::vector<double>> prod_red_rates;

View File

@ -36,6 +36,7 @@
#include <opm/simulators/timestepping/SimulatorTimer.hpp>
#include <opm/simulators/timestepping/TimeStepControl.hpp>
#include <opm/simulators/utils/SerializationPackers.hpp>
#include <opm/simulators/wells/GroupState.hpp>
#include <opm/simulators/wells/SegmentState.hpp>
#include <opm/simulators/wells/SingleWellState.hpp>
@ -76,6 +77,7 @@ BOOST_AUTO_TEST_CASE(NAME) \
#define TEST_FOR_TYPE(TYPE) \
TEST_FOR_TYPE_NAMED(TYPE, TYPE)
TEST_FOR_TYPE(GroupState)
TEST_FOR_TYPE(HardcodedTimeStepControl)
TEST_FOR_TYPE(PIDAndIterationCountTimeStepControl)
TEST_FOR_TYPE(PIDTimeStepControl)