From 74aca3fefb1129209e9d65ed6a7190059c1f6df1 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Fri, 6 Dec 2019 23:25:44 +0100 Subject: [PATCH] add mpi serialization for DynamicVector --- opm/simulators/utils/ParallelRestart.cpp | 22 ++++++++++++++++++++++ opm/simulators/utils/ParallelRestart.hpp | 12 ++++++++++++ 2 files changed, 34 insertions(+) diff --git a/opm/simulators/utils/ParallelRestart.cpp b/opm/simulators/utils/ParallelRestart.cpp index e4abf4283..a1fcdacac 100644 --- a/opm/simulators/utils/ParallelRestart.cpp +++ b/opm/simulators/utils/ParallelRestart.cpp @@ -191,6 +191,12 @@ std::size_t packSize(const DynamicState& data, Dune::MPIHelper::MPICommunicat return packSize(data.data(), comm) + packSize(data.initialRange(), comm); } +template +std::size_t packSize(const DynamicVector& data, Dune::MPIHelper::MPICommunicator comm) +{ + return packSize(data.data(), comm); +} + std::size_t packSize(const char* str, Dune::MPIHelper::MPICommunicator comm) { #if HAVE_MPI @@ -1016,6 +1022,13 @@ void pack(const DynamicState& data, std::vector& buffer, int& position, pack(data.initialRange(), buffer, position, comm); } +template +void pack(const DynamicVector& data, std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm) +{ + pack(data.data(), buffer, position, comm); +} + void pack(const char* str, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm) { @@ -1912,6 +1925,15 @@ void unpack(DynamicState& data, std::vector& buffer, int& position, data = DynamicState(ddata, initial_range); } +template +void unpack(DynamicVector& data, std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm) +{ + std::vector ddata; + unpack(ddata, buffer, position, comm); + data = DynamicVector(ddata); +} + 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 d43d8b4e3..9f3d265bf 100644 --- a/opm/simulators/utils/ParallelRestart.hpp +++ b/opm/simulators/utils/ParallelRestart.hpp @@ -40,6 +40,7 @@ #include #include #include +#include #include #include @@ -156,6 +157,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 DynamicVector& data, Dune::MPIHelper::MPICommunicator comm); + template std::size_t packSize(const DynamicState& data, Dune::MPIHelper::MPICommunicator comm); @@ -273,6 +277,10 @@ template void pack(const DynamicState& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); +template +void pack(const DynamicVector& data, std::vector& buffer, + int& position, Dune::MPIHelper::MPICommunicator comm); + template void pack(const Tabulated1DFunction& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); @@ -406,6 +414,10 @@ template void unpack(DynamicState& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); +template +void unpack(DynamicVector& data, std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm); + template void unpack(Tabulated1DFunction& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm);