mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-01-27 16:16:28 -06:00
EclGenericVanguard: add serialization support
This commit is contained in:
parent
afba3f948c
commit
a825a060c3
@ -24,18 +24,46 @@
|
|||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <ebos/eclgenericvanguard.hh>
|
#include <ebos/eclgenericvanguard.hh>
|
||||||
|
|
||||||
|
#include <opm/common/utility/MemPacker.hpp>
|
||||||
|
#include <opm/common/utility/Serializer.hpp>
|
||||||
|
|
||||||
#include <opm/common/ErrorMacros.hpp>
|
#include <opm/common/ErrorMacros.hpp>
|
||||||
#include <opm/common/utility/TimeService.hpp>
|
#include <opm/common/utility/TimeService.hpp>
|
||||||
#include <opm/input/eclipse/EclipseState/Aquifer/NumericalAquifer/NumericalAquiferCell.hpp>
|
#include <opm/input/eclipse/EclipseState/Aquifer/NumericalAquifer/NumericalAquiferCell.hpp>
|
||||||
#include <opm/input/eclipse/EclipseState/EclipseState.hpp>
|
#include <opm/input/eclipse/EclipseState/EclipseState.hpp>
|
||||||
#include <opm/input/eclipse/Parser/InputErrorAction.hpp>
|
#include <opm/input/eclipse/Parser/InputErrorAction.hpp>
|
||||||
|
#include <opm/input/eclipse/Schedule/Action/Actions.hpp>
|
||||||
|
#include <opm/input/eclipse/Schedule/Action/ASTNode.hpp>
|
||||||
#include <opm/input/eclipse/Schedule/Action/State.hpp>
|
#include <opm/input/eclipse/Schedule/Action/State.hpp>
|
||||||
|
#include <opm/input/eclipse/Schedule/GasLiftOpt.hpp>
|
||||||
|
#include <opm/input/eclipse/Schedule/Group/GConSale.hpp>
|
||||||
|
#include <opm/input/eclipse/Schedule/Group/GConSump.hpp>
|
||||||
|
#include <opm/input/eclipse/Schedule/Group/GuideRateConfig.hpp>
|
||||||
|
#include <opm/input/eclipse/Schedule/Network/Balance.hpp>
|
||||||
|
#include <opm/input/eclipse/Schedule/Network/ExtNetwork.hpp>
|
||||||
|
#include <opm/input/eclipse/Schedule/MSW/WellSegments.hpp>
|
||||||
#include <opm/input/eclipse/Schedule/OilVaporizationProperties.hpp>
|
#include <opm/input/eclipse/Schedule/OilVaporizationProperties.hpp>
|
||||||
|
#include <opm/input/eclipse/Schedule/RFTConfig.hpp>
|
||||||
|
#include <opm/input/eclipse/Schedule/RPTConfig.hpp>
|
||||||
#include <opm/input/eclipse/Schedule/Schedule.hpp>
|
#include <opm/input/eclipse/Schedule/Schedule.hpp>
|
||||||
#include <opm/input/eclipse/Schedule/Well/Well.hpp>
|
|
||||||
#include <opm/input/eclipse/Schedule/Well/WellTestState.hpp>
|
|
||||||
#include <opm/input/eclipse/Schedule/SummaryState.hpp>
|
#include <opm/input/eclipse/Schedule/SummaryState.hpp>
|
||||||
|
#include <opm/input/eclipse/Schedule/UDQ/UDQActive.hpp>
|
||||||
|
#include <opm/input/eclipse/Schedule/UDQ/UDQASTNode.hpp>
|
||||||
|
#include <opm/input/eclipse/Schedule/UDQ/UDQConfig.hpp>
|
||||||
#include <opm/input/eclipse/Schedule/UDQ/UDQState.hpp>
|
#include <opm/input/eclipse/Schedule/UDQ/UDQState.hpp>
|
||||||
|
#include <opm/input/eclipse/Schedule/Well/NameOrder.hpp>
|
||||||
|
#include <opm/input/eclipse/Schedule/Well/Well.hpp>
|
||||||
|
#include <opm/input/eclipse/Schedule/Well/WellBrineProperties.hpp>
|
||||||
|
#include <opm/input/eclipse/Schedule/Well/WellConnections.hpp>
|
||||||
|
#include <opm/input/eclipse/Schedule/Well/WellEconProductionLimits.hpp>
|
||||||
|
#include <opm/input/eclipse/Schedule/Well/WellFoamProperties.hpp>
|
||||||
|
#include <opm/input/eclipse/Schedule/Well/WellMICPProperties.hpp>
|
||||||
|
#include <opm/input/eclipse/Schedule/Well/WellPolymerProperties.hpp>
|
||||||
|
#include <opm/input/eclipse/Schedule/Well/WellTestConfig.hpp>
|
||||||
|
#include <opm/input/eclipse/Schedule/Well/WellTestState.hpp>
|
||||||
|
#include <opm/input/eclipse/Schedule/Well/WellTracerProperties.hpp>
|
||||||
|
#include <opm/input/eclipse/Schedule/Well/WListManager.hpp>
|
||||||
|
#include <opm/input/eclipse/Schedule/Well/WVFPEXP.hpp>
|
||||||
#include <opm/input/eclipse/EclipseState/SummaryConfig/SummaryConfig.hpp>
|
#include <opm/input/eclipse/EclipseState/SummaryConfig/SummaryConfig.hpp>
|
||||||
#include <opm/input/eclipse/Python/Python.hpp>
|
#include <opm/input/eclipse/Python/Python.hpp>
|
||||||
#include <opm/simulators/utils/readDeck.hpp>
|
#include <opm/simulators/utils/readDeck.hpp>
|
||||||
@ -57,9 +85,25 @@ std::unique_ptr<Parallel::Communication> EclGenericVanguard::comm_;
|
|||||||
EclGenericVanguard::SimulationModelParams EclGenericVanguard::modelParams_;
|
EclGenericVanguard::SimulationModelParams EclGenericVanguard::modelParams_;
|
||||||
|
|
||||||
EclGenericVanguard::EclGenericVanguard()
|
EclGenericVanguard::EclGenericVanguard()
|
||||||
|
: EclGenericVanguard(std::move(modelParams_))
|
||||||
|
{}
|
||||||
|
|
||||||
|
EclGenericVanguard::EclGenericVanguard(SimulationModelParams&& params)
|
||||||
: python(std::make_shared<Python>())
|
: python(std::make_shared<Python>())
|
||||||
{
|
{
|
||||||
defineSimulationModel(std::move(modelParams_));
|
defineSimulationModel(std::move(params));
|
||||||
|
}
|
||||||
|
|
||||||
|
EclGenericVanguard::SimulationModelParams
|
||||||
|
EclGenericVanguard::serializationTestParams()
|
||||||
|
{
|
||||||
|
SimulationModelParams result;
|
||||||
|
result.actionState_ = std::make_unique<Action::State>(Action::State::serializationTestObject());
|
||||||
|
result.eclSchedule_ = std::make_unique<Schedule>(Schedule::serializationTestObject());
|
||||||
|
result.summaryState_ = std::make_unique<SummaryState>(SummaryState::serializationTestObject());
|
||||||
|
result.udqState_ = std::make_unique<UDQState>(UDQState::serializationTestObject());
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
EclGenericVanguard::~EclGenericVanguard() = default;
|
EclGenericVanguard::~EclGenericVanguard() = default;
|
||||||
@ -73,6 +117,7 @@ void EclGenericVanguard::defineSimulationModel(SimulationModelParams&& params)
|
|||||||
setupTime_ = params.setupTime_;
|
setupTime_ = params.setupTime_;
|
||||||
udqState_ = std::move(params.udqState_);
|
udqState_ = std::move(params.udqState_);
|
||||||
wtestState_ = std::move(params.wtestState_);
|
wtestState_ = std::move(params.wtestState_);
|
||||||
|
summaryState_ = std::move(params.summaryState_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EclGenericVanguard::readDeck(const std::string& filename)
|
void EclGenericVanguard::readDeck(const std::string& filename)
|
||||||
@ -80,7 +125,7 @@ void EclGenericVanguard::readDeck(const std::string& filename)
|
|||||||
Dune::Timer setupTimer;
|
Dune::Timer setupTimer;
|
||||||
setupTimer.start();
|
setupTimer.start();
|
||||||
|
|
||||||
Opm::readDeck(EclGenericVanguard::comm(),
|
Opm::readDeck(comm(),
|
||||||
filename,
|
filename,
|
||||||
modelParams_.eclState_,
|
modelParams_.eclState_,
|
||||||
modelParams_.eclSchedule_,
|
modelParams_.eclSchedule_,
|
||||||
@ -178,7 +223,8 @@ void EclGenericVanguard::init()
|
|||||||
std::transform(caseName_.begin(), caseName_.end(), caseName_.begin(), ::toupper);
|
std::transform(caseName_.begin(), caseName_.end(), caseName_.begin(), ::toupper);
|
||||||
}
|
}
|
||||||
|
|
||||||
this->summaryState_ = std::make_unique<SummaryState>( TimeService::from_time_t(this->eclSchedule_->getStartTime() ));
|
if (!this->summaryState_)
|
||||||
|
this->summaryState_ = std::make_unique<SummaryState>( TimeService::from_time_t(this->eclSchedule_->getStartTime() ));
|
||||||
|
|
||||||
// Initialize parallelWells with all local wells
|
// Initialize parallelWells with all local wells
|
||||||
const auto& schedule_wells = schedule().getWellsatEnd();
|
const auto& schedule_wells = schedule().getWellsatEnd();
|
||||||
@ -201,7 +247,7 @@ void EclGenericVanguard::init()
|
|||||||
if (comm.rank() == 0)
|
if (comm.rank() == 0)
|
||||||
{
|
{
|
||||||
const auto& wells = this->schedule().getWellsatEnd();
|
const auto& wells = this->schedule().getWellsatEnd();
|
||||||
for ( const auto& well: wells)
|
for (const auto& well : wells)
|
||||||
{
|
{
|
||||||
hasMsWell = hasMsWell || well.isMultiSegment();
|
hasMsWell = hasMsWell || well.isMultiSegment();
|
||||||
}
|
}
|
||||||
@ -244,4 +290,34 @@ std::unordered_map<size_t, const NumericalAquiferCell*> EclGenericVanguard::allA
|
|||||||
return this->eclState_->aquifer().numericalAquifers().allAquiferCells();
|
return this->eclState_->aquifer().numericalAquifers().allAquiferCells();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
void EclGenericVanguard::
|
||||||
|
serializeOp<Serializer<Serialization::MemPacker>>(Serializer<Serialization::MemPacker>& serializer)
|
||||||
|
{
|
||||||
|
serializer(*summaryState_);
|
||||||
|
serializer(*udqState_);
|
||||||
|
serializer(*actionState_);
|
||||||
|
serializer(*eclSchedule_);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EclGenericVanguard::operator==(const EclGenericVanguard& rhs) const
|
||||||
|
{
|
||||||
|
auto cmp_ptr = [](const auto& a, const auto& b)
|
||||||
|
{
|
||||||
|
if (!a && !b) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (a && b) {
|
||||||
|
return *a == *b;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
return cmp_ptr(this->summaryState_, rhs.summaryState_);
|
||||||
|
cmp_ptr(this->udqState_, rhs.udqState_) &&
|
||||||
|
cmp_ptr(this->actionState_, rhs.actionState_) &&
|
||||||
|
cmp_ptr(this->eclSchedule_, rhs.eclSchedule_);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Opm
|
} // namespace Opm
|
||||||
|
@ -28,8 +28,11 @@
|
|||||||
#define EWOMS_ECL_GENERIC_VANGUARD_HH
|
#define EWOMS_ECL_GENERIC_VANGUARD_HH
|
||||||
|
|
||||||
#include <opm/grid/common/GridEnums.hpp>
|
#include <opm/grid/common/GridEnums.hpp>
|
||||||
|
|
||||||
#include <opm/input/eclipse/Schedule/Well/WellTestState.hpp>
|
#include <opm/input/eclipse/Schedule/Well/WellTestState.hpp>
|
||||||
|
|
||||||
#include <opm/simulators/utils/ParallelCommunication.hpp>
|
#include <opm/simulators/utils/ParallelCommunication.hpp>
|
||||||
|
|
||||||
#if DUNE_VERSION_NEWER(DUNE_COMMON, 2, 7)
|
#if DUNE_VERSION_NEWER(DUNE_COMMON, 2, 7)
|
||||||
#include <dune/common/parallel/communication.hh>
|
#include <dune/common/parallel/communication.hh>
|
||||||
#else
|
#else
|
||||||
@ -68,9 +71,9 @@ public:
|
|||||||
|
|
||||||
struct SimulationModelParams {
|
struct SimulationModelParams {
|
||||||
double setupTime_;
|
double setupTime_;
|
||||||
std::unique_ptr<Parallel::Communication> comm_;
|
|
||||||
std::unique_ptr<UDQState> udqState_;
|
std::unique_ptr<UDQState> udqState_;
|
||||||
std::unique_ptr<Action::State> actionState_;
|
std::unique_ptr<Action::State> actionState_;
|
||||||
|
std::unique_ptr<SummaryState> summaryState_;
|
||||||
std::unique_ptr<WellTestState> wtestState_;
|
std::unique_ptr<WellTestState> wtestState_;
|
||||||
std::shared_ptr<EclipseState> eclState_;
|
std::shared_ptr<EclipseState> eclState_;
|
||||||
std::shared_ptr<Schedule> eclSchedule_;
|
std::shared_ptr<Schedule> eclSchedule_;
|
||||||
@ -84,6 +87,7 @@ public:
|
|||||||
* \details Needs to be in compile unit.
|
* \details Needs to be in compile unit.
|
||||||
*/
|
*/
|
||||||
EclGenericVanguard();
|
EclGenericVanguard();
|
||||||
|
explicit EclGenericVanguard(SimulationModelParams&& params);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Destructor.
|
* \brief Destructor.
|
||||||
@ -91,6 +95,8 @@ public:
|
|||||||
*/
|
*/
|
||||||
~EclGenericVanguard();
|
~EclGenericVanguard();
|
||||||
|
|
||||||
|
static SimulationModelParams serializationTestParams();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Returns the canonical path to a deck file.
|
* \brief Returns the canonical path to a deck file.
|
||||||
*
|
*
|
||||||
@ -255,6 +261,14 @@ public:
|
|||||||
return *comm_;
|
return *comm_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Private to avoid pulling schedule in header.
|
||||||
|
// Static state is not serialized, only use for restart.
|
||||||
|
template<class Serializer>
|
||||||
|
void serializeOp(Serializer& serializer);
|
||||||
|
|
||||||
|
// Only compares dynamic state.
|
||||||
|
bool operator==(const EclGenericVanguard& rhs) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void updateOutputDir_(std::string outputDir,
|
void updateOutputDir_(std::string outputDir,
|
||||||
bool enableEclCompatFile);
|
bool enableEclCompatFile);
|
||||||
|
@ -20,9 +20,15 @@
|
|||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
#include <ebos/ebos.hh>
|
#include <ebos/ebos.hh>
|
||||||
|
#include <ebos/eclgenericvanguard.hh>
|
||||||
|
|
||||||
#include <opm/common/utility/Serializer.hpp>
|
#include <opm/common/utility/Serializer.hpp>
|
||||||
|
|
||||||
|
#include <opm/input/eclipse/Schedule/Action/State.hpp>
|
||||||
|
#include <opm/input/eclipse/EclipseState/SummaryConfig/SummaryConfig.hpp>
|
||||||
|
#include <opm/input/eclipse/Schedule/SummaryState.hpp>
|
||||||
|
#include <opm/input/eclipse/Schedule/UDQ/UDQState.hpp>
|
||||||
|
|
||||||
#include <opm/simulators/timestepping/AdaptiveTimeSteppingEbos.hpp>
|
#include <opm/simulators/timestepping/AdaptiveTimeSteppingEbos.hpp>
|
||||||
#include <opm/simulators/timestepping/SimulatorTimer.hpp>
|
#include <opm/simulators/timestepping/SimulatorTimer.hpp>
|
||||||
#include <opm/simulators/timestepping/TimeStepControl.hpp>
|
#include <opm/simulators/timestepping/TimeStepControl.hpp>
|
||||||
@ -75,6 +81,28 @@ TEST_FOR_TYPE_NAMED_OBJ(ATE, AdaptiveTimeSteppingEbosPID, serializationTestObjec
|
|||||||
TEST_FOR_TYPE_NAMED_OBJ(ATE, AdaptiveTimeSteppingEbosPIDIt, serializationTestObjectPIDIt)
|
TEST_FOR_TYPE_NAMED_OBJ(ATE, AdaptiveTimeSteppingEbosPIDIt, serializationTestObjectPIDIt)
|
||||||
TEST_FOR_TYPE_NAMED_OBJ(ATE, AdaptiveTimeSteppingEbosSimple, serializationTestObjectSimple)
|
TEST_FOR_TYPE_NAMED_OBJ(ATE, AdaptiveTimeSteppingEbosSimple, serializationTestObjectSimple)
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(EclGenericVanguard)
|
||||||
|
{
|
||||||
|
auto in_params = Opm::EclGenericVanguard::serializationTestParams();
|
||||||
|
Opm::EclGenericVanguard val1(std::move(in_params));
|
||||||
|
Opm::Serialization::MemPacker packer;
|
||||||
|
Opm::Serializer ser(packer);
|
||||||
|
ser.pack(val1);
|
||||||
|
const size_t pos1 = ser.position();
|
||||||
|
Opm::EclGenericVanguard::SimulationModelParams out_params;
|
||||||
|
out_params.setupTime_ = 0.0;
|
||||||
|
out_params.actionState_ = std::make_unique<Opm::Action::State>();
|
||||||
|
out_params.udqState_ = std::make_unique<Opm::UDQState>();
|
||||||
|
out_params.eclSchedule_ = std::make_shared<Opm::Schedule>();
|
||||||
|
out_params.summaryState_ = std::make_unique<Opm::SummaryState>();
|
||||||
|
Opm::EclGenericVanguard val2(std::move(out_params));
|
||||||
|
ser.unpack(val2);
|
||||||
|
const size_t pos2 = ser.position();
|
||||||
|
|
||||||
|
BOOST_CHECK_MESSAGE(pos1 == pos2, "Packed size differ from unpack size for EclGenericVanguard");
|
||||||
|
BOOST_CHECK_MESSAGE(val1 == val2, "Deserialized EclGenericVanguard differ");
|
||||||
|
}
|
||||||
|
|
||||||
bool init_unit_test_func()
|
bool init_unit_test_func()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user