From ecbfd4e9c445b5d1b900ccbc04d10e1e3024ac27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Wed, 13 Sep 2023 18:07:29 +0200 Subject: [PATCH] Support Region Set Tags For All Region Level Summary Vectors This commit switches the existing, somewhat spotty, support for matching region set tags on region level summary vector keywords. We leverage the recent support for 'deck_name_regex_suffix' keys in the JSON keyword model to extend the keyword matching algorithm to also account for these region set tags. There is a potential for false positives here, but we'll use this as an initial proof-of-concept implementation. --- .../keywords/000_Eclipse100/R/REGION_PROBE | 10 +-- tests/parser/SummaryConfigTests.cpp | 74 +++++++++++++------ 2 files changed, 56 insertions(+), 28 deletions(-) diff --git a/src/opm/input/eclipse/share/keywords/000_Eclipse100/R/REGION_PROBE b/src/opm/input/eclipse/share/keywords/000_Eclipse100/R/REGION_PROBE index bb8b994c1..0e5d85a86 100644 --- a/src/opm/input/eclipse/share/keywords/000_Eclipse100/R/REGION_PROBE +++ b/src/opm/input/eclipse/share/keywords/000_Eclipse100/R/REGION_PROBE @@ -5,9 +5,9 @@ ], "comment": "Tracer keywords where the 2nd letter is a 'T' should be compounded with the tracer name", "deck_names": [ - "RRPV_[0-9A-Z][0-9A-Z][0-9A-Z]", - "ROEW_[0-9A-Z][0-9A-Z][0-9A-Z]", - "RHPV_[0-9A-Z][0-9A-Z][0-9A-Z]", + "RRPV", + "ROEW", + "RHPV", "ROSAT", "ROIP", "ROIPL", @@ -109,9 +109,9 @@ "RTFTTSUR", "RTADSUR" ], - "CommentFip": "This regexp should work for region output of arbitrary named FIPxxxx regions. Current implementation is not entirely correct", "CommentTracer": "???", - "deck_name_regex": "R[OGW]?[OIP][EPRT]_.+|RU.+|RTIPF.+|RTIPS.+|RTFTF.+|RTFTS.+|RTFTT.+|RTIPT.+|RTIPF.+|RTIPS.+|RTIP[1-9][0-9]*.+|RTFTT.+|RTFTF.+|RTFTS.+|RTFT[1-9][0-9]*.+|RTADS.+|RTDCY.+", + "deck_name_regex": "RU.+|RTIPF.+|RTIPS.+|RTFTF.+|RTFTS.+|RTFTT.+|RTIPT.+|RTIPF.+|RTIPS.+|RTIP[1-9][0-9]*.+|RTFTT.+|RTFTF.+|RTFTS.+|RTFT[1-9][0-9]*.+|RTADS.+|RTDCY.+", + "deck_name_regex_suffix": "_{0,2}[A-Z0-9]{3}", "data": { "value_type": "INT" } diff --git a/tests/parser/SummaryConfigTests.cpp b/tests/parser/SummaryConfigTests.cpp index c3fdf851f..15ab8cc03 100644 --- a/tests/parser/SummaryConfigTests.cpp +++ b/tests/parser/SummaryConfigTests.cpp @@ -1950,12 +1950,23 @@ RUNSUM BOOST_AUTO_TEST_CASE(FIPREG) { - std::string deck_string = R"( --- The FIPREG region has three distinct values, i.e. --- there will be three different RPR__REG keywords. + const std::string deck_string = R"( +-- Both the FIPREG and the FIPXYZ region sets have three distinct +-- values (i.e., region IDs). Consequently, there will be three +-- separate *_REG or *XYZ summary configuration nodes for each +-- region level summary vector requested here. RPR__REG / +RPRP_REG +/ + +RPRH_REG +/ + +RODENXYZ +/ + ROPT_REG / @@ -1969,34 +1980,51 @@ RHPV_REG / )"; - const auto& summary_config = createSummary(deck_string); - // The +5 corresponds to five additional COPT summary config keywords which - // have been automatically added for the ROEW calculation. - BOOST_CHECK_EQUAL(summary_config.size(), 15 + 5); - BOOST_CHECK(summary_config.hasKeyword("RPR__REG")); - BOOST_CHECK(summary_config.hasKeyword("ROPT_REG")); - BOOST_CHECK(summary_config.hasKeyword("RRPV_REG")); - BOOST_CHECK(summary_config.hasKeyword("ROEW_REG")); - BOOST_CHECK(summary_config.hasKeyword("RHPV_REG")); + + const auto summary_config = createSummary(deck_string); + + // The +5 corresponds to five additional COPT summary config keywords + // which have been automatically added for the ROEW calculation. + const auto numRegKw = 8; + BOOST_CHECK_EQUAL(summary_config.size(), numRegKw*3 + 5); + + BOOST_CHECK( summary_config.hasKeyword("RPR__REG")); + BOOST_CHECK( summary_config.hasKeyword("RPRP_REG")); + BOOST_CHECK( summary_config.hasKeyword("RPRH_REG")); + BOOST_CHECK( summary_config.hasKeyword("RODENXYZ")); + BOOST_CHECK( summary_config.hasKeyword("ROPT_REG")); + BOOST_CHECK( summary_config.hasKeyword("RRPV_REG")); + BOOST_CHECK( summary_config.hasKeyword("ROEW_REG")); + BOOST_CHECK( summary_config.hasKeyword("RHPV_REG")); BOOST_CHECK(!summary_config.hasKeyword("RPR")); BOOST_CHECK(!summary_config.match("BPR*")); - BOOST_CHECK(summary_config.match("RPR*")); + BOOST_CHECK( summary_config.match("RPR*")); + for (const auto& node : summary_config) { - if (node.category() == EclIO::SummaryNode::Category::Region) - BOOST_CHECK_EQUAL( node.fip_region(), "FIPREG" ); + if (node.category() == EclIO::SummaryNode::Category::Region) { + if (node.keyword() == "RODENXYZ") { + BOOST_CHECK_EQUAL(node.fip_region(), "FIPXYZ"); + } + else { + BOOST_CHECK_EQUAL(node.fip_region(), "FIPREG"); + } + } } - const auto& fip_regions = summary_config.fip_regions(); - BOOST_CHECK_EQUAL(fip_regions.size(), 1U); + { + const auto& fip_regions = summary_config.fip_regions(); + BOOST_CHECK_EQUAL(fip_regions.size(), 2U); - auto reg_iter = fip_regions.find("FIPREG"); - BOOST_CHECK( reg_iter != fip_regions.end() ); + auto reg_iter = fip_regions.find("FIPREG"); + BOOST_CHECK(reg_iter != fip_regions.end()); + } + { + auto rpr = summary_config.keywords("RP*"); + BOOST_CHECK_EQUAL(rpr.size(), 9U); + } - auto rpr = summary_config.keywords("RP*"); - BOOST_CHECK_EQUAL(rpr.size(), 3U); - - // See comment on the roew() function in Summary.cpp for this uglyness. + // See comment on the roew() function in Summary.cpp for this ugliness. BOOST_CHECK(summary_config.hasKeyword("COPT")); }