mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
add mpi serialization for UDQASTNode
This commit is contained in:
parent
5873b56025
commit
7d825cea82
@ -36,6 +36,7 @@
|
|||||||
#include <opm/parser/eclipse/EclipseState/Schedule/MSW/Valve.hpp>
|
#include <opm/parser/eclipse/EclipseState/Schedule/MSW/Valve.hpp>
|
||||||
#include <opm/parser/eclipse/EclipseState/Schedule/OilVaporizationProperties.hpp>
|
#include <opm/parser/eclipse/EclipseState/Schedule/OilVaporizationProperties.hpp>
|
||||||
#include <opm/parser/eclipse/EclipseState/Schedule/TimeMap.hpp>
|
#include <opm/parser/eclipse/EclipseState/Schedule/TimeMap.hpp>
|
||||||
|
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQASTNode.hpp>
|
||||||
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQFunction.hpp>
|
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQFunction.hpp>
|
||||||
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQFunctionTable.hpp>
|
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQFunctionTable.hpp>
|
||||||
#include <opm/parser/eclipse/EclipseState/Schedule/VFPInjTable.hpp>
|
#include <opm/parser/eclipse/EclipseState/Schedule/VFPInjTable.hpp>
|
||||||
@ -1293,6 +1294,18 @@ std::size_t packSize(const UDQFunctionTable& data,
|
|||||||
packSize(data.functionMap(), comm);
|
packSize(data.functionMap(), comm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::size_t packSize(const UDQASTNode& data,
|
||||||
|
Dune::MPIHelper::MPICommunicator comm)
|
||||||
|
{
|
||||||
|
return packSize(data.var_type, comm) +
|
||||||
|
packSize(data.getType(), comm) +
|
||||||
|
packSize(data.stringValue(), comm) +
|
||||||
|
packSize(data.scalarValue(), comm) +
|
||||||
|
packSize(data.getSelectors(), comm) +
|
||||||
|
packSize(data.getLeft(), comm) +
|
||||||
|
packSize(data.getRight(), comm);
|
||||||
|
}
|
||||||
|
|
||||||
////// pack routines
|
////// pack routines
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
@ -2602,6 +2615,19 @@ void pack(const UDQFunctionTable& data,
|
|||||||
pack(data.functionMap(), buffer, position, comm);
|
pack(data.functionMap(), buffer, position, comm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void pack(const UDQASTNode& data,
|
||||||
|
std::vector<char>& buffer, int& position,
|
||||||
|
Dune::MPIHelper::MPICommunicator comm)
|
||||||
|
{
|
||||||
|
pack(data.var_type, buffer, position, comm);
|
||||||
|
pack(data.getType(), buffer, position, comm);
|
||||||
|
pack(data.stringValue(), buffer, position, comm);
|
||||||
|
pack(data.scalarValue(), buffer, position, comm);
|
||||||
|
pack(data.getSelectors(), buffer, position, comm);
|
||||||
|
pack(data.getLeft(), buffer, position, comm);
|
||||||
|
pack(data.getRight(), buffer, position, comm);
|
||||||
|
}
|
||||||
|
|
||||||
/// unpack routines
|
/// unpack routines
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
@ -4448,6 +4474,28 @@ void unpack(UDQFunctionTable& data,
|
|||||||
data = UDQFunctionTable(params, map);
|
data = UDQFunctionTable(params, map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void unpack(UDQASTNode& data,
|
||||||
|
std::vector<char>& buffer, int& position,
|
||||||
|
Dune::MPIHelper::MPICommunicator comm)
|
||||||
|
{
|
||||||
|
UDQVarType var_type;
|
||||||
|
UDQTokenType type;
|
||||||
|
std::string stringValue;
|
||||||
|
double scalarValue;
|
||||||
|
std::vector<std::string> selectors;
|
||||||
|
std::shared_ptr<UDQASTNode> left;
|
||||||
|
std::shared_ptr<UDQASTNode> right;
|
||||||
|
|
||||||
|
unpack(var_type, buffer, position, comm);
|
||||||
|
unpack(type, buffer, position, comm);
|
||||||
|
unpack(stringValue, buffer, position, comm);
|
||||||
|
unpack(scalarValue, buffer, position, comm);
|
||||||
|
unpack(selectors, buffer, position, comm);
|
||||||
|
unpack(left, buffer, position, comm);
|
||||||
|
unpack(right, buffer, position, comm);
|
||||||
|
data = UDQASTNode(var_type, type, stringValue, scalarValue, selectors, left, right);
|
||||||
|
}
|
||||||
|
|
||||||
#define INSTANTIATE_PACK_VECTOR(T) \
|
#define INSTANTIATE_PACK_VECTOR(T) \
|
||||||
template std::size_t packSize(const std::vector<T>& data, \
|
template std::size_t packSize(const std::vector<T>& data, \
|
||||||
Dune::MPIHelper::MPICommunicator comm); \
|
Dune::MPIHelper::MPICommunicator comm); \
|
||||||
|
@ -112,6 +112,7 @@ class TableManager;
|
|||||||
class TableSchema;
|
class TableSchema;
|
||||||
class ThresholdPressure;
|
class ThresholdPressure;
|
||||||
class UDAValue;
|
class UDAValue;
|
||||||
|
class UDQASTNode;
|
||||||
class UDQFunction;
|
class UDQFunction;
|
||||||
class UDQFunctionTable;
|
class UDQFunctionTable;
|
||||||
class UDQParams;
|
class UDQParams;
|
||||||
@ -629,6 +630,7 @@ ADD_PACK_PROTOTYPES(ThresholdPressure)
|
|||||||
ADD_PACK_PROTOTYPES(TimeMap)
|
ADD_PACK_PROTOTYPES(TimeMap)
|
||||||
ADD_PACK_PROTOTYPES(TimeMap::StepData)
|
ADD_PACK_PROTOTYPES(TimeMap::StepData)
|
||||||
ADD_PACK_PROTOTYPES(UDAValue)
|
ADD_PACK_PROTOTYPES(UDAValue)
|
||||||
|
ADD_PACK_PROTOTYPES(UDQASTNode)
|
||||||
ADD_PACK_PROTOTYPES(UDQFunction)
|
ADD_PACK_PROTOTYPES(UDQFunction)
|
||||||
ADD_PACK_PROTOTYPES(UDQFunctionTable)
|
ADD_PACK_PROTOTYPES(UDQFunctionTable)
|
||||||
ADD_PACK_PROTOTYPES(UDQParams)
|
ADD_PACK_PROTOTYPES(UDQParams)
|
||||||
|
@ -43,6 +43,7 @@
|
|||||||
#include <opm/parser/eclipse/EclipseState/Schedule/MSW/Valve.hpp>
|
#include <opm/parser/eclipse/EclipseState/Schedule/MSW/Valve.hpp>
|
||||||
#include <opm/parser/eclipse/EclipseState/Schedule/OilVaporizationProperties.hpp>
|
#include <opm/parser/eclipse/EclipseState/Schedule/OilVaporizationProperties.hpp>
|
||||||
#include <opm/parser/eclipse/EclipseState/Schedule/TimeMap.hpp>
|
#include <opm/parser/eclipse/EclipseState/Schedule/TimeMap.hpp>
|
||||||
|
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQASTNode.hpp>
|
||||||
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQFunction.hpp>
|
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQFunction.hpp>
|
||||||
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQFunctionTable.hpp>
|
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQFunctionTable.hpp>
|
||||||
#include <opm/parser/eclipse/EclipseState/Schedule/VFPInjTable.hpp>
|
#include <opm/parser/eclipse/EclipseState/Schedule/VFPInjTable.hpp>
|
||||||
@ -1690,6 +1691,24 @@ BOOST_AUTO_TEST_CASE(UDQFunctionTable)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(UDQASTNode)
|
||||||
|
{
|
||||||
|
#ifdef HAVE_MPI
|
||||||
|
std::shared_ptr<Opm::UDQASTNode> n0;
|
||||||
|
std::shared_ptr<Opm::UDQASTNode> n1(new Opm::UDQASTNode(Opm::UDQVarType::NONE,
|
||||||
|
Opm::UDQTokenType::error,
|
||||||
|
"test1", 1.0, {"test2"},
|
||||||
|
n0, n0));
|
||||||
|
Opm::UDQASTNode val1(Opm::UDQVarType::NONE,
|
||||||
|
Opm::UDQTokenType::error,
|
||||||
|
"test", 1.0, {"test3"}, n1, n1);
|
||||||
|
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()
|
bool init_unit_test_func()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user