Merge pull request #2393 from joakim-hove/rst-bits

Add named constant IGroup::ExceedAction = 7
This commit is contained in:
Joakim Hove
2021-03-30 22:11:21 +02:00
committed by GitHub
9 changed files with 56 additions and 55 deletions

View File

@@ -41,8 +41,7 @@ struct RstGroup {
std::string name;
int parent_group;
int prod_active_cmode;
int gconprod_cmode;
int prod_cmode;
int winj_cmode;
int ginj_cmode;
int guide_rate_def;

View File

@@ -58,6 +58,7 @@ namespace Opm { namespace RestartIO { namespace Helpers { namespace VectorItems
enum index : std::vector<int>::size_type {
ProdActiveCMode = 1,
GuideRateDef = 6,
ExceedAction = 7,
WInjCMode = 16,
GConProdCMode = 10,
GInjCMode = 21,

View File

@@ -187,8 +187,7 @@ struct GroupProductionProperties {
GroupProductionProperties(const UnitSystem& unit_system, const std::string& gname);
std::string name;
ProductionCMode gconprod_cmode = ProductionCMode::NONE;
ProductionCMode active_cmode = ProductionCMode::NONE;
ProductionCMode cmode = ProductionCMode::NONE;
ExceedAction exceed_action = ExceedAction::NONE;
UDAValue oil_target;
UDAValue water_target;
@@ -209,8 +208,7 @@ struct GroupProductionProperties {
void serializeOp(Serializer& serializer)
{
serializer(name);
serializer(gconprod_cmode);
serializer(active_cmode);
serializer(cmode);
serializer(exceed_action);
oil_target.serializeOp(serializer);
water_target.serializeOp(serializer);
@@ -286,7 +284,7 @@ struct ProductionControls {
const GroupProductionProperties& productionProperties() const;
const std::map<Phase , GroupInjectionProperties>& injectionProperties() const;
const GroupType& getGroupType() const;
ProductionCMode gconprod_cmode() const;
ProductionCMode prod_cmode() const;
InjectionCMode injection_cmode() const;
Phase injection_phase() const;
bool has_control(ProductionCMode control) const;

View File

@@ -500,8 +500,9 @@ namespace Opm
const FieldPropsManager* fp,
const std::string& prefix);
void addACTIONX(const Action::ActionX& action);
void addGroupToGroup( const std::string& parent_group, const std::string& child_group, std::size_t timeStep);
void addGroupToGroup( const std::string& parent_group, const std::string& child_group);
void addGroup(const std::string& groupName , std::size_t timeStep);
void addGroup(Group group);
void addWell(const std::string& wellName, const DeckRecord& record, std::size_t timeStep, Connection::Order connection_order);
void checkIfAllConnectionsIsShut(std::size_t currentStep);
void handleKeyword(std::size_t currentStep,

View File

@@ -48,8 +48,8 @@ RstGroup::RstGroup(const ::Opm::UnitSystem& unit_system,
const double * xgrp) :
name(trim_copy(zwel[0])),
parent_group(igrp[header.nwgmax + VI::IGroup::ParentGroup] ),
prod_active_cmode(igrp[header.nwgmax + VI::IGroup::ProdActiveCMode]),
gconprod_cmode(igrp[header.nwgmax + VI::IGroup::GConProdCMode]),
// prod_active_cmode(igrp[header.nwgmax + VI::IGroup::ProdActiveCMode]),
prod_cmode(igrp[header.nwgmax + VI::IGroup::GConProdCMode]),
winj_cmode(igrp[header.nwgmax + VI::IGroup::WInjCMode]),
ginj_cmode(igrp[header.nwgmax + VI::IGroup::GInjCMode]),
guide_rate_def(igrp[header.nwgmax + VI::IGroup::GuideRateDef]),

View File

@@ -257,7 +257,7 @@ bool higherLevelProdCMode_NotNoneFld(const Opm::Schedule& sched,
auto current = group;
while (current.name() != "FIELD") {
current = sched.getGroup(current.parent(), simStep);
const auto& prod_cmode = group.gconprod_cmode();
const auto& prod_cmode = group.prod_cmode();
if (prod_cmode != Opm::Group::ProductionCMode::FLD)
return true;
@@ -317,7 +317,7 @@ void gconprodCMode(const Opm::Group& group,
IGrpArray& iGrp) {
using IGroup = ::Opm::RestartIO::Helpers::VectorItems::IGroup::index;
const auto& prod_cmode = group.gconprod_cmode();
const auto& prod_cmode = group.prod_cmode();
switch (prod_cmode) {
case Opm::Group::ProductionCMode::NONE:
iGrp[nwgmax + IGroup::GConProdCMode] = 0;
@@ -410,7 +410,7 @@ void productionGroup(const Opm::Schedule& sched,
// default value
const auto& cgroup = controlGroup(sched, sumState, group, simStep);
const auto& deck_cmode = group.gconprod_cmode();
const auto& deck_cmode = group.prod_cmode();
// Start branching for determining iGrp[nwgmax + 5]
// use default value if group is not available for group control
@@ -511,31 +511,31 @@ void productionGroup(const Opm::Schedule& sched,
const auto& p_exceed_act = production_controls.exceed_action;
switch (deck_cmode) {
case Opm::Group::ProductionCMode::NONE:
iGrp[nwgmax + 7] = (p_exceed_act == Opm::Group::ExceedAction::NONE) ? 0 : 4;
iGrp[nwgmax + IGroup::ExceedAction] = (p_exceed_act == Opm::Group::ExceedAction::NONE) ? 0 : 4;
break;
case Opm::Group::ProductionCMode::ORAT:
iGrp[nwgmax + 7] = (p_exceed_act == Opm::Group::ExceedAction::NONE) ? -40000 : 4;
iGrp[nwgmax + IGroup::ExceedAction] = (p_exceed_act == Opm::Group::ExceedAction::NONE) ? -40000 : 4;
break;
case Opm::Group::ProductionCMode::WRAT:
iGrp[nwgmax + 7] = (p_exceed_act == Opm::Group::ExceedAction::NONE) ? -4000 : 4;
iGrp[nwgmax + IGroup::ExceedAction] = (p_exceed_act == Opm::Group::ExceedAction::NONE) ? -4000 : 4;
break;
case Opm::Group::ProductionCMode::GRAT:
iGrp[nwgmax + 7] = (p_exceed_act == Opm::Group::ExceedAction::NONE) ? -400 : 4;
iGrp[nwgmax + IGroup::ExceedAction] = (p_exceed_act == Opm::Group::ExceedAction::NONE) ? -400 : 4;
break;
case Opm::Group::ProductionCMode::LRAT:
iGrp[nwgmax + 7] = (p_exceed_act == Opm::Group::ExceedAction::NONE) ? -40 : 4;
iGrp[nwgmax + IGroup::ExceedAction] = (p_exceed_act == Opm::Group::ExceedAction::NONE) ? -40 : 4;
break;
case Opm::Group::ProductionCMode::RESV:
iGrp[nwgmax + 7] = (p_exceed_act == Opm::Group::ExceedAction::NONE) ? -4 : 4; // need to be checked
iGrp[nwgmax + IGroup::ExceedAction] = (p_exceed_act == Opm::Group::ExceedAction::NONE) ? -4 : 4; // need to be checked
break;
case Opm::Group::ProductionCMode::FLD:
if (cgroup && (prod_guide_rate_def != Opm::Group::GuideRateProdTarget::NO_GUIDE_RATE)) {
iGrp[nwgmax + IGroup::GuideRateDef] = Value::GuideRateMode::Form;
}
iGrp[nwgmax + 7] = (p_exceed_act == Opm::Group::ExceedAction::NONE) ? 4 : 4;
iGrp[nwgmax + IGroup::ExceedAction] = (p_exceed_act == Opm::Group::ExceedAction::NONE) ? 4 : 4;
break;
default:
iGrp[nwgmax + 7] = 0;
iGrp[nwgmax + IGroup::ExceedAction] = 0;
}
}

View File

@@ -57,19 +57,18 @@ Group::Group(const std::string& name, std::size_t insert_index_arg, double udq_u
Group::Group(const RestartIO::RstGroup& rst_group, std::size_t insert_index_arg, double udq_undefined_arg, const UnitSystem& unit_system_arg) :
Group(rst_group.name, insert_index_arg, udq_undefined_arg, unit_system_arg)
{
if (rst_group.prod_active_cmode != 0) {
if (rst_group.prod_cmode != 0) {
Group::GroupProductionProperties production(unit_system_arg, this->m_name);
production.oil_target.update(rst_group.oil_rate_limit);
production.gas_target.update(rst_group.gas_rate_limit);
production.water_target.update(rst_group.water_rate_limit);
production.liquid_target.update(rst_group.liquid_rate_limit);
production.active_cmode = Group::ProductionCModeFromInt(rst_group.prod_active_cmode);
production.gconprod_cmode = Group::ProductionCModeFromInt(rst_group.gconprod_cmode);
production.cmode = Group::ProductionCModeFromInt(rst_group.prod_cmode);
production.guide_rate_def = Group::GuideRateProdTargetFromInt(rst_group.guide_rate_def);
if ((production.active_cmode == Group::ProductionCMode::ORAT) ||
(production.active_cmode == Group::ProductionCMode::WRAT) ||
(production.active_cmode == Group::ProductionCMode::GRAT) ||
(production.active_cmode == Group::ProductionCMode::LRAT))
if ((production.cmode == Group::ProductionCMode::ORAT) ||
(production.cmode == Group::ProductionCMode::WRAT) ||
(production.cmode == Group::ProductionCMode::GRAT) ||
(production.cmode == Group::ProductionCMode::LRAT))
production.exceed_action = Group::ExceedAction::RATE;
this->updateProduction(production);
}
@@ -291,8 +290,7 @@ Group::GroupProductionProperties Group::GroupProductionProperties::serializeObje
{
Group::GroupProductionProperties result(UnitSystem(UnitSystem::UnitType::UNIT_TYPE_METRIC), "Group123");
result.name = "Group123";
result.gconprod_cmode = ProductionCMode::PRBL;
result.active_cmode = ProductionCMode::PRBL;
result.cmode = ProductionCMode::PRBL;
result.exceed_action = ExceedAction::WELL;
result.oil_target = UDAValue(1.0);
result.water_target = UDAValue(2.0);
@@ -310,8 +308,7 @@ Group::GroupProductionProperties Group::GroupProductionProperties::serializeObje
bool Group::GroupProductionProperties::operator==(const GroupProductionProperties& other) const {
return
this->name == other.name &&
this->active_cmode == other.active_cmode &&
this->gconprod_cmode == other.gconprod_cmode &&
this->cmode == other.cmode &&
this->exceed_action == other.exceed_action &&
this->oil_target == other.oil_target &&
this->water_target == other.water_target &&
@@ -514,7 +511,7 @@ bool Group::updateParent(const std::string& parent) {
Group::ProductionControls Group::productionControls(const SummaryState& st) const {
Group::ProductionControls pc;
pc.cmode = this->production_properties.active_cmode;
pc.cmode = this->production_properties.cmode;
pc.exceed_action = this->production_properties.exceed_action;
pc.oil_target = UDA::eval_group_uda(this->production_properties.oil_target, this->m_name, st, this->udq_undefined);
pc.water_target = UDA::eval_group_uda(this->production_properties.water_target, this->m_name, st, this->udq_undefined);
@@ -556,8 +553,8 @@ bool Group::hasInjectionControl(Phase phase) const {
Group::ProductionCMode Group::gconprod_cmode() const {
return this->production_properties.gconprod_cmode;
Group::ProductionCMode Group::prod_cmode() const {
return this->production_properties.cmode;
}
bool Group::ProductionControls::has_control(Group::ProductionCMode control) const {

View File

@@ -469,8 +469,7 @@ namespace {
const bool availableForGroupControl { respond_to_parent && !is_field } ;
auto new_group = this->snapshots.back().groups.get(group_name);
Group::GroupProductionProperties production(this->m_static.m_unit_system, group_name);
production.gconprod_cmode = controlMode;
production.active_cmode = controlMode;
production.cmode = controlMode;
production.oil_target = oil_target;
production.gas_target = gas_target;
production.water_target = water_target;
@@ -480,10 +479,10 @@ namespace {
production.resv_target = resv_target;
production.available_group_control = availableForGroupControl;
if ((production.gconprod_cmode == Group::ProductionCMode::ORAT) ||
(production.gconprod_cmode == Group::ProductionCMode::WRAT) ||
(production.gconprod_cmode == Group::ProductionCMode::GRAT) ||
(production.gconprod_cmode == Group::ProductionCMode::LRAT))
if ((production.cmode == Group::ProductionCMode::ORAT) ||
(production.cmode == Group::ProductionCMode::WRAT) ||
(production.cmode == Group::ProductionCMode::GRAT) ||
(production.cmode == Group::ProductionCMode::LRAT))
production.exceed_action = Group::ExceedAction::RATE;
else
production.exceed_action = exceedAction;
@@ -667,7 +666,7 @@ namespace {
if (!this->snapshots.back().groups.has(parentName))
addGroup(parentName, handlerContext.currentStep);
this->addGroupToGroup(parentName, childName, handlerContext.currentStep);
this->addGroupToGroup(parentName, childName);
}
}
@@ -807,7 +806,7 @@ namespace {
We do not really handle the SAVE keyword, we just interpret it as: Write a
normal restart file at this report step.
*/
void Schedule::handleSAVE(const HandlerContext& handlerContext, const ParseContext&, ErrorGuard&) {
void Schedule::handleSAVE(const HandlerContext&, const ParseContext&, ErrorGuard&) {
auto rst_config = this->snapshots.back().rst_config();
rst_config.save = true;
this->snapshots.back().rst_config.update(std::move(rst_config));

View File

@@ -1009,34 +1009,40 @@ void Schedule::iterateScheduleSection(std::size_t load_start, std::size_t load_e
}
void Schedule::addGroup(const std::string& groupName, std::size_t timeStep) {
auto udq_undefined = this->getUDQConfig(timeStep).params().undefinedValue();
void Schedule::addGroup(Group group) {
std::string group_name = group.name();
auto& sched_state = this->snapshots.back();
auto insert_index = sched_state.groups.size();
sched_state.groups.update( Group{ groupName, insert_index, udq_undefined, this->m_static.m_unit_system} );
sched_state.groups.update(std::move(group) );
sched_state.events().addEvent( ScheduleEvents::NEW_GROUP );
sched_state.wellgroup_events().addGroup(groupName);
sched_state.wellgroup_events().addGroup(group_name);
{
auto go = sched_state.group_order.get();
go.add( groupName );
go.add( group_name );
sched_state.group_order.update( std::move(go) );
}
// All newly created groups are attached to the field group,
// can then be relocated with the GRUPTREE keyword.
if (groupName != "FIELD")
this->addGroupToGroup("FIELD", groupName, timeStep);
if (group_name != "FIELD")
this->addGroupToGroup("FIELD", group_name);
}
void Schedule::addGroupToGroup( const std::string& parent_name, const std::string& child_name, std::size_t timeStep) {
void Schedule::addGroup(const std::string& groupName, std::size_t timeStep) {
auto udq_undefined = this->getUDQConfig(timeStep).params().undefinedValue();
const auto& sched_state = this->snapshots.back();
auto insert_index = sched_state.groups.size();
this->addGroup( Group(groupName, insert_index, udq_undefined, this->m_static.m_unit_system) );
}
void Schedule::addGroupToGroup( const std::string& parent_name, const std::string& child_name) {
auto parent_group = this->snapshots.back().groups.get(parent_name);
if (parent_group.addGroup(child_name))
this->snapshots.back().groups.update( std::move(parent_group) );
// Check and update backreference in child
const auto& child_group = this->getGroup(child_name, timeStep);
const auto& child_group = this->snapshots.back().groups.get(child_name);
if (child_group.parent() != parent_name) {
auto old_parent = this->snapshots.back().groups.get(child_group.parent());
old_parent.delGroup(child_group.name());
@@ -1291,7 +1297,7 @@ namespace {
continue;
const auto& parent_group = rst_state.groups[rst_group.parent_group - 1];
this->addGroupToGroup(parent_group.name, rst_group.name, report_step);
this->addGroupToGroup(parent_group.name, rst_group.name);
}
for (const auto& rst_well : rst_state.wells) {