From 085785bf26de99e12c2405537c7b7f59dc28b3ae Mon Sep 17 00:00:00 2001 From: Kai Bao Date: Thu, 3 Nov 2016 13:12:12 +0100 Subject: [PATCH] adding function findWellNode() to WellCollection to return the WellNode* instead of WellGroupInterface* --- opm/core/wells/WellCollection.cpp | 15 +++++++++++++++ opm/core/wells/WellCollection.hpp | 4 ++++ 2 files changed, 19 insertions(+) diff --git a/opm/core/wells/WellCollection.cpp b/opm/core/wells/WellCollection.cpp index d94aa947..720282d4 100644 --- a/opm/core/wells/WellCollection.cpp +++ b/opm/core/wells/WellCollection.cpp @@ -116,6 +116,21 @@ namespace Opm return NULL; } + + WellNode* WellCollection::findWellNode(const std::string& name) const + { + auto well_node = std::find_if(leaf_nodes_.begin(), leaf_nodes_.end(), + [&] ( WellNode* w) { + return w->name() == name; + }); + + if (well_node != leaf_nodes_.end()) { + return *well_node; + } else { + return nullptr; + } + } + /// Adds the child to the collection /// and appends it to parent's children. /// \param[in] child the child node diff --git a/opm/core/wells/WellCollection.hpp b/opm/core/wells/WellCollection.hpp index b98d992f..d4ac7d70 100644 --- a/opm/core/wells/WellCollection.hpp +++ b/opm/core/wells/WellCollection.hpp @@ -95,6 +95,10 @@ namespace Opm /// \return the pointer to the group if found, NULL otherwise const WellsGroupInterface* findNode(const std::string& name) const; + + WellNode* findWellNode(const std::string& name) const; + + /// Applies all group controls (injection and production) void applyGroupControls();