mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
add shared_ptr handling in eclmpiserializer
This commit is contained in:
parent
30535b472a
commit
30cac6b648
@ -40,12 +40,16 @@ public:
|
|||||||
template<class T>
|
template<class T>
|
||||||
void operator()(const T& data)
|
void operator()(const T& data)
|
||||||
{
|
{
|
||||||
if (m_op == Operation::PACKSIZE)
|
if constexpr (is_shared_ptr<T>::value) {
|
||||||
m_packSize += Mpi::packSize(data, m_comm);
|
shared_ptr(data);
|
||||||
else if (m_op == Operation::PACK)
|
} else {
|
||||||
Mpi::pack(data, m_buffer, m_position, m_comm);
|
if (m_op == Operation::PACKSIZE)
|
||||||
else if (m_op == Operation::UNPACK)
|
m_packSize += Mpi::packSize(data, m_comm);
|
||||||
Mpi::unpack(const_cast<T&>(data), m_buffer, m_position, m_comm);
|
else if (m_op == Operation::PACK)
|
||||||
|
Mpi::pack(data, m_buffer, m_position, m_comm);
|
||||||
|
else if (m_op == Operation::UNPACK)
|
||||||
|
Mpi::unpack(const_cast<T&>(data), m_buffer, m_position, m_comm);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
@ -56,6 +60,8 @@ public:
|
|||||||
for (auto& it : d) {
|
for (auto& it : d) {
|
||||||
if constexpr (is_pair<T>::value)
|
if constexpr (is_pair<T>::value)
|
||||||
pair(it);
|
pair(it);
|
||||||
|
else if constexpr (is_shared_ptr<T>::value)
|
||||||
|
shared_ptr(it);
|
||||||
else
|
else
|
||||||
it.serializeOp(*this);
|
it.serializeOp(*this);
|
||||||
}
|
}
|
||||||
@ -131,6 +137,16 @@ protected:
|
|||||||
constexpr static bool value = true;
|
constexpr static bool value = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
struct is_shared_ptr {
|
||||||
|
constexpr static bool value = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T1>
|
||||||
|
struct is_shared_ptr<std::shared_ptr<T1>> {
|
||||||
|
constexpr static bool value = true;
|
||||||
|
};
|
||||||
|
|
||||||
template<class T1, class T2>
|
template<class T1, class T2>
|
||||||
void pair(const std::pair<T1,T2>& data)
|
void pair(const std::pair<T1,T2>& data)
|
||||||
{
|
{
|
||||||
@ -145,6 +161,18 @@ protected:
|
|||||||
const_cast<T2&>(data.second).serializeOp(*this);
|
const_cast<T2&>(data.second).serializeOp(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<class T1>
|
||||||
|
void shared_ptr(const std::shared_ptr<T1>& data)
|
||||||
|
{
|
||||||
|
bool value = data ? true : false;
|
||||||
|
(*this)(value);
|
||||||
|
if (m_op == Operation::UNPACK && value) {
|
||||||
|
const_cast<std::shared_ptr<T1>&>(data) = std::make_shared<T1>();
|
||||||
|
}
|
||||||
|
if (data)
|
||||||
|
data->serializeOp(*this);
|
||||||
|
}
|
||||||
|
|
||||||
Dune::CollectiveCommunication<Dune::MPIHelper::MPICommunicator> m_comm;
|
Dune::CollectiveCommunication<Dune::MPIHelper::MPICommunicator> m_comm;
|
||||||
|
|
||||||
Operation m_op = Operation::PACKSIZE;
|
Operation m_op = Operation::PACKSIZE;
|
||||||
|
Loading…
Reference in New Issue
Block a user