From a869641ee4ea2e041d1175f663163793a6a2c6e9 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Fri, 29 Nov 2019 15:58:59 +0100 Subject: [PATCH] add mpi serialization of DynamicState --- opm/simulators/utils/ParallelRestart.cpp | 24 ++++++++++++++++++++++++ opm/simulators/utils/ParallelRestart.hpp | 12 ++++++++++++ 2 files changed, 36 insertions(+) diff --git a/opm/simulators/utils/ParallelRestart.cpp b/opm/simulators/utils/ParallelRestart.cpp index e6151205c..6c12c25e1 100644 --- a/opm/simulators/utils/ParallelRestart.cpp +++ b/opm/simulators/utils/ParallelRestart.cpp @@ -150,6 +150,11 @@ std::size_t packSize(const OrderedMap& data, Dune::MPIHelper::MPIComm return packSize(data.getIndex(), comm) + packSize(data.getStorage(), comm); } +template +std::size_t packSize(const DynamicState& data, Dune::MPIHelper::MPICommunicator comm) +{ + return packSize(data.data(), comm) + packSize(data.initialRange(), comm); +} std::size_t packSize(const char* str, Dune::MPIHelper::MPICommunicator comm) { @@ -460,6 +465,14 @@ void pack(const OrderedMap& data, std::vector& buffer, int& po pack(data.getStorage(), buffer, position, comm); } +template +void pack(const DynamicState& data, std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm) +{ + pack(data.data(), buffer, position, comm); + pack(data.initialRange(), buffer, position, comm); +} + void pack(const char* str, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm) { @@ -804,6 +817,17 @@ void unpack(OrderedMap& data, std::vector& buffer, int& positio data = OrderedMap(index, storage); } +template +void unpack(DynamicState& data, std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm) +{ + std::vector ddata; + size_t initial_range; + unpack(ddata, buffer, position, comm); + unpack(initial_range, buffer, position, comm); + data = DynamicState(ddata, initial_range); +} + void unpack(char* str, std::size_t length, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm) { diff --git a/opm/simulators/utils/ParallelRestart.hpp b/opm/simulators/utils/ParallelRestart.hpp index a95500eaf..8c2478bd1 100644 --- a/opm/simulators/utils/ParallelRestart.hpp +++ b/opm/simulators/utils/ParallelRestart.hpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -103,6 +104,9 @@ std::size_t packSize(const std::unordered_map& data, Dune::MPIHelpe template std::size_t packSize(const OrderedMap& data, Dune::MPIHelper::MPICommunicator comm); +template +std::size_t packSize(const DynamicState& data, Dune::MPIHelper::MPICommunicator comm); + ////// pack routines template @@ -154,6 +158,10 @@ template void pack(const OrderedMap& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); +template +void pack(const DynamicState& data, std::vector& buffer, + int& position, Dune::MPIHelper::MPICommunicator comm); + void pack(const char* str, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); @@ -208,6 +216,10 @@ template void unpack(OrderedMap& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); +template +void unpack(DynamicState& data, std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm); + void unpack(char* str, std::size_t length, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm);