diff --git a/opm/core/wells/WellCollection.cpp b/opm/core/wells/WellCollection.cpp index 88de6ba3..9bcaf140 100644 --- a/opm/core/wells/WellCollection.cpp +++ b/opm/core/wells/WellCollection.cpp @@ -193,22 +193,51 @@ namespace Opm //TODO: later, it should be extended to update group targets bool WellCollection::needUpdateWellTargets() const + { + return needUpdateInjectionTargets() || needUpdateProductionTargets(); + } + + + bool WellCollection::needUpdateInjectionTargets() const { bool any_group_control_node = false; bool any_should_update_node = false; + for (size_t i = 0; i < leaf_nodes_.size(); ++i) { - std::cout << " well " << leaf_nodes_[i]->name() << " under group control ? " << !leaf_nodes_[i]->individualControl() << " should update well target? " << leaf_nodes_[i]->shouldUpdateWellTargets() << std::endl; - if (leaf_nodes_[i]->shouldUpdateWellTargets()) { - any_should_update_node = true; - } - if (!leaf_nodes_[i]->individualControl()) { - any_group_control_node = true; + if (leaf_nodes_[i]->isInjector()) { + if (leaf_nodes_[i]->shouldUpdateWellTargets()) { + any_should_update_node = true; + } + + if (leaf_nodes_[i]->individualControl()) { + any_group_control_node = true; + } } } - std::cout << " any_group_control_node " << any_group_control_node << " any_should_update_node " << any_should_update_node << std::endl; + return (any_group_control_node && any_should_update_node); } + bool WellCollection::needUpdateProductionTargets() const { + bool any_group_control_node = false; + bool any_should_update_node = false; + + for (size_t i = 0; i < leaf_nodes_.size(); ++i) { + if (leaf_nodes_[i]->isProducer()) { + if (leaf_nodes_[i]->shouldUpdateWellTargets()) { + any_should_update_node = true; + } + + if (leaf_nodes_[i]->individualControl()) { + any_group_control_node = true; + } + } + } + + return (any_group_control_node && any_should_update_node); + } + + const size_t WellCollection::numNode() const { diff --git a/opm/core/wells/WellCollection.hpp b/opm/core/wells/WellCollection.hpp index 4822a722..d19e5673 100644 --- a/opm/core/wells/WellCollection.hpp +++ b/opm/core/wells/WellCollection.hpp @@ -117,6 +117,9 @@ namespace Opm /// strategy might be required. bool needUpdateWellTargets() const; + bool needUpdateInjectionTargets() const; + bool needUpdateProductionTargets() const; + const size_t numNode() const; WellNode* getNode(size_t i) const;