From 92bf4a96ea791dd329476cf8929ca6950a0b6cff Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Tue, 27 Oct 2020 20:48:03 +0100 Subject: [PATCH 1/2] Separately load active and requested group control from restart file Use named constants for access to IGRP vector --- opm/io/eclipse/rst/group.hpp | 3 +- opm/output/eclipse/VectorItems/group.hpp | 3 +- src/opm/io/eclipse/rst/group.cpp | 3 +- src/opm/output/eclipse/AggregateGroupData.cpp | 36 +++++++++---------- 4 files changed, 24 insertions(+), 21 deletions(-) diff --git a/opm/io/eclipse/rst/group.hpp b/opm/io/eclipse/rst/group.hpp index 5fddd0f97..0ac506a47 100644 --- a/opm/io/eclipse/rst/group.hpp +++ b/opm/io/eclipse/rst/group.hpp @@ -41,7 +41,8 @@ struct RstGroup { std::string name; int parent_group; - int prod_cmode; + int prod_active_cmode; + int gconprod_cmode; int winj_cmode; int ginj_cmode; int guide_rate_def; diff --git a/opm/output/eclipse/VectorItems/group.hpp b/opm/output/eclipse/VectorItems/group.hpp index dfd5341eb..e2e27f159 100644 --- a/opm/output/eclipse/VectorItems/group.hpp +++ b/opm/output/eclipse/VectorItems/group.hpp @@ -56,9 +56,10 @@ namespace Opm { namespace RestartIO { namespace Helpers { namespace VectorItems // Observe that these value should not be used as ordinary indices into // the the IGRP vector, they should all be used as IGRP[NWGMAX + $index] enum index : std::vector::size_type { - ProdCMode = 1, + ProdActiveCMode = 1, GuideRateDef = 6, WInjCMode = 16, + GConProdCMode = 10, GInjCMode = 21, ParentGroup = 28, }; diff --git a/src/opm/io/eclipse/rst/group.cpp b/src/opm/io/eclipse/rst/group.cpp index a68e4e04a..f4d2a569f 100644 --- a/src/opm/io/eclipse/rst/group.cpp +++ b/src/opm/io/eclipse/rst/group.cpp @@ -40,7 +40,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_cmode(igrp[header.nwgmax + VI::IGroup::ProdCMode]), + prod_active_cmode(igrp[header.nwgmax + VI::IGroup::ProdActiveCMode]), + gconprod_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]), diff --git a/src/opm/output/eclipse/AggregateGroupData.cpp b/src/opm/output/eclipse/AggregateGroupData.cpp index cb1b03842..bbdb99b08 100644 --- a/src/opm/output/eclipse/AggregateGroupData.cpp +++ b/src/opm/output/eclipse/AggregateGroupData.cpp @@ -574,73 +574,73 @@ void productionGroup(const Opm::Schedule& sched, using IGroup = ::Opm::RestartIO::Helpers::VectorItems::IGroup::index; namespace Value = ::Opm::RestartIO::Helpers::VectorItems::IGroup::Value; if (higher_lev_ctrl > 0 && (group.getGroupType() != Opm::Group::GroupType::NONE)) { - iGrp[nwgmax + IGroup::ProdCMode] + iGrp[nwgmax + IGroup::ProdActiveCMode] = (prod_guide_rate_def != Opm::Group::GuideRateTarget::NO_GUIDE_RATE) ? higher_lev_ctrl_mode : 0; } else { switch (pctl_mode) { case Opm::Group::ProductionCMode::NONE: - iGrp[nwgmax + IGroup::ProdCMode] = 0; + iGrp[nwgmax + IGroup::ProdActiveCMode] = 0; break; case Opm::Group::ProductionCMode::ORAT: - iGrp[nwgmax + IGroup::ProdCMode] = 1; + iGrp[nwgmax + IGroup::ProdActiveCMode] = 1; break; case Opm::Group::ProductionCMode::WRAT: - iGrp[nwgmax + IGroup::ProdCMode] = 2; + iGrp[nwgmax + IGroup::ProdActiveCMode] = 2; break; case Opm::Group::ProductionCMode::GRAT: - iGrp[nwgmax + IGroup::ProdCMode] = 3; + iGrp[nwgmax + IGroup::ProdActiveCMode] = 3; break; case Opm::Group::ProductionCMode::LRAT: - iGrp[nwgmax + IGroup::ProdCMode] = 4; + iGrp[nwgmax + IGroup::ProdActiveCMode] = 4; break; case Opm::Group::ProductionCMode::RESV: - iGrp[nwgmax + IGroup::ProdCMode] = 5; + iGrp[nwgmax + IGroup::ProdActiveCMode] = 5; break; case Opm::Group::ProductionCMode::FLD: - iGrp[nwgmax + IGroup::ProdCMode] = 0; // need to be checked!! + iGrp[nwgmax + IGroup::ProdActiveCMode] = 0; // need to be checked!! break; default: - iGrp[nwgmax + IGroup::ProdCMode] = 0; + iGrp[nwgmax + IGroup::ProdActiveCMode] = 0; } } - iGrp[nwgmax + 9] = iGrp[nwgmax + IGroup::ProdCMode]; + 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 + 10] = 0; + 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 + 10] = 1; + 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 + 10] = 2; + 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 + 10] = 3; + 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 + 10] = 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 + 10] = 5; + 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 + 10] = 0; // need to be checked!! + iGrp[nwgmax + IGroup::GConProdCMode] = 0; // need to be checked!! break; default: iGrp[nwgmax + 7] = 0; - iGrp[nwgmax + 10] = 0; // need to be checked!! + iGrp[nwgmax + IGroup::GConProdCMode] = 0; // need to be checked!! } } From 1f7ec57895707cbdc5d4e9ef3ab72b52ba1cc6a6 Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Tue, 27 Oct 2020 20:50:12 +0100 Subject: [PATCH 2/2] Use named constants in IGRP access --- opm/output/eclipse/VectorItems/group.hpp | 1 + src/opm/output/eclipse/AggregateGroupData.cpp | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/opm/output/eclipse/VectorItems/group.hpp b/opm/output/eclipse/VectorItems/group.hpp index e2e27f159..ec22a719e 100644 --- a/opm/output/eclipse/VectorItems/group.hpp +++ b/opm/output/eclipse/VectorItems/group.hpp @@ -62,6 +62,7 @@ namespace Opm { namespace RestartIO { namespace Helpers { namespace VectorItems GConProdCMode = 10, GInjCMode = 21, ParentGroup = 28, + FlowingWells = 33, }; namespace Value { diff --git a/src/opm/output/eclipse/AggregateGroupData.cpp b/src/opm/output/eclipse/AggregateGroupData.cpp index bbdb99b08..89d9b2025 100644 --- a/src/opm/output/eclipse/AggregateGroupData.cpp +++ b/src/opm/output/eclipse/AggregateGroupData.cpp @@ -439,9 +439,11 @@ void productionGroup(const Opm::Schedule& sched, const std::map& pCtrlToPCmode, IGrpArray& iGrp) { + using IGroup = ::Opm::RestartIO::Helpers::VectorItems::IGroup::index; + namespace Value = ::Opm::RestartIO::Helpers::VectorItems::IGroup::Value; const auto& prod_cmode = group.gconprod_cmode(); if (group.name() == "FIELD") { - iGrp[nwgmax + 6] = 0; + iGrp[nwgmax + IGroup::GuideRateDef] = Value::GuideRateMode::None; iGrp[nwgmax + 7] = 0; switch (prod_cmode) { case Opm::Group::ProductionCMode::NONE: @@ -571,8 +573,6 @@ void productionGroup(const Opm::Schedule& sched, Other reduction options are currently not covered in the code */ - using IGroup = ::Opm::RestartIO::Helpers::VectorItems::IGroup::index; - namespace Value = ::Opm::RestartIO::Helpers::VectorItems::IGroup::Value; if (higher_lev_ctrl > 0 && (group.getGroupType() != Opm::Group::GroupType::NONE)) { iGrp[nwgmax + IGroup::ProdActiveCMode] = (prod_guide_rate_def != Opm::Group::GuideRateTarget::NO_GUIDE_RATE) ? higher_lev_ctrl_mode : 0; @@ -839,6 +839,7 @@ 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; @@ -865,7 +866,7 @@ void staticContrib(const Opm::Schedule& sched, // 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 + 33] = g_act_pwells + g_act_iwells; + iGrp[nwgmax + IGroup::FlowingWells] = g_act_pwells + g_act_iwells; // Treat al groups which are *not* pure injection groups. if (group.getGroupType() != Opm::Group::GroupType::INJECTION)