Added output of IGRP[NWGMAX + 39] - node sequence number for groups in external network

This commit is contained in:
Jostein Alvestad 2021-11-01 13:47:55 +01:00
parent f8d33def59
commit ffad873b0f
4 changed files with 49 additions and 15 deletions

View File

@ -74,6 +74,7 @@ namespace Opm { namespace RestartIO { namespace Helpers { namespace VectorItems
GroupLevel = 27,
ParentGroup = 28,
FlowingWells = 33,
NodeNumber = 39
};
namespace Value {

View File

@ -112,25 +112,13 @@ void groupLoop(const std::vector<const Opm::Group*>& groups,
}
}
template < typename T>
std::pair<bool, int > findInVector(const std::vector<T> & vecOfElements, const T & element)
template <typename T>
std::optional<int> findInVector(const std::vector<T> & vecOfElements, const T & element)
{
std::pair<bool, int > 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<int>{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 <class IGrpArray>
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 <class IGrpArray>
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

View File

@ -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

View File

@ -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