From 6714c53dc874bf48c5d46d0837e03d7ee56ca609 Mon Sep 17 00:00:00 2001 From: Kai Bao Date: Tue, 15 Nov 2016 14:36:19 +0100 Subject: [PATCH] adding target_updated_ flag to WellNode to save some repeated efforts when updating Well Targets. --- opm/core/wells/WellCollection.cpp | 7 ++++++- opm/core/wells/WellsGroup.cpp | 19 ++++++++++++++++++- opm/core/wells/WellsGroup.hpp | 10 ++++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/opm/core/wells/WellCollection.cpp b/opm/core/wells/WellCollection.cpp index 651f53397..095d17639 100644 --- a/opm/core/wells/WellCollection.cpp +++ b/opm/core/wells/WellCollection.cpp @@ -294,13 +294,18 @@ namespace Opm return; } + // set the target_updated to be false + for (WellNode* well_node : leaf_nodes_) { + well_node->setTargetUpdated(false); + } + // TODO: currently, we only handle the level of the well groups for the moment, i.e. the level just above wells // We believe the relations between groups are similar to the relations between different wells inside the same group. // While there will be somre more complication invloved for sure. for (size_t i = 0; i < leaf_nodes_.size(); ++i) { // find a node needs to update targets, then update targets for all the wellls inside the group. // if (leaf_nodes_[i]->shouldUpdateWellTargets() && !leaf_nodes_[i]->individualControl()) { - if (!leaf_nodes_[i]->individualControl()) { + if (!leaf_nodes_[i]->individualControl() && !leaf_nodes_[i]->targetUpdated()) { WellsGroupInterface* parent_node = leaf_nodes_[i]->getParent(); // update the target within this group. if (leaf_nodes_[i]->isProducer()) { diff --git a/opm/core/wells/WellsGroup.cpp b/opm/core/wells/WellsGroup.cpp index b307e39d6..da3bac843 100644 --- a/opm/core/wells/WellsGroup.cpp +++ b/opm/core/wells/WellsGroup.cpp @@ -792,6 +792,7 @@ namespace Opm if (!children_[i]->individualControl() && children_[i]->isProducer()) { const double children_guide_rate = children_[i]->productionGuideRate(true); children_[i]->applyProdGroupControl(prod_mode, (children_guide_rate / my_guide_rate) * rate_for_group_control, true); + children_[i]->setTargetUpdated(true); } } } @@ -802,6 +803,11 @@ namespace Opm // Will finish it when having an examples with more than one injection wells within same injection group. } + void WellsGroup::setTargetUpdated(const bool /* flag */) + { + // do nothing + } + bool WellsGroup::isProducer() const { @@ -833,7 +839,8 @@ namespace Opm wells_(0), self_index_(-1), group_control_index_(-1), - shut_well_(true) // This is default for now + shut_well_(true), // This is default for now + target_updated_(false) // This is default for now, not sure whether to use the default value { } @@ -1510,4 +1517,14 @@ namespace Opm return self_index_; } + + bool WellNode::targetUpdated() const { + return target_updated_; + } + + + void WellNode::setTargetUpdated(const bool flag) { + target_updated_ = flag; + } + } diff --git a/opm/core/wells/WellsGroup.hpp b/opm/core/wells/WellsGroup.hpp index 984be04ca..6f3c6c117 100644 --- a/opm/core/wells/WellsGroup.hpp +++ b/opm/core/wells/WellsGroup.hpp @@ -241,6 +241,8 @@ namespace Opm virtual void updateWellInjectionTargets(const std::vector& well_rates) = 0; + virtual void setTargetUpdated(const bool flag) = 0; + double efficiencyFactor() const; void setEfficiencyFactor(const double efficiency_factor); @@ -370,6 +372,8 @@ namespace Opm virtual void updateWellInjectionTargets(const std::vector& well_rates); + virtual void setTargetUpdated(const bool flag); + /// Whether it is a production well /// Should only appy for WellNode virtual bool isProducer() const; @@ -505,11 +509,17 @@ namespace Opm int selfIndex() const; + bool targetUpdated() const; + + virtual void setTargetUpdated(const bool flag); + private: Wells* wells_; int self_index_; int group_control_index_; bool shut_well_; + // TODO: used when updating well targets + bool target_updated_; }; /// Creates the WellsGroupInterface for the given well