add mpi serialization for Tuning

This commit is contained in:
Arne Morten Kvarving 2019-12-17 13:22:05 +01:00
parent f461db3316
commit 5be1955e47
3 changed files with 230 additions and 1 deletions

View File

@ -39,6 +39,7 @@
#include <opm/parser/eclipse/EclipseState/Schedule/OilVaporizationProperties.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/RFTConfig.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/TimeMap.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Tuning.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>
@ -1521,6 +1522,48 @@ std::size_t packSize(const Deck& data,
packSize(data.unitSystemAccessCount(), comm);
}
std::size_t packSize(const Tuning& data,
Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.getTSINIT(), comm) +
packSize(data.getTSMAXZ(), comm) +
packSize(data.getTSMINZ(), comm) +
packSize(data.getTSMCHP(), comm) +
packSize(data.getTSFMAX(), comm) +
packSize(data.getTSFMIN(), comm) +
packSize(data.getTSFCNV(), comm) +
packSize(data.getTFDIFF(), comm) +
packSize(data.getTHRUPT(), comm) +
packSize(data.getTMAXWC(), comm) +
packSize(data.getTMAXWC_has_value(), comm) +
packSize(data.getTRGTTE(), comm) +
packSize(data.getTRGCNV(), comm) +
packSize(data.getTRGMBE(), comm) +
packSize(data.getTRGLCV(), comm) +
packSize(data.getXXXTTE(), comm) +
packSize(data.getXXXCNV(), comm) +
packSize(data.getXXXMBE(), comm) +
packSize(data.getXXXLCV(), comm) +
packSize(data.getXXXWFL(), comm) +
packSize(data.getTRGFIP(), comm) +
packSize(data.getTRGSFT(), comm) +
packSize(data.getTRGSFT_has_value(), comm) +
packSize(data.getTHIONX(), comm) +
packSize(data.getTRWGHT(), comm) +
packSize(data.getNEWTMX(), comm) +
packSize(data.getNEWTMN(), comm) +
packSize(data.getLITMAX(), comm) +
packSize(data.getLITMIN(), comm) +
packSize(data.getMXWSIT(), comm) +
packSize(data.getMXWPIT(), comm) +
packSize(data.getDDPLIM(), comm) +
packSize(data.getDDSLIM(), comm) +
packSize(data.getTRGDPR(), comm) +
packSize(data.getXXXDPR(), comm) +
packSize(data.getXXXDPR_has_value(), comm) +
packSize(data.getResetValues(), comm);
}
////// pack routines
template<class T>
@ -3069,6 +3112,49 @@ void pack(const Deck& data,
pack(data.unitSystemAccessCount(), buffer, position, comm);
}
void pack(const Tuning& data,
std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
pack(data.getTSINIT(), buffer, position, comm);
pack(data.getTSMAXZ(), buffer, position, comm);
pack(data.getTSMINZ(), buffer, position, comm);
pack(data.getTSMCHP(), buffer, position, comm);
pack(data.getTSFMAX(), buffer, position, comm);
pack(data.getTSFMIN(), buffer, position, comm);
pack(data.getTSFCNV(), buffer, position, comm);
pack(data.getTFDIFF(), buffer, position, comm);
pack(data.getTHRUPT(), buffer, position, comm);
pack(data.getTMAXWC(), buffer, position, comm);
pack(data.getTMAXWC_has_value(), buffer, position, comm);
pack(data.getTRGTTE(), buffer, position, comm);
pack(data.getTRGCNV(), buffer, position, comm);
pack(data.getTRGMBE(), buffer, position, comm);
pack(data.getTRGLCV(), buffer, position, comm);
pack(data.getXXXTTE(), buffer, position, comm);
pack(data.getXXXCNV(), buffer, position, comm);
pack(data.getXXXMBE(), buffer, position, comm);
pack(data.getXXXLCV(), buffer, position, comm);
pack(data.getXXXWFL(), buffer, position, comm);
pack(data.getTRGFIP(), buffer, position, comm);
pack(data.getTRGSFT(), buffer, position, comm);
pack(data.getTRGSFT_has_value(), buffer, position, comm);
pack(data.getTHIONX(), buffer, position, comm);
pack(data.getTRWGHT(), buffer, position, comm);
pack(data.getNEWTMX(), buffer, position, comm);
pack(data.getNEWTMN(), buffer, position, comm);
pack(data.getLITMAX(), buffer, position, comm);
pack(data.getLITMIN(), buffer, position, comm);
pack(data.getMXWSIT(), buffer, position, comm);
pack(data.getMXWPIT(), buffer, position, comm);
pack(data.getDDPLIM(), buffer, position, comm);
pack(data.getDDSLIM(), buffer, position, comm);
pack(data.getTRGDPR(), buffer, position, comm);
pack(data.getXXXDPR(), buffer, position, comm);
pack(data.getXXXDPR_has_value(), buffer, position, comm);
pack(data.getResetValues(), buffer, position, comm);
}
/// unpack routines
template<class T>
@ -5248,6 +5334,93 @@ void unpack(Deck& data, std::vector<char>& buffer, int& position,
activeUnitSystem.get(), dataFile, inputPath, accessCount);
}
void unpack(Tuning& data, std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
DynamicState<double> TSINIT;
DynamicState<double> TSMAXZ;
DynamicState<double> TSMINZ;
DynamicState<double> TSMCHP;
DynamicState<double> TSFMAX;
DynamicState<double> TSFMIN;
DynamicState<double> TSFCNV;
DynamicState<double> TFDIFF;
DynamicState<double> THRUPT;
DynamicState<double> TMAXWC;
DynamicState<int> TMAXWC_has_value;
DynamicState<double> TRGTTE;
DynamicState<double> TRGCNV;
DynamicState<double> TRGMBE;
DynamicState<double> TRGLCV;
DynamicState<double> XXXTTE;
DynamicState<double> XXXCNV;
DynamicState<double> XXXMBE;
DynamicState<double> XXXLCV;
DynamicState<double> XXXWFL;
DynamicState<double> TRGFIP;
DynamicState<double> TRGSFT;
DynamicState<int> TRGSFT_has_value;
DynamicState<double> THIONX;
DynamicState<int> TRWGHT;
DynamicState<int> NEWTMX;
DynamicState<int> NEWTMN;
DynamicState<int> LITMAX;
DynamicState<int> LITMIN;
DynamicState<int> MXWSIT;
DynamicState<int> MXWPIT;
DynamicState<double> DDPLIM;
DynamicState<double> DDSLIM;
DynamicState<double> TRGDPR;
DynamicState<double> XXXDPR;
DynamicState<int> XXXDPR_has_value;
std::map<std::string, bool> ResetValue;
unpack(TSINIT, buffer, position, comm);
unpack(TSMAXZ, buffer, position, comm);
unpack(TSMINZ, buffer, position, comm);
unpack(TSMCHP, buffer, position, comm);
unpack(TSFMAX, buffer, position, comm);
unpack(TSFMIN, buffer, position, comm);
unpack(TSFCNV, buffer, position, comm);
unpack(TFDIFF, buffer, position, comm);
unpack(THRUPT, buffer, position, comm);
unpack(TMAXWC, buffer, position, comm);
unpack(TMAXWC_has_value, buffer, position, comm);
unpack(TRGTTE, buffer, position, comm);
unpack(TRGCNV, buffer, position, comm);
unpack(TRGMBE, buffer, position, comm);
unpack(TRGLCV, buffer, position, comm);
unpack(XXXTTE, buffer, position, comm);
unpack(XXXCNV, buffer, position, comm);
unpack(XXXMBE, buffer, position, comm);
unpack(XXXLCV, buffer, position, comm);
unpack(XXXWFL, buffer, position, comm);
unpack(TRGFIP, buffer, position, comm);
unpack(TRGSFT, buffer, position, comm);
unpack(TRGSFT_has_value, buffer, position, comm);
unpack(THIONX, buffer, position, comm);
unpack(TRWGHT, buffer, position, comm);
unpack(NEWTMX, buffer, position, comm);
unpack(NEWTMN, buffer, position, comm);
unpack(LITMAX, buffer, position, comm);
unpack(LITMIN, buffer, position, comm);
unpack(MXWSIT, buffer, position, comm);
unpack(MXWPIT, buffer, position, comm);
unpack(DDPLIM, buffer, position, comm);
unpack(DDSLIM, buffer, position, comm);
unpack(TRGDPR, buffer, position, comm);
unpack(XXXDPR, buffer, position, comm);
unpack(XXXDPR_has_value, buffer, position, comm);
unpack(ResetValue, buffer, position, comm);
data = Tuning(TSINIT, TSMAXZ, TSMINZ, TSMCHP, TSFMAX, TSFMIN, TSFCNV,
TFDIFF, THRUPT, TMAXWC, TMAXWC_has_value, TRGTTE,
TRGCNV, TRGMBE, TRGLCV, XXXTTE, XXXCNV, XXXMBE, XXXLCV,
XXXWFL, TRGFIP, TRGSFT, TRGSFT_has_value, THIONX, TRWGHT,
NEWTMX, NEWTMN, LITMAX, LITMIN, MXWSIT, MXWPIT, DDPLIM,
DDSLIM, TRGDPR, XXXDPR, XXXDPR_has_value, ResetValue);
}
#define INSTANTIATE_PACK_VECTOR(T) \
template std::size_t packSize(const std::vector<T>& data, \
Dune::MPIHelper::MPICommunicator comm); \

