mirror of
https://github.com/OPM/opm-simulators.git
synced 2024-11-25 10:40:21 -06:00
Changed the WellCollection addChild functions to be more specific, and strict
This commit is contained in:
parent
f94f63ff56
commit
d7568b4adf
@ -27,56 +27,52 @@
|
||||
|
||||
namespace Opm
|
||||
{
|
||||
void WellCollection::addChild(GroupConstPtr groupChild, GroupConstPtr groupParent,
|
||||
void WellCollection::addField(GroupConstPtr fieldGroup, size_t timeStep, const PhaseUsage& phaseUsage) {
|
||||
WellsGroupInterface* fieldNode = findNode(fieldGroup->name());
|
||||
if (fieldNode) {
|
||||
OPM_THROW(std::runtime_error, "Trying to add FIELD node, but this already exists. Can only have one FIELD node.");
|
||||
}
|
||||
|
||||
roots_.push_back(createGroupWellsGroup(fieldGroup, timeStep, phaseUsage));
|
||||
}
|
||||
|
||||
void WellCollection::addGroup(GroupConstPtr groupChild, std::string parent_name,
|
||||
size_t timeStep, const PhaseUsage& phaseUsage) {
|
||||
WellsGroupInterface* parent = findNode(groupParent->name());
|
||||
WellsGroupInterface* parent = findNode(parent_name);
|
||||
if (!parent) {
|
||||
roots_.push_back(createGroupWellsGroup(groupParent, timeStep, phaseUsage));
|
||||
parent = roots_[roots_.size() - 1].get();
|
||||
OPM_THROW(std::runtime_error, "Trying to add child to group named " << parent_name << ", but this does not exist in the WellCollection.");
|
||||
}
|
||||
|
||||
std::shared_ptr<WellsGroupInterface> child = getAndUnRootChild(groupChild->name());
|
||||
if (findNode(groupChild->name())) {
|
||||
OPM_THROW(std::runtime_error, "Trying to add child named " << groupChild->name() << ", but this group is already in the WellCollection.");
|
||||
|
||||
if (!child.get()) {
|
||||
child = createGroupWellsGroup(groupChild, timeStep, phaseUsage);
|
||||
}
|
||||
|
||||
std::shared_ptr<WellsGroupInterface> child = createGroupWellsGroup(groupChild, timeStep, phaseUsage);
|
||||
|
||||
WellsGroup* parent_as_group = static_cast<WellsGroup*> (parent);
|
||||
if (!parent_as_group) {
|
||||
OPM_THROW(std::runtime_error, "Trying to add child to group named " << groupParent->name() << ", but it's not a group.");
|
||||
OPM_THROW(std::runtime_error, "Trying to add child to group named " << parent->name() << ", but it's not a group.");
|
||||
}
|
||||
parent_as_group->addChild(child);
|
||||
|
||||
if(child->isLeafNode()) {
|
||||
leaf_nodes_.push_back(static_cast<WellNode*>(child.get()));
|
||||
}
|
||||
|
||||
child->setParent(parent);
|
||||
}
|
||||
|
||||
void WellCollection::addChild(WellConstPtr wellChild, GroupConstPtr groupParent,
|
||||
size_t timeStep, const PhaseUsage& phaseUsage) {
|
||||
WellsGroupInterface* parent = findNode(groupParent->name());
|
||||
void WellCollection::addWell(WellConstPtr wellChild, size_t timeStep, const PhaseUsage& phaseUsage) {
|
||||
WellsGroupInterface* parent = findNode(wellChild->getGroupName(timeStep));
|
||||
if (!parent) {
|
||||
roots_.push_back(createGroupWellsGroup(groupParent, timeStep, phaseUsage));
|
||||
parent = roots_[roots_.size() - 1].get();
|
||||
OPM_THROW(std::runtime_error, "Trying to add child to group named " << wellChild->getGroupName(timeStep) << ", but this group does not exist in the WellCollection.");
|
||||
}
|
||||
|
||||
std::shared_ptr<WellsGroupInterface> child = getAndUnRootChild(wellChild->name());
|
||||
|
||||
if (!child.get()) {
|
||||
child = createWellWellsGroup(wellChild, timeStep, phaseUsage);
|
||||
}
|
||||
std::shared_ptr<WellsGroupInterface> child = createWellWellsGroup(wellChild, timeStep, phaseUsage);
|
||||
|
||||
WellsGroup* parent_as_group = static_cast<WellsGroup*> (parent);
|
||||
if (!parent_as_group) {
|
||||
OPM_THROW(std::runtime_error, "Trying to add child to group named " << groupParent->name() << ", but it's not a group.");
|
||||
OPM_THROW(std::runtime_error, "Trying to add child to group named " << wellChild->getGroupName(timeStep) << ", but it's not a group.");
|
||||
}
|
||||
parent_as_group->addChild(child);
|
||||
|
||||
if(child->isLeafNode()) {
|
||||
leaf_nodes_.push_back(static_cast<WellNode*>(child.get()));
|
||||
}
|
||||
leaf_nodes_.push_back(static_cast<WellNode*>(child.get()));
|
||||
|
||||
child->setParent(parent);
|
||||
}
|
||||
|
@ -40,28 +40,13 @@ namespace Opm
|
||||
{
|
||||
public:
|
||||
|
||||
/// Adds and creates if necessary the child to the collection
|
||||
/// and appends it to parent's children. Also adds and creates the parent
|
||||
/// if necessary.
|
||||
/// \param[in] wellChild the child well
|
||||
/// \param[in] groupParent the parent group
|
||||
/// \param[in] phaseUsage the phase usage
|
||||
/// \param[in] timeStep the current time step
|
||||
void addChild(WellConstPtr wellChild, GroupConstPtr groupParent,
|
||||
void addField(GroupConstPtr fieldGroup, size_t timeStep, const PhaseUsage& phaseUsage);
|
||||
|
||||
void addWell(WellConstPtr wellChild, size_t timeStep, const PhaseUsage& phaseUsage);
|
||||
|
||||
void addGroup(GroupConstPtr groupChild, std::string parent_name,
|
||||
size_t timeStep, const PhaseUsage& phaseUsage);
|
||||
|
||||
|
||||
/// Adds and creates if necessary the child to the collection
|
||||
/// and appends it to parent's children. Also adds and creates the parent
|
||||
/// if necessary.
|
||||
/// \param[in] groupChild the child group
|
||||
/// \param[in] groupParent the parent group
|
||||
/// \param[in] phaseUsage the phase usage
|
||||
/// \param[in] timeStep the current time step
|
||||
void addChild(GroupConstPtr groupChild, GroupConstPtr groupParent,
|
||||
size_t timeStep, const PhaseUsage& phaseUsage);
|
||||
|
||||
|
||||
/// Adds and creates if necessary the child to the collection
|
||||
/// and appends it to parent's children. Also adds and creates the parent
|
||||
/// if necessary.
|
||||
|
@ -52,22 +52,24 @@ BOOST_AUTO_TEST_CASE(AddWellsAndGroupToCollection) {
|
||||
|
||||
// Add groups to WellCollection
|
||||
GroupConstPtr fieldGroup = eclipseState->getSchedule()->getGroup(field->name());
|
||||
collection.addField(fieldGroup, 2, pu);
|
||||
|
||||
for (auto iter = field->begin(); iter != field->end(); ++iter) {
|
||||
GroupConstPtr childGroupNode = eclipseState->getSchedule()->getGroup((*iter).second->name());
|
||||
collection.addChild(childGroupNode, fieldGroup, 2, pu);
|
||||
collection.addGroup(childGroupNode, fieldGroup->name(), 2, pu);
|
||||
}
|
||||
|
||||
GroupConstPtr g1Group = eclipseState->getSchedule()->getGroup(g1->name());
|
||||
for (auto iter = g1->begin(); iter != g1->end(); ++iter) {
|
||||
GroupConstPtr childGroupNode = eclipseState->getSchedule()->getGroup((*iter).second->name());
|
||||
collection.addChild(childGroupNode, g1Group, 2, pu);
|
||||
collection.addGroup(childGroupNode, g1Group->name(), 2, pu);
|
||||
}
|
||||
|
||||
|
||||
GroupConstPtr g2Group = eclipseState->getSchedule()->getGroup(g2->name());
|
||||
for (auto iter = g2->begin(); iter != g2->end(); ++iter) {
|
||||
GroupConstPtr childGroupNode = eclipseState->getSchedule()->getGroup((*iter).second->name());
|
||||
collection.addChild(childGroupNode, g2Group, 2, pu);
|
||||
collection.addGroup(childGroupNode, g2Group->name(), 2, pu);
|
||||
}
|
||||
|
||||
BOOST_CHECK_EQUAL("FIELD", collection.findNode("FIELD")->name());
|
||||
@ -78,8 +80,7 @@ BOOST_AUTO_TEST_CASE(AddWellsAndGroupToCollection) {
|
||||
WellCollection wellCollection;
|
||||
std::vector<WellConstPtr> wells = eclipseState->getSchedule()->getWells();
|
||||
for (size_t i=0; i<wells.size(); i++) {
|
||||
GroupConstPtr parentGroup = eclipseState->getSchedule()->getGroup(wells[i]->getGroupName(2));
|
||||
collection.addChild(wells[i], parentGroup, 2, pu);
|
||||
collection.addWell(wells[i], 2, pu);
|
||||
}
|
||||
|
||||
BOOST_CHECK_EQUAL("G1", collection.findNode("INJ1")->getParent()->name());
|
||||
|
@ -42,6 +42,13 @@ WELSPECS
|
||||
'PROD2' 'G2' 10 10 8400 'OIL' /
|
||||
/
|
||||
|
||||
GCONINJE
|
||||
'G1' GAS RATE 30000 /
|
||||
/
|
||||
|
||||
GCONPROD
|
||||
'G2' ORAT 10000 /
|
||||
/
|
||||
|
||||
WCONINJE
|
||||
'INJ1' 'WATER' 'OPEN' 'RESV' 10 20 40 /
|
||||
|
Loading…
Reference in New Issue
Block a user