mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Serialize std::chrono::system_clock::time_point through std::time_t
This commit is contained in:
parent
c037bd762d
commit
fff19a2cf3
@ -22,6 +22,7 @@
|
||||
#endif
|
||||
|
||||
#include "ParallelRestart.hpp"
|
||||
#include <ctime>
|
||||
#include <dune/common/parallel/mpitraits.hh>
|
||||
|
||||
#define HANDLE_AS_POD(T) \
|
||||
@ -282,6 +283,13 @@ std::size_t packSize(const RestartValue& data, Dune::MPIHelper::MPICommunicator
|
||||
+ packSize(data.extra, comm);
|
||||
}
|
||||
|
||||
std::size_t packSize(const std::chrono::system_clock::time_point&, Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
std::time_t tp;
|
||||
return packSize(tp, comm);
|
||||
}
|
||||
|
||||
|
||||
////// pack routines
|
||||
|
||||
template<class T>
|
||||
@ -568,6 +576,13 @@ void pack(const RestartValue& data, std::vector<char>& buffer, int& position,
|
||||
pack(data.extra, buffer, position, comm);
|
||||
}
|
||||
|
||||
void pack(const std::chrono::system_clock::time_point& data, std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
pack(std::chrono::system_clock::to_time_t(data), buffer, position, comm);
|
||||
}
|
||||
|
||||
|
||||
/// unpack routines
|
||||
|
||||
template<class T>
|
||||
@ -872,6 +887,15 @@ void unpack(RestartValue& data, std::vector<char>& buffer, int& position,
|
||||
unpack(data.extra, buffer, position, comm);
|
||||
}
|
||||
|
||||
void unpack(std::chrono::system_clock::time_point& data, std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
std::time_t tp;
|
||||
unpack(tp, buffer, position, comm);
|
||||
data = std::chrono::system_clock::from_time_t(tp);
|
||||
}
|
||||
|
||||
|
||||
#define INSTANTIATE_PACK_VECTOR(...) \
|
||||
template std::size_t packSize(const std::vector<__VA_ARGS__>& data, \
|
||||
Dune::MPIHelper::MPICommunicator comm); \
|
||||
|
@ -30,6 +30,7 @@
|
||||
|
||||
#include <dune/common/parallel/mpihelper.hh>
|
||||
|
||||
#include <chrono>
|
||||
#include <optional>
|
||||
#include <map>
|
||||
#include <set>
|
||||
@ -317,6 +318,7 @@ ADD_PACK_PROTOTYPES(data::WellRates)
|
||||
ADD_PACK_PROTOTYPES(RestartKey)
|
||||
ADD_PACK_PROTOTYPES(RestartValue)
|
||||
ADD_PACK_PROTOTYPES(std::string)
|
||||
ADD_PACK_PROTOTYPES(std::chrono::system_clock::time_point)
|
||||
|
||||
} // end namespace Mpi
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user