Made the WellNode be aware of their own index

This commit is contained in:
Kjetil Olsen Lye 2012-04-12 14:25:39 +02:00
parent 7dcec8976b
commit c931e2a1fb
6 changed files with 60 additions and 2 deletions

View File

@ -68,6 +68,8 @@ namespace Opm
} }
} }
const std::vector<std::tr1::shared_ptr<WellsGroupInterface> >& WellCollection::getLeafNodes() const { const std::vector<std::tr1::shared_ptr<WellsGroupInterface> >& WellCollection::getLeafNodes() const {
return leaf_nodes_; return leaf_nodes_;
} }
@ -83,4 +85,16 @@ namespace Opm
} }
return NULL; 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) ) {
return false;
}
}
return true;
}
} }

View File

@ -24,6 +24,7 @@ along with OpenRS. If not, see <http://www.gnu.org/licenses/>.
#include <vector> #include <vector>
#include <opm/core/WellsGroup.hpp> #include <opm/core/WellsGroup.hpp>
#include <opm/core/grid.h>
#include <opm/core/eclipse/EclipseGridParser.hpp> #include <opm/core/eclipse/EclipseGridParser.hpp>
namespace Opm namespace Opm
@ -38,6 +39,8 @@ 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;
const std::vector<std::tr1::shared_ptr<WellsGroupInterface> >& getLeafNodes() const; const std::vector<std::tr1::shared_ptr<WellsGroupInterface> >& getLeafNodes() const;
private: private:
// To account for the possibility of a forest // To account for the possibility of a forest

View File

@ -40,6 +40,7 @@ namespace Opm
return false; return false;
} }
WellsGroupInterface* WellsGroup::findGroup(std::string name_of_node) WellsGroupInterface* WellsGroup::findGroup(std::string name_of_node)
{ {
if (name() == name_of_node) { if (name() == name_of_node) {
@ -57,6 +58,12 @@ namespace Opm
} }
} }
bool WellsGroup::conditionsMet(const std::vector<double> pressure, const UnstructuredGrid& grid)
{
return true;
}
void WellsGroup::addChild(std::tr1::shared_ptr<WellsGroupInterface> child) void WellsGroup::addChild(std::tr1::shared_ptr<WellsGroupInterface> child)
{ {
children_.push_back(child); children_.push_back(child);
@ -69,6 +76,11 @@ namespace Opm
{ {
} }
bool WellNode::conditionsMet(const std::vector<double> pressure, const UnstructuredGrid& grid)
{
return true;
}
WellsGroupInterface* WellNode::findGroup(std::string name_of_node) WellsGroupInterface* WellNode::findGroup(std::string name_of_node)
{ {
if (name() == name_of_node) { if (name() == name_of_node) {
@ -84,6 +96,11 @@ namespace Opm
return true; return true;
} }
void WellNode::setWellsPointer(const struct Wells* wells, int self_index) {
wells_ = wells;
self_index_ = self_index;
}
namespace namespace
{ {

View File

@ -4,6 +4,7 @@
#include <opm/core/InjectionSpecification.hpp> #include <opm/core/InjectionSpecification.hpp>
#include <opm/core/ProductionSpecification.hpp> #include <opm/core/ProductionSpecification.hpp>
#include <opm/core/eclipse/EclipseGridParser.hpp> #include <opm/core/eclipse/EclipseGridParser.hpp>
#include <opm/core/grid.h>
#include <string> #include <string>
@ -30,6 +31,8 @@ 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;
@ -51,6 +54,8 @@ namespace Opm
virtual WellsGroupInterface* findGroup(std::string name_of_node); virtual WellsGroupInterface* findGroup(std::string name_of_node);
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);
private: private:
std::vector<std::tr1::shared_ptr<WellsGroupInterface> > children_; std::vector<std::tr1::shared_ptr<WellsGroupInterface> > children_;
}; };
@ -65,8 +70,14 @@ 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 isLeafNode() const; virtual bool isLeafNode() const;
void setWellsPointer(const struct Wells* wells, int self_index);
private:
const struct Wells* wells_;
int self_index_;
}; };
/// Doc me! /// Doc me!

View File

@ -520,6 +520,13 @@ namespace Opm
WelspecsLine line = welspecs.welspecs[i]; WelspecsLine line = welspecs.welspecs[i];
wells_.addChild(line.name_, line.group_, deck); wells_.addChild(line.name_, line.group_, deck);
} }
for(size_t i = 0; i < wells_.getLeafNodes().size(); i++) {
WellNode* node = static_cast<WellNode*>(wells_.getLeafNodes()[i].get());
// We know that getLeafNodes() is ordered the same way as they're indexed in w_
node->setWellsPointer(w_, i);
}
} }
@ -541,6 +548,10 @@ namespace Opm
return w_; return w_;
} }
const WellCollection& WellsManager::wellCollection() const
{
return well_collection_;
}

View File

@ -55,6 +55,8 @@ namespace Opm
/// to make it clear that we are returning a C-compatible struct. /// to make it clear that we are returning a C-compatible struct.
const Wells* c_wells() const; const Wells* c_wells() const;
const WellCollection& wellCollection() const;
private: private:
// Disable copying and assignment. // Disable copying and assignment.
WellsManager(const WellsManager& other); WellsManager(const WellsManager& other);