2014-02-12 08:39:57 -06:00
|
|
|
/*
|
|
|
|
Copyright 2012 SINTEF ICT, Applied Mathematics.
|
|
|
|
|
|
|
|
This file is part of the Open Porous Media project (OPM).
|
|
|
|
|
|
|
|
OPM 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.
|
|
|
|
|
|
|
|
OPM 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 OPM. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#if HAVE_DYNAMIC_BOOST_TEST
|
|
|
|
#define BOOST_TEST_DYN_LINK
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define NVERBOSE // Suppress own messages when throw()ing
|
|
|
|
|
|
|
|
#define BOOST_TEST_MODULE WellCollectionTest
|
|
|
|
#include <boost/test/unit_test.hpp>
|
|
|
|
#include <opm/core/wells/WellCollection.hpp>
|
|
|
|
#include <opm/parser/eclipse/Parser/Parser.hpp>
|
2016-03-16 20:57:59 -05:00
|
|
|
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
|
2014-02-12 08:39:57 -06:00
|
|
|
#include <opm/parser/eclipse/Deck/Deck.hpp>
|
|
|
|
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
|
|
|
|
#include <opm/parser/eclipse/EclipseState/Schedule/Well.hpp>
|
2016-01-20 07:12:04 -06:00
|
|
|
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
|
2014-02-12 08:39:57 -06:00
|
|
|
#include <opm/parser/eclipse/EclipseState/Schedule/Group.hpp>
|
2016-01-20 07:12:04 -06:00
|
|
|
#include <opm/parser/eclipse/EclipseState/Schedule/GroupTree.hpp>
|
2014-02-12 08:39:57 -06:00
|
|
|
|
|
|
|
using namespace Opm;
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(AddWellsAndGroupToCollection) {
|
|
|
|
ParserPtr parser(new Parser());
|
2016-01-24 16:09:47 -06:00
|
|
|
std::string scheduleFile("wells_group.data");
|
2016-03-16 20:57:59 -05:00
|
|
|
ParseContext parseContext;
|
|
|
|
DeckConstPtr deck = parser->parseFile(scheduleFile, parseContext);
|
2016-08-08 03:02:53 -05:00
|
|
|
EclipseStateConstPtr eclipseState(new EclipseState(*deck, parseContext));
|
2014-02-12 08:39:57 -06:00
|
|
|
PhaseUsage pu = phaseUsageFromDeck(eclipseState);
|
|
|
|
|
|
|
|
GroupTreeNodePtr field=eclipseState->getSchedule()->getGroupTree(2)->getNode("FIELD");
|
|
|
|
GroupTreeNodePtr g1=eclipseState->getSchedule()->getGroupTree(2)->getNode("G1");
|
|
|
|
GroupTreeNodePtr g2=eclipseState->getSchedule()->getGroupTree(2)->getNode("G2");
|
|
|
|
|
|
|
|
WellCollection collection;
|
|
|
|
|
|
|
|
// Add groups to WellCollection
|
2016-06-16 02:33:43 -05:00
|
|
|
const auto* fieldGroup = eclipseState->getSchedule()->getGroup(field->name());
|
2014-02-13 09:00:39 -06:00
|
|
|
collection.addField(fieldGroup, 2, pu);
|
|
|
|
|
2014-02-12 08:39:57 -06:00
|
|
|
for (auto iter = field->begin(); iter != field->end(); ++iter) {
|
2016-06-16 02:33:43 -05:00
|
|
|
const auto* childGroupNode = eclipseState->getSchedule()->getGroup((*iter).second->name());
|
2014-02-13 09:00:39 -06:00
|
|
|
collection.addGroup(childGroupNode, fieldGroup->name(), 2, pu);
|
2014-02-12 08:39:57 -06:00
|
|
|
}
|
|
|
|
|
2016-06-16 02:33:43 -05:00
|
|
|
const auto* g1Group = eclipseState->getSchedule()->getGroup(g1->name());
|
2014-02-12 08:39:57 -06:00
|
|
|
for (auto iter = g1->begin(); iter != g1->end(); ++iter) {
|
2016-06-16 02:33:43 -05:00
|
|
|
const auto* childGroupNode = eclipseState->getSchedule()->getGroup((*iter).second->name());
|
2014-02-13 09:00:39 -06:00
|
|
|
collection.addGroup(childGroupNode, g1Group->name(), 2, pu);
|
2014-02-12 08:39:57 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-06-16 02:33:43 -05:00
|
|
|
const auto* g2Group = eclipseState->getSchedule()->getGroup(g2->name());
|
2014-02-12 08:39:57 -06:00
|
|
|
for (auto iter = g2->begin(); iter != g2->end(); ++iter) {
|
2016-06-16 02:33:43 -05:00
|
|
|
const auto* childGroupNode = eclipseState->getSchedule()->getGroup((*iter).second->name());
|
2014-02-13 09:00:39 -06:00
|
|
|
collection.addGroup(childGroupNode, g2Group->name(), 2, pu);
|
2014-02-12 08:39:57 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOST_CHECK_EQUAL("FIELD", collection.findNode("FIELD")->name());
|
|
|
|
BOOST_CHECK_EQUAL("FIELD", collection.findNode("G1")->getParent()->name());
|
|
|
|
BOOST_CHECK_EQUAL("FIELD", collection.findNode("G2")->getParent()->name());
|
|
|
|
|
|
|
|
// Add wells to WellCollection
|
|
|
|
WellCollection wellCollection;
|
2016-06-16 02:33:43 -05:00
|
|
|
auto wells = eclipseState->getSchedule()->getWells();
|
2014-02-12 08:39:57 -06:00
|
|
|
for (size_t i=0; i<wells.size(); i++) {
|
2014-02-13 09:00:39 -06:00
|
|
|
collection.addWell(wells[i], 2, pu);
|
2014-02-12 08:39:57 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOST_CHECK_EQUAL("G1", collection.findNode("INJ1")->getParent()->name());
|
|
|
|
BOOST_CHECK_EQUAL("G1", collection.findNode("INJ2")->getParent()->name());
|
|
|
|
BOOST_CHECK_EQUAL("G2", collection.findNode("PROD1")->getParent()->name());
|
|
|
|
BOOST_CHECK_EQUAL("G2", collection.findNode("PROD2")->getParent()->name());
|
|
|
|
}
|
|
|
|
|