diff --git a/src/opm/parser/eclipse/EclipseState/InitConfig/FoamConfig.cpp b/src/opm/parser/eclipse/EclipseState/InitConfig/FoamConfig.cpp index 1cfddf659..c18067768 100644 --- a/src/opm/parser/eclipse/EclipseState/InitConfig/FoamConfig.cpp +++ b/src/opm/parser/eclipse/EclipseState/InitConfig/FoamConfig.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -132,25 +133,19 @@ FoamConfig::FoamConfig(const Deck& deck) // setup for foam at this point, so we detect and deal with it here even though we // do not store any data related to it. const auto& kw_foamopts = deck.getKeyword(); - transport_phase_ = get_phase(kw_foamopts.getRecord(0).getItem(0).get(0)); - std::string mobModel = kw_foamopts.getRecord(0).getItem(1).get(0); - if (mobModel.empty()) { - if (transport_phase_ == Phase::GAS) { - mobility_model_ = MobilityModel::TAB; - } else if (transport_phase_ == Phase::WATER) { - mobility_model_ = MobilityModel::FUNC; - } - } else if (mobModel == "TAB") { - mobility_model_ = MobilityModel::TAB; - } else if (mobModel == "FUNC") { - mobility_model_ = MobilityModel::FUNC; + this->transport_phase_ = get_phase(kw_foamopts.getRecord(0).getItem(0).get(0)); + if (!(this->transport_phase_ == Phase::GAS || this->transport_phase_ == Phase::WATER)) + throw OpmInputError("Only WATER and GAS phases are allowed for foam transport", kw_foamopts.location()); + + this->mobility_model_ = MobilityModel::TAB; + if (this->transport_phase_ == Phase::WATER) { + auto mobModel = kw_foamopts.getRecord(0).getItem(1).get(0); + if (mobModel == "FUNC") + this->mobility_model_ = MobilityModel::FUNC; } } + if (deck.hasKeyword()) { - if (!deck.hasKeyword()) { - throw std::runtime_error("FOAMFSC present but no FOAMROCK keyword found."); - } - // We have both FOAMFSC and FOAMROCK. const auto& kw_foamfsc = deck.getKeyword(); const auto& kw_foamrock = deck.getKeyword(); if (kw_foamfsc.size() != kw_foamrock.size()) { diff --git a/src/opm/parser/eclipse/share/keywords/000_Eclipse100/F/FOAMFSC b/src/opm/parser/eclipse/share/keywords/000_Eclipse100/F/FOAMFSC index 41059adfa..a79707cb9 100644 --- a/src/opm/parser/eclipse/share/keywords/000_Eclipse100/F/FOAMFSC +++ b/src/opm/parser/eclipse/share/keywords/000_Eclipse100/F/FOAMFSC @@ -3,6 +3,7 @@ "sections": [ "PROPS" ], + "requires" : ["FOAMROCK"], "size": { "keyword": "TABDIMS", "item": "NTSFUN" diff --git a/tests/parser/FoamTests.cpp b/tests/parser/FoamTests.cpp index dcaab01d8..3b193bcfc 100644 --- a/tests/parser/FoamTests.cpp +++ b/tests/parser/FoamTests.cpp @@ -82,15 +82,16 @@ PROPS FOAMOPTS GAS TAB / +FOAMROCK +1 2000 / +2 1800 / +2 2400 / + FOAMFSC 1 2 0.3 / 4 5 / 6 / -FOAMROCK -1 2000 / -2 1800 / -2 2400 / REGIONS SWAT @@ -194,7 +195,6 @@ BOOST_AUTO_TEST_CASE(FoamConfigTest) { } BOOST_AUTO_TEST_CASE(FoamConfigFailureTest) { - auto deck = createFailingDeck(); - BOOST_CHECK_THROW(EclipseState state(deck), std::runtime_error); + BOOST_CHECK_THROW( createFailingDeck(), std::exception ); }