add mpi serialization for Schedule

This commit is contained in:
Arne Morten Kvarving 2019-12-18 12:25:59 +01:00
parent 16ce8af5e9
commit 66949e0a59
3 changed files with 229 additions and 3 deletions

View File

@ -43,6 +43,7 @@
#include <opm/parser/eclipse/EclipseState/Schedule/MSW/Valve.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/OilVaporizationProperties.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/RFTConfig.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/TimeMap.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Tuning.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQASTNode.hpp>
@ -1623,6 +1624,34 @@ std::size_t packSize(const Action::Actions& data,
return packSize(data.getActions(), comm);
}
std::size_t packSize(const Schedule& data,
Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.getTimeMap(), comm) +
packSize(data.getStaticWells(), comm) +
packSize(data.getGroups(), comm) +
packSize(data.getOilVapProps(), comm) +
packSize(data.getEvents(), comm) +
packSize(data.getModifierDeck(), comm) +
packSize(data.getTuning(), comm) +
packSize(data.getMessageLimits(), comm) +
packSize(data.getRunspec(), comm) +
packSize(data.getVFPProdTables(), comm) +
packSize(data.getVFPInjTables(), comm) +
packSize(data.getWellTestConfig(), comm) +
packSize(data.getWListManager(), comm) +
packSize(data.getUDQConfig(), comm) +
packSize(data.getUDQActive(), comm) +
packSize(data.getGuideRateConfig(), comm) +
packSize(data.getGConSale(), comm) +
packSize(data.getGConSump(), comm) +
packSize(data.getGlobalWhistCtlMode(), comm) +
packSize(data.getActions(), comm) +
packSize(data.rftConfig(), comm) +
packSize(data.getNupCol(), comm) +
packSize(data.getWellGroupEvents(), comm);
}
////// pack routines
template<class T>
@ -3274,6 +3303,35 @@ void pack(const Action::Actions& data,
pack(data.getActions(), buffer, position, comm);
}
void pack(const Schedule& data,
std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
pack(data.getTimeMap(), buffer, position, comm);
pack(data.getStaticWells(), buffer, position, comm);
pack(data.getGroups(), buffer, position, comm);
pack(data.getOilVapProps(), buffer, position, comm);
pack(data.getEvents(), buffer, position, comm);
pack(data.getModifierDeck(), buffer, position, comm);
pack(data.getTuning(), buffer, position, comm);
pack(data.getMessageLimits(), buffer, position, comm);
pack(data.getRunspec(), buffer, position, comm);
pack(data.getVFPProdTables(), buffer, position, comm);
pack(data.getVFPInjTables(), buffer, position, comm);
pack(data.getWellTestConfig(), buffer, position, comm);
pack(data.getWListManager(), buffer, position, comm);
pack(data.getUDQConfig(), buffer, position, comm);
pack(data.getUDQActive(), buffer, position, comm);
pack(data.getGuideRateConfig(), buffer, position, comm);
pack(data.getGConSale(), buffer, position, comm);
pack(data.getGConSump(), buffer, position, comm);
pack(data.getGlobalWhistCtlMode(), buffer, position, comm);
pack(data.getActions(), buffer, position, comm);
pack(data.rftConfig(), buffer, position, comm);
pack(data.getNupCol(), buffer, position, comm);
pack(data.getWellGroupEvents(), buffer, position, comm);
}
/// unpack routines
template<class T>
@ -5618,6 +5676,64 @@ void unpack(Action::Actions& data, std::vector<char>& buffer, int& position,
data = Action::Actions(actions);
}
void unpack(Schedule& data, std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
TimeMap timeMap;
Schedule::WellMap staticWells;
Schedule::GroupMap groups;
DynamicState<OilVaporizationProperties> oilVapProps;
Events events;
DynamicVector<Deck> modifierDeck;
Tuning tuning;
MessageLimits messageLimits;
Runspec runspec;
Schedule::VFPProdMap vfpProdTables;
Schedule::VFPInjMap vfpInjTables;
DynamicState<std::shared_ptr<WellTestConfig>> wellTestConfig;
DynamicState<std::shared_ptr<WListManager>> wListManager;
DynamicState<std::shared_ptr<UDQConfig>> udqConfig;
DynamicState<std::shared_ptr<UDQActive>> udqActive;
DynamicState<std::shared_ptr<GuideRateConfig>> guideRateConfig;
DynamicState<std::shared_ptr<GConSale>> gconSale;
DynamicState<std::shared_ptr<GConSump>> gconSump;
DynamicState<Well::ProducerCMode> globalWhistCtlMode;
DynamicState<std::shared_ptr<Action::Actions>> actions;
RFTConfig rftConfig;
DynamicState<int> nupCol;
std::map<std::string,Events> wellGroupEvents;
unpack(timeMap, buffer, position, comm);
unpack(staticWells, buffer, position, comm);
unpack(groups, buffer, position, comm);
unpack(oilVapProps, buffer, position, comm);
unpack(events, buffer, position, comm);
unpack(modifierDeck, buffer, position, comm);
unpack(tuning, buffer, position, comm);
unpack(messageLimits, buffer, position, comm);
unpack(runspec, buffer, position, comm);
unpack(vfpProdTables, buffer, position, comm);
unpack(vfpInjTables, buffer, position, comm);
unpack(wellTestConfig, buffer, position, comm);
unpack(wListManager, buffer, position, comm);
unpack(udqConfig, buffer, position, comm);
unpack(udqActive, buffer, position, comm);
unpack(guideRateConfig, buffer, position, comm);
unpack(gconSale, buffer, position, comm);
unpack(gconSump, buffer, position, comm);
unpack(globalWhistCtlMode, buffer, position, comm);
unpack(actions, buffer, position, comm);
unpack(rftConfig, buffer, position, comm);
unpack(nupCol, buffer, position, comm);
unpack(wellGroupEvents, buffer, position, comm);
data = Schedule(timeMap, staticWells, groups, oilVapProps, events,
modifierDeck, tuning, messageLimits, runspec,
vfpProdTables, vfpInjTables, wellTestConfig,
wListManager, udqConfig, udqActive, guideRateConfig,
gconSale, gconSump, globalWhistCtlMode, actions,
rftConfig, nupCol, wellGroupEvents);
}
#define INSTANTIATE_PACK_VECTOR(T) \
template std::size_t packSize(const std::vector<T>& data, \
Dune::MPIHelper::MPICommunicator comm); \

