From ffad873b0feaa4d97c6befc6a9452bb7fbfda4d6 Mon Sep 17 00:00:00 2001 From: Jostein Alvestad Date: Mon, 1 Nov 2021 13:47:55 +0100 Subject: [PATCH] Added output of IGRP[NWGMAX + 39] - node sequence number for groups in external network --- opm/output/eclipse/VectorItems/group.hpp | 1 + src/opm/output/eclipse/AggregateGroupData.cpp | 40 ++++++++++++------- tests/MOD4_TEST_IGRP-DATA.DATA | 20 ++++++++++ tests/test_AggregateGroupData.cpp | 3 ++ 4 files changed, 49 insertions(+), 15 deletions(-) diff --git a/opm/output/eclipse/VectorItems/group.hpp b/opm/output/eclipse/VectorItems/group.hpp index 7ddf26ef0..793db5452 100644 --- a/opm/output/eclipse/VectorItems/group.hpp +++ b/opm/output/eclipse/VectorItems/group.hpp @@ -74,6 +74,7 @@ namespace Opm { namespace RestartIO { namespace Helpers { namespace VectorItems GroupLevel = 27, ParentGroup = 28, FlowingWells = 33, + NodeNumber = 39 }; namespace Value { diff --git a/src/opm/output/eclipse/AggregateGroupData.cpp b/src/opm/output/eclipse/AggregateGroupData.cpp index 21df78390..a237fec38 100644 --- a/src/opm/output/eclipse/AggregateGroupData.cpp +++ b/src/opm/output/eclipse/AggregateGroupData.cpp @@ -112,25 +112,13 @@ void groupLoop(const std::vector& groups, } } -template < typename T> -std::pair findInVector(const std::vector & vecOfElements, const T & element) +template +std::optional findInVector(const std::vector & vecOfElements, const T & element) { - std::pair result; - // Find given element in vector auto it = std::find(vecOfElements.begin(), vecOfElements.end(), element); - if (it != vecOfElements.end()) - { - result.second = std::distance(vecOfElements.begin(), it); - result.first = true; - } - else - { - result.first = false; - result.second = -1; - } - return result; + return (it != vecOfElements.end()) ? std::optional{std::distance(vecOfElements.begin(), it)} : std::nullopt; } int currentGroupLevel(const Opm::Schedule& sched, const Opm::Group& group, const size_t simStep) @@ -627,6 +615,24 @@ void injectionGroup(const Opm::Schedule& sched, } } +template +void storeNodeSequenceNo(const Opm::Schedule& sched, + const Opm::Group& group, + const int nwgmax, + const std::size_t simStep, + IGrpArray& iGrp) { + + using IGroup = ::Opm::RestartIO::Helpers::VectorItems::IGroup::index; + + const auto& netwrk = sched[simStep].network(); + const auto seq_ind = findInVector(netwrk.node_names(), group.name()); + + // The igrp node number is equal to the node sequence number from the BRANPROP keyword + // for the groups that also are nodes in the external network (BRANPROP, NODEPROP) + // If not - the node numbr is zero. + iGrp[nwgmax + IGroup::NodeNumber] = seq_ind ? seq_ind.value()+1 : 0; +} + template void storeGroupTree(const Opm::Schedule& sched, const Opm::Group& group, @@ -702,6 +708,10 @@ void staticContrib(const Opm::Schedule& sched, const bool is_field = group.name() == "FIELD"; storeGroupTree(sched, group, nwgmax, ngmaxz, simStep, iGrp); + + //node-number for groups in external network (according to sequence in BRANPROP) + storeNodeSequenceNo(sched, group, nwgmax, simStep, iGrp); + storeFlowingWells(group, nwgmax, sumState, iGrp); // Treat all groups for production controls diff --git a/tests/MOD4_TEST_IGRP-DATA.DATA b/tests/MOD4_TEST_IGRP-DATA.DATA index 46acea9df..1feb50366 100644 --- a/tests/MOD4_TEST_IGRP-DATA.DATA +++ b/tests/MOD4_TEST_IGRP-DATA.DATA @@ -75,6 +75,10 @@ REGDIMS -- ntfip nmfipr nrfreg 1 1 1* / +NETWORK + 3 2 / + + -- Well dimension data -- nwmaxz: max wells in the model -- ncwmax: max connections per well @@ -9709,6 +9713,22 @@ GRUPTREE / + +BRANPROP +-- Downtree Uptree #VFP ALQ + LOWER MOD4 9999 1* / + UPPER MOD4 9999 1* / +/ + +NODEPROP +-- Node_name Press autoChoke? addGasLift? Group_name + MOD4 21.0 NO NO 1* / + UPPER 1* NO NO 1* / + LOWER 1* NO NO 1* / +/ + + + -- This reservoir simulation deck is made available under the Open Database -- License: http://opendatacommons.org/licenses/odbl/1.0/. Any rights in -- individual contents of the database are licensed under the Database Contents diff --git a/tests/test_AggregateGroupData.cpp b/tests/test_AggregateGroupData.cpp index 52e9610e1..e35025c5d 100644 --- a/tests/test_AggregateGroupData.cpp +++ b/tests/test_AggregateGroupData.cpp @@ -811,16 +811,19 @@ BOOST_AUTO_TEST_CASE (Declared_Group_Data_2) BOOST_CHECK_EQUAL(iGrp[start + nwgmax + 5] , 2); // group available for higher level production control BOOST_CHECK_EQUAL(iGrp[start + nwgmax + 17] , 1); // group available for higher level water injection control BOOST_CHECK_EQUAL(iGrp[start + nwgmax + 22] , -1); // group available for higher level gas injection control + BOOST_CHECK_EQUAL(iGrp[start + nwgmax + 39] , 3); // groups sequence number in the external networt defined start = 1*ih[VI::intehead::NIGRPZ]; BOOST_CHECK_EQUAL(iGrp[start + nwgmax + 5] , 0); // group available for higher level production control BOOST_CHECK_EQUAL(iGrp[start + nwgmax + 17] , -1); // group available for higher level water injection control BOOST_CHECK_EQUAL(iGrp[start + nwgmax + 22] , -1); // group available for higher level gas injection control + BOOST_CHECK_EQUAL(iGrp[start + nwgmax + 39] , 2); // groups sequence number in the external networt defined start = 2*ih[VI::intehead::NIGRPZ]; BOOST_CHECK_EQUAL(iGrp[start + nwgmax + 5] , 2); // group available for higher level production control BOOST_CHECK_EQUAL(iGrp[start + nwgmax + 17] , 2); // group available for higher level water injection control BOOST_CHECK_EQUAL(iGrp[start + nwgmax + 22] , -1); // group available for higher level gas injection control + BOOST_CHECK_EQUAL(iGrp[start + nwgmax + 39] , 1); // groups sequence number in the external networt defined start = 3*ih[VI::intehead::NIGRPZ]; BOOST_CHECK_EQUAL(iGrp[start + nwgmax + 5] , -1); // group available for higher level production control