add mpi serialization of DynamicState

This commit is contained in:
Arne Morten Kvarving 2019-11-29 15:58:59 +01:00
parent 3e93b3e043
commit a869641ee4
2 changed files with 36 additions and 0 deletions

View File

@ -150,6 +150,11 @@ std::size_t packSize(const OrderedMap<Key,Value>& data, Dune::MPIHelper::MPIComm
return packSize(data.getIndex(), comm) + packSize(data.getStorage(), comm); return packSize(data.getIndex(), comm) + packSize(data.getStorage(), comm);
} }
template<class T>
std::size_t packSize(const DynamicState<T>& 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) std::size_t packSize(const char* str, Dune::MPIHelper::MPICommunicator comm)
{ {
@ -460,6 +465,14 @@ void pack(const OrderedMap<Key, Value>& data, std::vector<char>& buffer, int& po
pack(data.getStorage(), buffer, position, comm); pack(data.getStorage(), buffer, position, comm);
} }
template<class T>
void pack(const DynamicState<T>& data, std::vector<char>& 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<char>& buffer, int& position, void pack(const char* str, std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm) Dune::MPIHelper::MPICommunicator comm)
{ {
@ -804,6 +817,17 @@ void unpack(OrderedMap<Key,Value>& data, std::vector<char>& buffer, int& positio
data = OrderedMap<Key,Value>(index, storage); data = OrderedMap<Key,Value>(index, storage);
} }
template<class T>
void unpack(DynamicState<T>& data, std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
std::vector<T> ddata;
size_t initial_range;
unpack(ddata, buffer, position, comm);
unpack(initial_range, buffer, position, comm);
data = DynamicState<T>(ddata, initial_range);
}
void unpack(char* str, std::size_t length, std::vector<char>& buffer, int& position, void unpack(char* str, std::size_t length, std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm) Dune::MPIHelper::MPICommunicator comm)
{ {

View File

@ -26,6 +26,7 @@
#include <opm/output/eclipse/RestartValue.hpp> #include <opm/output/eclipse/RestartValue.hpp>
#include <opm/output/eclipse/EclipseIO.hpp> #include <opm/output/eclipse/EclipseIO.hpp>
#include <opm/output/eclipse/Summary.hpp> #include <opm/output/eclipse/Summary.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/DynamicState.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/TimeMap.hpp> #include <opm/parser/eclipse/EclipseState/Schedule/TimeMap.hpp>
#include <opm/parser/eclipse/EclipseState/Util/OrderedMap.hpp> #include <opm/parser/eclipse/EclipseState/Util/OrderedMap.hpp>
@ -103,6 +104,9 @@ std::size_t packSize(const std::unordered_map<T1,T2,H,P,A>& data, Dune::MPIHelpe
template<class Key, class Value> template<class Key, class Value>
std::size_t packSize(const OrderedMap<Key,Value>& data, Dune::MPIHelper::MPICommunicator comm); std::size_t packSize(const OrderedMap<Key,Value>& data, Dune::MPIHelper::MPICommunicator comm);
template<class T>
std::size_t packSize(const DynamicState<T>& data, Dune::MPIHelper::MPICommunicator comm);
////// pack routines ////// pack routines
template<class T> template<class T>
@ -154,6 +158,10 @@ template<class Key, class Value>
void pack(const OrderedMap<Key,Value>& data, std::vector<char>& buffer, void pack(const OrderedMap<Key,Value>& data, std::vector<char>& buffer,
int& position, Dune::MPIHelper::MPICommunicator comm); int& position, Dune::MPIHelper::MPICommunicator comm);
template<class T>
void pack(const DynamicState<T>& data, std::vector<char>& buffer,
int& position, Dune::MPIHelper::MPICommunicator comm);
void pack(const char* str, std::vector<char>& buffer, int& position, void pack(const char* str, std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm); Dune::MPIHelper::MPICommunicator comm);
@ -208,6 +216,10 @@ template<class Key, class Value>
void unpack(OrderedMap<Key,Value>& data, std::vector<char>& buffer, int& position, void unpack(OrderedMap<Key,Value>& data, std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm); Dune::MPIHelper::MPICommunicator comm);
template<class T>
void unpack(DynamicState<T>& data, std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm);
void unpack(char* str, std::size_t length, std::vector<char>& buffer, int& position, void unpack(char* str, std::size_t length, std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm); Dune::MPIHelper::MPICommunicator comm);