Add Means of Retrieving Node Names from Extended Network

This commit adds a new member function

    ExtNetwork::node_names() const

which collects the names (std::string) of all nodes in a network.
The immediate use case is creating summary config nodes for network
level quantities specified without explicit lists of nodes, e.g.,

    GPR
    /

Add a simple unit test for demonstration.
This commit is contained in:
Bård Skaflestad
2020-09-19 00:13:13 +02:00
parent 6ea0e73512
commit dbfd013cf4
3 changed files with 67 additions and 3 deletions

View File

@@ -17,10 +17,12 @@
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#define BOOST_TEST_MODULE ScheduleTests
#define BOOST_TEST_MODULE NetworkTests
#include <boost/test/unit_test.hpp>
#include <algorithm>
#include <opm/parser/eclipse/EclipseState/Schedule/Network/ExtNetwork.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Network/Node.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Network/Branch.hpp>
@@ -32,6 +34,7 @@
using namespace Opm;
namespace {
Schedule make_schedule(const std::string& schedule_string) {
Parser parser;
auto python = std::make_shared<Python>();
@@ -43,7 +46,7 @@ Schedule make_schedule(const std::string& schedule_string) {
Schedule schedule(deck, grid , fp, runspec, python);
return schedule;
}
}
BOOST_AUTO_TEST_CASE(CreateNetwork) {
@@ -266,3 +269,50 @@ BRANPROP
}
}
BOOST_AUTO_TEST_CASE(NodeNames) {
const auto sched = make_schedule(R"(
SCHEDULE
GRUPTREE
'PROD' 'FIELD' /
'M5S' 'PLAT-A' /
'M5N' 'PLAT-A' /
'C1' 'M5N' /
'F1' 'M5N' /
'B1' 'M5S' /
'G1' 'M5S' /
/
BRANPROP
-- Downtree Uptree #VFP ALQ
B1 PLAT-A 9999 1* /
C1 PLAT-A 9999 1* /
/
NODEPROP
-- Node_name Pr autoChock? addGasLift? Group_name
PLAT-A 21.0 NO NO 1* /
B1 1* YES NO 1* /
C1 1* YES NO 'GROUP' /
/
TSTEP
10 /
BRANPROP
-- Downtree Uptree #VFP ALQ
C1 PLAT-A 0 1* /
/
)");
const auto expect = std::vector<std::string> {
"B1", "C1", "PLAT-A"
};
auto nodes = sched.network(0).node_names();
std::sort(nodes.begin(), nodes.end());
BOOST_CHECK_EQUAL_COLLECTIONS(nodes.begin(), nodes.end(), expect.begin(), expect.end());
}