From 2df5aaf876c8532837a1565f6d26f25ec87c2820 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Wed, 11 Dec 2019 13:29:06 +0100 Subject: [PATCH] add mpi serialization for IOrderedSet --- opm/simulators/utils/ParallelRestart.cpp | 28 ++++++++++++++++++++++++ opm/simulators/utils/ParallelRestart.hpp | 12 ++++++++++ 2 files changed, 40 insertions(+) diff --git a/opm/simulators/utils/ParallelRestart.cpp b/opm/simulators/utils/ParallelRestart.cpp index 471841bf0..f96626527 100644 --- a/opm/simulators/utils/ParallelRestart.cpp +++ b/opm/simulators/utils/ParallelRestart.cpp @@ -64,6 +64,7 @@ #include #include #include +#include #include #define HANDLE_AS_POD(T) \ @@ -1206,6 +1207,14 @@ std::size_t packSize(const Well& data, return size; } +template +std::size_t packSize(const IOrderSet& data, + Dune::MPIHelper::MPICommunicator comm) +{ + return packSize(data.index(), comm) + + packSize(data.data(), comm); +} + ////// pack routines template @@ -2426,6 +2435,14 @@ void pack(const Well& data, pack(data.getSegments(), buffer, position, comm); } +template +void pack(const IOrderSet& data, std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm) +{ + pack(data.index(), buffer, position, comm); + pack(data.data(), buffer, position, comm); +} + /// unpack routines template @@ -4152,6 +4169,17 @@ void unpack(Well& data, connection, production, injection, segments); } +template +void unpack(IOrderSet& data, std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm) +{ + typename IOrderSet::index_type index; + typename IOrderSet::storage_type storage; + unpack(index, buffer, position, comm); + unpack(storage, buffer, position, comm); + data = IOrderSet(index, storage); +} + #define INSTANTIATE_PACK_VECTOR(T) \ template std::size_t packSize(const std::vector& data, \ Dune::MPIHelper::MPICommunicator comm); \ diff --git a/opm/simulators/utils/ParallelRestart.hpp b/opm/simulators/utils/ParallelRestart.hpp index 8c167bdfa..3bc202fae 100644 --- a/opm/simulators/utils/ParallelRestart.hpp +++ b/opm/simulators/utils/ParallelRestart.hpp @@ -74,6 +74,7 @@ class FoamConfig; class FoamData; class InitConfig; class IOConfig; +template class IOrderSet; class JFunc; class MessageLimits; class MLimits; @@ -246,6 +247,9 @@ std::size_t packSize(const ConstantCompressibilityWaterPvt& data, template std::size_t packSize(const WaterPvtThermal& data, Dune::MPIHelper::MPICommunicator comm); +template +std::size_t packSize(const IOrderSet& data, Dune::MPIHelper::MPICommunicator comm); + ////// pack routines template @@ -389,6 +393,10 @@ template void pack(const WaterPvtThermal& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); +template +void pack(const IOrderSet& data, std::vector& buffer, + int& position, Dune::MPIHelper::MPICommunicator comm); + void pack(const char* str, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); @@ -531,6 +539,10 @@ template void unpack(ConstantCompressibilityWaterPvt& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); +template +void unpack(IOrderSet& 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);