Extracted common functionality from the three create functions
This commit is contained in:
parent
36348a8f8a
commit
663eb5a56d
@ -35,20 +35,8 @@ namespace Opm
|
|||||||
parent = roots_[roots_.size() - 1].get();
|
parent = roots_[roots_.size() - 1].get();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<WellsGroupInterface> child;
|
std::shared_ptr<WellsGroupInterface> child = getAndUnRootChild(groupChild->name());
|
||||||
|
|
||||||
for (size_t i = 0; i < roots_.size(); ++i) {
|
|
||||||
if (roots_[i]->name() == groupChild->name()) {
|
|
||||||
child = roots_[i];
|
|
||||||
// We've found a new parent to the previously thought root, need to remove it
|
|
||||||
for(size_t j = i; j < roots_.size() - 1; ++j) {
|
|
||||||
roots_[j] = roots_[j+1];
|
|
||||||
}
|
|
||||||
|
|
||||||
roots_.resize(roots_.size()-1);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!child.get()) {
|
if (!child.get()) {
|
||||||
child = createGroupWellsGroup(groupChild, timeStep, phaseUsage);
|
child = createGroupWellsGroup(groupChild, timeStep, phaseUsage);
|
||||||
}
|
}
|
||||||
@ -74,20 +62,8 @@ namespace Opm
|
|||||||
parent = roots_[roots_.size() - 1].get();
|
parent = roots_[roots_.size() - 1].get();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<WellsGroupInterface> child;
|
std::shared_ptr<WellsGroupInterface> child = getAndUnRootChild(wellChild->name());
|
||||||
|
|
||||||
for (size_t i = 0; i < roots_.size(); ++i) {
|
|
||||||
if (roots_[i]->name() == wellChild->name()) {
|
|
||||||
child = roots_[i];
|
|
||||||
// We've found a new parent to the previously thought root, need to remove it
|
|
||||||
for(size_t j = i; j < roots_.size() - 1; ++j) {
|
|
||||||
roots_[j] = roots_[j+1];
|
|
||||||
}
|
|
||||||
|
|
||||||
roots_.resize(roots_.size()-1);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!child.get()) {
|
if (!child.get()) {
|
||||||
child = createWellWellsGroup(wellChild, timeStep, phaseUsage);
|
child = createWellWellsGroup(wellChild, timeStep, phaseUsage);
|
||||||
}
|
}
|
||||||
@ -115,20 +91,9 @@ namespace Opm
|
|||||||
roots_.push_back(createWellsGroup(parent_name, deck));
|
roots_.push_back(createWellsGroup(parent_name, deck));
|
||||||
parent = roots_[roots_.size() - 1].get();
|
parent = roots_[roots_.size() - 1].get();
|
||||||
}
|
}
|
||||||
std::shared_ptr<WellsGroupInterface> child;
|
|
||||||
|
|
||||||
for (size_t i = 0; i < roots_.size(); ++i) {
|
std::shared_ptr<WellsGroupInterface> child = getAndUnRootChild(child_name);
|
||||||
if (roots_[i]->name() == child_name) {
|
|
||||||
child = roots_[i];
|
|
||||||
// We've found a new parent to the previously thought root, need to remove it
|
|
||||||
for(size_t j = i; j < roots_.size() - 1; ++j) {
|
|
||||||
roots_[j] = roots_[j+1];
|
|
||||||
}
|
|
||||||
|
|
||||||
roots_.resize(roots_.size()-1);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!child.get()) {
|
if (!child.get()) {
|
||||||
child = createWellsGroup(child_name, deck);
|
child = createWellsGroup(child_name, deck);
|
||||||
}
|
}
|
||||||
@ -147,6 +112,23 @@ namespace Opm
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::shared_ptr<WellsGroupInterface> WellCollection::getAndUnRootChild(std::string child_name) {
|
||||||
|
std::shared_ptr<WellsGroupInterface> child;
|
||||||
|
|
||||||
|
for (size_t i = 0; i < roots_.size(); ++i) {
|
||||||
|
if (roots_[i]->name() == child_name) {
|
||||||
|
child = roots_[i];
|
||||||
|
// We've found a new parent to the previously thought root, need to remove it
|
||||||
|
for(size_t j = i; j < roots_.size() - 1; ++j) {
|
||||||
|
roots_[j] = roots_[j+1];
|
||||||
|
}
|
||||||
|
|
||||||
|
roots_.resize(roots_.size()-1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return child;
|
||||||
|
}
|
||||||
|
|
||||||
const std::vector<WellNode*>& WellCollection::getLeafNodes() const {
|
const std::vector<WellNode*>& WellCollection::getLeafNodes() const {
|
||||||
return leaf_nodes_;
|
return leaf_nodes_;
|
||||||
|
@ -140,6 +140,7 @@ namespace Opm
|
|||||||
const std::vector<double>& well_surfacerates_phase);
|
const std::vector<double>& well_surfacerates_phase);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
std::shared_ptr<WellsGroupInterface> getAndUnRootChild(std::string child_name);
|
||||||
// To account for the possibility of a forest
|
// To account for the possibility of a forest
|
||||||
std::vector<std::shared_ptr<WellsGroupInterface> > roots_;
|
std::vector<std::shared_ptr<WellsGroupInterface> > roots_;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user