2012-03-29 11:34:51 -05:00
|
|
|
/*
|
|
|
|
Copyright 2011 SINTEF ICT, Applied Mathematics.
|
|
|
|
|
|
|
|
|
|
|
|
This file is part of The Open Reservoir Simulator Project (OpenRS).
|
|
|
|
|
|
|
|
OpenRS is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
OpenRS is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with OpenRS. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "WellCollection.hpp"
|
|
|
|
|
|
|
|
namespace Opm
|
|
|
|
{
|
|
|
|
|
2012-04-25 07:03:57 -05:00
|
|
|
void WellCollection::addChild(const std::string& child_name,
|
|
|
|
const std::string& parent_name,
|
|
|
|
const EclipseGridParser& deck)
|
2012-03-29 11:34:51 -05:00
|
|
|
{
|
|
|
|
WellsGroupInterface* parent = findNode(parent_name);
|
|
|
|
if (!parent) {
|
|
|
|
roots_.push_back(createWellsGroup(parent_name, deck));
|
|
|
|
parent = roots_[roots_.size() - 1].get();
|
|
|
|
}
|
|
|
|
std::tr1::shared_ptr<WellsGroupInterface> child;
|
|
|
|
|
2012-04-10 08:01:52 -05:00
|
|
|
for (size_t i = 0; i < roots_.size(); ++i) {
|
2012-03-29 11:34:51 -05:00
|
|
|
if (roots_[i]->name() == child_name) {
|
|
|
|
child = roots_[i];
|
|
|
|
// We've found a new parent to the previously thought root, need to remove it
|
2012-04-10 08:01:52 -05:00
|
|
|
for(size_t j = i; j < roots_.size() - 1; ++j) {
|
2012-03-29 11:34:51 -05:00
|
|
|
roots_[j] = roots_[j+1];
|
|
|
|
}
|
|
|
|
|
|
|
|
roots_.resize(roots_.size()-1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!child.get()) {
|
|
|
|
child = createWellsGroup(child_name, deck);
|
|
|
|
}
|
|
|
|
|
|
|
|
WellsGroup* parent_as_group = static_cast<WellsGroup*> (parent);
|
|
|
|
if (!parent_as_group) {
|
|
|
|
THROW("Trying to add child to group named " << parent_name << ", but it's not a group.");
|
|
|
|
}
|
|
|
|
parent_as_group->addChild(child);
|
|
|
|
|
2012-03-30 03:51:31 -05:00
|
|
|
if(child->isLeafNode()) {
|
2012-04-25 07:19:47 -05:00
|
|
|
leaf_nodes_.push_back(static_cast<WellNode*>(child.get()));
|
2012-03-30 03:51:31 -05:00
|
|
|
}
|
2012-04-12 08:48:24 -05:00
|
|
|
|
|
|
|
child->setParent(parent);
|
2012-03-30 03:51:31 -05:00
|
|
|
}
|
|
|
|
|
2012-04-12 07:25:39 -05:00
|
|
|
|
|
|
|
|
2012-04-25 07:19:47 -05:00
|
|
|
const std::vector<WellNode*>& WellCollection::getLeafNodes() const {
|
2012-03-30 03:51:31 -05:00
|
|
|
return leaf_nodes_;
|
2012-03-29 11:34:51 -05:00
|
|
|
}
|
|
|
|
|
2012-04-25 09:42:55 -05:00
|
|
|
WellsGroupInterface* WellCollection::findNode(const std::string& name)
|
2012-03-29 11:34:51 -05:00
|
|
|
{
|
|
|
|
|
2012-04-10 08:01:52 -05:00
|
|
|
for (size_t i = 0; i < roots_.size(); i++) {
|
2012-03-29 11:34:51 -05:00
|
|
|
WellsGroupInterface* result = roots_[i]->findGroup(name);
|
|
|
|
if (result) {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
2012-04-12 07:25:39 -05:00
|
|
|
|
2012-04-25 09:42:55 -05:00
|
|
|
const WellsGroupInterface* WellCollection::findNode(const std::string& name) const
|
2012-04-23 06:24:47 -05:00
|
|
|
{
|
|
|
|
|
|
|
|
for (size_t i = 0; i < roots_.size(); i++) {
|
|
|
|
WellsGroupInterface* result = roots_[i]->findGroup(name);
|
|
|
|
if (result) {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-04-25 09:14:40 -05:00
|
|
|
bool WellCollection::conditionsMet(const std::vector<double>& well_bhp,
|
2012-05-02 06:02:59 -05:00
|
|
|
const std::vector<double>& well_reservoirrates_phase,
|
|
|
|
const std::vector<double>& well_surfacerates_phase)
|
2012-04-25 07:03:57 -05:00
|
|
|
{
|
2012-04-25 09:14:40 -05:00
|
|
|
for (size_t i = 0; i < roots_.size(); i++) {
|
|
|
|
WellPhasesSummed phases;
|
2012-05-02 06:02:59 -05:00
|
|
|
if (!roots_[i]->conditionsMet(well_bhp,
|
|
|
|
well_reservoirrates_phase,
|
|
|
|
well_surfacerates_phase,
|
|
|
|
phases)) {
|
2012-04-25 09:14:40 -05:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
2012-04-12 07:25:39 -05:00
|
|
|
}
|
2012-04-25 07:19:47 -05:00
|
|
|
|
2012-04-25 09:14:40 -05:00
|
|
|
void WellCollection::setWellsPointer(Wells* wells) {
|
2012-04-25 07:19:47 -05:00
|
|
|
for(size_t i = 0; i < leaf_nodes_.size(); i++) {
|
|
|
|
leaf_nodes_[i]->setWellsPointer(wells, i);
|
|
|
|
}
|
|
|
|
}
|
2012-05-02 06:02:59 -05:00
|
|
|
|
|
|
|
void WellCollection::applyGroupControls()
|
|
|
|
{
|
|
|
|
for (size_t i = 0; i < roots_.size(); ++i) {
|
|
|
|
roots_[i]->applyProdGroupControls();
|
|
|
|
roots_[i]->applyInjGroupControls();
|
|
|
|
}
|
|
|
|
}
|
2012-04-25 07:03:57 -05:00
|
|
|
}
|