Add ParseContext for undefined UDQ

This commit is contained in:
Joakim Hove
2019-03-09 10:19:11 +01:00
parent 25d7e99413
commit f4196ff25e
4 changed files with 39 additions and 1 deletions

View File

@@ -271,6 +271,8 @@ namespace Opm {
const static std::string SUMMARY_UNKNOWN_WELL;
const static std::string SUMMARY_UNKNOWN_GROUP;
const static std::string SUMMARY_UNHANDLED_KEYWORD;
const static std::string SUMMARY_UNDEFINED_UDQ;
const static std::string SUMMARY_UDQ_MISSING_UNIT;
/*
A well must be specified (e.g. WELSPECS) and have completions

View File

@@ -34,6 +34,7 @@
#include <opm/parser/eclipse/EclipseState/Tables/TableManager.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/EclipseGrid.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/GridDims.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQInput.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Group.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/TimeMap.hpp>
@@ -124,6 +125,9 @@ namespace {
{"SGAS" , {"BSGAS"}}
};
bool is_udq(const std::string& keyword) {
return (keyword.size() > 1 && keyword[1] == 'U');
}
void handleMissingWell( const ParseContext& parseContext, ErrorGuard& errors, const std::string& keyword, const std::string& well) {
@@ -534,6 +538,21 @@ inline void keywordMISC( SummaryConfig::keyword_list& list,
ErrorGuard& errors,
const GridDims& dims) {
const auto var_type = ecl_smspec_identify_var_type( keyword.name().c_str() );
const auto& name = keyword.name();
if (is_udq(name)) {
const auto& udq = schedule.getUDQConfig(schedule.size() - 1);
if (!udq.has_keyword(name)) {
std::string msg{"Summary output has been requested for UDQ keyword: " + name + " but it has not been configured"};
parseContext.handleError(ParseContext::SUMMARY_UNDEFINED_UDQ, msg, errors);
return;
}
if (!udq.has_unit(name)) {
std::string msg{"Summary output has been requested for UDQ keyword: " + name + " but no unit has not been configured"};
parseContext.handleError(ParseContext::SUMMARY_UDQ_MISSING_UNIT, msg, errors);
}
}
switch( var_type ) {
case ECL_SMSPEC_WELL_VAR: return keywordW( list, parseContext, errors, keyword, schedule );

View File

@@ -17,11 +17,11 @@
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#include <ert/util/util.h>
#include <cstdlib>
#include <iostream>
#include <boost/algorithm/string.hpp>
#include <ert/util/util.h>
#include <opm/parser/eclipse/Parser/ErrorGuard.hpp>
#include <opm/parser/eclipse/Parser/InputErrorAction.hpp>
@@ -94,6 +94,8 @@ namespace Opm {
addKey(SUMMARY_UNKNOWN_WELL, InputError::THROW_EXCEPTION);
addKey(SUMMARY_UNKNOWN_GROUP, InputError::THROW_EXCEPTION);
addKey(SUMMARY_UNHANDLED_KEYWORD, InputError::WARN);
addKey(SUMMARY_UNDEFINED_UDQ, InputError::WARN);
addKey(SUMMARY_UDQ_MISSING_UNIT, InputError::WARN);
addKey(SCHEDULE_INVALID_NAME, InputError::THROW_EXCEPTION);
addKey(ACTIONX_ILLEGAL_KEYWORD, InputError::THROW_EXCEPTION);
@@ -321,6 +323,8 @@ namespace Opm {
const std::string ParseContext::SUMMARY_UNKNOWN_WELL = "SUMMARY_UNKNOWN_WELL";
const std::string ParseContext::SUMMARY_UNKNOWN_GROUP = "SUMMARY_UNKNOWN_GROUP";
const std::string ParseContext::SUMMARY_UNHANDLED_KEYWORD = "SUMMARY_UNHANDLED_KEYWORD";
const std::string ParseContext::SUMMARY_UNDEFINED_UDQ = "SUMMARY_UNDEFINED_UDQ";
const std::string ParseContext::SUMMARY_UDQ_MISSING_UNIT = "SUMMARY_UDQ_MISSING_UNIT";
const std::string ParseContext::RPT_MIXED_STYLE = "RPT_MIXED_STYLE";
const std::string ParseContext::RPT_UNKNOWN_MNEMONIC = "RPT_UNKNOWN_MNEMONIC";

View File

@@ -432,6 +432,19 @@ BOOST_AUTO_TEST_CASE(INVALID_WELL2) {
BOOST_CHECK_NO_THROW( createSummary( input , parseContext ));
}
BOOST_AUTO_TEST_CASE(UNDEFINED_UDQ_WELL) {
ParseContext parseContext;
const auto input = "WUWCT\n"
"/\n";
parseContext.updateKey( ParseContext::SUMMARY_UNDEFINED_UDQ, InputError::THROW_EXCEPTION );
BOOST_CHECK_THROW( createSummary( input , parseContext ) , std::invalid_argument);
parseContext.updateKey( ParseContext::SUMMARY_UNDEFINED_UDQ, InputError::IGNORE );
BOOST_CHECK_NO_THROW( createSummary( input , parseContext ));
}
BOOST_AUTO_TEST_CASE(INVALID_GROUP) {
ParseContext parseContext;