Merge pull request #2586 from joakim-hove/foam-validation

Enforce keyword requirement with "requires": []
This commit is contained in:
Joakim Hove 2021-08-04 07:53:15 +02:00 committed by GitHub
commit d36e5a86a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 22 deletions

View File

@ -21,6 +21,7 @@
#include <opm/parser/eclipse/Deck/DeckItem.hpp>
#include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
#include <opm/parser/eclipse/Deck/DeckRecord.hpp>
#include <opm/common/utility/OpmInputError.hpp>
#include <opm/parser/eclipse/EclipseState/InitConfig/FoamConfig.hpp>
#include <opm/parser/eclipse/Parser/ParserKeywords/F.hpp>
@ -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<ParserKeywords::FOAMOPTS>();
transport_phase_ = get_phase(kw_foamopts.getRecord(0).getItem(0).get<std::string>(0));
std::string mobModel = kw_foamopts.getRecord(0).getItem(1).get<std::string>(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<std::string>(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<std::string>(0);
if (mobModel == "FUNC")
this->mobility_model_ = MobilityModel::FUNC;
}
}
if (deck.hasKeyword<ParserKeywords::FOAMFSC>()) {
if (!deck.hasKeyword<ParserKeywords::FOAMROCK>()) {
throw std::runtime_error("FOAMFSC present but no FOAMROCK keyword found.");
}
// We have both FOAMFSC and FOAMROCK.
const auto& kw_foamfsc = deck.getKeyword<ParserKeywords::FOAMFSC>();
const auto& kw_foamrock = deck.getKeyword<ParserKeywords::FOAMROCK>();
if (kw_foamfsc.size() != kw_foamrock.size()) {

View File

@ -3,6 +3,7 @@
"sections": [
"PROPS"
],
"requires" : ["FOAMROCK"],
"size": {
"keyword": "TABDIMS",
"item": "NTSFUN"

View File

@ -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 );
}