diff --git a/src/opm/parser/eclipse/Parser/Parser.cpp b/src/opm/parser/eclipse/Parser/Parser.cpp index 67a4c2f39..52bebfefa 100644 --- a/src/opm/parser/eclipse/Parser/Parser.cpp +++ b/src/opm/parser/eclipse/Parser/Parser.cpp @@ -19,6 +19,7 @@ #include #include +#include #include #include @@ -600,7 +601,10 @@ RawKeyword * newRawKeyword(const ParserKeyword& parserKeyword, const std::string if( deck.hasKeyword(keyword_size.keyword ) ) { const auto& sizeDefinitionKeyword = deck.getKeyword(keyword_size.keyword); const auto& record = sizeDefinitionKeyword.getRecord(0); - const auto targetSize = record.getItem( keyword_size.item ).get< int >( 0 ) + keyword_size.shift; + auto targetSize = record.getItem( keyword_size.item ).get< int >( 0 ) + keyword_size.shift; + if (parserKeyword.isAlternatingKeyword()) + targetSize *= std::distance( parserKeyword.begin(), parserKeyword.end() ); + return new RawKeyword( keywordString, parserState.current_path().string(), parserState.line(), diff --git a/src/opm/parser/eclipse/Parser/ParserKeyword.cpp b/src/opm/parser/eclipse/Parser/ParserKeyword.cpp index e6b729a40..e26378b8a 100644 --- a/src/opm/parser/eclipse/Parser/ParserKeyword.cpp +++ b/src/opm/parser/eclipse/Parser/ParserKeyword.cpp @@ -206,8 +206,6 @@ namespace Opm { if (jsonConfig.has_item("alternating_records")) { alternating_keyword = true; - if (!jsonConfig.has_item("num_tables") || jsonConfig.has_item("size")) - throw std::invalid_argument("alternating_records must have num_tables."); const Json::JsonObject recordsConfig = jsonConfig.get_item("alternating_records"); parseRecords( recordsConfig ); } diff --git a/src/opm/parser/eclipse/share/keywords/000_Eclipse100/P/PVTWSALT b/src/opm/parser/eclipse/share/keywords/000_Eclipse100/P/PVTWSALT index 985c135b3..916ce3ca5 100644 --- a/src/opm/parser/eclipse/share/keywords/000_Eclipse100/P/PVTWSALT +++ b/src/opm/parser/eclipse/share/keywords/000_Eclipse100/P/PVTWSALT @@ -1,9 +1,10 @@ { - "name" : "PVTWSALT", "sections" : ["PROPS"], "num_tables" : {"keyword" : "TABDIMS" , "item" : "NTPVT"}, "alternating_records" : [ + "name" : "PVTWSALT", "sections" : ["PROPS"], "size" : {"keyword" : "TABDIMS" , "item" : "NTPVT"}, "alternating_records" : [ [ - {"name" : "REF_TEMP", "value_type" : "DOUBLE", "dimension" : "Temperature"} + {"name":"P_REF", "value_type" : "DOUBLE", "dimension":"Pressure"}, + {"name":"SALT_CONCENTRATION_REF", "value_type" : "DOUBLE", "default" : 0.0,"dimension":"Density"} ], - [ - {"name" : "table", "value_type" : "DOUBLE", "size_type" : "ALL", "dimension" : ["Pressure" , "1", "Viscosity"]} + [ + {"name" : "table", "value_type" : "DOUBLE", "size_type" : "ALL", "dimension" : ["Density","1","1/Pressure","Viscosity", "1/Pressure"]} ]] } diff --git a/src/opm/parser/eclipse/share/keywords/000_Eclipse100/P/PVZG b/src/opm/parser/eclipse/share/keywords/000_Eclipse100/P/PVZG index 675112fbf..ac69dc249 100644 --- a/src/opm/parser/eclipse/share/keywords/000_Eclipse100/P/PVZG +++ b/src/opm/parser/eclipse/share/keywords/000_Eclipse100/P/PVZG @@ -1,9 +1,10 @@ { - "name" : "PVZG", "sections" : ["PROPS"], "num_tables" : {"keyword" : "TABDIMS" , "item" : "NTPVT"}, "alternating_records" : [ + "name" : "PVZG", "sections" : ["PROPS"], "size" : {"keyword" : "TABDIMS" , "item" : "NTPVT"}, "alternating_records" : [ [ {"name" : "REF_TEMP", "value_type" : "DOUBLE", "dimension" : "Temperature"} ], - [ + [ {"name" : "table", "value_type" : "DOUBLE", "size_type" : "ALL", "dimension" : ["Pressure" , "1", "Viscosity"]} ]] } + diff --git a/src/opm/parser/eclipse/share/keywords/000_Eclipse100/S/STOG b/src/opm/parser/eclipse/share/keywords/000_Eclipse100/S/STOG index 2cfa3c457..b1007759d 100644 --- a/src/opm/parser/eclipse/share/keywords/000_Eclipse100/S/STOG +++ b/src/opm/parser/eclipse/share/keywords/000_Eclipse100/S/STOG @@ -1,9 +1,9 @@ { - "name" : "STOG", "sections" : ["PROPS"], "num_tables" : {"keyword" : "TABDIMS" , "item" : "NTPVT"}, "alternating_records" : [ + "name" : "STOG", "sections" : ["PROPS"], "size" : {"keyword" : "TABDIMS" , "item" : "NTPVT"}, "alternating_records" : [ [ {"name" : "REF_OIL_PHASE_PRESSURE", "value_type" : "DOUBLE", "dimension" : "Pressure"} ], - [ + [ {"name" : "table", "value_type" : "DOUBLE", "size_type" : "ALL", "dimension" : ["Pressure" , "SurfaceTension"]} ]] } diff --git a/src/opm/parser/eclipse/share/keywords/000_Eclipse100/S/STOW b/src/opm/parser/eclipse/share/keywords/000_Eclipse100/S/STOW index 6c61cf42d..e96724498 100644 --- a/src/opm/parser/eclipse/share/keywords/000_Eclipse100/S/STOW +++ b/src/opm/parser/eclipse/share/keywords/000_Eclipse100/S/STOW @@ -1,9 +1,9 @@ { - "name" : "STOW", "sections" : ["PROPS"], "num_tables" : {"keyword" : "TABDIMS" , "item" : "NTPVT"}, "alternating_records" : [ + "name" : "STOW", "sections" : ["PROPS"], "size" : {"keyword" : "TABDIMS" , "item" : "NTPVT"}, "alternating_records" : [ [ {"name" : "REF_OIL_PRESSURE", "value_type" : "DOUBLE", "dimension" : "Pressure"} ], - [ + [ {"name" : "table", "value_type" : "DOUBLE", "size_type" : "ALL", "dimension" : ["Pressure" , "SurfaceTension"]} ]] } diff --git a/src/opm/parser/eclipse/share/keywords/000_Eclipse100/S/STWG b/src/opm/parser/eclipse/share/keywords/000_Eclipse100/S/STWG index 7068d2da9..29a729ba4 100644 --- a/src/opm/parser/eclipse/share/keywords/000_Eclipse100/S/STWG +++ b/src/opm/parser/eclipse/share/keywords/000_Eclipse100/S/STWG @@ -1,9 +1,9 @@ { - "name" : "STWG", "sections" : ["PROPS"], "num_tables" : {"keyword" : "TABDIMS" , "item" : "NTPVT"}, "alternating_records" : [ + "name" : "STWG", "sections" : ["PROPS"], "size" : {"keyword" : "TABDIMS" , "item" : "NTPVT"}, "alternating_records" : [ [ {"name" : "REF_OIL_PRESSURE", "value_type" : "DOUBLE", "dimension" : "Pressure"} ], - [ + [ {"name" : "table", "value_type" : "DOUBLE", "size_type" : "ALL", "dimension" : ["Pressure" , "SurfaceTension"]} ]] } diff --git a/tests/parser/ParserTests.cpp b/tests/parser/ParserTests.cpp index 7a3a35c1a..d8330bad2 100644 --- a/tests/parser/ParserTests.cpp +++ b/tests/parser/ParserTests.cpp @@ -1748,16 +1748,6 @@ BOOST_AUTO_TEST_CASE(ConstructFromJson_withAlternatingRecordswithItems) { BOOST_CHECK_THROW( ParserKeyword kw( jsonObject ), std::invalid_argument); } -BOOST_AUTO_TEST_CASE(ConstructFromJson_withAlternatingRecordsSizeWithoutBrackets) { - const std::string json_string = R"( - {"name" : "STOG", "sections" : ["PROPS"] , "size" : 6, "alternating_records" : [[ - {"name" : "ref_oil_pressure", "value_type" : "DOUBLE"}], [ - {"name" : "oil_phase_pressure" , "value_type" : "DOUBLE"}, - {"name" : "surface_rension", "value_type" : "DOUBLE"}]]} - )"; - Json::JsonObject jsonObject( json_string ); - BOOST_CHECK_THROW( ParserKeyword kw( jsonObject ), std::invalid_argument); -} BOOST_AUTO_TEST_CASE(GetAlternatingKeywordFromParser) { Parser parser; diff --git a/tests/parser/integration/ParseKEYWORD.cpp b/tests/parser/integration/ParseKEYWORD.cpp index 213a2eb6b..2aac4e5b3 100644 --- a/tests/parser/integration/ParseKEYWORD.cpp +++ b/tests/parser/integration/ParseKEYWORD.cpp @@ -1455,3 +1455,45 @@ WORKLIM )"; Parser().parseString( input ); } + + + +BOOST_AUTO_TEST_CASE(PVTWSALT) { + const std::string input = R"( +RUNSPEC + +TABDIMS + 1 2 / + +PROPS + +PVTWSALT + 1000 0 / + 1 2 3 4 5 + 6 7 8 9 10 / + 2000 0.50 / + 1.5 2.5 3.5 4.5 5.5 + 6.5 7.5 8.5 9.5 10.5/ + +-- S_g k_rg k_rog p_cog +SGOF + 0.1 0.0 1.0 0.0 + 0.2 0.1 1.0 1.0 + 0.3 0.2 0.9 2.0 + 0.4 0.3 0.8 3.0 + 0.5 0.5 0.5 4.0 + 0.6 0.6 0.4 5.0 + 0.7 0.8 0.3 6.0 + 0.8 0.9 0.2 7.0 + 0.9 0.5 0.1 8.0 + 1.0 1.0 0.1 9.0 /; + + +)"; + auto deck = Parser{}.parseString(input); + const auto& pvtwsalt = deck.getKeyword("PVTWSALT"); + BOOST_CHECK_EQUAL(pvtwsalt.size(), 4); + + const auto& sgof = deck.getKeyword("SGOF"); + BOOST_CHECK_EQUAL(sgof.size(), 1); +}