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 77dc0991cf
commit 49b18b2d96
5 changed files with 42 additions and 14 deletions

View File

@ -67,8 +67,8 @@ int main(int argc, char** argv) {
std::vector<double> pressure;
std::vector<double> face_flux;
pressure_solver.solve(totmob, omega, src, bcs.c_bcs(), pressure, face_flux);
//pressure_solver.solve(totmob, omega, src, bcs.c_bcs(), pressure, face_flux);
if(wells.wellCollection().conditionsMet(pressure, *grid.c_grid())) {
std::cout << "Conditions met for wells!" << std::endl;
}

View File

@ -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<double> 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<double>& pressure, const UnstructuredGrid& grid) const {
for(size_t i = 0; i < leaf_nodes_.size(); i++) {
if(! static_cast<WellNode*>(leaf_nodes_[i].get())->conditionsMet(pressure, grid) ) {
return false;
}
}

View File

@ -38,8 +38,9 @@ namespace Opm
void addChild(std::string child, std::string parent,
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;
private:

View File

@ -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<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;
}
@ -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)

View File

@ -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<double> 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<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:
std::vector<std::tr1::shared_ptr<WellsGroupInterface> > children_;
};
@ -70,7 +74,7 @@ namespace Opm
InjectionSpecification inj_spec);
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;
void setWellsPointer(const struct Wells* wells, int self_index);