diff --git a/opm/core/WellCollection.cpp b/opm/core/WellCollection.cpp index 002c2d9bb..30818c1c1 100644 --- a/opm/core/WellCollection.cpp +++ b/opm/core/WellCollection.cpp @@ -66,6 +66,8 @@ namespace Opm if(child->isLeafNode()) { leaf_nodes_.push_back(child); } + + child->setParent(parent); } @@ -86,9 +88,9 @@ namespace Opm return NULL; } - bool WellCollection::conditionsMet(const std::vector pressure, const UnstructuredGrid& grid) const { - for(size_t i = 0; i < roots_.size(); i++) { - if(! roots_[i]->conditionsMet(pressure, grid) ) { + bool WellCollection::conditionsMet(const std::vector& pressure, const UnstructuredGrid& grid) const { + for(size_t i = 0; i < leaf_nodes_.size(); i++) { + if(! static_cast(leaf_nodes_[i].get())->conditionsMet(pressure, grid) ) { return false; } } diff --git a/opm/core/WellCollection.hpp b/opm/core/WellCollection.hpp index 71c158217..c93b3f268 100644 --- a/opm/core/WellCollection.hpp +++ b/opm/core/WellCollection.hpp @@ -38,8 +38,9 @@ namespace Opm void addChild(std::string child, std::string parent, const EclipseGridParser& deck); + - bool conditionsMet(const std::vector pressure, const UnstructuredGrid& grid) const; + bool conditionsMet(const std::vector& pressure, const UnstructuredGrid& grid) const; const std::vector >& getLeafNodes() const; private: diff --git a/opm/core/WellsGroup.cpp b/opm/core/WellsGroup.cpp index 9ec719c03..99ed02e1d 100644 --- a/opm/core/WellsGroup.cpp +++ b/opm/core/WellsGroup.cpp @@ -15,7 +15,8 @@ namespace Opm InjectionSpecification inje_spec) : name_(myname), production_specification_(prod_spec), - injection_specification_(inje_spec) + injection_specification_(inje_spec), + parent_(NULL) { } @@ -40,6 +41,10 @@ namespace Opm return false; } + void WellsGroupInterface::setParent(WellsGroupInterface* parent) + { + parent_ = parent; + } WellsGroupInterface* WellsGroup::findGroup(std::string name_of_node) { @@ -59,8 +64,15 @@ namespace Opm } - bool WellsGroup::conditionsMet(const std::vector pressure, const UnstructuredGrid& grid) + bool WellsGroup::conditionsMet(const std::vector& pressure, + const UnstructuredGrid& grid, const struct Wells* wells, int index_of_well) { + if(parent_ != NULL) { + bool parent_ok = (static_cast(parent_))->conditionsMet(pressure, grid, wells, index_of_well); + if(!parent_ok) { + return false; + } + } return true; } @@ -76,9 +88,18 @@ namespace Opm { } - bool WellNode::conditionsMet(const std::vector pressure, const UnstructuredGrid& grid) + bool WellNode::conditionsMet(const std::vector& pressure, const UnstructuredGrid& grid) { - return true; + if(parent_ != NULL) { + bool parent_ok = (static_cast(parent_))->conditionsMet(pressure, grid, wells_, self_index_); + if(!parent_ok) { + return false; + } + } + + + + } WellsGroupInterface* WellNode::findGroup(std::string name_of_node) diff --git a/opm/core/WellsGroup.hpp b/opm/core/WellsGroup.hpp index c8c9f8a2a..35a46d0c6 100644 --- a/opm/core/WellsGroup.hpp +++ b/opm/core/WellsGroup.hpp @@ -31,11 +31,14 @@ namespace Opm /// \returns true if the object is a leaf node (WellNode), false otherwise. virtual bool isLeafNode() const; - virtual bool conditionsMet(const std::vector pressure, const UnstructuredGrid& grid) = 0; - /// \returns the pointer to the WellsGroupInterface with the given name. NULL if /// the name is not found.a virtual WellsGroupInterface* findGroup(std::string name_of_node) = 0; + + void setParent(WellsGroupInterface* parent); + protected: + WellsGroupInterface* parent_; + private: std::string name_; ProductionSpecification production_specification_; @@ -55,7 +58,8 @@ namespace Opm void addChild(std::tr1::shared_ptr child); - virtual bool conditionsMet(const std::vector pressure, const UnstructuredGrid& grid); + bool conditionsMet(const std::vector& pressure, const UnstructuredGrid& grid, const struct Wells* wells, + int index_of_well); private: std::vector > children_; }; @@ -70,7 +74,7 @@ namespace Opm InjectionSpecification inj_spec); virtual WellsGroupInterface* findGroup(std::string name_of_node); - virtual bool conditionsMet(const std::vector pressure, const UnstructuredGrid& grid); + virtual bool conditionsMet(const std::vector& pressure, const UnstructuredGrid& grid); virtual bool isLeafNode() const; void setWellsPointer(const struct Wells* wells, int self_index);