Made queries upwards from wells to group to group

This commit is contained in:
Kjetil Olsen Lye 2012-04-12 15:48:24 +02:00
parent c931e2a1fb
commit 4150e4a184
4 changed files with 40 additions and 12 deletions

View File

@ -66,6 +66,8 @@ namespace Opm
if(child->isLeafNode()) { if(child->isLeafNode()) {
leaf_nodes_.push_back(child); leaf_nodes_.push_back(child);
} }
child->setParent(parent);
} }
@ -86,9 +88,9 @@ namespace Opm
return NULL; return NULL;
} }
bool WellCollection::conditionsMet(const std::vector<double> pressure, const UnstructuredGrid& grid) const { bool WellCollection::conditionsMet(const std::vector<double>& pressure, const UnstructuredGrid& grid) const {
for(size_t i = 0; i < roots_.size(); i++) { for(size_t i = 0; i < leaf_nodes_.size(); i++) {
if(! roots_[i]->conditionsMet(pressure, grid) ) { if(! static_cast<WellNode*>(leaf_nodes_[i].get())->conditionsMet(pressure, grid) ) {
return false; return false;
} }
} }

View File

@ -38,8 +38,9 @@ namespace Opm
void addChild(std::string child, std::string parent, void addChild(std::string child, std::string parent,
const EclipseGridParser& deck); const EclipseGridParser& deck);
bool conditionsMet(const std::vector<double> pressure, const UnstructuredGrid& grid) const; bool conditionsMet(const std::vector<double>& pressure, const UnstructuredGrid& grid) const;
const std::vector<std::tr1::shared_ptr<WellsGroupInterface> >& getLeafNodes() const; const std::vector<std::tr1::shared_ptr<WellsGroupInterface> >& getLeafNodes() const;
private: private:

View File

@ -15,7 +15,8 @@ namespace Opm
InjectionSpecification inje_spec) InjectionSpecification inje_spec)
: name_(myname), : name_(myname),
production_specification_(prod_spec), production_specification_(prod_spec),
injection_specification_(inje_spec) injection_specification_(inje_spec),
parent_(NULL)
{ {
} }
@ -40,6 +41,10 @@ namespace Opm
return false; return false;
} }
void WellsGroupInterface::setParent(WellsGroupInterface* parent)
{
parent_ = parent;
}
WellsGroupInterface* WellsGroup::findGroup(std::string name_of_node) WellsGroupInterface* WellsGroup::findGroup(std::string name_of_node)
{ {
@ -59,8 +64,15 @@ namespace Opm
} }
bool WellsGroup::conditionsMet(const std::vector<double> pressure, const UnstructuredGrid& grid) bool WellsGroup::conditionsMet(const std::vector<double>& pressure,
const UnstructuredGrid& grid, const struct Wells* wells, int index_of_well)
{ {
if(parent_ != NULL) {
bool parent_ok = (static_cast<WellsGroup*>(parent_))->conditionsMet(pressure, grid, wells, index_of_well);
if(!parent_ok) {
return false;
}
}
return true; return true;
} }
@ -76,9 +88,18 @@ namespace Opm
{ {
} }
bool WellNode::conditionsMet(const std::vector<double> pressure, const UnstructuredGrid& grid) bool WellNode::conditionsMet(const std::vector<double>& pressure, const UnstructuredGrid& grid)
{ {
return true; if(parent_ != NULL) {
bool parent_ok = (static_cast<WellsGroup*>(parent_))->conditionsMet(pressure, grid, wells_, self_index_);
if(!parent_ok) {
return false;
}
}
} }
WellsGroupInterface* WellNode::findGroup(std::string name_of_node) WellsGroupInterface* WellNode::findGroup(std::string name_of_node)

View File

@ -31,11 +31,14 @@ namespace Opm
/// \returns true if the object is a leaf node (WellNode), false otherwise. /// \returns true if the object is a leaf node (WellNode), false otherwise.
virtual bool isLeafNode() const; virtual bool isLeafNode() const;
virtual bool conditionsMet(const std::vector<double> pressure, const UnstructuredGrid& grid) = 0;
/// \returns the pointer to the WellsGroupInterface with the given name. NULL if /// \returns the pointer to the WellsGroupInterface with the given name. NULL if
/// the name is not found.a /// the name is not found.a
virtual WellsGroupInterface* findGroup(std::string name_of_node) = 0; virtual WellsGroupInterface* findGroup(std::string name_of_node) = 0;
void setParent(WellsGroupInterface* parent);
protected:
WellsGroupInterface* parent_;
private: private:
std::string name_; std::string name_;
ProductionSpecification production_specification_; ProductionSpecification production_specification_;
@ -55,7 +58,8 @@ namespace Opm
void addChild(std::tr1::shared_ptr<WellsGroupInterface> child); void addChild(std::tr1::shared_ptr<WellsGroupInterface> child);
virtual bool conditionsMet(const std::vector<double> pressure, const UnstructuredGrid& grid); bool conditionsMet(const std::vector<double>& pressure, const UnstructuredGrid& grid, const struct Wells* wells,
int index_of_well);
private: private:
std::vector<std::tr1::shared_ptr<WellsGroupInterface> > children_; std::vector<std::tr1::shared_ptr<WellsGroupInterface> > children_;
}; };
@ -70,7 +74,7 @@ namespace Opm
InjectionSpecification inj_spec); InjectionSpecification inj_spec);
virtual WellsGroupInterface* findGroup(std::string name_of_node); virtual WellsGroupInterface* findGroup(std::string name_of_node);
virtual bool conditionsMet(const std::vector<double> pressure, const UnstructuredGrid& grid); virtual bool conditionsMet(const std::vector<double>& pressure, const UnstructuredGrid& grid);
virtual bool isLeafNode() const; virtual bool isLeafNode() const;
void setWellsPointer(const struct Wells* wells, int self_index); void setWellsPointer(const struct Wells* wells, int self_index);