From 2820efc4634ec11fd69a589b0683199c9bb5a965 Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Wed, 4 Nov 2020 09:56:09 +0100 Subject: [PATCH] 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!! } }