mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
add mpi serialization for Action::ActionX
This commit is contained in:
parent
92811754a8
commit
9fb68ef289
@ -32,6 +32,7 @@
|
||||
#include <opm/parser/eclipse/EclipseState/IOConfig/RestartConfig.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Edit/EDITNNC.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Action/ActionAST.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Action/ActionX.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Action/ASTNode.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Action/Condition.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Events.hpp>
|
||||
@ -1601,6 +1602,20 @@ std::size_t packSize(const Action::Condition& data,
|
||||
packSize(data.cmp_string, comm);
|
||||
}
|
||||
|
||||
std::size_t packSize(const Action::ActionX& data,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
return packSize(data.name(), comm) +
|
||||
packSize(data.max_run(), comm) +
|
||||
packSize(data.min_wait(), comm) +
|
||||
packSize(data.start_time(), comm) +
|
||||
packSize(data.getKeywords(), comm) +
|
||||
packSize(data.getCondition(), comm) +
|
||||
packSize(data.conditions(), comm) +
|
||||
packSize(data.getRunCount(), comm) +
|
||||
packSize(data.getLastRun(), comm);
|
||||
}
|
||||
|
||||
////// pack routines
|
||||
|
||||
template<class T>
|
||||
@ -3230,6 +3245,21 @@ void pack(const Action::Condition& data,
|
||||
pack(data.cmp_string, buffer, position, comm);
|
||||
}
|
||||
|
||||
void pack(const Action::ActionX& data,
|
||||
std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
pack(data.name(), buffer, position, comm);
|
||||
pack(data.max_run(), buffer, position, comm);
|
||||
pack(data.min_wait(), buffer, position, comm);
|
||||
pack(data.start_time(), buffer, position, comm);
|
||||
pack(data.getKeywords(), buffer, position, comm);
|
||||
pack(data.getCondition(), buffer, position, comm);
|
||||
pack(data.conditions(), buffer, position, comm);
|
||||
pack(data.getRunCount(), buffer, position, comm);
|
||||
pack(data.getLastRun(), buffer, position, comm);
|
||||
}
|
||||
|
||||
/// unpack routines
|
||||
|
||||
template<class T>
|
||||
@ -5540,6 +5570,32 @@ void unpack(Action::Condition& data, std::vector<char>& buffer, int& position,
|
||||
unpack(data.cmp_string, buffer, position, comm);
|
||||
}
|
||||
|
||||
void unpack(Action::ActionX& data, std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
std::string name;
|
||||
size_t max_run;
|
||||
double min_wait;
|
||||
std::time_t start_time;
|
||||
std::vector<DeckKeyword> keywords;
|
||||
Action::AST condition;
|
||||
std::vector<Action::Condition> conditions;
|
||||
size_t run_count;
|
||||
std::time_t last_run;
|
||||
|
||||
unpack(name, buffer, position, comm);
|
||||
unpack(max_run, buffer, position, comm);
|
||||
unpack(min_wait, buffer, position, comm);
|
||||
unpack(start_time, buffer, position, comm);
|
||||
unpack(keywords, buffer, position, comm);
|
||||
unpack(condition, buffer, position, comm);
|
||||
unpack(conditions, buffer, position, comm);
|
||||
unpack(run_count, buffer, position, comm);
|
||||
unpack(last_run, buffer, position, comm);
|
||||
data = Action::ActionX(name, max_run, min_wait, start_time, keywords,
|
||||
condition, conditions, run_count, last_run);
|
||||
}
|
||||
|
||||
#define INSTANTIATE_PACK_VECTOR(T) \
|
||||
template std::size_t packSize(const std::vector<T>& data, \
|
||||
Dune::MPIHelper::MPICommunicator comm); \
|
||||
|
@ -65,6 +65,7 @@ namespace Opm
|
||||
class Actdims;
|
||||
|
||||
namespace Action {
|
||||
class ActionX;
|
||||
class AST;
|
||||
class ASTNode;
|
||||
class Condition;
|
||||
@ -606,6 +607,7 @@ void unpack(char* str, std::size_t length, std::vector<char>& buffer, int& posit
|
||||
Dune::MPIHelper::MPICommunicator comm);
|
||||
|
||||
ADD_PACK_PROTOTYPES(Actdims)
|
||||
ADD_PACK_PROTOTYPES(Action::ActionX)
|
||||
ADD_PACK_PROTOTYPES(Action::AST)
|
||||
ADD_PACK_PROTOTYPES(Action::ASTNode)
|
||||
ADD_PACK_PROTOTYPES(Action::Condition)
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include <opm/parser/eclipse/EclipseState/IOConfig/IOConfig.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/IOConfig/RestartConfig.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Action/ActionAST.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Action/ActionX.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Action/ASTNode.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Action/Condition.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Events.hpp>
|
||||
@ -444,6 +445,22 @@ Opm::Action::Condition getCondition()
|
||||
val1.cmp_string = "test";
|
||||
return val1;
|
||||
}
|
||||
|
||||
|
||||
Opm::Action::ActionX getActionX()
|
||||
{
|
||||
std::shared_ptr<Opm::Action::ASTNode> node;
|
||||
node.reset(new Opm::Action::ASTNode(number, FuncType::field,
|
||||
"test1", {"test2"}, 1.0, {}));
|
||||
Opm::Action::AST ast(node);
|
||||
return Opm::Action::ActionX("test", 1, 2.0, 3,
|
||||
{Opm::DeckKeyword("test", {"test",1},
|
||||
{getDeckRecord(), getDeckRecord()},
|
||||
true, false)},
|
||||
ast, {getCondition()}, 4, 5);
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@ -2190,6 +2207,17 @@ BOOST_AUTO_TEST_CASE(Condition)
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(ActionX)
|
||||
{
|
||||
#ifdef HAVE_MPI
|
||||
Opm::Action::ActionX val1 = getActionX();
|
||||
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()
|
||||
{
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user