Use ScheduleState to manage UDQActive
This commit is contained in:
parent
bc3c3490bb
commit
344972624a
@ -106,7 +106,6 @@ namespace Opm
|
||||
class TimeMap;
|
||||
class ErrorGuard;
|
||||
class UDQConfig;
|
||||
class UDQActive;
|
||||
|
||||
|
||||
struct ScheduleStatic {
|
||||
@ -276,7 +275,6 @@ namespace Opm
|
||||
std::vector<Well> getChildWells2(const std::string& group_name, std::size_t timeStep) const;
|
||||
Well::ProducerCMode getGlobalWhistctlMmode(std::size_t timestep) const;
|
||||
|
||||
const UDQActive& udqActive(std::size_t timeStep) const;
|
||||
const UDQConfig& getUDQConfig(std::size_t timeStep) const;
|
||||
std::vector<const UDQConfig*> udqConfigList() const;
|
||||
void evalAction(const SummaryState& summary_state, std::size_t timeStep);
|
||||
@ -341,7 +339,6 @@ namespace Opm
|
||||
serializer.vector(splitGroups.first);
|
||||
serializer(splitGroups.second);
|
||||
udq_config.serializeOp(serializer);
|
||||
udq_active.serializeOp(serializer);
|
||||
guide_rate_config.serializeOp(serializer);
|
||||
m_glo.serializeOp(serializer);
|
||||
rft_config.serializeOp(serializer);
|
||||
@ -362,7 +359,6 @@ namespace Opm
|
||||
WellMap wells_static;
|
||||
GroupMap groups;
|
||||
DynamicState<std::shared_ptr<UDQConfig>> udq_config;
|
||||
DynamicState<std::shared_ptr<UDQActive>> udq_active;
|
||||
DynamicState<std::shared_ptr<GuideRateConfig>> guide_rate_config;
|
||||
DynamicState<std::shared_ptr<GasLiftOpt>> m_glo;
|
||||
RFTConfig rft_config;
|
||||
@ -395,7 +391,6 @@ namespace Opm
|
||||
GTNode groupTree(const std::string& root_node, std::size_t report_step, std::size_t level, const std::optional<std::string>& parent_name) const;
|
||||
void updateGroup(std::shared_ptr<Group> group, std::size_t reportStep);
|
||||
bool checkGroups(const ParseContext& parseContext, ErrorGuard& errors);
|
||||
void updateUDQActive( std::size_t timeStep, std::shared_ptr<UDQActive> udq );
|
||||
bool updateWellStatus( const std::string& well, std::size_t reportStep, bool runtime, Well::Status status, std::optional<KeywordLocation> = {});
|
||||
void addWellToGroup( const std::string& group_name, const std::string& well_name , std::size_t timeStep);
|
||||
void iterateScheduleSection(std::size_t load_start,
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/VFPProdTable.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/VFPInjTable.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Action/Actions.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQActive.hpp>
|
||||
|
||||
namespace Opm {
|
||||
|
||||
@ -130,6 +131,9 @@ namespace Opm {
|
||||
const Action::Actions& actions() const;
|
||||
void actions(Action::Actions actions);
|
||||
|
||||
const UDQActive& udq_active() const;
|
||||
void udq_active(UDQActive udq_active);
|
||||
|
||||
template<class Serializer>
|
||||
void serializeOp(Serializer& serializer) {
|
||||
serializer(m_start_time);
|
||||
@ -152,6 +156,7 @@ namespace Opm {
|
||||
serializer.map(m_vfpprod);
|
||||
serializer.map(m_vfpinj);
|
||||
serializer(m_actions);
|
||||
serializer(m_udq_active);
|
||||
}
|
||||
|
||||
|
||||
@ -175,6 +180,7 @@ namespace Opm {
|
||||
std::shared_ptr<Network::ExtNetwork> m_network;
|
||||
std::shared_ptr<RPTConfig> m_rptconfig;
|
||||
std::shared_ptr<Action::Actions> m_actions;
|
||||
std::shared_ptr<UDQActive> m_udq_active;
|
||||
std::map<int, std::shared_ptr<VFPProdTable>> m_vfpprod;
|
||||
std::map<int, std::shared_ptr<VFPInjTable>> m_vfpinj;
|
||||
};
|
||||
|
@ -811,7 +811,7 @@ captureDeclaredUDQData(const Opm::Schedule& sched,
|
||||
}
|
||||
|
||||
|
||||
auto udq_active = sched.udqActive(simStep);
|
||||
auto udq_active = sched[simStep].udq_active();
|
||||
if (udq_active) {
|
||||
const auto& udq_records = udq_active.get_iuad();
|
||||
int cnt_iuad = 0;
|
||||
|
@ -168,7 +168,7 @@ namespace {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const auto& udqAct = sched.udqActive(simStep);
|
||||
const auto& udqAct = sched[simStep].udq_active();
|
||||
const auto& iuad = udqAct.get_iuad();
|
||||
|
||||
return std::count_if(iuad.begin(), iuad.end(), [](const Opm::UDQActive::Record rec) {
|
||||
@ -184,7 +184,7 @@ namespace {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const auto& udqAct = sched.udqActive(simStep);
|
||||
const auto& udqAct = sched[simStep].udq_active();
|
||||
const auto& iuap = udqAct.get_iuap();
|
||||
|
||||
return std::count_if(iuap.begin(), iuap.end(), [](const Opm::UDQActive::InputRecord rec) {
|
||||
|
@ -463,9 +463,9 @@ namespace {
|
||||
this->snapshots.back().events().addEvent(ScheduleEvents::GROUP_PRODUCTION_UPDATE);
|
||||
this->snapshots.back().wellgroup_events().addEvent( group_name, ScheduleEvents::GROUP_PRODUCTION_UPDATE);
|
||||
|
||||
auto udq = std::make_shared<UDQActive>(this->udqActive(current_step));
|
||||
if (production.updateUDQActive(this->getUDQConfig(current_step), *udq))
|
||||
this->updateUDQActive(current_step, udq);
|
||||
auto udq_active = UDQActive(this->snapshots.back().udq_active());
|
||||
if (production.updateUDQActive(this->getUDQConfig(current_step), udq_active))
|
||||
this->snapshots.back().udq_active( std::move(udq_active));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -966,9 +966,9 @@ namespace {
|
||||
this->updateWell(std::move(well2), handlerContext.currentStep);
|
||||
}
|
||||
|
||||
auto udq = std::make_shared<UDQActive>(this->udqActive(handlerContext.currentStep));
|
||||
if (properties->updateUDQActive(this->getUDQConfig(handlerContext.currentStep), *udq))
|
||||
this->updateUDQActive(handlerContext.currentStep, udq);
|
||||
auto udq_active = UDQActive( this->snapshots.back().udq_active() );
|
||||
if (properties->updateUDQActive(this->getUDQConfig(handlerContext.currentStep), udq_active))
|
||||
this->snapshots.back().udq_active( std::move(udq_active));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1028,9 +1028,9 @@ namespace {
|
||||
}
|
||||
}
|
||||
|
||||
auto udq = std::make_shared<UDQActive>(this->udqActive(handlerContext.currentStep));
|
||||
if (injection->updateUDQActive(this->getUDQConfig(handlerContext.currentStep), *udq))
|
||||
this->updateUDQActive(handlerContext.currentStep, udq);
|
||||
auto udq_active = UDQActive(this->snapshots.back().udq_active());
|
||||
if (injection->updateUDQActive(this->getUDQConfig(handlerContext.currentStep), udq_active))
|
||||
this->snapshots.back().udq_active( std::move(udq_active) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1289,9 +1289,9 @@ namespace {
|
||||
if (cmode == Well::WELTARGCMode::GUID)
|
||||
update |= well2->updateWellGuideRate(new_arg.get<double>());
|
||||
|
||||
auto udq = std::make_shared<UDQActive>(this->udqActive(handlerContext.currentStep));
|
||||
if (prop->updateUDQActive(this->getUDQConfig(handlerContext.currentStep), *udq))
|
||||
this->updateUDQActive(handlerContext.currentStep, udq);
|
||||
auto udq_active = UDQActive(this->snapshots.back().udq_active());
|
||||
if (prop->updateUDQActive(this->getUDQConfig(handlerContext.currentStep), udq_active))
|
||||
this->snapshots.back().udq_active( std::move(udq_active));
|
||||
} else {
|
||||
auto inj = std::make_shared<Well::WellInjectionProperties>(well2->getInjectionProperties());
|
||||
inj->handleWELTARG(cmode, new_arg, SiFactorP);
|
||||
|
@ -114,7 +114,6 @@ namespace {
|
||||
m_sched_deck(deck, restart_info(rst) ),
|
||||
m_timeMap( deck , restart_info( rst )),
|
||||
udq_config(this->m_timeMap, std::make_shared<UDQConfig>(deck)),
|
||||
udq_active(this->m_timeMap, std::make_shared<UDQActive>()),
|
||||
guide_rate_config(this->m_timeMap, std::make_shared<GuideRateConfig>()),
|
||||
m_glo(this->m_timeMap, std::make_shared<GasLiftOpt>()),
|
||||
rft_config(this->m_timeMap),
|
||||
@ -253,7 +252,6 @@ namespace {
|
||||
result.groups.insert({"test2", {{std::make_shared<Opm::Group>(Opm::Group::serializeObject())},1}});
|
||||
result.udq_config = {{std::make_shared<UDQConfig>(UDQConfig::serializeObject())}, 1};
|
||||
result.m_glo = {{std::make_shared<GasLiftOpt>(GasLiftOpt::serializeObject())}, 1};
|
||||
result.udq_active = {{std::make_shared<UDQActive>(UDQActive::serializeObject())}, 1};
|
||||
result.guide_rate_config = {{std::make_shared<GuideRateConfig>(GuideRateConfig::serializeObject())}, 1};
|
||||
result.rft_config = RFTConfig::serializeObject();
|
||||
result.restart_config = RestartConfig::serializeObject();
|
||||
@ -1307,14 +1305,6 @@ void Schedule::iterateScheduleSection(std::size_t load_start, std::size_t load_e
|
||||
}
|
||||
|
||||
|
||||
const UDQActive& Schedule::udqActive(std::size_t timeStep) const {
|
||||
return *this->udq_active[timeStep];
|
||||
}
|
||||
|
||||
void Schedule::updateUDQActive( std::size_t timeStep, std::shared_ptr<UDQActive> udq ) {
|
||||
this->udq_active.update(timeStep, udq);
|
||||
}
|
||||
|
||||
const UDQConfig& Schedule::getUDQConfig(std::size_t timeStep) const {
|
||||
const auto& ptr = this->udq_config.get(timeStep);
|
||||
return *ptr;
|
||||
@ -1488,7 +1478,6 @@ void Schedule::iterateScheduleSection(std::size_t load_start, std::size_t load_e
|
||||
compareMap(this->groups, data.groups) &&
|
||||
compareDynState(this->m_glo, data.m_glo) &&
|
||||
compareDynState(this->udq_config, data.udq_config) &&
|
||||
compareDynState(this->udq_active, data.udq_active) &&
|
||||
compareDynState(this->guide_rate_config, data.guide_rate_config) &&
|
||||
rft_config == data.rft_config &&
|
||||
this->restart_config == data.restart_config &&
|
||||
@ -1899,6 +1888,7 @@ void Schedule::create_first(const std::chrono::system_clock::time_point& start_t
|
||||
sched_state.network( Network::ExtNetwork() );
|
||||
sched_state.rpt_config( RPTConfig() );
|
||||
sched_state.actions( Action::Actions() );
|
||||
sched_state.udq_active( UDQActive() );
|
||||
this->addGroup("FIELD", 0);
|
||||
}
|
||||
|
||||
|
@ -182,6 +182,7 @@ bool ScheduleState::operator==(const ScheduleState& other) const {
|
||||
*this->m_gconsump == *other.m_gconsump &&
|
||||
*this->m_wlist_manager == *other.m_wlist_manager &&
|
||||
*this->m_rptconfig == *other.m_rptconfig &&
|
||||
*this->m_udq_active == *other.m_udq_active &&
|
||||
this->m_nupcol == other.m_nupcol;
|
||||
}
|
||||
|
||||
@ -204,6 +205,7 @@ ScheduleState ScheduleState::serializeObject() {
|
||||
ts.m_vfpinj.emplace( std::make_pair(177, std::make_shared<VFPInjTable>(VFPInjTable::serializeObject() )));
|
||||
ts.m_vfpinj.emplace( std::make_pair(178, std::make_shared<VFPInjTable>(VFPInjTable::serializeObject() )));
|
||||
ts.m_actions = std::make_shared<Action::Actions>( Action::Actions::serializeObject() );
|
||||
ts.m_udq_active = std::make_shared<UDQActive>( UDQActive::serializeObject() );
|
||||
return ts;
|
||||
}
|
||||
|
||||
@ -345,4 +347,12 @@ void ScheduleState::actions(Action::Actions actions) {
|
||||
this->m_actions = std::make_shared<Action::Actions>( std::move(actions) );
|
||||
}
|
||||
|
||||
const UDQActive& ScheduleState::udq_active() const {
|
||||
return *this->m_udq_active;
|
||||
}
|
||||
|
||||
void ScheduleState::udq_active(UDQActive udq_active) {
|
||||
this->m_udq_active = std::make_shared<UDQActive>( std::move(udq_active) );
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1515,7 +1515,7 @@ BOOST_AUTO_TEST_CASE(IntegrationTest) {
|
||||
#include "data/integration_tests/udq.data"
|
||||
auto schedule = make_schedule(deck_string);
|
||||
{
|
||||
const auto& active = schedule.udqActive(1);
|
||||
const auto& active = schedule[1].udq_active();
|
||||
BOOST_CHECK_EQUAL(active.IUAD_size(), 6U);
|
||||
|
||||
BOOST_CHECK(active[0].control == UDAControl::WCONPROD_ORAT);
|
||||
@ -1595,7 +1595,7 @@ WCONPROD
|
||||
|
||||
// First timestep
|
||||
{
|
||||
const auto& udq_active = schedule.udqActive(0);
|
||||
const auto& udq_active = schedule[0].udq_active();
|
||||
BOOST_CHECK(udq_active);
|
||||
BOOST_CHECK_EQUAL(udq_active.IUAD_size(), 2U);
|
||||
|
||||
@ -1616,7 +1616,7 @@ WCONPROD
|
||||
// Second timestep
|
||||
// - The WUOPRU and WULPRU udq are still used in the same manner for the PROD1 well.
|
||||
// - The new UDQs WUXO and WUXL are now used for the PROD2 well.
|
||||
const auto& udq_active = schedule.udqActive(1);
|
||||
const auto& udq_active = schedule[1].udq_active();
|
||||
BOOST_CHECK(udq_active);
|
||||
BOOST_CHECK_EQUAL(udq_active.IUAD_size(), 4U);
|
||||
|
||||
@ -1649,7 +1649,7 @@ WCONPROD
|
||||
// Third timestep
|
||||
// - The new UDQs WUXO and WUXL are now used for the PROD2 well.
|
||||
// - The PROD1 well does not use UDQ
|
||||
const auto& udq_active = schedule.udqActive(2);
|
||||
const auto& udq_active = schedule[2].udq_active();
|
||||
BOOST_CHECK(udq_active);
|
||||
BOOST_CHECK_EQUAL(udq_active.IUAD_size(), 2U);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user