mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
added: handler for vectors in eclmpiserializer
this shall be used by users when they have a vector of types with a serializeOp template. it cannot (at least not right now) be part of the regular operator() as some vectors should go directly to the underlying serializer (trivial types). we can possibly find some traits magic for this later.
This commit is contained in:
@@ -48,6 +48,31 @@ public:
|
||||
Mpi::unpack(const_cast<T&>(data), m_buffer, m_position, m_comm);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void vector(std::vector<T>& data)
|
||||
{
|
||||
static_assert(!std::is_pod<T>::value, "Do not call this for POD vectors");
|
||||
auto handle = [&](auto& d)
|
||||
{
|
||||
for (auto& it : d) {
|
||||
it.serializeOp(*this);
|
||||
}
|
||||
};
|
||||
|
||||
if (m_op == Operation::PACKSIZE) {
|
||||
m_packSize += Mpi::packSize(data.size(), m_comm);
|
||||
handle(data);
|
||||
} else if (m_op == Operation::PACK) {
|
||||
Mpi::pack(data.size(), m_buffer, m_position, m_comm);
|
||||
handle(data);
|
||||
} else if (m_op == Operation::UNPACK) {
|
||||
size_t size;
|
||||
Mpi::unpack(size, m_buffer, m_position, m_comm);
|
||||
data.resize(size);
|
||||
handle(data);
|
||||
}
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void pack(T& data)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user