View File

@ -118,6 +118,7 @@ class RockTable;
class Rock2dTable;
class Rock2dtrTable;
class Runspec;
class Schedule;
class Segment;
class SimulationConfig;
class SimpleTable;
@ -680,13 +681,14 @@ ADD_PACK_PROTOTYPES(RockTable)
ADD_PACK_PROTOTYPES(Rock2dTable)
ADD_PACK_PROTOTYPES(Rock2dtrTable)
ADD_PACK_PROTOTYPES(Runspec)
ADD_PACK_PROTOTYPES(std::string)
ADD_PACK_PROTOTYPES(Schedule)
ADD_PACK_PROTOTYPES(Segment)
ADD_PACK_PROTOTYPES(SimulationConfig)
ADD_PACK_PROTOTYPES(SimpleTable)
ADD_PACK_PROTOTYPES(SkprpolyTable)
ADD_PACK_PROTOTYPES(SkprwatTable)
ADD_PACK_PROTOTYPES(SpiralICD)
ADD_PACK_PROTOTYPES(std::string)
ADD_PACK_PROTOTYPES(Tabdims)
ADD_PACK_PROTOTYPES(TableColumn)
ADD_PACK_PROTOTYPES(TableContainer)

View File

@ -52,6 +52,7 @@
#include <opm/parser/eclipse/EclipseState/Schedule/MSW/Valve.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/OilVaporizationProperties.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/RFTConfig.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/TimeMap.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Tuning.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQActive.hpp>
@ -460,8 +461,6 @@ Opm::Action::ActionX getActionX()
true, false)},
ast, {getCondition()}, 4, 5);
}
#endif
@ -2230,6 +2229,115 @@ BOOST_AUTO_TEST_CASE(Actions)
}
BOOST_AUTO_TEST_CASE(Schedule)
{
#ifdef HAVE_MPI
Opm::UnitSystem unitSystem;
Opm::Schedule::WellMap wells;
wells.insert({"test", {{std::make_shared<Opm::Well>(getFullWell())},1}});
Opm::Schedule::GroupMap groups;
groups.insert({"test", {{std::make_shared<Opm::Group>("test1", 1, 2, 3.0, unitSystem,
Opm::Group::GroupType::PRODUCTION,
4.0, true, 5, "test2",
Opm::IOrderSet<std::string>({"test3", "test4"}, {"test3","test4"}),
Opm::IOrderSet<std::string>({"test5", "test6"}, {"test5","test6"}),
Opm::Group::GroupInjectionProperties(),
Opm::Group::GroupProductionProperties())},1}});
using VapType = Opm::OilVaporizationProperties::OilVaporization;
Opm::DynamicState<Opm::OilVaporizationProperties> oilvap{{Opm::OilVaporizationProperties(VapType::VAPPARS,
{1.0, 2.0}, {3.0, 4.0}, {5.0, 6.0},
{false, true}, {7.0, 8.0})},1};
Opm::Events events(Opm::DynamicVector<uint64_t>({1,2,3,4,5}));
std::unique_ptr<Opm::UnitSystem> unitSys(new Opm::UnitSystem);
Opm::Deck sdeck({Opm::DeckKeyword("test", {"test",1},
{getDeckRecord(), getDeckRecord()}, true, false)},
Opm::UnitSystem(), unitSys.get(),
"test2", "test3", 2);
Opm::DynamicVector<Opm::Deck> modifierDeck({sdeck});
std::vector<Opm::MLimits> limits{Opm::MLimits{1,2,3,4,5,6,7,8,9,10,11,12}};
Opm::MessageLimits messageLimits(Opm::DynamicState<Opm::MLimits>(limits,2));
Opm::Runspec runspec(Opm::Phases(true, true, true, false, true, false, true, false),
Opm::Tabdims(1,2,3,4,5,6),
Opm::EndpointScaling(std::bitset<4>(13)),
Opm::Welldims(1,2,3,4),
Opm::WellSegmentDims(1,2,3),
Opm::UDQParams(true, 1, 2.0, 3.0, 4.0),
Opm::EclHysterConfig(true, 1, 2),
Opm::Actdims(1,2,3,4));
Opm::Schedule::VFPProdMap vfpProd {{1, {{std::make_shared<Opm::VFPProdTable>(getVFPProdTable())},1}}};
Opm::Schedule::VFPInjMap vfpIn{{1, {{std::make_shared<Opm::VFPInjTable>(getVFPInjTable())},1}}};
Opm::WellTestConfig::WTESTWell tw{"test", Opm::WellTestConfig::ECONOMIC,
1.0, 2, 3.0, 4};
Opm::WellTestConfig wtc({tw, tw, tw});
Opm::WList wl({"test1", "test2", "test3"});
std::map<std::string,Opm::WList> data{{"test", wl}, {"test2", wl}};
Opm::WListManager wlm(data);
Opm::UDQActive udqa({Opm::UDQActive::InputRecord(1, "test1", "test2",
Opm::UDAControl::WCONPROD_ORAT)},
{Opm::UDQActive::Record("test1", 1, 2, "test2",
Opm::UDAControl::WCONPROD_ORAT)},
{{"test1", 1}}, {{"test2", 2}});
auto model = std::make_shared<Opm::GuideRateModel>(getGuideRateModel());
Opm::GuideRateConfig grc(model,
{{"test1", getGuideRateConfigWell()}},
{{"test2", getGuideRateConfigGroup()}});
Opm::GConSale::GCONSALEGroup group{Opm::UDAValue(1.0),
Opm::UDAValue(2.0),
Opm::UDAValue(3.0),
Opm::GConSale::MaxProcedure::PLUG,
4.0, Opm::UnitSystem()};
Opm::GConSale gcs({{"test1", group}, {"test2", group}});
Opm::GConSump::GCONSUMPGroup grp{Opm::UDAValue(1.0),
Opm::UDAValue(2.0),
"test",
3.0, Opm::UnitSystem()};
Opm::GConSump gcm({{"test1", grp}, {"test2", grp}});
Opm::Action::Actions acnts({getActionX()});
Opm::RFTConfig rftc(getTimeMap(),
{true, 1},
{"test1", "test2"},
{{"test3", 2}},
{{"test1", {{{Opm::RFTConfig::RFT::TIMESTEP, 3}}, 4}}},
{{"test2", {{{Opm::RFTConfig::PLT::REPT, 5}}, 6}}});
Opm::Schedule val1(getTimeMap(),
wells,
groups,
oilvap,
events,
modifierDeck,
getTuning(),
messageLimits,
runspec,
vfpProd,
vfpIn,
{{std::make_shared<Opm::WellTestConfig>(wtc)}, 1},
{{std::make_shared<Opm::WListManager>(wlm)}, 1},
{{std::make_shared<Opm::UDQConfig>(getUDQConfig())}, 1},
{{std::make_shared<Opm::UDQActive>(udqa)}, 1},
{{std::make_shared<Opm::GuideRateConfig>(grc)}, 1},
{{std::make_shared<Opm::GConSale>(gcs)}, 1},
{{std::make_shared<Opm::GConSump>(gcm)}, 1},
{{Opm::Well::ProducerCMode::CRAT}, 1},
{{std::make_shared<Opm::Action::Actions>(acnts)}, 1},
rftc,
{std::vector<int>{1}, 1},
{{"test", events}});
auto val2 = PackUnpack(val1);
BOOST_CHECK(std::get<1>(val2) == std::get<2>(val2));
BOOST_CHECK(val1 == std::get<0>(val2));
#endif
}
bool init_unit_test_func()
{
return true;