mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-01-19 16:22:57 -06:00
add mpi serialization for UDQConfig
This commit is contained in:
parent
dc5a3d0e0e
commit
01d05c9585
@ -37,6 +37,7 @@
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/OilVaporizationProperties.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/UDQConfig.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQDefine.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQFunction.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQInput.hpp>
|
||||
@ -1341,6 +1342,18 @@ std::size_t packSize(const UDQIndex& data,
|
||||
packSize(data.var_type, comm);
|
||||
}
|
||||
|
||||
std::size_t packSize(const UDQConfig& data,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
return packSize(data.params(), comm) +
|
||||
packSize(data.function_table(), comm) +
|
||||
packSize(data.definitionMap(), comm) +
|
||||
packSize(data.assignmentMap(), comm) +
|
||||
packSize(data.unitsMap(), comm) +
|
||||
packSize(data.inputIndex(), comm) +
|
||||
packSize(data.typeCount(), comm);
|
||||
}
|
||||
|
||||
////// pack routines
|
||||
|
||||
template<class T>
|
||||
@ -2700,6 +2713,19 @@ void pack(const UDQIndex& data,
|
||||
pack(data.var_type, buffer, position, comm);
|
||||
}
|
||||
|
||||
void pack(const UDQConfig& data,
|
||||
std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
pack(data.params(), buffer, position, comm);
|
||||
pack(data.function_table(), buffer, position, comm);
|
||||
pack(data.definitionMap(), buffer, position, comm);
|
||||
pack(data.assignmentMap(), buffer, position, comm);
|
||||
pack(data.unitsMap(), buffer, position, comm);
|
||||
pack(data.inputIndex(), buffer, position, comm);
|
||||
pack(data.typeCount(), buffer, position, comm);
|
||||
}
|
||||
|
||||
/// unpack routines
|
||||
|
||||
template<class T>
|
||||
@ -4615,6 +4641,29 @@ void unpack(UDQIndex& data,
|
||||
unpack(data.var_type, buffer, position, comm);
|
||||
}
|
||||
|
||||
void unpack(UDQConfig& data,
|
||||
std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
UDQParams params;
|
||||
UDQFunctionTable function_table;
|
||||
std::unordered_map<std::string,UDQDefine> definitionsMap;
|
||||
std::unordered_map<std::string,UDQAssign> assignmentsMap;
|
||||
std::unordered_map<std::string,std::string> units;
|
||||
OrderedMap<std::string,UDQIndex> inputIndex;
|
||||
std::map<UDQVarType,std::size_t> typeCount;
|
||||
|
||||
unpack(params, buffer, position, comm);
|
||||
unpack(function_table, buffer, position, comm);
|
||||
unpack(definitionsMap, buffer, position, comm);
|
||||
unpack(assignmentsMap, buffer, position, comm);
|
||||
unpack(units, buffer, position, comm);
|
||||
unpack(inputIndex, buffer, position, comm);
|
||||
unpack(typeCount, buffer, position, comm);
|
||||
data = UDQConfig(params, function_table, definitionsMap,
|
||||
assignmentsMap, units, inputIndex, typeCount);
|
||||
}
|
||||
|
||||
#define INSTANTIATE_PACK_VECTOR(T) \
|
||||
template std::size_t packSize(const std::vector<T>& data, \
|
||||
Dune::MPIHelper::MPICommunicator comm); \
|
||||
|
@ -114,6 +114,7 @@ class TableSchema;
|
||||
class ThresholdPressure;
|
||||
class UDAValue;
|
||||
class UDQASTNode;
|
||||
class UDQConfig;
|
||||
class UDQDefine;
|
||||
class UDQFunction;
|
||||
class UDQFunctionTable;
|
||||
@ -636,6 +637,7 @@ ADD_PACK_PROTOTYPES(UDAValue)
|
||||
ADD_PACK_PROTOTYPES(UDQAssign)
|
||||
ADD_PACK_PROTOTYPES(UDQAssign::AssignRecord)
|
||||
ADD_PACK_PROTOTYPES(UDQASTNode)
|
||||
ADD_PACK_PROTOTYPES(UDQConfig)
|
||||
ADD_PACK_PROTOTYPES(UDQDefine)
|
||||
ADD_PACK_PROTOTYPES(UDQFunction)
|
||||
ADD_PACK_PROTOTYPES(UDQFunctionTable)
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/TimeMap.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQAssign.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQASTNode.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQConfig.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQDefine.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQFunction.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQFunctionTable.hpp>
|
||||
@ -305,6 +306,34 @@ Opm::VFPProdTable getVFPProdTable()
|
||||
{1.0, 2.0, 3.0},
|
||||
{1.0, 2.0, 3.0, 4.0}, table);
|
||||
}
|
||||
|
||||
|
||||
Opm::UDQConfig getUDQConfig()
|
||||
{
|
||||
Opm::UDQParams params(true, 1, 2.0, 3.0, 4.0);
|
||||
Opm::UDQFunctionTable::FunctionMap map{{"test", std::make_shared<Opm::UDQFunction>()}};
|
||||
std::shared_ptr<Opm::UDQASTNode> n0;
|
||||
Opm::UDQASTNode n1(Opm::UDQVarType::NONE,
|
||||
Opm::UDQTokenType::error,
|
||||
"test", 1.0, {"test1", "test2"}, n0, n0);
|
||||
Opm::UDQDefine def("test", std::make_shared<Opm::UDQASTNode>(n1),
|
||||
Opm::UDQVarType::NONE, "test2");
|
||||
Opm::UDQAssign ass("test", Opm::UDQVarType::NONE,
|
||||
{Opm::UDQAssign::AssignRecord{{"test1"}, 1.0},
|
||||
Opm::UDQAssign::AssignRecord{{"test2"}, 2.0}});
|
||||
Opm::OrderedMap<std::string, Opm::UDQIndex> omap;
|
||||
omap.insert({"test8", Opm::UDQIndex(1, 2, Opm::UDQAction::ASSIGN,
|
||||
Opm::UDQVarType::WELL_VAR)});
|
||||
omap.insert({"test9", Opm::UDQIndex(3, 4, Opm::UDQAction::ASSIGN,
|
||||
Opm::UDQVarType::WELL_VAR)});
|
||||
return Opm::UDQConfig(params,
|
||||
Opm::UDQFunctionTable(params, map),
|
||||
{{"test1", def}, {"test2", def}},
|
||||
{{"test3", ass}, {"test4", ass}},
|
||||
{{"test5", "test6"}, {"test7", "test8"}},
|
||||
omap,
|
||||
{{Opm::UDQVarType::SCALAR, 5}, {Opm::UDQVarType::WELL_VAR, 6}});
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@ -1751,6 +1780,17 @@ BOOST_AUTO_TEST_CASE(UDQIndex)
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(UDQConfig)
|
||||
{
|
||||
#ifdef HAVE_MPI
|
||||
Opm::UDQConfig val1 = getUDQConfig();
|
||||
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