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 {
return leaf_nodes_;
}
@ -83,4 +85,16 @@ 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) ) {
return false;
}
}
return true;
}
}

View File

@ -24,6 +24,7 @@ along with OpenRS. If not, see <http://www.gnu.org/licenses/>.
#include <vector>
#include <opm/core/WellsGroup.hpp>
#include <opm/core/grid.h>
#include <opm/core/eclipse/EclipseGridParser.hpp>
namespace Opm
@ -38,6 +39,8 @@ namespace Opm
void addChild(std::string child, std::string parent,
const EclipseGridParser& deck);
bool conditionsMet(const std::vector<double> pressure, const UnstructuredGrid& grid) const;
const std::vector<std::tr1::shared_ptr<WellsGroupInterface> >& getLeafNodes() const;
private:
// To account for the possibility of a forest

View File

@ -40,6 +40,7 @@ namespace Opm
return false;
}
WellsGroupInterface* WellsGroup::findGroup(std::string name_of_node)
{
if (name() == name_of_node) {
@ -56,6 +57,12 @@ namespace Opm
return NULL;
}
}
bool WellsGroup::conditionsMet(const std::vector<double> pressure, const UnstructuredGrid& grid)
{
return true;
}
void WellsGroup::addChild(std::tr1::shared_ptr<WellsGroupInterface> child)
{
@ -68,6 +75,11 @@ namespace Opm
: WellsGroupInterface(myname, prod_spec, inj_spec)
{
}
bool WellNode::conditionsMet(const std::vector<double> pressure, const UnstructuredGrid& grid)
{
return true;
}
WellsGroupInterface* WellNode::findGroup(std::string name_of_node)
{
@ -83,7 +95,12 @@ namespace Opm
{
return true;
}
void WellNode::setWellsPointer(const struct Wells* wells, int self_index) {
wells_ = wells;
self_index_ = self_index;
}
namespace
{

View File

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

View File

@ -520,6 +520,13 @@ namespace Opm
WelspecsLine line = welspecs.welspecs[i];
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_;
}
const WellCollection& WellsManager::wellCollection() const
{
return well_collection_;
}

View File

@ -54,6 +54,8 @@ namespace Opm
/// The method is named similarly to c_str() in std::string,
/// to make it clear that we are returning a C-compatible struct.
const Wells* c_wells() const;
const WellCollection& wellCollection() const;
private:
// Disable copying and assignment.