View File

@ -120,6 +120,7 @@ class TableContainer;
class TableManager;
class TableSchema;
class ThresholdPressure;
class Tuning;
class UDAValue;
class UDQASTNode;
class UDQConfig;
@ -678,6 +679,7 @@ ADD_PACK_PROTOTYPES(TableSchema)
ADD_PACK_PROTOTYPES(ThresholdPressure)
ADD_PACK_PROTOTYPES(TimeMap)
ADD_PACK_PROTOTYPES(TimeMap::StepData)
ADD_PACK_PROTOTYPES(Tuning)
ADD_PACK_PROTOTYPES(UDAValue)
ADD_PACK_PROTOTYPES(UDQActive)
ADD_PACK_PROTOTYPES(UDQActive::InputRecord)

View File

@ -48,6 +48,7 @@
#include <opm/parser/eclipse/EclipseState/Schedule/OilVaporizationProperties.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/RFTConfig.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/TimeMap.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Tuning.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQActive.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQAssign.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQASTNode.hpp>
@ -352,7 +353,6 @@ Opm::GuideRateModel getGuideRateModel()
Opm::UDAValue(10.0),
Opm::UDAValue(11.0)});
}
#endif
Opm::GuideRateConfig::GroupTarget getGuideRateConfigGroup()
@ -387,6 +387,49 @@ Opm::DeckRecord getDeckRecord()
}
Opm::Tuning getTuning()
{
return Opm::Tuning(Opm::DynamicState<double>(std::vector<double>{1.0}, 1), //TSINIT
Opm::DynamicState<double>(std::vector<double>{2.0}, 1), //TSMAXZ
Opm::DynamicState<double>(std::vector<double>{3.0}, 1), //TSMINZ
Opm::DynamicState<double>(std::vector<double>{4.0}, 1), //TSMCHP
Opm::DynamicState<double>(std::vector<double>{5.0}, 1), //TSFMAX
Opm::DynamicState<double>(std::vector<double>{6.0}, 1), //TSFMIN
Opm::DynamicState<double>(std::vector<double>{7.0}, 1), //TSFCNV
Opm::DynamicState<double>(std::vector<double>{8.0}, 1), //TFDIFF
Opm::DynamicState<double>(std::vector<double>{9.0}, 1), //THRUPT
Opm::DynamicState<double>(std::vector<double>{10.0}, 1), //TMAXWC
Opm::DynamicState<int>(std::vector<int>{1}, 1), //TMAXWC_has_value
Opm::DynamicState<double>(std::vector<double>{11.0}, 1), //TRGTTE
Opm::DynamicState<double>(std::vector<double>{12.0}, 1), //TRGCNV
Opm::DynamicState<double>(std::vector<double>{13.0}, 1), //TRGMBE
Opm::DynamicState<double>(std::vector<double>{14.0}, 1), //TRGLCV
Opm::DynamicState<double>(std::vector<double>{15.0}, 1), //XXXTTE
Opm::DynamicState<double>(std::vector<double>{16.0}, 1), //XXXCNV
Opm::DynamicState<double>(std::vector<double>{17.0}, 1), //XXXMBE
Opm::DynamicState<double>(std::vector<double>{18.0}, 1), //XXXLCV
Opm::DynamicState<double>(std::vector<double>{19.0}, 1), //XXXWFL
Opm::DynamicState<double>(std::vector<double>{20.0}, 1), ///TRGFIP
Opm::DynamicState<double>(std::vector<double>{21.0}, 1), //TRGSFT
Opm::DynamicState<int>(std::vector<int>{2}, 1), //TRGSFT_has_value
Opm::DynamicState<double>(std::vector<double>{22.0}, 1), // THIONX
Opm::DynamicState<int>(std::vector<int>{3}, 1), //TRWGHT
Opm::DynamicState<int>(std::vector<int>{4}, 1), //NEWTMX
Opm::DynamicState<int>(std::vector<int>{5}, 1), //NEWTMN
Opm::DynamicState<int>(std::vector<int>{6}, 1), //LITMAX
Opm::DynamicState<int>(std::vector<int>{7}, 1), //LITMIN
Opm::DynamicState<int>(std::vector<int>{8}, 1), //MXWSIT
Opm::DynamicState<int>(std::vector<int>{9}, 1), //MXWPIT
Opm::DynamicState<double>(std::vector<double>{23.0}, 1), //DDPLIM
Opm::DynamicState<double>(std::vector<double>{24.0}, 1), //DDSLIM
Opm::DynamicState<double>(std::vector<double>{25.0}, 1), //TGRDPR
Opm::DynamicState<double>(std::vector<double>{26.0}, 1), //XXXDPR
Opm::DynamicState<int>(std::vector<int>{10}, 1), //XXDPR_has_value
std::map<std::string,bool>{{"test", false}}); // resetValue
}
#endif
}
@ -2069,6 +2112,17 @@ BOOST_AUTO_TEST_CASE(Deck)
}
BOOST_AUTO_TEST_CASE(Tuning)
{
#ifdef HAVE_MPI
Opm::Tuning val1 = getTuning();
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;