Merge pull request #2668 from joakim-hove/aicd

Aicd
This commit is contained in:
Joakim Hove 2020-06-12 09:12:33 +02:00 committed by GitHub
commit bba5ca48ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -103,22 +103,22 @@ public:
The std::variant<> serialization is a first attempt and *not* particularly
general. In particular that implies:
1. It is hardcoded to hold exactly three alternative types T1, T2 and
1. It is hardcoded to hold exactly four alternative types T0, T1, T2 and
T3.
2. All the three types T1, T2 and T3 must implement the ::serializeOp( )
2. All the four types T0, T1, T2 and T3 must implement the ::serializeOp( )
method. This implies that a variant with a fundamental type like e.g.
std::variant<int, Opm::Well, Opm::Group> will *not* work in the
std::variant<int, double, Opm::Well, Opm::Group> will *not* work in the
current implementation.
*/
template<class T1, class T2, class T3>
void variant(const std::variant<T1,T2,T3>& _data)
template<class T0, class T1, class T2, class T3>
void variant(const std::variant<T0,T1,T2,T3>& _data)
{
auto handle = [&](auto& d) {
d.serializeOp(*this);
};
std::variant<T1,T2,T3>& data = const_cast<std::variant<T1,T2,T3>&>(_data);
std::variant<T0,T1,T2,T3>& data = const_cast<std::variant<T0,T1,T2,T3>&>(_data);
if (m_op == Operation::PACKSIZE) {
m_packSize += Mpi::packSize(data.index(), m_comm);
std::visit( [&] (auto& arg) { handle(arg); }, data);
@ -130,16 +130,19 @@ public:
Mpi::unpack(index, m_buffer, m_position, m_comm);
if (index == 0) {
data = T1();
data = T0();
handle(std::get<0>(data));
} else if (index == 1) {
data = T2();
data = T1();
handle(std::get<1>(data));
} else if (index == 2) {
data = T3();
data = T2();
handle(std::get<2>(data));
} else if (index == 3) {
data = T3();
handle(std::get<3>(data));
} else
std::logic_error("Internal meltdown in std::variant<T1,T2,T3> unpack");
std::logic_error("Internal meltdown in std::variant<T0,T1,T2,T3> unpack");
}
}