From 5746c068c505c83d3a2167bd8da18b39daf51ecd Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Wed, 4 Nov 2020 08:45:24 +0100 Subject: [PATCH 01/14] Add names for group type and level index --- opm/output/eclipse/VectorItems/group.hpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/opm/output/eclipse/VectorItems/group.hpp b/opm/output/eclipse/VectorItems/group.hpp index ec22a719e..444a2bfb5 100644 --- a/opm/output/eclipse/VectorItems/group.hpp +++ b/opm/output/eclipse/VectorItems/group.hpp @@ -61,6 +61,8 @@ namespace Opm { namespace RestartIO { namespace Helpers { namespace VectorItems WInjCMode = 16, GConProdCMode = 10, GInjCMode = 21, + GroupType = 26, + GroupLevel = 27, ParentGroup = 28, FlowingWells = 33, }; @@ -76,6 +78,12 @@ namespace Opm { namespace RestartIO { namespace Helpers { namespace VectorItems Form = 8, Comb = 9, }; + + enum GroupType : int { + WellGroup = 0, + TreeGroup = 1, + }; + } } From 2b6ffeb068c1b0f055a4b8f088229bb189819a9b Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Wed, 4 Nov 2020 08:49:18 +0100 Subject: [PATCH 02/14] Refactor IGRP StaticContrib --- src/opm/output/eclipse/AggregateGroupData.cpp | 131 +++++++++--------- 1 file changed, 66 insertions(+), 65 deletions(-) diff --git a/src/opm/output/eclipse/AggregateGroupData.cpp b/src/opm/output/eclipse/AggregateGroupData.cpp index ead49af4b..8b7b77962 100644 --- a/src/opm/output/eclipse/AggregateGroupData.cpp +++ b/src/opm/output/eclipse/AggregateGroupData.cpp @@ -395,20 +395,6 @@ int higherLevelInjCMode_NotNoneFld_SeqIndex(const Opm::Schedule& sched, } -int groupType(const Opm::Group& group) { - if (group.wellgroup()) - return 0; - else - return 1; -} - - -std::size_t groupSize(const Opm::Group& group) { - if (group.wellgroup()) - return group.wells().size(); - else - return group.groups().size(); -} namespace IGrp { std::size_t entriesPerGroup(const std::vector& inteHead) @@ -659,6 +645,7 @@ void injectionGroup(const Opm::Schedule& sched, auto group_parent_list = groupParentSeqIndex(sched, group, simStep); using IGroup = ::Opm::RestartIO::Helpers::VectorItems::IGroup::index; + // set "default value" in case a group is only injection group if (group.isInjectionGroup() && !group.isProductionGroup()) { iGrp[nwgmax + 5] = 1; @@ -827,6 +814,67 @@ void injectionGroup(const Opm::Schedule& sched, } } +template +void storeGroupTree(const Opm::Schedule& sched, + const Opm::Group& group, + const int nwgmax, + const int ngmaxz, + const std::size_t simStep, + IGrpArray& iGrp) { + + namespace Value = ::Opm::RestartIO::Helpers::VectorItems::IGroup::Value; + using IGroup = ::Opm::RestartIO::Helpers::VectorItems::IGroup::index; + const bool is_field = group.name() == "FIELD"; + + // Store index of all child wells or child groups. + if (group.wellgroup()) { + int igrpCount = 0; + for (const auto& well_name : group.wells()) { + const auto& well = sched.getWell(well_name, simStep); + iGrp[igrpCount] = well.seqIndex() + 1; + igrpCount += 1; + } + iGrp[nwgmax] = group.wells().size(); + iGrp[nwgmax + IGroup::GroupType] = Value::GroupType::WellGroup; + } else { + int igrpCount = 0; + for (const auto& group_name : group.groups()) { + const auto& child_group = sched.getGroup(group_name, simStep); + iGrp[igrpCount] = child_group.insert_index(); + igrpCount += 1; + } + iGrp[nwgmax] = group.groups().size(); + iGrp[nwgmax + IGroup::GroupType] = Value::GroupType::TreeGroup; + } + + + // Store index of parent group + if (is_field) + iGrp[nwgmax + IGroup::ParentGroup] = 0; + else { + const auto& parent_group = sched.getGroup(group.parent(), simStep); + if (parent_group.name() == "FIELD") + iGrp[nwgmax + IGroup::ParentGroup] = ngmaxz; + else + iGrp[nwgmax + IGroup::ParentGroup] = parent_group.insert_index(); + } + + iGrp[nwgmax + IGroup::GroupLevel] = currentGroupLevel(sched, group, simStep); +} + + +template +void storeFlowingWells(const Opm::Group& group, + const int nwgmax, + const Opm::SummaryState& sumState, + IGrpArray& iGrp) { + using IGroup = ::Opm::RestartIO::Helpers::VectorItems::IGroup::index; + const bool is_field = group.name() == "FIELD"; + const double g_act_pwells = is_field ? sumState.get("FMWPR", 0) : sumState.get_group_var(group.name(), "GMWPR", 0); + const double g_act_iwells = is_field ? sumState.get("FMWIN", 0) : sumState.get_group_var(group.name(), "GMWIN", 0); + iGrp[nwgmax + IGroup::FlowingWells] = static_cast(g_act_pwells) + static_cast(g_act_iwells); +} + template void staticContrib(const Opm::Schedule& sched, @@ -839,54 +887,22 @@ void staticContrib(const Opm::Schedule& sched, const std::map& cmodeToNum, IGrpArray& iGrp) { - using IGroup = ::Opm::RestartIO::Helpers::VectorItems::IGroup::index; const bool is_field = group.name() == "FIELD"; - if (group.wellgroup()) { - int igrpCount = 0; - //group has child wells - //store the well number (sequence index) in iGrp according to the sequence they are defined - for (const auto& well_name : group.wells()) { - const auto& well = sched.getWell(well_name, simStep); - iGrp[igrpCount] = well.seqIndex() + 1; - igrpCount += 1; - } - } else if (!group.groups().empty()) { - int igrpCount = 0; - for (const auto& group_name : group.groups()) { - const auto& child_group = sched.getGroup(group_name, simStep); - iGrp[igrpCount] = child_group.insert_index(); - igrpCount += 1; - } - } - //assign the number of child wells or child groups to - // location nwgmax - iGrp[nwgmax] = groupSize(group); + storeGroupTree(sched, group, nwgmax, ngmaxz, simStep, iGrp); + storeFlowingWells(group, nwgmax, sumState, iGrp); - // Find number of active production wells and injection wells for group - const double g_act_pwells = is_field ? sumState.get("FMWPR", 0) : sumState.get_group_var(group.name(), "GMWPR", 0); - const double g_act_iwells = is_field ? sumState.get("FMWIN", 0) : sumState.get_group_var(group.name(), "GMWIN", 0); - iGrp[nwgmax + IGroup::FlowingWells] = g_act_pwells + g_act_iwells; + iGrp[nwgmax + 17] = -1; + iGrp[nwgmax + 22] = -1; // Treat al groups which are *not* pure injection groups. if (group.getGroupType() != Opm::Group::GroupType::INJECTION) productionGroup(sched, group, nwgmax, simStep, sumState, pCtrlToPCmode, iGrp); - //default value - - iGrp[nwgmax + 17] = -1; - iGrp[nwgmax + 22] = -1; // Treat al groups which are *not* pure production groups. if (group.getGroupType() != Opm::Group::GroupType::PRODUCTION) injectionGroup(sched, group, nwgmax, simStep, sumState, cmodeToNum, iGrp); - iGrp[nwgmax + 26] = groupType(group); - - //find group level ("FIELD" is level 0) and store the level in - //location nwgmax + 27 - iGrp[nwgmax+27] = currentGroupLevel(sched, group, simStep); - - // set values for group probably connected to GCONPROD settings - // if (is_field) { //the maximum number of groups in the model @@ -907,21 +923,6 @@ void staticContrib(const Opm::Schedule& sched, iGrp[nwgmax+95] = group.insert_index(); iGrp[nwgmax+96] = group.insert_index(); } - - //find parent group and store index of parent group in - //location nwgmax + IGroup::ParentGroup - - using IGroup = ::Opm::RestartIO::Helpers::VectorItems::IGroup::index; - if (is_field) - iGrp[nwgmax + IGroup::ParentGroup] = 0; - else { - const auto& parent_group = sched.getGroup(group.parent(), simStep); - if (parent_group.name() == "FIELD") - iGrp[nwgmax + IGroup::ParentGroup] = ngmaxz; - else - iGrp[nwgmax + IGroup::ParentGroup] = parent_group.insert_index(); - } - } } // Igrp From 2820efc4634ec11fd69a589b0683199c9bb5a965 Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Wed, 4 Nov 2020 09:56:09 +0100 Subject: [PATCH 03/14] Extract assignment of GCONPROD cmode to separate function --- src/opm/output/eclipse/AggregateGroupData.cpp | 72 ++++++++++--------- 1 file changed, 38 insertions(+), 34 deletions(-) diff --git a/src/opm/output/eclipse/AggregateGroupData.cpp b/src/opm/output/eclipse/AggregateGroupData.cpp index 8b7b77962..7dbf2686c 100644 --- a/src/opm/output/eclipse/AggregateGroupData.cpp +++ b/src/opm/output/eclipse/AggregateGroupData.cpp @@ -415,6 +415,40 @@ allocate(const std::vector& inteHead) +template +void gconprodCMode(const Opm::Group& group, + const int nwgmax, + IGrpArray& iGrp) { + using IGroup = ::Opm::RestartIO::Helpers::VectorItems::IGroup::index; + + const auto& prod_cmode = group.gconprod_cmode(); + switch (prod_cmode) { + case Opm::Group::ProductionCMode::NONE: + iGrp[nwgmax + IGroup::GConProdCMode] = 0; + break; + case Opm::Group::ProductionCMode::ORAT: + iGrp[nwgmax + IGroup::GConProdCMode] = 1; + break; + case Opm::Group::ProductionCMode::WRAT: + iGrp[nwgmax + IGroup::GConProdCMode] = 2; + break; + case Opm::Group::ProductionCMode::GRAT: + iGrp[nwgmax + IGroup::GConProdCMode] = 3; + break; + case Opm::Group::ProductionCMode::LRAT: + iGrp[nwgmax + IGroup::GConProdCMode] = 4; + break; + case Opm::Group::ProductionCMode::RESV: + iGrp[nwgmax + IGroup::GConProdCMode] = 5; + break; + case Opm::Group::ProductionCMode::FLD: + iGrp[nwgmax + IGroup::GConProdCMode] = 0; // need to be checked!! + break; + default: + iGrp[nwgmax + IGroup::GConProdCMode] = 0; // need to be checked!! + } +} + template void productionGroup(const Opm::Schedule& sched, @@ -427,35 +461,11 @@ void productionGroup(const Opm::Schedule& sched, { using IGroup = ::Opm::RestartIO::Helpers::VectorItems::IGroup::index; namespace Value = ::Opm::RestartIO::Helpers::VectorItems::IGroup::Value; - const auto& prod_cmode = group.gconprod_cmode(); + gconprodCMode(group, nwgmax, iGrp); + if (group.name() == "FIELD") { iGrp[nwgmax + IGroup::GuideRateDef] = Value::GuideRateMode::None; iGrp[nwgmax + 7] = 0; - switch (prod_cmode) { - case Opm::Group::ProductionCMode::NONE: - iGrp[nwgmax + IGroup::GConProdCMode] = 0; - break; - case Opm::Group::ProductionCMode::ORAT: - iGrp[nwgmax + IGroup::GConProdCMode] = 1; - break; - case Opm::Group::ProductionCMode::WRAT: - iGrp[nwgmax + IGroup::GConProdCMode] = 2; - break; - case Opm::Group::ProductionCMode::GRAT: - iGrp[nwgmax + IGroup::GConProdCMode] = 3; - break; - case Opm::Group::ProductionCMode::LRAT: - iGrp[nwgmax + IGroup::GConProdCMode] = 4; - break; - case Opm::Group::ProductionCMode::RESV: - iGrp[nwgmax + IGroup::GConProdCMode] = 5; - break; - case Opm::Group::ProductionCMode::FLD: - iGrp[nwgmax + IGroup::GConProdCMode] = 0; - break; - default: - iGrp[nwgmax + IGroup::GConProdCMode] = 0; - } return; } @@ -508,6 +518,7 @@ void productionGroup(const Opm::Schedule& sched, iGrp[nwgmax + 5] = -1; const int higher_lev_ctrl = higherLevelProdControlGroupSeqIndex(sched, sumState, group, simStep); const int higher_lev_ctrl_mode = higherLevelProdControlMode(sched, sumState, group, simStep); + const auto& prod_cmode = group.gconprod_cmode(); // Start branching for determining iGrp[nwgmax + 5] // use default value if group is not available for group control if (groupProductionControllable(sched, sumState, group, simStep)) { @@ -592,41 +603,34 @@ void productionGroup(const Opm::Schedule& sched, iGrp[nwgmax + 9] = iGrp[nwgmax + IGroup::ProdActiveCMode]; iGrp[nwgmax + IGroup::GuideRateDef] = Value::GuideRateMode::None; + switch (prod_cmode) { case Opm::Group::ProductionCMode::NONE: iGrp[nwgmax + 7] = (p_exceed_act == Opm::Group::ExceedAction::NONE) ? 0 : 4; - iGrp[nwgmax + IGroup::GConProdCMode] = 0; break; case Opm::Group::ProductionCMode::ORAT: iGrp[nwgmax + 7] = (p_exceed_act == Opm::Group::ExceedAction::NONE) ? -40000 : 4; - iGrp[nwgmax + IGroup::GConProdCMode] = 1; break; case Opm::Group::ProductionCMode::WRAT: iGrp[nwgmax + 7] = (p_exceed_act == Opm::Group::ExceedAction::NONE) ? -4000 : 4; - iGrp[nwgmax + IGroup::GConProdCMode] = 2; break; case Opm::Group::ProductionCMode::GRAT: iGrp[nwgmax + 7] = (p_exceed_act == Opm::Group::ExceedAction::NONE) ? -400 : 4; - iGrp[nwgmax + IGroup::GConProdCMode] = 3; break; case Opm::Group::ProductionCMode::LRAT: iGrp[nwgmax + 7] = (p_exceed_act == Opm::Group::ExceedAction::NONE) ? -40 : 4; - iGrp[nwgmax + IGroup::GConProdCMode] = 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::GConProdCMode] = 5; break; case Opm::Group::ProductionCMode::FLD: if ((higher_lev_ctrl > 0) && (prod_guide_rate_def != Opm::Group::GuideRateTarget::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::GConProdCMode] = 0; // need to be checked!! break; default: iGrp[nwgmax + 7] = 0; - iGrp[nwgmax + IGroup::GConProdCMode] = 0; // need to be checked!! } } From 4e5cc1c94d9558db8fce5d9e2a82c7b52e43b58f Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Wed, 4 Nov 2020 10:41:01 +0100 Subject: [PATCH 04/14] Refactor function groupInjectionControllable() --- src/opm/output/eclipse/AggregateGroupData.cpp | 62 ++++++++----------- 1 file changed, 25 insertions(+), 37 deletions(-) diff --git a/src/opm/output/eclipse/AggregateGroupData.cpp b/src/opm/output/eclipse/AggregateGroupData.cpp index 7dbf2686c..fc2a83f36 100644 --- a/src/opm/output/eclipse/AggregateGroupData.cpp +++ b/src/opm/output/eclipse/AggregateGroupData.cpp @@ -156,50 +156,38 @@ bool groupProductionControllable(const Opm::Schedule& sched, const Opm::SummaryS } } -bool groupInjectionControllable(const Opm::Schedule& sched, const Opm::SummaryState& sumState, const Opm::Group& group, const Opm::Phase& iPhase, const size_t simStep) +void groupInjectionControllable(const Opm::Schedule& sched, const Opm::SummaryState& sumState, const Opm::Group& group, const Opm::Phase& iPhase, const size_t simStep, bool& controllable) { using wellCtrlMode = ::Opm::RestartIO::Helpers::VectorItems::IWell::Value::WellCtrlMode; - bool controllable = false; - if (group.defined( simStep )) { - if (!group.wellgroup()) { - if(!group.groups().empty()) { - for (const auto& group_name : group.groups()) { - if (groupInjectionControllable(sched, sumState, sched.getGroup(group_name, simStep), iPhase, simStep)) { - controllable = true; - continue; - } - } + if (controllable) + return; + + for (const auto& group_name : group.groups()) + groupInjectionControllable(sched, sumState, sched.getGroup(group_name, simStep), iPhase, simStep, controllable); + + for (const auto& well_name : group.wells()) { + const auto& well = sched.getWell(well_name, simStep); + if (well.isInjector() && iPhase == well.wellType().injection_phase()) { + int cur_inj_ctrl = 0; + // Find control mode for well + const std::string sum_key = "WMCTL"; + if (sumState.has_well_var(well_name, sum_key)) { + cur_inj_ctrl = static_cast(sumState.get_well_var(well_name, sum_key)); + } + + if (cur_inj_ctrl == wellCtrlMode::Group) { + controllable = true; + return; } } - else { - for (const auto& well_name : group.wells()) { - const auto& well = sched.getWell(well_name, simStep); - if (well.isInjector()) { - if (((iPhase == Opm::Phase::WATER) && (well.injectionControls(sumState).injector_type == Opm::InjectorType::WATER)) || - ((iPhase == Opm::Phase::GAS) && (well.injectionControls(sumState).injector_type == Opm::InjectorType::GAS)) - ) { - int cur_inj_ctrl = 0; - // Find control mode for well - std::string well_key_1 = "WMCTL:" + well_name; - if (sumState.has(well_key_1)) { - cur_inj_ctrl = static_cast(sumState.get(well_key_1)); - } - if (cur_inj_ctrl == wellCtrlMode::Group) { - controllable = true; - continue; - } - } - } - } - } - return controllable; - } else { - std::stringstream str; - str << "actual group has not been defined at report time: " << simStep; - throw std::invalid_argument(str.str()); } } +bool groupInjectionControllable(const Opm::Schedule& sched, const Opm::SummaryState& sumState, const Opm::Group& group, const Opm::Phase& iPhase, const size_t simStep) { + bool controllable = false; + groupInjectionControllable(sched, sumState, group, iPhase, simStep, controllable); + return controllable; +} int higherLevelProdControlGroupSeqIndex(const Opm::Schedule& sched, From b28ed60b02daff03e3214033c9869a9c1e06651d Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Wed, 4 Nov 2020 11:49:17 +0100 Subject: [PATCH 05/14] Reactor function groupProductionControllable() --- src/opm/output/eclipse/AggregateGroupData.cpp | 60 +++++++++---------- 1 file changed, 27 insertions(+), 33 deletions(-) diff --git a/src/opm/output/eclipse/AggregateGroupData.cpp b/src/opm/output/eclipse/AggregateGroupData.cpp index fc2a83f36..980e48f07 100644 --- a/src/opm/output/eclipse/AggregateGroupData.cpp +++ b/src/opm/output/eclipse/AggregateGroupData.cpp @@ -116,46 +116,40 @@ int currentGroupLevel(const Opm::Schedule& sched, const Opm::Group& group, const } } -bool groupProductionControllable(const Opm::Schedule& sched, const Opm::SummaryState& sumState, const Opm::Group& group, const size_t simStep) +void groupProductionControllable(const Opm::Schedule& sched, const Opm::SummaryState& sumState, const Opm::Group& group, const size_t simStep, bool& controllable) { using wellCtrlMode = ::Opm::RestartIO::Helpers::VectorItems::IWell::Value::WellCtrlMode; - bool controllable = false; - if (group.defined( simStep )) { - if (!group.wellgroup()) { - if(!group.groups().empty()) { - for (const auto& group_name : group.groups()) { - if (groupProductionControllable(sched, sumState, sched.getGroup(group_name, simStep), simStep)) { - controllable = true; - continue; - } - } + if (controllable) + return; + + for (const auto& group_name : group.groups()) + groupProductionControllable(sched, sumState, sched.getGroup(group_name, simStep), simStep, controllable); + + for (const auto& well_name : group.wells()) { + const auto& well = sched.getWell(well_name, simStep); + if (well.isProducer()) { + int cur_prod_ctrl = 0; + // Find control mode for well + const std::string sum_key = "WMCTL"; + if (sumState.has_well_var(well_name, sum_key)) { + cur_prod_ctrl = static_cast(sumState.get_well_var(well_name, sum_key)); + } + if (cur_prod_ctrl == wellCtrlMode::Group) { + controllable = true; + return; } } - else { - for (const auto& well_name : group.wells()) { - const auto& well = sched.getWell(well_name, simStep); - if (well.isProducer()) { - int cur_prod_ctrl = 0; - // Find control mode for well - std::string well_key_1 = "WMCTL:" + well_name; - if (sumState.has(well_key_1)) { - cur_prod_ctrl = static_cast(sumState.get(well_key_1)); - } - if (cur_prod_ctrl == wellCtrlMode::Group) { - controllable = true; - continue; - } - } - } - } - return controllable; - } else { - std::stringstream str; - str << "actual group has not been defined at report time: " << simStep; - throw std::invalid_argument(str.str()); } } + +bool groupProductionControllable(const Opm::Schedule& sched, const Opm::SummaryState& sumState, const Opm::Group& group, const size_t simStep) { + bool controllable = false; + groupProductionControllable(sched, sumState, group, simStep, controllable); + return controllable; +} + + void groupInjectionControllable(const Opm::Schedule& sched, const Opm::SummaryState& sumState, const Opm::Group& group, const Opm::Phase& iPhase, const size_t simStep, bool& controllable) { using wellCtrlMode = ::Opm::RestartIO::Helpers::VectorItems::IWell::Value::WellCtrlMode; From ee662f8e38a15b7f5f6b7f343ff3525b9609cca8 Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Wed, 4 Nov 2020 12:07:27 +0100 Subject: [PATCH 06/14] Store GroupProductionControls in local variable --- src/opm/output/eclipse/AggregateGroupData.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/opm/output/eclipse/AggregateGroupData.cpp b/src/opm/output/eclipse/AggregateGroupData.cpp index 980e48f07..23deec0cb 100644 --- a/src/opm/output/eclipse/AggregateGroupData.cpp +++ b/src/opm/output/eclipse/AggregateGroupData.cpp @@ -451,9 +451,9 @@ void productionGroup(const Opm::Schedule& sched, return; } - - const auto& prod_guide_rate_def = group.productionControls(sumState).guide_rate_def; - const auto& p_exceed_act = group.productionControls(sumState).exceed_action; + const auto& production_controls = group.productionControls(sumState); + const auto& prod_guide_rate_def = production_controls.guide_rate_def; + const auto& p_exceed_act = production_controls.exceed_action; // Find production control mode for group const double cur_prod_ctrl = sumState.get_group_var(group.name(), "GMCTP", -1); Opm::Group::ProductionCMode pctl_mode = Opm::Group::ProductionCMode::NONE; @@ -514,7 +514,7 @@ void productionGroup(const Opm::Schedule& sched, iGrp[nwgmax + 5] = -1; // only value that seems to work when no group at higher level has active control } else if (higher_lev_ctrl > 0) { if (((prod_cmode == Opm::Group::ProductionCMode::FLD) || (prod_cmode == Opm::Group::ProductionCMode::NONE)) - && (group.productionControls(sumState).guide_rate_def != Opm::Group::GuideRateTarget::NO_GUIDE_RATE)) { + && (prod_guide_rate_def != Opm::Group::GuideRateTarget::NO_GUIDE_RATE)) { iGrp[nwgmax + 5] = higher_lev_ctrl; } else { iGrp[nwgmax + 5] = 1; From a65bb1e9691fa4c0b86debadfa6e0159266ba0a5 Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Wed, 4 Nov 2020 12:12:01 +0100 Subject: [PATCH 07/14] Rename prod_cmode -> deck_cmode --- src/opm/output/eclipse/AggregateGroupData.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/opm/output/eclipse/AggregateGroupData.cpp b/src/opm/output/eclipse/AggregateGroupData.cpp index 23deec0cb..8fc41c35c 100644 --- a/src/opm/output/eclipse/AggregateGroupData.cpp +++ b/src/opm/output/eclipse/AggregateGroupData.cpp @@ -500,7 +500,7 @@ void productionGroup(const Opm::Schedule& sched, iGrp[nwgmax + 5] = -1; const int higher_lev_ctrl = higherLevelProdControlGroupSeqIndex(sched, sumState, group, simStep); const int higher_lev_ctrl_mode = higherLevelProdControlMode(sched, sumState, group, simStep); - const auto& prod_cmode = group.gconprod_cmode(); + const auto& deck_cmode = group.gconprod_cmode(); // Start branching for determining iGrp[nwgmax + 5] // use default value if group is not available for group control if (groupProductionControllable(sched, sumState, group, simStep)) { @@ -513,26 +513,26 @@ void productionGroup(const Opm::Schedule& sched, // if (pctl_mode != Opm::Group::ProductionCMode::FLD) - need to use this test? - else remove iGrp[nwgmax + 5] = -1; // only value that seems to work when no group at higher level has active control } else if (higher_lev_ctrl > 0) { - if (((prod_cmode == Opm::Group::ProductionCMode::FLD) || (prod_cmode == Opm::Group::ProductionCMode::NONE)) + if (((deck_cmode == Opm::Group::ProductionCMode::FLD) || (deck_cmode == Opm::Group::ProductionCMode::NONE)) && (prod_guide_rate_def != Opm::Group::GuideRateTarget::NO_GUIDE_RATE)) { iGrp[nwgmax + 5] = higher_lev_ctrl; } else { iGrp[nwgmax + 5] = 1; } } else if (higherLevelProdCMode_NotNoneFld(sched, group, simStep)) { - if (!((prod_cmode == Opm::Group::ProductionCMode::FLD) - || (prod_cmode == Opm::Group::ProductionCMode::NONE))) { + if (!((deck_cmode == Opm::Group::ProductionCMode::FLD) + || (deck_cmode == Opm::Group::ProductionCMode::NONE))) { iGrp[nwgmax + 5] = -1; } else { iGrp[nwgmax + 5] = 1; } - } else if ((prod_cmode == Opm::Group::ProductionCMode::FLD) - || (prod_cmode == Opm::Group::ProductionCMode::NONE)) { + } else if ((deck_cmode == Opm::Group::ProductionCMode::FLD) + || (deck_cmode == Opm::Group::ProductionCMode::NONE)) { iGrp[nwgmax + 5] = -1; } else { iGrp[nwgmax + 5] = -1; } - } else if (prod_cmode == Opm::Group::ProductionCMode::NONE) { + } else if (deck_cmode == Opm::Group::ProductionCMode::NONE) { iGrp[nwgmax + 5] = 1; } @@ -586,7 +586,7 @@ void productionGroup(const Opm::Schedule& sched, iGrp[nwgmax + IGroup::GuideRateDef] = Value::GuideRateMode::None; - switch (prod_cmode) { + switch (deck_cmode) { case Opm::Group::ProductionCMode::NONE: iGrp[nwgmax + 7] = (p_exceed_act == Opm::Group::ExceedAction::NONE) ? 0 : 4; break; From 4ca4e865c9ed1cdb80fe3398777c4783ec4bd848 Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Wed, 4 Nov 2020 12:13:17 +0100 Subject: [PATCH 08/14] Rename pctl_mode -> active_cmode --- src/opm/output/eclipse/AggregateGroupData.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/opm/output/eclipse/AggregateGroupData.cpp b/src/opm/output/eclipse/AggregateGroupData.cpp index 8fc41c35c..c6b92077f 100644 --- a/src/opm/output/eclipse/AggregateGroupData.cpp +++ b/src/opm/output/eclipse/AggregateGroupData.cpp @@ -456,11 +456,11 @@ void productionGroup(const Opm::Schedule& sched, const auto& p_exceed_act = production_controls.exceed_action; // Find production control mode for group const double cur_prod_ctrl = sumState.get_group_var(group.name(), "GMCTP", -1); - Opm::Group::ProductionCMode pctl_mode = Opm::Group::ProductionCMode::NONE; + Opm::Group::ProductionCMode active_cmode = Opm::Group::ProductionCMode::NONE; if (cur_prod_ctrl >= 0) { const auto it_ctrl = pCtrlToPCmode.find(cur_prod_ctrl); if (it_ctrl != pCtrlToPCmode.end()) { - pctl_mode = it_ctrl->second; + active_cmode = it_ctrl->second; } } #if ENABLE_GCNTL_DEBUG_OUTPUT @@ -508,9 +508,9 @@ void productionGroup(const Opm::Schedule& sched, if (!group.productionGroupControlAvailable() && (higher_lev_ctrl <= 0)) { // group can respond to higher level control iGrp[nwgmax + 5] = 0; - } else if (((pctl_mode != Opm::Group::ProductionCMode::NONE)) && (higher_lev_ctrl < 0)) { + } else if (((active_cmode != Opm::Group::ProductionCMode::NONE)) && (higher_lev_ctrl < 0)) { // group is constrained by its own limits or controls - // if (pctl_mode != Opm::Group::ProductionCMode::FLD) - need to use this test? - else remove + // if (active_cmode != Opm::Group::ProductionCMode::FLD) - need to use this test? - else remove iGrp[nwgmax + 5] = -1; // only value that seems to work when no group at higher level has active control } else if (higher_lev_ctrl > 0) { if (((deck_cmode == Opm::Group::ProductionCMode::FLD) || (deck_cmode == Opm::Group::ProductionCMode::NONE)) @@ -556,7 +556,7 @@ void productionGroup(const Opm::Schedule& sched, iGrp[nwgmax + IGroup::ProdActiveCMode] = (prod_guide_rate_def != Opm::Group::GuideRateTarget::NO_GUIDE_RATE) ? higher_lev_ctrl_mode : 0; } else { - switch (pctl_mode) { + switch (active_cmode) { case Opm::Group::ProductionCMode::NONE: iGrp[nwgmax + IGroup::ProdActiveCMode] = 0; break; From 05814ad90ec36e98843ae84b024822132e09ca49 Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Wed, 4 Nov 2020 12:20:40 +0100 Subject: [PATCH 09/14] Simplified initialization --- src/opm/output/eclipse/AggregateGroupData.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/opm/output/eclipse/AggregateGroupData.cpp b/src/opm/output/eclipse/AggregateGroupData.cpp index c6b92077f..6e250386e 100644 --- a/src/opm/output/eclipse/AggregateGroupData.cpp +++ b/src/opm/output/eclipse/AggregateGroupData.cpp @@ -453,16 +453,13 @@ void productionGroup(const Opm::Schedule& sched, const auto& production_controls = group.productionControls(sumState); const auto& prod_guide_rate_def = production_controls.guide_rate_def; - const auto& p_exceed_act = production_controls.exceed_action; - // Find production control mode for group - const double cur_prod_ctrl = sumState.get_group_var(group.name(), "GMCTP", -1); Opm::Group::ProductionCMode active_cmode = Opm::Group::ProductionCMode::NONE; - if (cur_prod_ctrl >= 0) { - const auto it_ctrl = pCtrlToPCmode.find(cur_prod_ctrl); - if (it_ctrl != pCtrlToPCmode.end()) { - active_cmode = it_ctrl->second; - } + { + auto cur_prod_ctrl = sumState.get_group_var(group.name(), "GMCTP", -1); + if (cur_prod_ctrl >= 0) + active_cmode = pCtrlToPCmode.at(static_cast(cur_prod_ctrl)); } + #if ENABLE_GCNTL_DEBUG_OUTPUT else { // std::stringstream str; @@ -586,6 +583,7 @@ void productionGroup(const Opm::Schedule& sched, iGrp[nwgmax + IGroup::GuideRateDef] = Value::GuideRateMode::None; + 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; From 2ae5d6634df276955bddb9928566f6883f6f8c34 Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Wed, 4 Nov 2020 16:05:02 +0100 Subject: [PATCH 10/14] Use std::optional when searching upwards for control group --- src/opm/output/eclipse/AggregateGroupData.cpp | 111 +++++------------- 1 file changed, 31 insertions(+), 80 deletions(-) diff --git a/src/opm/output/eclipse/AggregateGroupData.cpp b/src/opm/output/eclipse/AggregateGroupData.cpp index 6e250386e..ceb86bebf 100644 --- a/src/opm/output/eclipse/AggregateGroupData.cpp +++ b/src/opm/output/eclipse/AggregateGroupData.cpp @@ -183,79 +183,24 @@ bool groupInjectionControllable(const Opm::Schedule& sched, const Opm::SummarySt return controllable; } +/* + Searches upwards in the group tree for the first parent group with active + control different from NONE and FLD. The function will return an empty + optional if no such group can be found. +*/ -int higherLevelProdControlGroupSeqIndex(const Opm::Schedule& sched, - const Opm::SummaryState& sumState, - const Opm::Group& group, - const size_t simStep) -// -// returns the sequence number of higher (highest) level group with active control different from (NONE or FLD) -// -{ - int ctrl_grup_seq_no = -1; - if (group.defined( simStep )) { - auto current = group; - double cur_prod_ctrl = -1.; - while (current.name() != "FIELD" && ctrl_grup_seq_no < 0) { - current = sched.getGroup(current.parent(), simStep); - cur_prod_ctrl = -1.; - if (sumState.has_group_var(current.name(), "GMCTP")) { - cur_prod_ctrl = sumState.get_group_var(current.name(), "GMCTP"); - } - else { -#if ENABLE_GCNTL_DEBUG_OUTPUT - std::cout << "Current group control is not defined for group: " << current.name() << " at timestep: " << simStep << std::endl; -#endif // ENABLE_GCNTL_DEBUG_OUTPUT - cur_prod_ctrl = 0.; - } - if (cur_prod_ctrl > 0. && ctrl_grup_seq_no < 0) { - ctrl_grup_seq_no = current.insert_index(); - } - } - return ctrl_grup_seq_no; - } - else { - std::stringstream str; - str << "actual group has not been defined at report time: " << simStep; - throw std::invalid_argument(str.str()); - } -} - -int higherLevelProdControlMode(const Opm::Schedule& sched, - const Opm::SummaryState& sumState, - const Opm::Group& group, - const size_t simStep) -// -// returns the sequence number of higher (highest) level group with active control different from (NONE or FLD) -// -{ - int ctrl_mode = -1; - if (group.defined( simStep )) { - auto current = group; - double cur_prod_ctrl = -1.; - while (current.name() != "FIELD" && ctrl_mode < 0.) { - current = sched.getGroup(current.parent(), simStep); - cur_prod_ctrl = -1.; - if (sumState.has_group_var(current.name(), "GMCTP")) { - cur_prod_ctrl = sumState.get_group_var(current.name(), "GMCTP"); - } - else { -#if ENABLE_GCNTL_DEBUG_OUTPUT - std::cout << "Current group control is not defined for group: " << current.name() << " at timestep: " << simStep << std::endl; -#endif // ENABLE_GCNTL_DEBUG_OUTPUT - cur_prod_ctrl = 0.; - } - if (cur_prod_ctrl > 0. && ctrl_mode < 0) { - ctrl_mode = static_cast(cur_prod_ctrl); - } - } - return ctrl_mode; - } - else { - std::stringstream str; - str << "actual group has not been defined at report time: " << simStep; - throw std::invalid_argument(str.str()); +std::optional controlGroup(const Opm::Schedule& sched, + const Opm::SummaryState& sumState, + const Opm::Group& group, + const std::size_t simStep) { + auto current = group; + while (current.name() != "FIELD") { + current = sched.getGroup(current.parent(), simStep); + auto cur_prod_ctrl = sumState.get_group_var(current.name(), "GMCTP", 0); + if (cur_prod_ctrl > 0) + return current; } + return {}; } @@ -494,25 +439,30 @@ void productionGroup(const Opm::Schedule& sched, */ // default value + iGrp[nwgmax + 5] = -1; - const int higher_lev_ctrl = higherLevelProdControlGroupSeqIndex(sched, sumState, group, simStep); - const int higher_lev_ctrl_mode = higherLevelProdControlMode(sched, sumState, group, simStep); + const auto& cgroup = controlGroup(sched, sumState, group, simStep); const auto& deck_cmode = group.gconprod_cmode(); // Start branching for determining iGrp[nwgmax + 5] // use default value if group is not available for group control + + if (cgroup && cgroup->name() == "FIELD") + throw std::logic_error("Got cgroup == FIELD - uncertain logic"); + + if (groupProductionControllable(sched, sumState, group, simStep)) { // this section applies if group is controllable - i.e. has wells that may be controlled - if (!group.productionGroupControlAvailable() && (higher_lev_ctrl <= 0)) { + if (!group.productionGroupControlAvailable() && (!cgroup)) { // group can respond to higher level control iGrp[nwgmax + 5] = 0; - } else if (((active_cmode != Opm::Group::ProductionCMode::NONE)) && (higher_lev_ctrl < 0)) { + } else if (((active_cmode != Opm::Group::ProductionCMode::NONE)) && (!cgroup)) { // group is constrained by its own limits or controls // if (active_cmode != Opm::Group::ProductionCMode::FLD) - need to use this test? - else remove iGrp[nwgmax + 5] = -1; // only value that seems to work when no group at higher level has active control - } else if (higher_lev_ctrl > 0) { + } else if (cgroup) { if (((deck_cmode == Opm::Group::ProductionCMode::FLD) || (deck_cmode == Opm::Group::ProductionCMode::NONE)) && (prod_guide_rate_def != Opm::Group::GuideRateTarget::NO_GUIDE_RATE)) { - iGrp[nwgmax + 5] = higher_lev_ctrl; + iGrp[nwgmax + 5] = cgroup->insert_index(); } else { iGrp[nwgmax + 5] = 1; } @@ -549,9 +499,10 @@ void productionGroup(const Opm::Schedule& sched, Other reduction options are currently not covered in the code */ - if (higher_lev_ctrl > 0 && (group.getGroupType() != Opm::Group::GroupType::NONE)) { + if (cgroup && (group.getGroupType() != Opm::Group::GroupType::NONE)) { + auto cgroup_control = static_cast(sumState.get_group_var(cgroup->name(), "GMCTP", 0)); iGrp[nwgmax + IGroup::ProdActiveCMode] - = (prod_guide_rate_def != Opm::Group::GuideRateTarget::NO_GUIDE_RATE) ? higher_lev_ctrl_mode : 0; + = (prod_guide_rate_def != Opm::Group::GuideRateTarget::NO_GUIDE_RATE) ? cgroup_control : 0; } else { switch (active_cmode) { case Opm::Group::ProductionCMode::NONE: @@ -604,7 +555,7 @@ void productionGroup(const Opm::Schedule& sched, iGrp[nwgmax + 7] = (p_exceed_act == Opm::Group::ExceedAction::NONE) ? -4 : 4; // need to be checked break; case Opm::Group::ProductionCMode::FLD: - if ((higher_lev_ctrl > 0) && (prod_guide_rate_def != Opm::Group::GuideRateTarget::NO_GUIDE_RATE)) { + if (cgroup && (prod_guide_rate_def != Opm::Group::GuideRateTarget::NO_GUIDE_RATE)) { iGrp[nwgmax + IGroup::GuideRateDef] = Value::GuideRateMode::Form; } iGrp[nwgmax + 7] = (p_exceed_act == Opm::Group::ExceedAction::NONE) ? 4 : 4; From 618595e5382350947193451bd0d1905dcf6728d2 Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Thu, 5 Nov 2020 08:53:21 +0100 Subject: [PATCH 11/14] Rewrite branching logic in AggregateGroupData --- src/opm/output/eclipse/AggregateGroupData.cpp | 43 ++++++++++++------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/src/opm/output/eclipse/AggregateGroupData.cpp b/src/opm/output/eclipse/AggregateGroupData.cpp index ceb86bebf..1a63ba72b 100644 --- a/src/opm/output/eclipse/AggregateGroupData.cpp +++ b/src/opm/output/eclipse/AggregateGroupData.cpp @@ -440,7 +440,6 @@ void productionGroup(const Opm::Schedule& sched, */ // default value - iGrp[nwgmax + 5] = -1; const auto& cgroup = controlGroup(sched, sumState, group, simStep); const auto& deck_cmode = group.gconprod_cmode(); // Start branching for determining iGrp[nwgmax + 5] @@ -450,38 +449,52 @@ void productionGroup(const Opm::Schedule& sched, throw std::logic_error("Got cgroup == FIELD - uncertain logic"); + iGrp[nwgmax + 5] = -1; if (groupProductionControllable(sched, sumState, group, simStep)) { // this section applies if group is controllable - i.e. has wells that may be controlled if (!group.productionGroupControlAvailable() && (!cgroup)) { // group can respond to higher level control iGrp[nwgmax + 5] = 0; - } else if (((active_cmode != Opm::Group::ProductionCMode::NONE)) && (!cgroup)) { + goto CGROUP_DONE; + } + + + if (((active_cmode != Opm::Group::ProductionCMode::NONE)) && (!cgroup)) { // group is constrained by its own limits or controls // if (active_cmode != Opm::Group::ProductionCMode::FLD) - need to use this test? - else remove iGrp[nwgmax + 5] = -1; // only value that seems to work when no group at higher level has active control - } else if (cgroup) { + goto CGROUP_DONE; + } + + + if (cgroup) { if (((deck_cmode == Opm::Group::ProductionCMode::FLD) || (deck_cmode == Opm::Group::ProductionCMode::NONE)) && (prod_guide_rate_def != Opm::Group::GuideRateTarget::NO_GUIDE_RATE)) { iGrp[nwgmax + 5] = cgroup->insert_index(); } else { iGrp[nwgmax + 5] = 1; } - } else if (higherLevelProdCMode_NotNoneFld(sched, group, simStep)) { - if (!((deck_cmode == Opm::Group::ProductionCMode::FLD) - || (deck_cmode == Opm::Group::ProductionCMode::NONE))) { - iGrp[nwgmax + 5] = -1; - } else { - iGrp[nwgmax + 5] = 1; - } - } else if ((deck_cmode == Opm::Group::ProductionCMode::FLD) - || (deck_cmode == Opm::Group::ProductionCMode::NONE)) { - iGrp[nwgmax + 5] = -1; - } else { - iGrp[nwgmax + 5] = -1; + goto CGROUP_DONE; } + + + if (higherLevelProdCMode_NotNoneFld(sched, group, simStep)) { + iGrp[nwgmax + 5] = -1; + + if (deck_cmode == Opm::Group::ProductionCMode::FLD) + iGrp[nwgmax] = 1; + if (deck_cmode == Opm::Group::ProductionCMode::NONE) + iGrp[nwgmax] = 1; + + goto CGROUP_DONE; + } + + goto CGROUP_DONE; } else if (deck_cmode == Opm::Group::ProductionCMode::NONE) { iGrp[nwgmax + 5] = 1; } + CGROUP_DONE: + // Set iGrp for [nwgmax + 7] /* From 25731a67dde2f425bea697844d57901e52c58d8c Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Thu, 5 Nov 2020 09:39:57 +0100 Subject: [PATCH 12/14] Minor refactor of function --- src/opm/output/eclipse/AggregateGroupData.cpp | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/opm/output/eclipse/AggregateGroupData.cpp b/src/opm/output/eclipse/AggregateGroupData.cpp index 1a63ba72b..d40324cc9 100644 --- a/src/opm/output/eclipse/AggregateGroupData.cpp +++ b/src/opm/output/eclipse/AggregateGroupData.cpp @@ -274,23 +274,19 @@ bool higherLevelProdCMode_NotNoneFld(const Opm::Schedule& sched, const Opm::Group& group, const size_t simStep) { - bool ctrl_mode_not_none_fld = false; - if (group.defined( simStep )) { - auto current = group; - while (current.name() != "FIELD" && ctrl_mode_not_none_fld == false) { - current = sched.getGroup(current.parent(), simStep); - const auto& prod_cmode = group.gconprod_cmode(); - if ((prod_cmode != Opm::Group::ProductionCMode::FLD) && (prod_cmode!= Opm::Group::ProductionCMode::NONE)) { - ctrl_mode_not_none_fld = true; - } - } - return ctrl_mode_not_none_fld; - } - else { - std::stringstream str; - str << "actual group has not been defined at report time: " << simStep; - throw std::invalid_argument(str.str()); + auto current = group; + while (current.name() != "FIELD") { + current = sched.getGroup(current.parent(), simStep); + const auto& prod_cmode = group.gconprod_cmode(); + + if (prod_cmode != Opm::Group::ProductionCMode::FLD) + return true; + + if (prod_cmode != Opm::Group::ProductionCMode::NONE) + return true; + } + return false; } int higherLevelInjCMode_NotNoneFld_SeqIndex(const Opm::Schedule& sched, From f64f8fd30eddf454c7d7800e2e5305ad1d8aef43 Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Thu, 5 Nov 2020 09:51:30 +0100 Subject: [PATCH 13/14] Remove code which just resets default value -1 --- src/opm/output/eclipse/AggregateGroupData.cpp | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/opm/output/eclipse/AggregateGroupData.cpp b/src/opm/output/eclipse/AggregateGroupData.cpp index d40324cc9..7b81225df 100644 --- a/src/opm/output/eclipse/AggregateGroupData.cpp +++ b/src/opm/output/eclipse/AggregateGroupData.cpp @@ -455,14 +455,6 @@ void productionGroup(const Opm::Schedule& sched, } - if (((active_cmode != Opm::Group::ProductionCMode::NONE)) && (!cgroup)) { - // group is constrained by its own limits or controls - // if (active_cmode != Opm::Group::ProductionCMode::FLD) - need to use this test? - else remove - iGrp[nwgmax + 5] = -1; // only value that seems to work when no group at higher level has active control - goto CGROUP_DONE; - } - - if (cgroup) { if (((deck_cmode == Opm::Group::ProductionCMode::FLD) || (deck_cmode == Opm::Group::ProductionCMode::NONE)) && (prod_guide_rate_def != Opm::Group::GuideRateTarget::NO_GUIDE_RATE)) { @@ -475,7 +467,6 @@ void productionGroup(const Opm::Schedule& sched, if (higherLevelProdCMode_NotNoneFld(sched, group, simStep)) { - iGrp[nwgmax + 5] = -1; if (deck_cmode == Opm::Group::ProductionCMode::FLD) iGrp[nwgmax] = 1; From f2bdde4b734ef766bb93ed6e161eba4abfa0d563 Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Thu, 5 Nov 2020 10:03:48 +0100 Subject: [PATCH 14/14] Minor refactor --- src/opm/output/eclipse/AggregateGroupData.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/opm/output/eclipse/AggregateGroupData.cpp b/src/opm/output/eclipse/AggregateGroupData.cpp index 7b81225df..82a3434f3 100644 --- a/src/opm/output/eclipse/AggregateGroupData.cpp +++ b/src/opm/output/eclipse/AggregateGroupData.cpp @@ -456,11 +456,13 @@ void productionGroup(const Opm::Schedule& sched, if (cgroup) { - if (((deck_cmode == Opm::Group::ProductionCMode::FLD) || (deck_cmode == Opm::Group::ProductionCMode::NONE)) - && (prod_guide_rate_def != Opm::Group::GuideRateTarget::NO_GUIDE_RATE)) { - iGrp[nwgmax + 5] = cgroup->insert_index(); - } else { - iGrp[nwgmax + 5] = 1; + iGrp[nwgmax + 5] = 1; + if (prod_guide_rate_def != Opm::Group::GuideRateTarget::NO_GUIDE_RATE) { + if (deck_cmode == Opm::Group::ProductionCMode::FLD) + iGrp[nwgmax + 5] = cgroup->insert_index(); + + if (deck_cmode == Opm::Group::ProductionCMode::NONE) + iGrp[nwgmax + 5] = cgroup->insert_index(); } goto CGROUP_DONE; } @@ -476,7 +478,6 @@ void productionGroup(const Opm::Schedule& sched, goto CGROUP_DONE; } - goto CGROUP_DONE; } else if (deck_cmode == Opm::Group::ProductionCMode::NONE) { iGrp[nwgmax + 5] = 1; }