mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
add mpi serialization for RestartConfig
This commit is contained in:
@@ -357,6 +357,16 @@ std::size_t packSize(const TimeMap& data, Dune::MPIHelper::MPICommunicator comm)
|
|||||||
packSize(data.firstTimeStepYears(), comm);
|
packSize(data.firstTimeStepYears(), comm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::size_t packSize(const RestartConfig& data, Dune::MPIHelper::MPICommunicator comm)
|
||||||
|
{
|
||||||
|
return packSize(data.timeMap(), comm) +
|
||||||
|
packSize(data.getFirstRestartStep(), comm) +
|
||||||
|
packSize(data.writeInitialRst(), comm) +
|
||||||
|
packSize(data.restartSchedule(), comm) +
|
||||||
|
packSize(data.restartKeywords(), comm) +
|
||||||
|
packSize(data.saveKeywords(), comm);
|
||||||
|
}
|
||||||
|
|
||||||
////// pack routines
|
////// pack routines
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
@@ -703,6 +713,17 @@ void pack(const TimeMap& data, std::vector<char>& buffer, int& position,
|
|||||||
pack(data.firstTimeStepYears(), buffer, position, comm);
|
pack(data.firstTimeStepYears(), buffer, position, comm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void pack(const RestartConfig& data, std::vector<char>& buffer, int& position,
|
||||||
|
Dune::MPIHelper::MPICommunicator comm)
|
||||||
|
{
|
||||||
|
pack(data.timeMap(), buffer, position, comm);
|
||||||
|
pack(data.getFirstRestartStep(), buffer, position, comm);
|
||||||
|
pack(data.writeInitialRst(), buffer, position, comm);
|
||||||
|
pack(data.restartSchedule(), buffer, position, comm);
|
||||||
|
pack(data.restartKeywords(), buffer, position, comm);
|
||||||
|
pack(data.saveKeywords(), buffer, position, comm);
|
||||||
|
}
|
||||||
|
|
||||||
/// unpack routines
|
/// unpack routines
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
@@ -1117,6 +1138,25 @@ void unpack(TimeMap& data, std::vector<char>& buffer, int& position,
|
|||||||
data = TimeMap(timeList, firstStepMonths, firstStepYears);
|
data = TimeMap(timeList, firstStepMonths, firstStepYears);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void unpack(RestartConfig& data, std::vector<char>& buffer, int& position,
|
||||||
|
Dune::MPIHelper::MPICommunicator comm)
|
||||||
|
{
|
||||||
|
TimeMap timemap;
|
||||||
|
int firstRstStep;
|
||||||
|
bool writeInitialRst;
|
||||||
|
DynamicState<RestartSchedule> restart_sched;
|
||||||
|
DynamicState<std::map<std::string,int>> restart_keyw;
|
||||||
|
std::vector<bool> save_keyw;
|
||||||
|
unpack(timemap, buffer, position, comm);
|
||||||
|
unpack(firstRstStep, buffer, position, comm);
|
||||||
|
unpack(writeInitialRst, buffer, position, comm);
|
||||||
|
unpack(restart_sched, buffer, position, comm);
|
||||||
|
unpack(restart_keyw, buffer, position, comm);
|
||||||
|
unpack(save_keyw, buffer, position, comm);
|
||||||
|
data = RestartConfig(timemap, firstRstStep, writeInitialRst, restart_sched,
|
||||||
|
restart_keyw, save_keyw);
|
||||||
|
}
|
||||||
|
|
||||||
} // end namespace Mpi
|
} // end namespace Mpi
|
||||||
RestartValue loadParallelRestart(const EclipseIO* eclIO, SummaryState& summaryState,
|
RestartValue loadParallelRestart(const EclipseIO* eclIO, SummaryState& summaryState,
|
||||||
const std::vector<Opm::RestartKey>& solutionKeys,
|
const std::vector<Opm::RestartKey>& solutionKeys,
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ class FoamData;
|
|||||||
class InitConfig;
|
class InitConfig;
|
||||||
class NNC;
|
class NNC;
|
||||||
struct NNCdata;
|
struct NNCdata;
|
||||||
|
class RestartConfig;
|
||||||
class RestartSchedule;
|
class RestartSchedule;
|
||||||
class Rock2dTable;
|
class Rock2dTable;
|
||||||
class Rock2dtrTable;
|
class Rock2dtrTable;
|
||||||
@@ -248,6 +249,7 @@ ADD_PACK_PROTOTYPES(FoamData)
|
|||||||
ADD_PACK_PROTOTYPES(InitConfig)
|
ADD_PACK_PROTOTYPES(InitConfig)
|
||||||
ADD_PACK_PROTOTYPES(NNC)
|
ADD_PACK_PROTOTYPES(NNC)
|
||||||
ADD_PACK_PROTOTYPES(NNCdata)
|
ADD_PACK_PROTOTYPES(NNCdata)
|
||||||
|
ADD_PACK_PROTOTYPES(RestartConfig)
|
||||||
ADD_PACK_PROTOTYPES(RestartKey)
|
ADD_PACK_PROTOTYPES(RestartKey)
|
||||||
ADD_PACK_PROTOTYPES(RestartSchedule)
|
ADD_PACK_PROTOTYPES(RestartSchedule)
|
||||||
ADD_PACK_PROTOTYPES(RestartValue)
|
ADD_PACK_PROTOTYPES(RestartValue)
|
||||||
|
|||||||
@@ -521,6 +521,19 @@ BOOST_AUTO_TEST_CASE(TimeMap)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(RestartConfig)
|
||||||
|
{
|
||||||
|
#if HAVE_MPI
|
||||||
|
Opm::DynamicState<Opm::RestartSchedule> rsched({Opm::RestartSchedule(1, 2, 3)}, 2);
|
||||||
|
Opm::DynamicState<std::map<std::string,int>> rkw({{{"test",3}}}, 3);
|
||||||
|
Opm::RestartConfig val1(getTimeMap(), 1, true, rsched, rkw, {false, true});
|
||||||
|
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()
|
bool init_unit_test_func()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user