mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
add mpi serialization for Action::Condition
This commit is contained in:
parent
a0c2d5b0f6
commit
92811754a8
@ -1591,6 +1591,16 @@ std::size_t packSize(const Action::Quantity& data,
|
||||
packSize(data.args, comm);
|
||||
}
|
||||
|
||||
std::size_t packSize(const Action::Condition& data,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
return packSize(data.lhs, comm) +
|
||||
packSize(data.rhs, comm) +
|
||||
packSize(data.logic, comm) +
|
||||
packSize(data.cmp, comm) +
|
||||
packSize(data.cmp_string, comm);
|
||||
}
|
||||
|
||||
////// pack routines
|
||||
|
||||
template<class T>
|
||||
@ -3209,6 +3219,17 @@ void pack(const Action::Quantity& data,
|
||||
pack(data.args, buffer, position, comm);
|
||||
}
|
||||
|
||||
void pack(const Action::Condition& data,
|
||||
std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
pack(data.lhs, buffer, position, comm);
|
||||
pack(data.rhs, buffer, position, comm);
|
||||
pack(data.logic, buffer, position, comm);
|
||||
pack(data.cmp, buffer, position, comm);
|
||||
pack(data.cmp_string, buffer, position, comm);
|
||||
}
|
||||
|
||||
/// unpack routines
|
||||
|
||||
template<class T>
|
||||
@ -5509,6 +5530,16 @@ void unpack(Action::Quantity& data, std::vector<char>& buffer, int& position,
|
||||
unpack(data.args, buffer, position, comm);
|
||||
}
|
||||
|
||||
void unpack(Action::Condition& data, std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
unpack(data.lhs, buffer, position, comm);
|
||||
unpack(data.rhs, buffer, position, comm);
|
||||
unpack(data.logic, buffer, position, comm);
|
||||
unpack(data.cmp, buffer, position, comm);
|
||||
unpack(data.cmp_string, buffer, position, comm);
|
||||
}
|
||||
|
||||
#define INSTANTIATE_PACK_VECTOR(T) \
|
||||
template std::size_t packSize(const std::vector<T>& data, \
|
||||
Dune::MPIHelper::MPICommunicator comm); \
|
||||
|
@ -67,6 +67,7 @@ class Actdims;
|
||||
namespace Action {
|
||||
class AST;
|
||||
class ASTNode;
|
||||
class Condition;
|
||||
class Quantity;
|
||||
}
|
||||
|
||||
@ -607,6 +608,7 @@ void unpack(char* str, std::size_t length, std::vector<char>& buffer, int& posit
|
||||
ADD_PACK_PROTOTYPES(Actdims)
|
||||
ADD_PACK_PROTOTYPES(Action::AST)
|
||||
ADD_PACK_PROTOTYPES(Action::ASTNode)
|
||||
ADD_PACK_PROTOTYPES(Action::Condition)
|
||||
ADD_PACK_PROTOTYPES(Action::Quantity)
|
||||
ADD_PACK_PROTOTYPES(Aqudims)
|
||||
ADD_PACK_PROTOTYPES(ColumnSchema)
|
||||
|
@ -430,6 +430,20 @@ Opm::Tuning getTuning()
|
||||
Opm::DynamicState<int>(std::vector<int>{10}, 1), //XXDPR_has_value
|
||||
std::map<std::string,bool>{{"test", false}}); // resetValue
|
||||
}
|
||||
|
||||
|
||||
Opm::Action::Condition getCondition()
|
||||
{
|
||||
Opm::Action::Quantity q;
|
||||
q.quantity = "test1";
|
||||
q.args = {"test2", "test3"};
|
||||
Opm::Action::Condition val1;
|
||||
val1.lhs = val1.rhs = q;
|
||||
val1.logic = Opm::Action::Condition::Logical::OR;
|
||||
val1.cmp = Opm::Action::Condition::Comparator::LESS;
|
||||
val1.cmp_string = "test";
|
||||
return val1;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@ -2165,6 +2179,16 @@ BOOST_AUTO_TEST_CASE(Quantity)
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(Condition)
|
||||
{
|
||||
#ifdef HAVE_MPI
|
||||
Opm::Action::Condition val1 = getCondition();
|
||||
auto val2 = PackUnpack(val1);
|
||||
BOOST_CHECK(std::get<1>(val2) == std::get<2>(val2));
|
||||
BOOST_CHECK(val1 == std::get<0>(val2));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
bool init_unit_test_func()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user