Merge pull request #2928 from bska/parse-interreg-sumkw

Recognize Additional Inter-Region Flow Summary Vector Keywords
This commit is contained in:
Joakim Hove
2022-01-14 10:05:33 +01:00
committed by GitHub
6 changed files with 118 additions and 20 deletions

View File

@@ -16,10 +16,12 @@
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <regex>
#include <set>
#include <stdexcept>
#include <string>
@@ -291,14 +293,15 @@ struct SummaryConfigContext {
return keyword == "WPIL";
}
bool is_region_to_region(const std::string& keyword) {
using sz_t = std::string::size_type;
if ((keyword.size() == sz_t{3}) && keyword[2] == 'F') return true;
if ((keyword == "RNLF") || (keyword == "RORFR")) return true;
if ((keyword.size() >= sz_t{4}) && ((keyword[2] == 'F') && ((keyword[3] == 'T') || (keyword[3] == 'R')))) return true;
if ((keyword.size() >= sz_t{5}) && ((keyword[3] == 'F') && ((keyword[4] == 'T') || (keyword[4] == 'R')))) return true;
bool is_region_to_region(const std::string& keyword)
{
static const auto rate = std::regex { R"(R[OGWEK]F[RT][-+GL]?)" };
static const auto ngl = std::regex { R"(RNLF[RT][-+]?)" };
return false;
// R[OGW]F[RT][-+GL]? (e.g., "ROFTG", "RGFR+", or "RWFT")
// RNLF[RT].? (e.g., "RNLFR-" or "RNLFT")
return std::regex_match(keyword, rate)
|| std::regex_match(keyword, ngl);
}
bool is_aquifer(const std::string& keyword)

View File

@@ -5,7 +5,11 @@
],
"deck_names": [
"ROFT",
"ROFTL",
"ROFTG",
"RGFT",
"RGFTL",
"RGFTG",
"RWFT"
],
"items": [

View File

@@ -46,8 +46,6 @@
"RGPTS",
"RGIR",
"RGIT",
"RGFTL",
"RGFTG",
"RPR",
"RPRH",
"RPRP",

View File

@@ -0,0 +1,18 @@
{
"name": "REGION2REGION_PROBE_E300",
"sections": [
"SUMMARY"
],
"comment": "E300 only",
"deck_name_regex": "R[OGWEK]F(R[-+]?|T[-+])",
"items": [
{
"name": "REGION1",
"value_type": "INT"
},
{
"name": "REGION2",
"value_type": "INT"
}
]
}

View File

@@ -1067,6 +1067,7 @@ set( keywords
001_Eclipse300/O/OPTIONS3
001_Eclipse300/P/PREF
001_Eclipse300/P/PREFS
001_Eclipse300/R/REGION2REGION_PROBE_E300
001_Eclipse300/S/SALINITY
001_Eclipse300/S/STCOND
001_Eclipse300/T/TEMPI

View File

@@ -357,17 +357,91 @@ BOOST_AUTO_TEST_CASE(regions) {
}
BOOST_AUTO_TEST_CASE(region2region) {
const auto input = "ROFT\n"
"1 2/\n"
"3 4/\n"
"/\n"
"RWIP\n"
"/\n"
"RGFT\n"
"5 6/\n"
"7 8/\n"
"/\n";
const auto input = std::string { R"(ROFT
1 2/
3 4/
/
ROFT+
1 2/
3 4/
/
ROFT-
1 2/
3 4/
/
ROFR
1 2/
3 4/
/
ROFR+
1 2/
3 4/
/
ROFR-
1 2/
3 4/
/
ROFTL
1 2/
3 4/
/
ROFTG
1 2/
3 4/
/
RGFT
5 6/
7 8/
/
RGFT+
5 6/
7 8/
/
RGFT-
5 6/
7 8/
/
RGFR
5 6/
7 8/
/
RGFR+
5 6/
7 8/
/
RGFR-
5 6/
7 8/
/
RGFTL
1 2 /
1 3 /
/
RGFTG
1 2 /
1 3 /
/
RWFT
2 3 /
/
RWFT+
2 3 /
/
RWFT-
2 3 /
/
RWFR
2 3 /
/
RWFR+
2 3 /
/
RWFR-
2 3 /
/
RWIP
/
)" };
ParseContext parseContext;
parseContext.update(ParseContext::SUMMARY_UNHANDLED_KEYWORD, InputError::IGNORE);