Merge pull request #3365 from akva2/inputerroraction.hpp_reduce_hotness

Schedule.hpp: forward InputErrorAction
This commit is contained in:
Bård Skaflestad 2023-01-16 23:27:18 +01:00 committed by GitHub
commit 67dbd5baa8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 351 additions and 291 deletions

View File

@ -241,6 +241,7 @@ if(ENABLE_ECL_INPUT)
src/opm/input/eclipse/Schedule/VFPInjTable.cpp
src/opm/input/eclipse/Schedule/VFPProdTable.cpp
src/opm/input/eclipse/Parser/ErrorGuard.cpp
src/opm/input/eclipse/Parser/InputErrorAction.cpp
src/opm/input/eclipse/Parser/ParseContext.cpp
src/opm/input/eclipse/Parser/Parser.cpp
src/opm/input/eclipse/Parser/ParserEnums.cpp

View File

@ -27,6 +27,7 @@
#include <opm/input/eclipse/Parser/Parser.hpp>
#include <opm/input/eclipse/Parser/ParseContext.hpp>
#include <opm/input/eclipse/Parser/ErrorGuard.hpp>
#include <opm/input/eclipse/Parser/InputErrorAction.hpp>
#include <opm/input/eclipse/Deck/Deck.hpp>
@ -54,10 +55,10 @@ std::vector<keyword> load_deck(const std::string& deck_file) {
std::vector<keyword> keywords;
/* Use the same default ParseContext as flow. */
parseContext.update(Opm::ParseContext::PARSE_RANDOM_SLASH, Opm::InputError::IGNORE);
parseContext.update(Opm::ParseContext::PARSE_MISSING_DIMS_KEYWORD, Opm::InputError::WARN);
parseContext.update(Opm::ParseContext::SUMMARY_UNKNOWN_WELL, Opm::InputError::WARN);
parseContext.update(Opm::ParseContext::SUMMARY_UNKNOWN_GROUP, Opm::InputError::WARN);
parseContext.update(Opm::ParseContext::PARSE_RANDOM_SLASH, Opm::InputErrorAction::IGNORE);
parseContext.update(Opm::ParseContext::PARSE_MISSING_DIMS_KEYWORD, Opm::InputErrorAction::WARN);
parseContext.update(Opm::ParseContext::SUMMARY_UNKNOWN_WELL, Opm::InputErrorAction::WARN);
parseContext.update(Opm::ParseContext::SUMMARY_UNKNOWN_GROUP, Opm::InputErrorAction::WARN);
auto deck = parser.parseFile(deck_file, parseContext, errors);
for (const auto& kw : deck) {

View File

@ -36,7 +36,7 @@
namespace fs = std::filesystem;
Opm::Deck pack_deck( const char * deck_file, std::ostream& os) {
Opm::ParseContext parseContext(Opm::InputError::WARN);
Opm::ParseContext parseContext(Opm::InputErrorAction::WARN);
Opm::ErrorGuard errors;
Opm::Parser parser;

View File

@ -163,15 +163,15 @@ struct Options {
Opm::Deck load_deck(const Options& opt) {
Opm::ParseContext parseContext(Opm::InputError::WARN);
Opm::ParseContext parseContext(Opm::InputErrorAction::WARN);
Opm::ErrorGuard errors;
Opm::Parser parser;
/* Use the same default ParseContext as flow. */
parseContext.update(Opm::ParseContext::PARSE_RANDOM_SLASH, Opm::InputError::IGNORE);
parseContext.update(Opm::ParseContext::PARSE_MISSING_DIMS_KEYWORD, Opm::InputError::WARN);
parseContext.update(Opm::ParseContext::SUMMARY_UNKNOWN_WELL, Opm::InputError::WARN);
parseContext.update(Opm::ParseContext::SUMMARY_UNKNOWN_GROUP, Opm::InputError::WARN);
parseContext.update(Opm::ParseContext::PARSE_RANDOM_SLASH, Opm::InputErrorAction::IGNORE);
parseContext.update(Opm::ParseContext::PARSE_MISSING_DIMS_KEYWORD, Opm::InputErrorAction::WARN);
parseContext.update(Opm::ParseContext::SUMMARY_UNKNOWN_WELL, Opm::InputErrorAction::WARN);
parseContext.update(Opm::ParseContext::SUMMARY_UNKNOWN_GROUP, Opm::InputErrorAction::WARN);
return parser.parseFile(opt.input_deck, parseContext, errors);
}

View File

@ -24,14 +24,19 @@
#include <chrono>
#include <sstream>
#include <opm/input/eclipse/Deck/Deck.hpp>
#include <opm/input/eclipse/EclipseState/EclipseState.hpp>
#include <opm/input/eclipse/Parser/ErrorGuard.hpp>
#include <opm/input/eclipse/Parser/InputErrorAction.hpp>
#include <opm/input/eclipse/Parser/Parser.hpp>
#include <opm/input/eclipse/Parser/ParseContext.hpp>
#include <opm/input/eclipse/Parser/ErrorGuard.hpp>
#include <opm/input/eclipse/Deck/Deck.hpp>
#include <opm/input/eclipse/EclipseState/EclipseState.hpp>
#include <opm/input/eclipse/Schedule/Schedule.hpp>
#include <opm/input/eclipse/Python/Python.hpp>
#include <opm/input/eclipse/Schedule/Schedule.hpp>
#include <opm/common/OpmLog/OpmLog.hpp>
#include <opm/common/OpmLog/StreamLog.hpp>
#include <opm/common/OpmLog/LogUtil.hpp>
@ -91,10 +96,10 @@ inline void createDot(const Opm::Schedule& schedule, const std::string& casename
inline Opm::Schedule loadSchedule(const std::string& deck_file)
{
Opm::ParseContext parseContext({{Opm::ParseContext::PARSE_RANDOM_SLASH, Opm::InputError::IGNORE},
{Opm::ParseContext::PARSE_MISSING_DIMS_KEYWORD, Opm::InputError::WARN},
{Opm::ParseContext::SUMMARY_UNKNOWN_WELL, Opm::InputError::WARN},
{Opm::ParseContext::SUMMARY_UNKNOWN_GROUP, Opm::InputError::WARN}});
Opm::ParseContext parseContext({{Opm::ParseContext::PARSE_RANDOM_SLASH, Opm::InputErrorAction::IGNORE},
{Opm::ParseContext::PARSE_MISSING_DIMS_KEYWORD, Opm::InputErrorAction::WARN},
{Opm::ParseContext::SUMMARY_UNKNOWN_WELL, Opm::InputErrorAction::WARN},
{Opm::ParseContext::SUMMARY_UNKNOWN_GROUP, Opm::InputErrorAction::WARN}});
Opm::ErrorGuard errors;
Opm::Parser parser;
auto python = std::make_shared<Opm::Python>();

View File

@ -20,29 +20,27 @@
#ifndef OPM_INPUT_ERROR_ACTION_HPP
#define OPM_INPUT_ERROR_ACTION_HPP
#include <iosfwd>
namespace Opm {
namespace InputError {
enum class InputErrorAction {
/*
The THROW_EXCEPTION and EXIT1 error handlers are overlapping, the
intention os that the EXIT1 handler should be used in situations which
are clearly user errors where an exception/traceback is of no use to
the developers. The prototype of an error mode which should be handled
with EXIT1 is PARSE_MISSING_INCLUDE.
*/
THROW_EXCEPTION = 0,
WARN = 1,
IGNORE = 2,
EXIT1 = 3,
DELAYED_EXIT1 = 4
};
std::ostream& operator<<(std::ostream& os, const InputErrorAction action);
/*
The THROW_EXCEPTION and EXIT1 error handlers are overlapping, the
intention os that the EXIT1 handler should be used in situations which
are clearly user errors where an exception/traceback is of no use to
the developers. The prototype of an error mode which should be handled
with EXIT1 is PARSE_MISSING_INCLUDE.
*/
enum Action {
THROW_EXCEPTION = 0,
WARN = 1,
IGNORE = 2,
EXIT1 = 3,
DELAYED_EXIT1 = 4
};
}
}
#endif

View File

@ -27,13 +27,9 @@
#include <string>
#include <vector>
#include <opm/common/OpmLog/OpmLog.hpp>
#include <opm/input/eclipse/Parser/InputErrorAction.hpp>
namespace Opm {
enum class InputErrorAction;
class KeywordLocation;
@ -88,28 +84,28 @@ class KeywordLocation;
class ParseContext {
public:
ParseContext();
explicit ParseContext(InputError::Action default_action);
explicit ParseContext(const std::vector<std::pair<std::string , InputError::Action>>& initial);
explicit ParseContext(InputErrorAction default_action);
explicit ParseContext(const std::vector<std::pair<std::string , InputErrorAction>>& initial);
void handleError( const std::string& errorKey, const std::string& msg, const std::optional<KeywordLocation>& location, ErrorGuard& errors) const;
void handleUnknownKeyword(const std::string& keyword, const std::optional<KeywordLocation>& location, ErrorGuard& errors) const;
bool hasKey(const std::string& key) const;
ParseContext withKey(const std::string& key, InputError::Action action = InputError::WARN) const;
ParseContext& withKey(const std::string& key, InputError::Action action = InputError::WARN);
void updateKey(const std::string& key , InputError::Action action);
void update(InputError::Action action);
void update(const std::string& keyString , InputError::Action action);
ParseContext withKey(const std::string& key, InputErrorAction action) const;
ParseContext& withKey(const std::string& key, InputErrorAction action);
void updateKey(const std::string& key , InputErrorAction action);
void update(InputErrorAction action);
void update(const std::string& keyString , InputErrorAction action);
void ignoreKeyword(const std::string& keyword);
InputError::Action get(const std::string& key) const;
std::map<std::string,InputError::Action>::const_iterator begin() const;
std::map<std::string,InputError::Action>::const_iterator end() const;
InputErrorAction get(const std::string& key) const;
std::map<std::string,InputErrorAction>::const_iterator begin() const;
std::map<std::string,InputErrorAction>::const_iterator end() const;
/*
When the key is added it is inserted in 'strict mode',
i.e. with the value 'InputError::THROW_EXCEPTION. If you
want a different value you must subsequently call the update
method.
*/
void addKey(const std::string& key, InputError::Action default_action);
void addKey(const std::string& key, InputErrorAction default_action);
/*
The PARSE_EXTRA_RECORDS field regulates how the parser
responds to keywords whose size has been defined in the
@ -361,10 +357,10 @@ class KeywordLocation;
private:
void initDefault();
void initEnv();
void envUpdate( const std::string& envVariable , InputError::Action action );
void patternUpdate( const std::string& pattern , InputError::Action action);
void envUpdate( const std::string& envVariable , InputErrorAction action );
void patternUpdate( const std::string& pattern , InputErrorAction action);
std::map<std::string , InputError::Action> m_errorContexts;
std::map<std::string , InputErrorAction> m_errorContexts;
std::set<std::string> ignore_keywords;
};
}

View File

@ -32,7 +32,6 @@
#include <vector>
#include <opm/input/eclipse/EclipseState/Runspec.hpp>
#include <opm/input/eclipse/Parser/InputErrorAction.hpp>
#include <opm/input/eclipse/Schedule/Group/Group.hpp>
#include <opm/input/eclipse/Schedule/MessageLimits.hpp>
#include <opm/input/eclipse/Schedule/ScheduleDeck.hpp>
@ -62,6 +61,7 @@ namespace Opm
class GTNode;
class GuideRateConfig;
class GuideRateModel;
enum class InputErrorAction;
class ParseContext;
class Python;
class RPTConfig;
@ -635,7 +635,7 @@ namespace Opm
void prefetch_cell_properties(const ScheduleGrid& grid, const DeckKeyword& keyword);
void store_wgnames(const DeckKeyword& keyword);
std::vector<std::string> wellNames(const std::string& pattern, const HandlerContext& context);
std::vector<std::string> wellNames(const std::string& pattern, std::size_t timeStep, const std::vector<std::string>& matching_wells, InputError::Action error_action, ErrorGuard& errors, const KeywordLocation& location) const;
std::vector<std::string> wellNames(const std::string& pattern, std::size_t timeStep, const std::vector<std::string>& matching_wells, InputErrorAction error_action, ErrorGuard& errors, const KeywordLocation& location) const;
void invalidNamePattern( const std::string& namePattern, const HandlerContext& context) const;
static std::string formatDate(std::time_t t);
std::string simulationDays(std::size_t currentStep) const;

View File

@ -1,3 +1,4 @@
#include <opm/input/eclipse/Parser/InputErrorAction.hpp>
#include <opm/input/eclipse/Parser/ParseContext.hpp>
#include <opm/input/eclipse/Deck/Deck.hpp>
#include <pybind11/stl.h>
@ -7,7 +8,7 @@
namespace {
void (ParseContext::*ctx_update)(const std::string&, InputError::Action) = &ParseContext::update;
void (ParseContext::*ctx_update)(const std::string&, InputErrorAction) = &ParseContext::update;
}
@ -15,13 +16,13 @@ void python::common::export_ParseContext(py::module& module) {
py::class_< ParseContext >(module, "ParseContext" )
.def(py::init<>())
.def(py::init<const std::vector<std::pair<std::string, InputError::Action>>>())
.def(py::init<const std::vector<std::pair<std::string, InputErrorAction>>>())
.def( "ignore_keyword", &ParseContext::ignoreKeyword )
.def( "update", ctx_update );
py::enum_< InputError::Action >( module, "action" )
.value( "throw", InputError::Action::THROW_EXCEPTION )
.value( "warn", InputError::Action::WARN )
.value( "ignore", InputError::Action::IGNORE );
py::enum_< InputErrorAction >( module, "action" )
.value( "throw", InputErrorAction::THROW_EXCEPTION )
.value( "warn", InputErrorAction::WARN )
.value( "ignore", InputErrorAction::IGNORE );
}

View File

@ -19,8 +19,7 @@
#include <opm/input/eclipse/EclipseState/SummaryConfig/SummaryConfig.hpp>
#include <opm/io/eclipse/EclUtil.hpp>
#include <opm/common/OpmLog/OpmLog.hpp>
#include <opm/common/utility/OpmInputError.hpp>
#include <opm/common/utility/shmatch.hpp>
@ -45,6 +44,8 @@
#include <opm/input/eclipse/Deck/DeckRecord.hpp>
#include <opm/input/eclipse/Deck/DeckSection.hpp>
#include <opm/io/eclipse/EclUtil.hpp>
#include <algorithm>
#include <array>
#include <cassert>

View File

@ -0,0 +1,40 @@
/*
Copyright 2015 Statoil ASA.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#include <config.h>
#include <opm/input/eclipse/Parser/InputErrorAction.hpp>
#include <ostream>
namespace Opm {
std::ostream& operator<<(std::ostream& os, const InputErrorAction action)
{
switch (action) {
case InputErrorAction::THROW_EXCEPTION: os << "throw exception"; break;
case InputErrorAction::WARN: os << "warn"; break;
case InputErrorAction::IGNORE: os << "ignore"; break;
case InputErrorAction::EXIT1: os << "exit1"; break;
case InputErrorAction::DELAYED_EXIT1: os << "delayed exit1"; break;
}
return os;
}
}

View File

@ -20,6 +20,8 @@
#include <cstdlib>
#include <iostream>
#include <opm/common/OpmLog/OpmLog.hpp>
#include <opm/input/eclipse/Parser/ErrorGuard.hpp>
#include <opm/input/eclipse/Parser/InputErrorAction.hpp>
#include <opm/input/eclipse/Parser/ParseContext.hpp>
@ -33,7 +35,7 @@ namespace Opm {
/*
A set of predefined error modes are added, with the default
setting 'InputError::IGNORE, then afterwards the environment
setting 'InputErrorAction::IGNORE, then afterwards the environment
variables 'OPM_ERRORS_EXCEPTION', 'OPM_ERRORS_WARN' and
'OPM_ERRORS_IGNORE' are consulted
*/
@ -49,7 +51,7 @@ namespace Opm {
after the hawrdwired settings.
*/
ParseContext::ParseContext(const std::vector<std::pair<std::string , InputError::Action>>& initial) {
ParseContext::ParseContext(const std::vector<std::pair<std::string , InputErrorAction>>& initial) {
initDefault();
for (const auto& pair : initial)
@ -64,74 +66,74 @@ namespace Opm {
environment variables will be used.
*/
ParseContext::ParseContext(InputError::Action default_action) {
ParseContext::ParseContext(InputErrorAction default_action) {
initDefault();
update(default_action);
initEnv();
}
void ParseContext::initDefault() {
addKey(PARSE_EXTRA_RECORDS, InputError::THROW_EXCEPTION);
addKey(PARSE_UNKNOWN_KEYWORD, InputError::THROW_EXCEPTION);
addKey(PARSE_RANDOM_TEXT, InputError::THROW_EXCEPTION);
addKey(PARSE_RANDOM_SLASH, InputError::THROW_EXCEPTION);
addKey(PARSE_MISSING_DIMS_KEYWORD, InputError::THROW_EXCEPTION);
addKey(PARSE_EXTRA_DATA, InputError::THROW_EXCEPTION);
addKey(PARSE_MISSING_INCLUDE, InputError::EXIT1);
addKey(PARSE_LONG_KEYWORD, InputError::WARN);
addKey(PARSE_WGNAME_SPACE, InputError::THROW_EXCEPTION);
addKey(PARSE_INVALID_KEYWORD_COMBINATION, InputError::THROW_EXCEPTION);
addKey(PARSE_EXTRA_RECORDS, InputErrorAction::THROW_EXCEPTION);
addKey(PARSE_UNKNOWN_KEYWORD, InputErrorAction::THROW_EXCEPTION);
addKey(PARSE_RANDOM_TEXT, InputErrorAction::THROW_EXCEPTION);
addKey(PARSE_RANDOM_SLASH, InputErrorAction::THROW_EXCEPTION);
addKey(PARSE_MISSING_DIMS_KEYWORD, InputErrorAction::THROW_EXCEPTION);
addKey(PARSE_EXTRA_DATA, InputErrorAction::THROW_EXCEPTION);
addKey(PARSE_MISSING_INCLUDE, InputErrorAction::EXIT1);
addKey(PARSE_LONG_KEYWORD, InputErrorAction::WARN);
addKey(PARSE_WGNAME_SPACE, InputErrorAction::THROW_EXCEPTION);
addKey(PARSE_INVALID_KEYWORD_COMBINATION, InputErrorAction::THROW_EXCEPTION);
addKey(UNIT_SYSTEM_MISMATCH, InputError::THROW_EXCEPTION);
addKey(UNIT_SYSTEM_MISMATCH, InputErrorAction::THROW_EXCEPTION);
this->addKey(RUNSPEC_NUMWELLS_TOO_LARGE, InputError::THROW_EXCEPTION);
this->addKey(RUNSPEC_CONNS_PER_WELL_TOO_LARGE, InputError::THROW_EXCEPTION);
this->addKey(RUNSPEC_NUMGROUPS_TOO_LARGE, InputError::THROW_EXCEPTION);
this->addKey(RUNSPEC_GROUPSIZE_TOO_LARGE, InputError::THROW_EXCEPTION);
this->addKey(RUNSPEC_NUMWELLS_TOO_LARGE, InputErrorAction::THROW_EXCEPTION);
this->addKey(RUNSPEC_CONNS_PER_WELL_TOO_LARGE, InputErrorAction::THROW_EXCEPTION);
this->addKey(RUNSPEC_NUMGROUPS_TOO_LARGE, InputErrorAction::THROW_EXCEPTION);
this->addKey(RUNSPEC_GROUPSIZE_TOO_LARGE, InputErrorAction::THROW_EXCEPTION);
addKey(UNSUPPORTED_INITIAL_THPRES, InputError::THROW_EXCEPTION);
addKey(UNSUPPORTED_TERMINATE_IF_BHP, InputError::THROW_EXCEPTION);
addKey(UNSUPPORTED_INITIAL_THPRES, InputErrorAction::THROW_EXCEPTION);
addKey(UNSUPPORTED_TERMINATE_IF_BHP, InputErrorAction::THROW_EXCEPTION);
addKey(INTERNAL_ERROR_UNINITIALIZED_THPRES, InputError::THROW_EXCEPTION);
addKey(INTERNAL_ERROR_UNINITIALIZED_THPRES, InputErrorAction::THROW_EXCEPTION);
addKey(SUMMARY_UNKNOWN_WELL, InputError::THROW_EXCEPTION);
addKey(SUMMARY_UNKNOWN_GROUP, InputError::THROW_EXCEPTION);
addKey(SUMMARY_UNKNOWN_NODE, InputError::WARN);
addKey(SUMMARY_UNKNOWN_AQUIFER, InputError::THROW_EXCEPTION);
addKey(SUMMARY_UNHANDLED_KEYWORD, InputError::WARN);
addKey(SUMMARY_UNDEFINED_UDQ, InputError::WARN);
addKey(SUMMARY_UDQ_MISSING_UNIT, InputError::WARN);
this->addKey(SUMMARY_INVALID_FIPNUM, InputError::WARN);
this->addKey(SUMMARY_EMPTY_REGION, InputError::WARN);
this->addKey(SUMMARY_REGION_TOO_LARGE, InputError::WARN);
addKey(SUMMARY_UNKNOWN_WELL, InputErrorAction::THROW_EXCEPTION);
addKey(SUMMARY_UNKNOWN_GROUP, InputErrorAction::THROW_EXCEPTION);
addKey(SUMMARY_UNKNOWN_NODE, InputErrorAction::WARN);
addKey(SUMMARY_UNKNOWN_AQUIFER, InputErrorAction::THROW_EXCEPTION);
addKey(SUMMARY_UNHANDLED_KEYWORD, InputErrorAction::WARN);
addKey(SUMMARY_UNDEFINED_UDQ, InputErrorAction::WARN);
addKey(SUMMARY_UDQ_MISSING_UNIT, InputErrorAction::WARN);
this->addKey(SUMMARY_INVALID_FIPNUM, InputErrorAction::WARN);
this->addKey(SUMMARY_EMPTY_REGION, InputErrorAction::WARN);
this->addKey(SUMMARY_REGION_TOO_LARGE, InputErrorAction::WARN);
addKey(ACTIONX_ILLEGAL_KEYWORD, InputError::THROW_EXCEPTION);
addKey(ACTIONX_ILLEGAL_KEYWORD, InputErrorAction::THROW_EXCEPTION);
addKey(RPT_MIXED_STYLE, InputError::WARN);
addKey(RPT_UNKNOWN_MNEMONIC, InputError::WARN);
addKey(RPT_MIXED_STYLE, InputErrorAction::WARN);
addKey(RPT_UNKNOWN_MNEMONIC, InputErrorAction::WARN);
addKey(SIMULATOR_KEYWORD_NOT_SUPPORTED, InputError::WARN);
addKey(SIMULATOR_KEYWORD_NOT_SUPPORTED_CRITICAL, InputError::THROW_EXCEPTION);
addKey(SIMULATOR_KEYWORD_ITEM_NOT_SUPPORTED, InputError::WARN);
addKey(SIMULATOR_KEYWORD_ITEM_NOT_SUPPORTED_CRITICAL, InputError::THROW_EXCEPTION);
addKey(SIMULATOR_KEYWORD_NOT_SUPPORTED, InputErrorAction::WARN);
addKey(SIMULATOR_KEYWORD_NOT_SUPPORTED_CRITICAL, InputErrorAction::THROW_EXCEPTION);
addKey(SIMULATOR_KEYWORD_ITEM_NOT_SUPPORTED, InputErrorAction::WARN);
addKey(SIMULATOR_KEYWORD_ITEM_NOT_SUPPORTED_CRITICAL, InputErrorAction::THROW_EXCEPTION);
this->addKey(UDQ_PARSE_ERROR, InputError::THROW_EXCEPTION);
this->addKey(UDQ_TYPE_ERROR, InputError::THROW_EXCEPTION);
this->addKey(SCHEDULE_GROUP_ERROR, InputError::THROW_EXCEPTION);
this->addKey(SCHEDULE_IGNORED_GUIDE_RATE, InputError::WARN);
this->addKey(SCHEDULE_COMPSEGS_INVALID, InputError::THROW_EXCEPTION);
this->addKey(SCHEDULE_COMPSEGS_NOT_SUPPORTED, InputError::THROW_EXCEPTION);
addKey(SCHEDULE_INVALID_NAME, InputError::THROW_EXCEPTION);
this->addKey(UDQ_PARSE_ERROR, InputErrorAction::THROW_EXCEPTION);
this->addKey(UDQ_TYPE_ERROR, InputErrorAction::THROW_EXCEPTION);
this->addKey(SCHEDULE_GROUP_ERROR, InputErrorAction::THROW_EXCEPTION);
this->addKey(SCHEDULE_IGNORED_GUIDE_RATE, InputErrorAction::WARN);
this->addKey(SCHEDULE_COMPSEGS_INVALID, InputErrorAction::THROW_EXCEPTION);
this->addKey(SCHEDULE_COMPSEGS_NOT_SUPPORTED, InputErrorAction::THROW_EXCEPTION);
addKey(SCHEDULE_INVALID_NAME, InputErrorAction::THROW_EXCEPTION);
}
void ParseContext::initEnv() {
envUpdate( "OPM_ERRORS_EXCEPTION" , InputError::THROW_EXCEPTION );
envUpdate( "OPM_ERRORS_WARN" , InputError::WARN );
envUpdate( "OPM_ERRORS_IGNORE" , InputError::IGNORE );
envUpdate( "OPM_ERRORS_EXIT1", InputError::EXIT1);
envUpdate( "OPM_ERRORS_EXIT", InputError::EXIT1);
envUpdate( "OPM_ERRORS_DELAYED_EXIT1", InputError::DELAYED_EXIT1);
envUpdate( "OPM_ERRORS_DELAYED_EXIT", InputError::DELAYED_EXIT1);
envUpdate( "OPM_ERRORS_EXCEPTION" , InputErrorAction::THROW_EXCEPTION );
envUpdate( "OPM_ERRORS_WARN" , InputErrorAction::WARN );
envUpdate( "OPM_ERRORS_IGNORE" , InputErrorAction::IGNORE );
envUpdate( "OPM_ERRORS_EXIT1", InputErrorAction::EXIT1);
envUpdate( "OPM_ERRORS_EXIT", InputErrorAction::EXIT1);
envUpdate( "OPM_ERRORS_DELAYED_EXIT1", InputErrorAction::DELAYED_EXIT1);
envUpdate( "OPM_ERRORS_DELAYED_EXIT", InputErrorAction::DELAYED_EXIT1);
}
@ -146,21 +148,21 @@ namespace Opm {
const std::optional<KeywordLocation>& location,
ErrorGuard& errors) const {
InputError::Action action = get( errorKey );
InputErrorAction action = get( errorKey );
std::string msg = location ? OpmInputError::format(msg_fmt, *location) : msg_fmt;
if (action == InputError::IGNORE) {
if (action == InputErrorAction::IGNORE) {
errors.addWarning(errorKey, msg);
return;
}
if (action == InputError::WARN) {
if (action == InputErrorAction::WARN) {
OpmLog::warning(msg);
errors.addWarning(errorKey, msg);
return;
}
if (action == InputError::THROW_EXCEPTION) {
if (action == InputErrorAction::THROW_EXCEPTION) {
OpmLog::error(msg);
// If we decide to throw immediately - we clear the error stack to
// make sure the error object does not terminate the application
@ -170,14 +172,14 @@ namespace Opm {
throw OpmInputError(msg, location.value_or(KeywordLocation{}));
}
if (action == InputError::EXIT1) {
if (action == InputErrorAction::EXIT1) {
OpmLog::error(msg);
std::cerr << "A fatal error has occurred and the application will stop." << std::endl;
std::cerr << msg << std::endl;
std::exit(1);
}
if (action == InputError::DELAYED_EXIT1) {
if (action == InputErrorAction::DELAYED_EXIT1) {
OpmLog::error(msg);
errors.addError(errorKey, msg);
return;
@ -191,22 +193,22 @@ namespace Opm {
}
}
std::map<std::string,InputError::Action>::const_iterator ParseContext::begin() const {
std::map<std::string,InputErrorAction>::const_iterator ParseContext::begin() const {
return m_errorContexts.begin();
}
std::map<std::string,InputError::Action>::const_iterator ParseContext::end() const {
std::map<std::string,InputErrorAction>::const_iterator ParseContext::end() const {
return m_errorContexts.end();
}
ParseContext ParseContext::withKey(const std::string& key, InputError::Action action) const {
ParseContext ParseContext::withKey(const std::string& key, InputErrorAction action) const {
ParseContext pc(*this);
pc.addKey(key, action);
return pc;
}
ParseContext& ParseContext::withKey(const std::string& key, InputError::Action action) {
ParseContext& ParseContext::withKey(const std::string& key, InputErrorAction action) {
this->addKey(key, action);
return *this;
}
@ -219,16 +221,16 @@ namespace Opm {
}
void ParseContext::addKey(const std::string& key, InputError::Action default_action) {
void ParseContext::addKey(const std::string& key, InputErrorAction default_action) {
if (key.find_first_of("|:*") != std::string::npos)
throw std::invalid_argument("The ParseContext keys can not contain '|', '*' or ':'");
if (!hasKey(key))
m_errorContexts.insert( std::pair<std::string , InputError::Action>( key , default_action));
m_errorContexts.insert( std::pair<std::string , InputErrorAction>( key , default_action));
}
InputError::Action ParseContext::get(const std::string& key) const {
InputErrorAction ParseContext::get(const std::string& key) const {
if (hasKey( key ))
return m_errorContexts.find( key )->second;
else
@ -245,11 +247,11 @@ namespace Opm {
static string constanst for the different error modes should be
used as arguments:
parseContext.updateKey( ParseContext::PARSE_RANDOM_SLASH , InputError::IGNORE )
parseContext.updateKey( ParseContext::PARSE_RANDOM_SLASH , InputErrorAction::IGNORE )
*/
void ParseContext::updateKey(const std::string& key , InputError::Action action) {
void ParseContext::updateKey(const std::string& key , InputErrorAction action) {
if (hasKey(key))
m_errorContexts[key] = action;
else
@ -257,14 +259,14 @@ namespace Opm {
}
void ParseContext::envUpdate( const std::string& envVariable , InputError::Action action ) {
void ParseContext::envUpdate( const std::string& envVariable , InputErrorAction action ) {
const char * userSetting = getenv(envVariable.c_str());
if (userSetting )
update( userSetting , action);
}
void ParseContext::update(InputError::Action action) {
void ParseContext::update(InputErrorAction action) {
for (const auto& pair : m_errorContexts) {
const std::string& key = pair.first;
updateKey( key , action );
@ -272,7 +274,7 @@ namespace Opm {
}
void ParseContext::patternUpdate( const std::string& pattern , InputError::Action action) {
void ParseContext::patternUpdate( const std::string& pattern , InputErrorAction action) {
for (const auto& pair : m_errorContexts) {
const std::string& key = pair.first;
if (shmatch( pattern , key))
@ -301,7 +303,7 @@ namespace Opm {
c) Otherwise - silently ignore.
*/
void ParseContext::update(const std::string& keyString , InputError::Action action) {
void ParseContext::update(const std::string& keyString , InputErrorAction action) {
std::vector<std::string> keys = split_string(keyString, ":|");
for (const auto& input_key : keys) {
std::vector<std::string> matching_keys;

View File

@ -29,6 +29,7 @@
#include <fmt/format.h>
#include <opm/common/OpmLog/OpmLog.hpp>
#include <opm/common/OpmLog/LogUtil.hpp>
#include <opm/common/utility/OpmInputError.hpp>
#include <opm/common/utility/numeric/cmp.hpp>

View File

@ -21,6 +21,7 @@
#include <opm/common/OpmLog/KeywordLocation.hpp>
#include <opm/input/eclipse/Parser/InputErrorAction.hpp>
#include <opm/input/eclipse/Parser/ParseContext.hpp>
#include <cassert>
@ -420,7 +421,7 @@ UDQParser::parse(const UDQParams& udq_params,
UDQ::typeName(tree.var_type));
parseContext.handleError(ParseContext::UDQ_TYPE_ERROR, msg_fmt, location, errors);
if (parseContext.get(ParseContext::UDQ_TYPE_ERROR) != InputError::IGNORE) {
if (parseContext.get(ParseContext::UDQ_TYPE_ERROR) != InputErrorAction::IGNORE) {
dump_tokens(target_var, tokens);
}
@ -434,7 +435,7 @@ UDQParser::parse(const UDQParams& udq_params,
"expression type.", target_var);
parseContext.handleError(ParseContext::UDQ_TYPE_ERROR, msg_fmt, location, errors);
if (parseContext.get(ParseContext::UDQ_TYPE_ERROR) != InputError::IGNORE) {
if (parseContext.get(ParseContext::UDQ_TYPE_ERROR) != InputErrorAction::IGNORE) {
dump_tokens(target_var, tokens);
}

View File

@ -51,6 +51,7 @@
#include <opm/input/eclipse/Schedule/Well/WListManager.hpp>
#include <opm/input/eclipse/Deck/Deck.hpp>
#include <opm/input/eclipse/Deck/DeckKeyword.hpp>
#include <opm/input/eclipse/Parser/InputErrorAction.hpp>
#include <opm/input/eclipse/Parser/Parser.hpp>
#include <opm/input/eclipse/Parser/ParseContext.hpp>
#include <opm/input/eclipse/Parser/ErrorGuard.hpp>
@ -187,7 +188,7 @@ TSTEP
}
// The deck3 contains the 'GRID' keyword in the ACTIONX block - that is not a whitelisted keyword.
ParseContext parseContext( {{ParseContext::ACTIONX_ILLEGAL_KEYWORD, InputError::THROW_EXCEPTION}} );
ParseContext parseContext( {{ParseContext::ACTIONX_ILLEGAL_KEYWORD, InputErrorAction::THROW_EXCEPTION}} );
BOOST_CHECK_THROW( make_schedule(WITH_GRID, parseContext), OpmInputError );
}

View File

@ -39,6 +39,7 @@
#include <opm/input/eclipse/Parser/Parser.hpp>
#include <opm/input/eclipse/Parser/ErrorGuard.hpp>
#include <opm/input/eclipse/Parser/InputErrorAction.hpp>
#include <opm/input/eclipse/Parser/ParseContext.hpp>
#include <opm/input/eclipse/Python/Python.hpp>
@ -123,8 +124,8 @@ WSEGAICD
Opm::ErrorGuard errorGuard;
Opm::ParseContext parseContext;
parseContext.update(Opm::ParseContext::SCHEDULE_COMPSEGS_INVALID, Opm::InputError::THROW_EXCEPTION);
parseContext.update(Opm::ParseContext::SCHEDULE_COMPSEGS_NOT_SUPPORTED, Opm::InputError::THROW_EXCEPTION);
parseContext.update(Opm::ParseContext::SCHEDULE_COMPSEGS_INVALID, Opm::InputErrorAction::THROW_EXCEPTION);
parseContext.update(Opm::ParseContext::SCHEDULE_COMPSEGS_NOT_SUPPORTED, Opm::InputErrorAction::THROW_EXCEPTION);
Opm::CompletedCells cells(grid);
Opm::FieldPropsManager fp(deck, Opm::Phases{true, true, true}, grid, Opm::TableManager());
const auto& [new_connection_set, new_segment_set] = Opm::Compsegs::processCOMPSEGS(compsegs, connection_set, segment_set, Opm::ScheduleGrid(grid, fp, cells), parseContext, errorGuard);
@ -284,8 +285,8 @@ WSEGSICD
Opm::ParseContext parseContext;
Opm::CompletedCells cells(grid);
Opm::FieldPropsManager fp(deck, Opm::Phases{true, true, true}, grid, Opm::TableManager());
parseContext.update(Opm::ParseContext::SCHEDULE_COMPSEGS_INVALID, Opm::InputError::THROW_EXCEPTION);
parseContext.update(Opm::ParseContext::SCHEDULE_COMPSEGS_NOT_SUPPORTED, Opm::InputError::THROW_EXCEPTION);
parseContext.update(Opm::ParseContext::SCHEDULE_COMPSEGS_INVALID, Opm::InputErrorAction::THROW_EXCEPTION);
parseContext.update(Opm::ParseContext::SCHEDULE_COMPSEGS_NOT_SUPPORTED, Opm::InputErrorAction::THROW_EXCEPTION);
const auto& [new_connection_set, new_segment_set] = Opm::Compsegs::processCOMPSEGS(compsegs, connection_set, segment_set, Opm::ScheduleGrid(grid, fp, cells), parseContext, errorGuard);
// checking the ICD segment
@ -443,10 +444,10 @@ BOOST_AUTO_TEST_CASE(WrongDistanceCOMPSEGS) {
Opm::ParseContext parseContext;
Opm::CompletedCells cells(grid);
Opm::FieldPropsManager fp(deck, Opm::Phases{true, true, true}, grid, Opm::TableManager());
parseContext.update(Opm::ParseContext::SCHEDULE_COMPSEGS_INVALID, Opm::InputError::THROW_EXCEPTION);
parseContext.update(Opm::ParseContext::SCHEDULE_COMPSEGS_INVALID, Opm::InputErrorAction::THROW_EXCEPTION);
BOOST_CHECK_THROW(Opm::Compsegs::processCOMPSEGS(compsegs, connection_set, segment_set, Opm::ScheduleGrid(grid, fp, cells), parseContext, errorGuard), Opm::OpmInputError);
parseContext.update(Opm::ParseContext::SCHEDULE_COMPSEGS_INVALID, Opm::InputError::IGNORE);
parseContext.update(Opm::ParseContext::SCHEDULE_COMPSEGS_INVALID, Opm::InputErrorAction::IGNORE);
BOOST_CHECK_NO_THROW(Opm::Compsegs::processCOMPSEGS(compsegs, connection_set, segment_set, Opm::ScheduleGrid(grid, fp, cells), parseContext, errorGuard));
}
@ -512,10 +513,10 @@ BOOST_AUTO_TEST_CASE(NegativeDepthCOMPSEGS) {
Opm::ParseContext parseContext;
Opm::CompletedCells cells(grid);
Opm::FieldPropsManager fp(deck, Opm::Phases{true, true, true}, grid, Opm::TableManager());
parseContext.update(Opm::ParseContext::SCHEDULE_COMPSEGS_NOT_SUPPORTED, Opm::InputError::THROW_EXCEPTION);
parseContext.update(Opm::ParseContext::SCHEDULE_COMPSEGS_NOT_SUPPORTED, Opm::InputErrorAction::THROW_EXCEPTION);
BOOST_CHECK_THROW(Opm::Compsegs::processCOMPSEGS(compsegs, connection_set, segment_set, Opm::ScheduleGrid(grid, fp, cells), parseContext, errorGuard), Opm::OpmInputError);
parseContext.update(Opm::ParseContext::SCHEDULE_COMPSEGS_NOT_SUPPORTED, Opm::InputError::IGNORE);
parseContext.update(Opm::ParseContext::SCHEDULE_COMPSEGS_NOT_SUPPORTED, Opm::InputErrorAction::IGNORE);
BOOST_CHECK_NO_THROW( Opm::Compsegs::processCOMPSEGS(compsegs, connection_set, segment_set, Opm::ScheduleGrid(grid, fp, cells), parseContext, errorGuard) );
}
@ -587,8 +588,8 @@ BOOST_AUTO_TEST_CASE(testwsegvalv) {
Opm::ParseContext parseContext;
Opm::CompletedCells cells(grid);
Opm::FieldPropsManager fp(deck, Opm::Phases{true, true, true}, grid, Opm::TableManager());
parseContext.update(Opm::ParseContext::SCHEDULE_COMPSEGS_INVALID, Opm::InputError::THROW_EXCEPTION);
parseContext.update(Opm::ParseContext::SCHEDULE_COMPSEGS_NOT_SUPPORTED, Opm::InputError::THROW_EXCEPTION);
parseContext.update(Opm::ParseContext::SCHEDULE_COMPSEGS_INVALID, Opm::InputErrorAction::THROW_EXCEPTION);
parseContext.update(Opm::ParseContext::SCHEDULE_COMPSEGS_NOT_SUPPORTED, Opm::InputErrorAction::THROW_EXCEPTION);
BOOST_CHECK_NO_THROW( Opm::Compsegs::processCOMPSEGS(compsegs, connection_set, segment_set, Opm::ScheduleGrid(grid, fp, cells), parseContext, errorGuard));
// checking the WSEGVALV segment

View File

@ -72,26 +72,26 @@ BOOST_AUTO_TEST_CASE(TestUnkownKeyword) {
parser.addKeyword<ParserKeywords::DIMENS>();
parseContext.update(ParseContext::PARSE_UNKNOWN_KEYWORD , InputError::THROW_EXCEPTION );
parseContext.update(ParseContext::PARSE_UNKNOWN_KEYWORD , InputErrorAction::THROW_EXCEPTION );
BOOST_CHECK_THROW( parser.parseString( deck1 , parseContext , errors) , OpmInputError);
parseContext.update(ParseContext::PARSE_UNKNOWN_KEYWORD , InputError::IGNORE );
parseContext.update(ParseContext::PARSE_UNKNOWN_KEYWORD , InputErrorAction::IGNORE );
BOOST_CHECK_NO_THROW( parser.parseString( deck1 , parseContext , errors) );
parseContext.update(ParseContext::PARSE_UNKNOWN_KEYWORD , InputError::THROW_EXCEPTION );
parseContext.update(ParseContext::PARSE_RANDOM_TEXT , InputError::IGNORE );
parseContext.update(ParseContext::PARSE_UNKNOWN_KEYWORD , InputErrorAction::THROW_EXCEPTION );
parseContext.update(ParseContext::PARSE_RANDOM_TEXT , InputErrorAction::IGNORE );
BOOST_CHECK_THROW( parser.parseString( deck2 , parseContext , errors) , OpmInputError);
parseContext.update(ParseContext::PARSE_UNKNOWN_KEYWORD , InputError::IGNORE );
parseContext.update(ParseContext::PARSE_RANDOM_TEXT , InputError::IGNORE );
parseContext.update(ParseContext::PARSE_UNKNOWN_KEYWORD , InputErrorAction::IGNORE );
parseContext.update(ParseContext::PARSE_RANDOM_TEXT , InputErrorAction::IGNORE );
BOOST_CHECK_NO_THROW( parser.parseString( deck2 , parseContext , errors) );
parseContext.update(ParseContext::PARSE_UNKNOWN_KEYWORD , InputError::IGNORE );
parseContext.update(ParseContext::PARSE_RANDOM_TEXT , InputError::THROW_EXCEPTION );
parseContext.update(ParseContext::PARSE_UNKNOWN_KEYWORD , InputErrorAction::IGNORE );
parseContext.update(ParseContext::PARSE_RANDOM_TEXT , InputErrorAction::THROW_EXCEPTION );
BOOST_CHECK_THROW( parser.parseString( deck2 , parseContext , errors) , OpmInputError);
parseContext.update(ParseContext::PARSE_UNKNOWN_KEYWORD , InputError::IGNORE );
parseContext.update(ParseContext::PARSE_RANDOM_TEXT , InputError::IGNORE );
parseContext.update(ParseContext::PARSE_UNKNOWN_KEYWORD , InputErrorAction::IGNORE );
parseContext.update(ParseContext::PARSE_RANDOM_TEXT , InputErrorAction::IGNORE );
BOOST_CHECK_NO_THROW( parser.parseString( deck2 , parseContext , errors) );
}
@ -110,7 +110,7 @@ BOOST_AUTO_TEST_CASE(TestUnkownKeywordII) {
parser.addKeyword<ParserKeywords::DIMENS>();
parseContext.update(ParseContext::PARSE_UNKNOWN_KEYWORD , InputError::THROW_EXCEPTION );
parseContext.update(ParseContext::PARSE_UNKNOWN_KEYWORD , InputErrorAction::THROW_EXCEPTION );
BOOST_CHECK_THROW( parser.parseString( deck1 , parseContext, errors ) , OpmInputError);
parseContext.ignoreKeyword("RUNSPEC");
BOOST_CHECK_NO_THROW( parser.parseString( deck1 , parseContext, errors ) );
@ -137,11 +137,11 @@ BOOST_AUTO_TEST_CASE(Handle_extra_records) {
parser.addKeyword<ParserKeywords::GRID>();
BOOST_CHECK_THROW( parser.parseString( deck_string , parseContext, errors ) , OpmInputError );
parseContext.update(ParseContext::PARSE_EXTRA_RECORDS , InputError::IGNORE );
parseContext.update(ParseContext::PARSE_EXTRA_RECORDS , InputErrorAction::IGNORE );
parser.parseString( deck_string , parseContext, errors );
BOOST_CHECK( parser.hasKeyword( "GRID" ) );
parseContext.update(ParseContext::PARSE_EXTRA_RECORDS , InputError::THROW_EXCEPTION );
parseContext.update(ParseContext::PARSE_EXTRA_RECORDS , InputErrorAction::THROW_EXCEPTION );
BOOST_CHECK_THROW( parser.parseString( deck_string , parseContext, errors ) , OpmInputError);
}
@ -168,7 +168,7 @@ BOOST_AUTO_TEST_CASE(Handle_extra_records_2) {
parser.addKeyword<ParserKeywords::GRID>();
parser.addKeyword<ParserKeywords::DIMENS>();
parseContext.update(ParseContext::PARSE_EXTRA_RECORDS , InputError::IGNORE );
parseContext.update(ParseContext::PARSE_EXTRA_RECORDS , InputErrorAction::IGNORE );
BOOST_CHECK_THROW( parser.parseString( deck_string , parseContext, errors ), OpmInputError );
}
@ -218,8 +218,8 @@ BOOST_AUTO_TEST_CASE(TestUnkownKeyword_DATA) {
parser.addKeyword<ParserKeywords::RUNSPEC>();
parser.addKeyword<ParserKeywords::DIMENS>();
parseContext.update(ParseContext::PARSE_UNKNOWN_KEYWORD , InputError::IGNORE );
parseContext.update(ParseContext::PARSE_RANDOM_TEXT , InputError::THROW_EXCEPTION );
parseContext.update(ParseContext::PARSE_UNKNOWN_KEYWORD , InputErrorAction::IGNORE );
parseContext.update(ParseContext::PARSE_RANDOM_TEXT , InputErrorAction::THROW_EXCEPTION );
{
Deck deck = parser.parseString( deck_string1 , parseContext, errors );
BOOST_CHECK( deck.hasKeyword( "RUNSPEC") );
@ -246,18 +246,18 @@ BOOST_AUTO_TEST_CASE(TEST_UNKNOWN_OPERATE) {
ParseContext parseContext;
Parser parser(false);
parseContext.update(ParseContext::PARSE_UNKNOWN_KEYWORD , InputError::THROW_EXCEPTION );
parseContext.update(ParseContext::PARSE_UNKNOWN_KEYWORD , InputErrorAction::THROW_EXCEPTION );
BOOST_CHECK_THROW( parser.parseString( deck , parseContext, errors ) , OpmInputError);
parseContext.update(ParseContext::PARSE_RANDOM_SLASH , InputError::IGNORE );
parseContext.update(ParseContext::PARSE_UNKNOWN_KEYWORD , InputError::IGNORE );
parseContext.update(ParseContext::PARSE_RANDOM_SLASH , InputErrorAction::IGNORE );
parseContext.update(ParseContext::PARSE_UNKNOWN_KEYWORD , InputErrorAction::IGNORE );
parser.parseString( deck , parseContext, errors );
BOOST_CHECK_NO_THROW( parser.parseString( deck , parseContext, errors ) );
parser.addKeyword<ParserKeywords::OPERATE>();
parser.parseString( deck , parseContext, errors );
parseContext.update(ParseContext::PARSE_RANDOM_SLASH , InputError::THROW_EXCEPTION );
parseContext.update(ParseContext::PARSE_UNKNOWN_KEYWORD , InputError::THROW_EXCEPTION );
parseContext.update(ParseContext::PARSE_RANDOM_SLASH , InputErrorAction::THROW_EXCEPTION );
parseContext.update(ParseContext::PARSE_UNKNOWN_KEYWORD , InputErrorAction::THROW_EXCEPTION );
BOOST_CHECK_NO_THROW( parser.parseString( deck , parseContext, errors ) );
}
@ -279,10 +279,10 @@ BOOST_AUTO_TEST_CASE( CheckMissingSizeKeyword) {
parser.addKeyword<ParserKeywords::EQLDIMS>();
parser.addKeyword<ParserKeywords::SOLUTION>();
parseContext.update( ParseContext::PARSE_MISSING_DIMS_KEYWORD , InputError::THROW_EXCEPTION );
parseContext.update( ParseContext::PARSE_MISSING_DIMS_KEYWORD , InputErrorAction::THROW_EXCEPTION );
BOOST_CHECK_THROW( parser.parseString( deck , parseContext, errors ) , OpmInputError);
parseContext.update( ParseContext::PARSE_MISSING_DIMS_KEYWORD , InputError::IGNORE );
parseContext.update( ParseContext::PARSE_MISSING_DIMS_KEYWORD , InputErrorAction::IGNORE );
BOOST_CHECK_NO_THROW( parser.parseString( deck , parseContext, errors ) );
}
@ -310,14 +310,14 @@ BOOST_AUTO_TEST_CASE(TestRandomSlash) {
parser.addKeyword<ParserKeywords::TSTEP>();
parser.addKeyword<ParserKeywords::SCHEDULE>();
parseContext.update(ParseContext::PARSE_RANDOM_SLASH , InputError::THROW_EXCEPTION);
parseContext.update(ParseContext::PARSE_RANDOM_TEXT , InputError::IGNORE);
parseContext.update(ParseContext::PARSE_RANDOM_SLASH , InputErrorAction::THROW_EXCEPTION);
parseContext.update(ParseContext::PARSE_RANDOM_TEXT , InputErrorAction::IGNORE);
BOOST_CHECK_THROW( parser.parseString( deck1 , parseContext, errors ) , OpmInputError);
BOOST_CHECK_THROW( parser.parseString( deck2 , parseContext, errors ) , OpmInputError);
parseContext.update(ParseContext::PARSE_RANDOM_SLASH , InputError::IGNORE);
parseContext.update(ParseContext::PARSE_RANDOM_TEXT , InputError::THROW_EXCEPTION);
parseContext.update(ParseContext::PARSE_RANDOM_SLASH , InputErrorAction::IGNORE);
parseContext.update(ParseContext::PARSE_RANDOM_TEXT , InputErrorAction::THROW_EXCEPTION);
BOOST_CHECK_NO_THROW( parser.parseString( deck1 , parseContext, errors ) );
BOOST_CHECK_NO_THROW( parser.parseString( deck2 , parseContext, errors ) );
}
@ -328,8 +328,8 @@ BOOST_AUTO_TEST_CASE(TestRandomSlash) {
BOOST_AUTO_TEST_CASE(TestInvalidKey) {
ParseContext parseContext;
BOOST_CHECK_THROW( parseContext.addKey("KEY*", InputError::THROW_EXCEPTION) , std::invalid_argument );
BOOST_CHECK_THROW( parseContext.addKey("KEY:", InputError::THROW_EXCEPTION) , std::invalid_argument );
BOOST_CHECK_THROW( parseContext.addKey("KEY*", InputErrorAction::THROW_EXCEPTION) , std::invalid_argument );
BOOST_CHECK_THROW( parseContext.addKey("KEY:", InputErrorAction::THROW_EXCEPTION) , std::invalid_argument );
}
@ -337,47 +337,47 @@ BOOST_AUTO_TEST_CASE(TestNew) {
ParseContext parseContext;
BOOST_CHECK_EQUAL( false , parseContext.hasKey("NO"));
parseContext.addKey("NEW_KEY", InputError::THROW_EXCEPTION);
parseContext.addKey("NEW_KEY", InputErrorAction::THROW_EXCEPTION);
BOOST_CHECK_EQUAL( true , parseContext.hasKey("NEW_KEY"));
BOOST_CHECK_THROW( parseContext.get("NO") , std::invalid_argument);
BOOST_CHECK_EQUAL( parseContext.get("NEW_KEY") , InputError::THROW_EXCEPTION );
parseContext.addKey("KEY2", InputError::THROW_EXCEPTION);
BOOST_CHECK_EQUAL( parseContext.get("NEW_KEY") , InputError::THROW_EXCEPTION );
BOOST_CHECK_EQUAL( parseContext.get("NEW_KEY") , InputErrorAction::THROW_EXCEPTION );
parseContext.addKey("KEY2", InputErrorAction::THROW_EXCEPTION);
BOOST_CHECK_EQUAL( parseContext.get("NEW_KEY") , InputErrorAction::THROW_EXCEPTION );
BOOST_CHECK_THROW( parseContext.updateKey("NO" , InputError::IGNORE) , std::invalid_argument);
BOOST_CHECK_THROW( parseContext.updateKey("NO" , InputErrorAction::IGNORE) , std::invalid_argument);
parseContext.updateKey("NEW_KEY" , InputError::WARN);
BOOST_CHECK_EQUAL( parseContext.get("NEW_KEY") , InputError::WARN );
parseContext.updateKey("NEW_KEY" , InputErrorAction::WARN);
BOOST_CHECK_EQUAL( parseContext.get("NEW_KEY") , InputErrorAction::WARN );
BOOST_CHECK_NO_THROW( parseContext.update("KEY2:NEW_KEY" , InputError::IGNORE));
BOOST_CHECK_NO_THROW( parseContext.update("UnknownKey" , InputError::IGNORE));
BOOST_CHECK_EQUAL( parseContext.get("NEW_KEY") , InputError::IGNORE );
BOOST_CHECK_EQUAL( parseContext.get("KEY2") , InputError::IGNORE );
BOOST_CHECK_NO_THROW( parseContext.update("KEY2:NEW_KEY" , InputErrorAction::IGNORE));
BOOST_CHECK_NO_THROW( parseContext.update("UnknownKey" , InputErrorAction::IGNORE));
BOOST_CHECK_EQUAL( parseContext.get("NEW_KEY") , InputErrorAction::IGNORE );
BOOST_CHECK_EQUAL( parseContext.get("KEY2") , InputErrorAction::IGNORE );
parseContext.addKey("SECRET_KEY", InputError::THROW_EXCEPTION);
parseContext.addKey("NEW_KEY2", InputError::THROW_EXCEPTION);
parseContext.addKey("NEW_KEY3", InputError::THROW_EXCEPTION);
parseContext.update("NEW_KEY*" , InputError::WARN);
BOOST_CHECK_EQUAL( parseContext.get("NEW_KEY") , InputError::WARN );
BOOST_CHECK_EQUAL( parseContext.get("NEW_KEY2") , InputError::WARN );
BOOST_CHECK_EQUAL( parseContext.get("NEW_KEY3") , InputError::WARN );
parseContext.addKey("SECRET_KEY", InputErrorAction::THROW_EXCEPTION);
parseContext.addKey("NEW_KEY2", InputErrorAction::THROW_EXCEPTION);
parseContext.addKey("NEW_KEY3", InputErrorAction::THROW_EXCEPTION);
parseContext.update("NEW_KEY*" , InputErrorAction::WARN);
BOOST_CHECK_EQUAL( parseContext.get("NEW_KEY") , InputErrorAction::WARN );
BOOST_CHECK_EQUAL( parseContext.get("NEW_KEY2") , InputErrorAction::WARN );
BOOST_CHECK_EQUAL( parseContext.get("NEW_KEY3") , InputErrorAction::WARN );
parseContext.update( InputError::IGNORE );
BOOST_CHECK_EQUAL( parseContext.get("NEW_KEY3") , InputError::IGNORE );
BOOST_CHECK_EQUAL( parseContext.get("SECRET_KEY") , InputError::IGNORE );
parseContext.update( InputErrorAction::IGNORE );
BOOST_CHECK_EQUAL( parseContext.get("NEW_KEY3") , InputErrorAction::IGNORE );
BOOST_CHECK_EQUAL( parseContext.get("SECRET_KEY") , InputErrorAction::IGNORE );
}
BOOST_AUTO_TEST_CASE( test_constructor_with_values) {
ParseContext parseContext( {{ParseContext::PARSE_RANDOM_SLASH , InputError::IGNORE},
{"UNSUPPORTED_*" , InputError::WARN},
{"UNKNWON-IGNORED" , InputError::WARN}});
ParseContext parseContext( {{ParseContext::PARSE_RANDOM_SLASH , InputErrorAction::IGNORE},
{"UNSUPPORTED_*" , InputErrorAction::WARN},
{"UNKNWON-IGNORED" , InputErrorAction::WARN}});
BOOST_CHECK_EQUAL( parseContext.get(ParseContext::PARSE_RANDOM_SLASH) , InputError::IGNORE );
BOOST_CHECK_EQUAL( parseContext.get(ParseContext::PARSE_RANDOM_TEXT) , InputError::THROW_EXCEPTION );
BOOST_CHECK_EQUAL( parseContext.get(ParseContext::UNSUPPORTED_INITIAL_THPRES) , InputError::WARN );
BOOST_CHECK_EQUAL( parseContext.get(ParseContext::PARSE_RANDOM_SLASH) , InputErrorAction::IGNORE );
BOOST_CHECK_EQUAL( parseContext.get(ParseContext::PARSE_RANDOM_TEXT) , InputErrorAction::THROW_EXCEPTION );
BOOST_CHECK_EQUAL( parseContext.get(ParseContext::UNSUPPORTED_INITIAL_THPRES) , InputErrorAction::WARN );
}
@ -394,10 +394,10 @@ BOOST_AUTO_TEST_CASE( test_too_much_data ) {
ErrorGuard errors;
parseContext.update(ParseContext::PARSE_EXTRA_DATA , InputError::THROW_EXCEPTION );
parseContext.update(ParseContext::PARSE_EXTRA_DATA , InputErrorAction::THROW_EXCEPTION );
BOOST_CHECK_THROW( parser.parseString( deckString , parseContext, errors ) , OpmInputError);
parseContext.update(ParseContext::PARSE_EXTRA_DATA , InputError::IGNORE );
parseContext.update(ParseContext::PARSE_EXTRA_DATA , InputErrorAction::IGNORE );
auto deck = parser.parseString( deckString , parseContext, errors );
}
@ -405,8 +405,8 @@ BOOST_AUTO_TEST_CASE( test_too_much_data ) {
BOOST_AUTO_TEST_CASE(test_1arg_constructor) {
setenv("OPM_ERRORS_IGNORE", "PARSE_RANDOM_SLASH", 1);
{
ParseContext ctx(InputError::WARN);
BOOST_CHECK_EQUAL(ctx.get(ParseContext::PARSE_RANDOM_SLASH), InputError::IGNORE);
ParseContext ctx(InputErrorAction::WARN);
BOOST_CHECK_EQUAL(ctx.get(ParseContext::PARSE_RANDOM_SLASH), InputErrorAction::IGNORE);
}
}
@ -423,10 +423,10 @@ AQUCT
BOOST_CHECK_THROW(parser.parseString(deckString, parseContext, errors), OpmInputError);
parseContext.update(ParseContext::PARSE_INVALID_KEYWORD_COMBINATION , InputError::IGNORE );
parseContext.update(ParseContext::PARSE_INVALID_KEYWORD_COMBINATION , InputErrorAction::IGNORE );
BOOST_CHECK_NO_THROW(parser.parseString(deckString, parseContext, errors));
parseContext.update(ParseContext::PARSE_INVALID_KEYWORD_COMBINATION , InputError::THROW_EXCEPTION );
parseContext.update(ParseContext::PARSE_INVALID_KEYWORD_COMBINATION , InputErrorAction::THROW_EXCEPTION );
BOOST_CHECK_THROW(parser.parseString(deckString, parseContext, errors), OpmInputError);
}
@ -448,10 +448,10 @@ RTEMPVD
BOOST_CHECK_THROW(parser.parseString(deckString, parseContext, errors), OpmInputError);
parseContext.update(ParseContext::PARSE_INVALID_KEYWORD_COMBINATION , InputError::IGNORE );
parseContext.update(ParseContext::PARSE_INVALID_KEYWORD_COMBINATION , InputErrorAction::IGNORE );
BOOST_CHECK_NO_THROW(parser.parseString(deckString, parseContext, errors));
parseContext.update(ParseContext::PARSE_INVALID_KEYWORD_COMBINATION , InputError::THROW_EXCEPTION );
parseContext.update(ParseContext::PARSE_INVALID_KEYWORD_COMBINATION , InputErrorAction::THROW_EXCEPTION );
BOOST_CHECK_THROW(parser.parseString(deckString, parseContext, errors), OpmInputError);
}
@ -491,7 +491,7 @@ BOOST_AUTO_TEST_CASE( test_invalid_wtemplate_config ) {
Parser parser;
ErrorGuard errors;
parseContext.update(ParseContext::SCHEDULE_INVALID_NAME , InputError::THROW_EXCEPTION );
parseContext.update(ParseContext::SCHEDULE_INVALID_NAME , InputErrorAction::THROW_EXCEPTION );
std::vector < std::string > testSamples;
std::string testSample;
@ -755,11 +755,11 @@ RPTRUNSPEC
ParseContext context;
ErrorGuard error;
context.update(ParseContext::PARSE_LONG_KEYWORD, InputError::IGNORE);
context.update(ParseContext::PARSE_LONG_KEYWORD, InputErrorAction::IGNORE);
auto deck = parser.parseString(deck_string, context, error);
BOOST_CHECK( deck.hasKeyword("RPTRUNSP") );
context.update(ParseContext::PARSE_LONG_KEYWORD, InputError::THROW_EXCEPTION);
context.update(ParseContext::PARSE_LONG_KEYWORD, InputErrorAction::THROW_EXCEPTION);
BOOST_CHECK_THROW( parser.parseString(deck_string, context, error), OpmInputError);
}

View File

@ -6,11 +6,12 @@
#include <opm/input/eclipse/Deck/Deck.hpp>
#include <opm/input/eclipse/Parser/ErrorGuard.hpp>
#include <opm/input/eclipse/Parser/InputErrorAction.hpp>
#include <opm/input/eclipse/Parser/Parser.hpp>
#include <opm/input/eclipse/Parser/ParseContext.hpp>
void exit1(Opm::InputError::Action action) {
void exit1(Opm::InputErrorAction action) {
const char * deckString =
"RUNSPEC\n"
"DIMENS\n"
@ -34,7 +35,7 @@ void exit1(Opm::InputError::Action action) {
this test is implemented without the BOOST testing framework.
*/
void test_exit(Opm::InputError::Action action) {
void test_exit(Opm::InputErrorAction action) {
pid_t pid = fork();
if (pid == 0)
exit1(action);
@ -54,6 +55,6 @@ void test_exit(Opm::InputError::Action action) {
}
int main() {
test_exit(Opm::InputError::Action::EXIT1);
test_exit(Opm::InputError::Action::DELAYED_EXIT1);
test_exit(Opm::InputErrorAction::EXIT1);
test_exit(Opm::InputErrorAction::DELAYED_EXIT1);
}

View File

@ -29,6 +29,7 @@
#include <opm/input/eclipse/Deck/Deck.hpp>
#include <opm/input/eclipse/Parser/ParseContext.hpp>
#include <opm/input/eclipse/Parser/ErrorGuard.hpp>
#include <opm/input/eclipse/Parser/InputErrorAction.hpp>
#include <iostream>
@ -44,10 +45,10 @@ BOOST_AUTO_TEST_CASE(ParserKeyword_includeInvalid) {
Opm::ParseContext parseContext;
Opm::ErrorGuard errors;
parseContext.update(Opm::ParseContext::PARSE_MISSING_INCLUDE , Opm::InputError::THROW_EXCEPTION );
parseContext.update(Opm::ParseContext::PARSE_MISSING_INCLUDE , Opm::InputErrorAction::THROW_EXCEPTION );
BOOST_CHECK_THROW(parser.parseFile(inputFilePath.string() , parseContext, errors) , Opm::OpmInputError);
parseContext.update(Opm::ParseContext::PARSE_MISSING_INCLUDE , Opm::InputError::IGNORE );
parseContext.update(Opm::ParseContext::PARSE_MISSING_INCLUDE , Opm::InputErrorAction::IGNORE );
BOOST_CHECK_NO_THROW(parser.parseFile(inputFilePath.string() , parseContext, errors));
}
@ -122,7 +123,7 @@ BOOST_AUTO_TEST_CASE(ParserKeyword_includeWrongCase) {
// have to change the current behavior one not-so-fine day...
Opm::ParseContext parseContext;
Opm::ErrorGuard errors;
parseContext.update(Opm::ParseContext::PARSE_MISSING_INCLUDE , Opm::InputError::THROW_EXCEPTION );
parseContext.update(Opm::ParseContext::PARSE_MISSING_INCLUDE , Opm::InputErrorAction::THROW_EXCEPTION );
BOOST_CHECK_THROW(parser.parseFile(inputFile1Path.string(), parseContext, errors), Opm::OpmInputError);
BOOST_CHECK_THROW(parser.parseFile(inputFile2Path.string(), parseContext, errors), Opm::OpmInputError);

View File

@ -29,13 +29,14 @@
#include <opm/input/eclipse/Units/UnitSystem.hpp>
#include <opm/input/eclipse/Deck/Deck.hpp>
#include <opm/input/eclipse/Deck/DeckKeyword.hpp>
#include <opm/input/eclipse/Parser/ParseContext.hpp>
#include <opm/input/eclipse/Parser/ErrorGuard.hpp>
#include <opm/input/eclipse/Parser/Parser.hpp>
#include <opm/input/eclipse/Parser/InputErrorAction.hpp>
#include <opm/input/eclipse/Parser/ParseContext.hpp>
#include <opm/input/eclipse/Parser/ParserKeyword.hpp>
#include <opm/input/eclipse/Parser/ParserKeywords/A.hpp>
#include <opm/input/eclipse/Parser/ParserKeywords/S.hpp>
#include <opm/input/eclipse/Parser/ParserKeywords/Builtin.hpp>
#include <opm/input/eclipse/Parser/Parser.hpp>
#include <opm/input/eclipse/Parser/ParserRecord.hpp>
#include "src/opm/input/eclipse/Parser/raw/RawKeyword.hpp"
@ -320,7 +321,7 @@ BOOST_AUTO_TEST_CASE( PATHS_has_global_scope ) {
ParseContext parseContext;
ErrorGuard errors;
parseContext.update( ParseContext::PARSE_MISSING_INCLUDE , Opm::InputError::THROW_EXCEPTION);
parseContext.update( ParseContext::PARSE_MISSING_INCLUDE , Opm::InputErrorAction::THROW_EXCEPTION);
const auto deck = parser.parseFile( prefix() + "parser/PATHSInInclude.data", parseContext, errors );
BOOST_CHECK(deck.hasKeyword("OIL"));
BOOST_CHECK_THROW( parser.parseFile( prefix() + "parser/PATHSInIncludeInvalid.data", parseContext, errors ), OpmInputError );
@ -331,7 +332,7 @@ BOOST_AUTO_TEST_CASE( PATHS_with_backslashes ) {
ParseContext parseContext;
ErrorGuard errors;
parseContext.update( ParseContext::PARSE_MISSING_INCLUDE , Opm::InputError::THROW_EXCEPTION);
parseContext.update( ParseContext::PARSE_MISSING_INCLUDE , Opm::InputErrorAction::THROW_EXCEPTION);
const auto deck = parser.parseFile( prefix() + "parser/PATHSWithBackslashes.data", parseContext, errors );
BOOST_CHECK(deck.hasKeyword("OIL"));
}
@ -2338,10 +2339,10 @@ GUIDERATE
/
)";
parseContext.update(ParseContext::PARSE_LONG_KEYWORD, Opm::InputError::THROW_EXCEPTION);
parseContext.update(ParseContext::PARSE_LONG_KEYWORD, Opm::InputErrorAction::THROW_EXCEPTION);
BOOST_CHECK_THROW(parser.parseString(deck_string, parseContext, errors), OpmInputError);
parseContext.update(ParseContext::PARSE_LONG_KEYWORD, Opm::InputError::IGNORE);
parseContext.update(ParseContext::PARSE_LONG_KEYWORD, Opm::InputErrorAction::IGNORE);
auto deck = parser.parseString(deck_string, parseContext, errors);
BOOST_CHECK( deck.hasKeyword("GUIDERAT") );
}
@ -2384,9 +2385,9 @@ BOOST_AUTO_TEST_CASE(parseSections) {
Opm::ParseContext parseContext;
parseContext.update(Opm::ParseContext::PARSE_EXTRA_DATA , Opm::InputError::IGNORE );
parseContext.update(Opm::ParseContext::PARSE_EXTRA_RECORDS , Opm::InputError::IGNORE );
parseContext.update(Opm::ParseContext::PARSE_RANDOM_SLASH , Opm::InputError::IGNORE );
parseContext.update(Opm::ParseContext::PARSE_EXTRA_DATA , Opm::InputErrorAction::IGNORE );
parseContext.update(Opm::ParseContext::PARSE_EXTRA_RECORDS , Opm::InputErrorAction::IGNORE );
parseContext.update(Opm::ParseContext::PARSE_RANDOM_SLASH , Opm::InputErrorAction::IGNORE );
const auto deck_all = parser.parseFile("./tests/SPE1CASE1.DATA", parseContext);

View File

@ -24,6 +24,7 @@
#include <opm/input/eclipse/Deck/DeckSection.hpp>
#include <opm/input/eclipse/Parser/Parser.hpp>
#include <opm/input/eclipse/Parser/ErrorGuard.hpp>
#include <opm/input/eclipse/Parser/InputErrorAction.hpp>
#include <opm/input/eclipse/Parser/ParseContext.hpp>
#include <opm/input/eclipse/Parser/ParserKeywords/F.hpp>
#include <opm/input/eclipse/Parser/ParserKeywords/G.hpp>
@ -67,9 +68,9 @@ BOOST_AUTO_TEST_CASE( test_parse ) {
ParseContext parseContext;
ErrorGuard errors;
parseContext.update( ParseContext::PARSE_UNKNOWN_KEYWORD , InputError::IGNORE );
parseContext.update( ParseContext::PARSE_RANDOM_TEXT , InputError::IGNORE );
parseContext.update( ParseContext::PARSE_RANDOM_SLASH , InputError::IGNORE );
parseContext.update( ParseContext::PARSE_UNKNOWN_KEYWORD , InputErrorAction::IGNORE );
parseContext.update( ParseContext::PARSE_RANDOM_TEXT , InputErrorAction::IGNORE );
parseContext.update( ParseContext::PARSE_RANDOM_SLASH , InputErrorAction::IGNORE );
parser.addKeyword<ParserKeywords::SPECGRID>();
parser.addKeyword<ParserKeywords::FAULTS>();
@ -90,9 +91,9 @@ BOOST_AUTO_TEST_CASE( test_state ) {
ErrorGuard errors;
parseContext.update( ParseContext::PARSE_UNKNOWN_KEYWORD , InputError::IGNORE );
parseContext.update( ParseContext::PARSE_RANDOM_TEXT , InputError::IGNORE );
parseContext.update( ParseContext::PARSE_RANDOM_SLASH , InputError::IGNORE );
parseContext.update( ParseContext::PARSE_UNKNOWN_KEYWORD , InputErrorAction::IGNORE );
parseContext.update( ParseContext::PARSE_RANDOM_TEXT , InputErrorAction::IGNORE );
parseContext.update( ParseContext::PARSE_RANDOM_SLASH , InputErrorAction::IGNORE );
parser.addKeyword<ParserKeywords::SPECGRID>();
parser.addKeyword<ParserKeywords::FAULTS>();

View File

@ -23,6 +23,7 @@
#include <opm/input/eclipse/Deck/Deck.hpp>
#include <opm/input/eclipse/EclipseState/EclipseState.hpp>
#include <opm/input/eclipse/Parser/InputErrorAction.hpp>
#include <opm/input/eclipse/Parser/Parser.hpp>
#include <opm/input/eclipse/Parser/ParseContext.hpp>
#include <opm/input/eclipse/Parser/ErrorGuard.hpp>
@ -539,7 +540,7 @@ BASIC=1
ErrorGuard errors;
auto deck = Parser().parseString( data);
EclipseState es(deck);
parseContext.update(ParseContext::RPT_MIXED_STYLE, InputError::THROW_EXCEPTION);
parseContext.update(ParseContext::RPT_MIXED_STYLE, InputErrorAction::THROW_EXCEPTION);
BOOST_CHECK_THROW( Schedule( deck, es, parseContext, errors, {} ), std::exception );
}
@ -790,12 +791,12 @@ DATES -- 3
EclipseState es1(deck1);
EclipseState es2(deck2);
ctx.update(ParseContext::RPT_UNKNOWN_MNEMONIC, InputError::IGNORE);
ctx.update(ParseContext::RPT_MIXED_STYLE, InputError::THROW_EXCEPTION);
ctx.update(ParseContext::RPT_UNKNOWN_MNEMONIC, InputErrorAction::IGNORE);
ctx.update(ParseContext::RPT_MIXED_STYLE, InputErrorAction::THROW_EXCEPTION);
BOOST_CHECK_THROW( Schedule( deck1, es1, ctx, errors, {} ), std::exception );
ctx.update(ParseContext::RPT_MIXED_STYLE, InputError::IGNORE);
ctx.update(ParseContext::RPT_MIXED_STYLE, InputErrorAction::IGNORE);
Schedule sched1(deck1, es1, ctx, errors, {});
@ -819,9 +820,9 @@ DATES -- 3
BOOST_CHECK_EQUAL_COLLECTIONS( expected.begin() ,expected.end(),
kw_list.begin() , kw_list.end() );
ctx.update(ParseContext::RPT_UNKNOWN_MNEMONIC, InputError::THROW_EXCEPTION);
ctx.update(ParseContext::RPT_UNKNOWN_MNEMONIC, InputErrorAction::THROW_EXCEPTION);
BOOST_CHECK_THROW( Schedule( deck2, es2, ctx, errors, {} ), std::exception );
ctx.update(ParseContext::RPT_UNKNOWN_MNEMONIC, InputError::IGNORE);
ctx.update(ParseContext::RPT_UNKNOWN_MNEMONIC, InputErrorAction::IGNORE);
Schedule sched2(deck2, es2, ctx, errors, {});

View File

@ -64,9 +64,10 @@
#include <opm/input/eclipse/Deck/DeckItem.hpp>
#include <opm/input/eclipse/Deck/DeckKeyword.hpp>
#include <opm/input/eclipse/Deck/DeckRecord.hpp>
#include <opm/input/eclipse/Parser/ErrorGuard.hpp>
#include <opm/input/eclipse/Parser/InputErrorAction.hpp>
#include <opm/input/eclipse/Parser/Parser.hpp>
#include <opm/input/eclipse/Parser/ParseContext.hpp>
#include <opm/input/eclipse/Parser/ErrorGuard.hpp>
#include <opm/input/eclipse/Units/Dimension.hpp>
#include <opm/input/eclipse/Units/UnitSystem.hpp>
@ -1467,10 +1468,10 @@ BOOST_AUTO_TEST_CASE(WELSPECS_WGNAME_SPACE) {
ParseContext parseContext;
ErrorGuard errors;
parseContext.update(ParseContext::PARSE_WGNAME_SPACE, InputError::THROW_EXCEPTION);
parseContext.update(ParseContext::PARSE_WGNAME_SPACE, InputErrorAction::THROW_EXCEPTION);
BOOST_CHECK_THROW( Opm::Schedule(deck, grid, fp, runspec, parseContext, errors, python), Opm::OpmInputError);
parseContext.update(ParseContext::PARSE_WGNAME_SPACE, InputError::IGNORE);
parseContext.update(ParseContext::PARSE_WGNAME_SPACE, InputErrorAction::IGNORE);
BOOST_CHECK_NO_THROW( Opm::Schedule(deck, grid, fp, runspec, parseContext, errors, python));
}

View File

@ -30,6 +30,7 @@
#include <opm/input/eclipse/Deck/DeckKeyword.hpp>
#include <opm/input/eclipse/Deck/DeckSection.hpp>
#include <opm/input/eclipse/Parser/ErrorGuard.hpp>
#include <opm/input/eclipse/Parser/InputErrorAction.hpp>
#include <opm/input/eclipse/Parser/ParseContext.hpp>
#include <opm/input/eclipse/Parser/Parser.hpp>
@ -217,7 +218,7 @@ BOOST_AUTO_TEST_CASE(SCHEDULESection_NotTerminated) {
BOOST_AUTO_TEST_CASE(Section_ValidDecks) {
ParseContext mode { { { ParseContext::PARSE_UNKNOWN_KEYWORD, InputError::IGNORE } } };
ParseContext mode { { { ParseContext::PARSE_UNKNOWN_KEYWORD, InputErrorAction::IGNORE } } };
Parser parser;
ErrorGuard errors;
@ -257,7 +258,7 @@ BOOST_AUTO_TEST_CASE(Section_ValidDecks) {
BOOST_AUTO_TEST_CASE(Section_InvalidDecks) {
Parser parser;
ParseContext mode { { { ParseContext::PARSE_UNKNOWN_KEYWORD, InputError::IGNORE } } };
ParseContext mode { { { ParseContext::PARSE_UNKNOWN_KEYWORD, InputErrorAction::IGNORE } } };
ErrorGuard errors;
const std::string keyword_before_RUNSPEC =

View File

@ -28,8 +28,9 @@
#include <opm/input/eclipse/EclipseState/EclipseState.hpp>
#include <opm/input/eclipse/EclipseState/SummaryConfig/SummaryConfig.hpp>
#include <opm/input/eclipse/Schedule/Schedule.hpp>
#include <opm/input/eclipse/Parser/ParseContext.hpp>
#include <opm/input/eclipse/Parser/ErrorGuard.hpp>
#include <opm/input/eclipse/Parser/InputErrorAction.hpp>
#include <opm/input/eclipse/Parser/ParseContext.hpp>
#include <opm/input/eclipse/Parser/Parser.hpp>
#include <algorithm>
@ -236,7 +237,7 @@ BOOST_AUTO_TEST_CASE(wells_missingI) {
ErrorGuard errors;
const auto input = "WWCT\n/\n";
auto deck = createDeck_no_wells( input );
parseContext.update(ParseContext::SUMMARY_UNKNOWN_WELL, InputError::THROW_EXCEPTION);
parseContext.update(ParseContext::SUMMARY_UNKNOWN_WELL, InputErrorAction::THROW_EXCEPTION);
EclipseState state( deck );
Schedule schedule(deck, state, parseContext, errors, python );
BOOST_CHECK_NO_THROW(SummaryConfig(deck, schedule, state.fieldProps(), state.aquifer(), parseContext, errors));
@ -557,7 +558,7 @@ RKFT
ParseContext parseContext;
parseContext.update(ParseContext::SUMMARY_UNHANDLED_KEYWORD, InputError::THROW_EXCEPTION);
parseContext.update(ParseContext::SUMMARY_UNHANDLED_KEYWORD, InputErrorAction::THROW_EXCEPTION);
BOOST_CHECK_THROW( createSummary(input, parseContext), OpmInputError);
}
@ -711,10 +712,10 @@ BOOST_AUTO_TEST_CASE(INVALID_WELL1) {
const auto input = "CWIR\n"
"NEW-WELL /\n"
"/\n";
parseContext.updateKey( ParseContext::SUMMARY_UNKNOWN_WELL , InputError::THROW_EXCEPTION );
parseContext.updateKey( ParseContext::SUMMARY_UNKNOWN_WELL , InputErrorAction::THROW_EXCEPTION );
BOOST_CHECK_THROW( createSummary( input , parseContext ) , OpmInputError);
parseContext.updateKey( ParseContext::SUMMARY_UNKNOWN_WELL , InputError::IGNORE );
parseContext.updateKey( ParseContext::SUMMARY_UNKNOWN_WELL , InputErrorAction::IGNORE );
BOOST_CHECK_NO_THROW( createSummary( input , parseContext ));
}
@ -723,10 +724,10 @@ BOOST_AUTO_TEST_CASE(INVALID_WELL2) {
ParseContext parseContext;
const auto input = "WWCT\n"
" NEW-WELL /\n";
parseContext.updateKey( ParseContext::SUMMARY_UNKNOWN_WELL , InputError::THROW_EXCEPTION );
parseContext.updateKey( ParseContext::SUMMARY_UNKNOWN_WELL , InputErrorAction::THROW_EXCEPTION );
BOOST_CHECK_THROW( createSummary( input , parseContext ) , OpmInputError);
parseContext.updateKey( ParseContext::SUMMARY_UNKNOWN_WELL , InputError::IGNORE );
parseContext.updateKey( ParseContext::SUMMARY_UNKNOWN_WELL , InputErrorAction::IGNORE );
BOOST_CHECK_NO_THROW( createSummary( input , parseContext ));
}
@ -734,10 +735,10 @@ BOOST_AUTO_TEST_CASE(UNDEFINED_UDQ_WELL) {
ParseContext parseContext;
const auto input = "WUWCT\n"
"/\n";
parseContext.updateKey( ParseContext::SUMMARY_UNDEFINED_UDQ, InputError::THROW_EXCEPTION );
parseContext.updateKey( ParseContext::SUMMARY_UNDEFINED_UDQ, InputErrorAction::THROW_EXCEPTION );
BOOST_CHECK_THROW( createSummary( input , parseContext ) , OpmInputError);
parseContext.updateKey( ParseContext::SUMMARY_UNDEFINED_UDQ, InputError::IGNORE );
parseContext.updateKey( ParseContext::SUMMARY_UNDEFINED_UDQ, InputErrorAction::IGNORE );
BOOST_CHECK_NO_THROW( createSummary( input , parseContext ));
}
@ -748,10 +749,10 @@ BOOST_AUTO_TEST_CASE(INVALID_GROUP) {
ParseContext parseContext;
const auto input = "GWCT\n"
" NEW-GR /\n";
parseContext.updateKey( ParseContext::SUMMARY_UNKNOWN_GROUP , InputError::THROW_EXCEPTION );
parseContext.updateKey( ParseContext::SUMMARY_UNKNOWN_GROUP , InputErrorAction::THROW_EXCEPTION );
BOOST_CHECK_THROW( createSummary( input , parseContext ) , OpmInputError);
parseContext.updateKey( ParseContext::SUMMARY_UNKNOWN_GROUP , InputError::IGNORE );
parseContext.updateKey( ParseContext::SUMMARY_UNKNOWN_GROUP , InputErrorAction::IGNORE );
BOOST_CHECK_NO_THROW( createSummary( input , parseContext ));
}
@ -2066,16 +2067,16 @@ WOPRL
ParseContext parseContext;
// Invalid well
parseContext.update(ParseContext::SUMMARY_UNKNOWN_WELL, InputError::THROW_EXCEPTION);
parseContext.update(ParseContext::SUMMARY_UNKNOWN_WELL, InputErrorAction::THROW_EXCEPTION);
BOOST_CHECK_THROW(createSummary( input1, parseContext ), OpmInputError);
// Invalid completion
parseContext.update(ParseContext::SUMMARY_UNHANDLED_KEYWORD, InputError::THROW_EXCEPTION);
parseContext.update(ParseContext::SUMMARY_UNHANDLED_KEYWORD, InputErrorAction::THROW_EXCEPTION);
BOOST_CHECK_THROW(createSummary( input2, parseContext ), OpmInputError);
parseContext.update(ParseContext::SUMMARY_UNHANDLED_KEYWORD, InputError::IGNORE);
parseContext.update(ParseContext::SUMMARY_UNKNOWN_WELL, InputError::IGNORE);
parseContext.update(ParseContext::SUMMARY_UNHANDLED_KEYWORD, InputErrorAction::IGNORE);
parseContext.update(ParseContext::SUMMARY_UNKNOWN_WELL, InputErrorAction::IGNORE);
const auto& summary_config1 = createSummary(input1, parseContext);
BOOST_CHECK(summary_config1.hasKeyword("WOPRL__2"));
BOOST_CHECK_EQUAL(summary_config1.size(), 1);
@ -2112,16 +2113,16 @@ COPRL
ParseContext parseContext;
// Invalid well
parseContext.update(ParseContext::SUMMARY_UNKNOWN_WELL, InputError::THROW_EXCEPTION);
parseContext.update(ParseContext::SUMMARY_UNKNOWN_WELL, InputErrorAction::THROW_EXCEPTION);
BOOST_CHECK_THROW(createSummary( input1, parseContext ), OpmInputError);
// Invalid connection
parseContext.update(ParseContext::SUMMARY_UNHANDLED_KEYWORD, InputError::THROW_EXCEPTION);
parseContext.update(ParseContext::SUMMARY_UNHANDLED_KEYWORD, InputErrorAction::THROW_EXCEPTION);
BOOST_CHECK_THROW(createSummary( input2, parseContext ), OpmInputError);
parseContext.update(ParseContext::SUMMARY_UNHANDLED_KEYWORD, InputError::IGNORE);
parseContext.update(ParseContext::SUMMARY_UNKNOWN_WELL, InputError::IGNORE);
parseContext.update(ParseContext::SUMMARY_UNHANDLED_KEYWORD, InputErrorAction::IGNORE);
parseContext.update(ParseContext::SUMMARY_UNKNOWN_WELL, InputErrorAction::IGNORE);
const auto& summary_config1 = createSummary(input1, parseContext);
BOOST_CHECK(summary_config1.hasKeyword("COPRL"));
BOOST_CHECK_EQUAL(summary_config1.size(), 1);
@ -2209,34 +2210,34 @@ RPR__REG
)";
ParseContext parse_context;
{
parse_context.update(ParseContext::SUMMARY_INVALID_FIPNUM, InputError::IGNORE);
parse_context.update(ParseContext::SUMMARY_INVALID_FIPNUM, InputErrorAction::IGNORE);
const auto& summary_config = createSummary(input, parse_context);
BOOST_CHECK(summary_config.hasKeyword("RWIP_REG"));
BOOST_CHECK(!summary_config.hasKeyword("RPR__ABC"));
}
{
parse_context.update(ParseContext::SUMMARY_INVALID_FIPNUM, InputError::THROW_EXCEPTION);
parse_context.update(ParseContext::SUMMARY_INVALID_FIPNUM, InputErrorAction::THROW_EXCEPTION);
BOOST_CHECK_THROW(createSummary(input, parse_context), std::exception);
}
{
parse_context.update(ParseContext::SUMMARY_REGION_TOO_LARGE, InputError::THROW_EXCEPTION);
parse_context.update(ParseContext::SUMMARY_REGION_TOO_LARGE, InputErrorAction::THROW_EXCEPTION);
BOOST_CHECK_THROW(createSummary(input_too_large, parse_context), std::exception);
}
{
parse_context.update(ParseContext::SUMMARY_REGION_TOO_LARGE, InputError::IGNORE);
parse_context.update(ParseContext::SUMMARY_REGION_TOO_LARGE, InputErrorAction::IGNORE);
const auto& summary_config = createSummary(input_too_large, parse_context);
BOOST_CHECK_EQUAL( summary_config.size(), 3);
}
{
parse_context.update(ParseContext::SUMMARY_EMPTY_REGION, InputError::THROW_EXCEPTION);
parse_context.update(ParseContext::SUMMARY_EMPTY_REGION, InputErrorAction::THROW_EXCEPTION);
BOOST_CHECK_THROW(createSummary(input_empty, parse_context), std::exception);
}
{
parse_context.update(ParseContext::SUMMARY_EMPTY_REGION, InputError::IGNORE);
parse_context.update(ParseContext::SUMMARY_EMPTY_REGION, InputErrorAction::IGNORE);
const auto& summary_config = createSummary(input_empty, parse_context);
BOOST_CHECK_EQUAL( summary_config.size(), 1);
}

View File

@ -37,7 +37,7 @@
#include <opm/input/eclipse/Parser/Parser.hpp>
#include <opm/input/eclipse/Parser/ParseContext.hpp>
#include <opm/input/eclipse/Parser/ErrorGuard.hpp>
#include <opm/input/eclipse/Parser/InputErrorAction.hpp>
using namespace Opm;
@ -338,14 +338,14 @@ BOOST_AUTO_TEST_CASE(ThresholdPressureThrowTest) {
BOOST_CHECK_THROW(Setup sx(inputStr), std::runtime_error);
ParseContext pc;
pc.update(ParseContext::UNSUPPORTED_INITIAL_THPRES, InputError::IGNORE);
pc.update(ParseContext::UNSUPPORTED_INITIAL_THPRES, InputErrorAction::IGNORE);
BOOST_CHECK_NO_THROW(Setup sx(inputStrMissingPressure, pc));
Setup s(inputStrMissingPressure, pc);
BOOST_CHECK( s.threshPres.hasRegionBarrier(2, 3));
BOOST_CHECK(!s.threshPres.hasThresholdPressure(2, 3));
pc.update(ParseContext::INTERNAL_ERROR_UNINITIALIZED_THPRES, InputError::THROW_EXCEPTION);
pc.update(ParseContext::INTERNAL_ERROR_UNINITIALIZED_THPRES, InputErrorAction::THROW_EXCEPTION);
BOOST_CHECK_THROW(s.threshPres.getThresholdPressure(2, 3), std::invalid_argument);
}

View File

@ -43,6 +43,7 @@ Copyright 2018 Statoil ASA.
#include <opm/input/eclipse/Utility/Typetools.hpp>
#include <opm/input/eclipse/Parser/ErrorGuard.hpp>
#include <opm/input/eclipse/Parser/InputErrorAction.hpp>
#include <opm/input/eclipse/Parser/ParseContext.hpp>
#include <opm/input/eclipse/Parser/Parser.hpp>
@ -1331,7 +1332,7 @@ BOOST_AUTO_TEST_CASE(UDQ_PARSE_ERROR) {
ErrorGuard errors;
std::vector<std::string> tokens = {"WBHP", "+"};
KeywordLocation location;
parseContext.update(ParseContext::UDQ_PARSE_ERROR, InputError::IGNORE);
parseContext.update(ParseContext::UDQ_PARSE_ERROR, InputErrorAction::IGNORE);
{
UDQDefine def1(udqp, "WUBHP",0, location, tokens, parseContext, errors);
SummaryState st(TimeService::now());
@ -1345,7 +1346,7 @@ BOOST_AUTO_TEST_CASE(UDQ_PARSE_ERROR) {
BOOST_CHECK_EQUAL(res["P1"].get(), udqp.undefinedValue());
}
parseContext.update(ParseContext::UDQ_PARSE_ERROR, InputError::THROW_EXCEPTION);
parseContext.update(ParseContext::UDQ_PARSE_ERROR, InputErrorAction::THROW_EXCEPTION);
BOOST_CHECK_THROW( UDQDefine(udqp, "WUBHP",0, location, tokens, parseContext, errors), OpmInputError);
}
@ -1356,7 +1357,7 @@ BOOST_AUTO_TEST_CASE(UDQ_TYPE_ERROR) {
std::vector<std::string> tokens1 = {"WBHP", "+", "1"};
std::vector<std::string> tokens2 = {"SUM", "(", "WBHP", ")"};
KeywordLocation location;
parseContext.update(ParseContext::UDQ_TYPE_ERROR, InputError::IGNORE);
parseContext.update(ParseContext::UDQ_TYPE_ERROR, InputErrorAction::IGNORE);
{
UDQDefine def1(udqp, "FUBHP",0, location, tokens1, parseContext, errors);
UDQDefine def2(udqp, "WUBHP",0, location, tokens2, parseContext, errors);
@ -1378,7 +1379,7 @@ BOOST_AUTO_TEST_CASE(UDQ_TYPE_ERROR) {
BOOST_CHECK_EQUAL(res2[index].get(), 3);
}
parseContext.update(ParseContext::UDQ_TYPE_ERROR, InputError::THROW_EXCEPTION);
parseContext.update(ParseContext::UDQ_TYPE_ERROR, InputErrorAction::THROW_EXCEPTION);
// This fails because the well expression (WBHP + 1) is assigned to the field variable FUBHP
BOOST_CHECK_THROW( UDQDefine(udqp, "FUBHP",0, location, tokens1, parseContext, errors), OpmInputError);

View File

@ -34,10 +34,11 @@
#include <opm/input/eclipse/EclipseState/Tables/SlgofTable.hpp>
#include <opm/input/eclipse/EclipseState/Tables/SwofTable.hpp>
#include <opm/input/eclipse/EclipseState/Tables/TlpmixpaTable.hpp>
#include <opm/input/eclipse/Parser/Parser.hpp>
#include <opm/input/eclipse/Units/Units.hpp>
#include <opm/input/eclipse/Parser/ParseContext.hpp>
#include <opm/input/eclipse/Parser/ErrorGuard.hpp>
#include <opm/input/eclipse/Parser/InputErrorAction.hpp>
#include <opm/input/eclipse/Parser/ParseContext.hpp>
#include <opm/input/eclipse/Parser/Parser.hpp>
#include <opm/common/utility/TimeService.hpp>
using namespace Opm;
@ -130,7 +131,7 @@ BOOST_AUTO_TEST_CASE( EQUIL_MISSING_DIMS ) {
Parser parser;
ErrorGuard errors;
ParseContext parseContext;
parseContext.update(ParseContext::PARSE_MISSING_DIMS_KEYWORD, InputError::IGNORE);
parseContext.update(ParseContext::PARSE_MISSING_DIMS_KEYWORD, InputErrorAction::IGNORE);
const std::string equil = "EQUIL\n"
"2469 382.4 1705.0 0.0 500 0.0 1 1 20 /";
auto deck = parser.parseString(equil, parseContext, errors);

View File

@ -29,9 +29,10 @@
#include <opm/input/eclipse/EclipseState/EclipseState.hpp>
#include <opm/input/eclipse/Schedule/Schedule.hpp>
#include <opm/input/eclipse/Parser/ErrorGuard.hpp>
#include <opm/input/eclipse/Parser/InputErrorAction.hpp>
#include <opm/input/eclipse/Parser/ParseContext.hpp>
#include <opm/input/eclipse/Parser/Parser.hpp>
#include <opm/input/eclipse/Parser/ErrorGuard.hpp>
#include <iostream>
#include <string>
@ -389,7 +390,7 @@ RedirectCERR::~RedirectCERR()
BOOST_AUTO_TEST_SUITE(WellDimensions)
namespace {
void setWellDimsContext(const Opm::InputError::Action action,
void setWellDimsContext(const Opm::InputErrorAction action,
Opm::ParseContext& ctxt)
{
ctxt.update(Opm::ParseContext::RUNSPEC_NUMWELLS_TOO_LARGE, action);
@ -422,7 +423,7 @@ BOOST_AUTO_TEST_CASE(ManyChildGroups)
BOOST_AUTO_TEST_CASE(WellDims)
{
Opm::ParseContext parseContext;
setWellDimsContext(Opm::InputError::THROW_EXCEPTION, parseContext);
setWellDimsContext(Opm::InputErrorAction::THROW_EXCEPTION, parseContext);
auto cse = CaseObjects{ simCaseWellDims(), parseContext};
@ -433,7 +434,7 @@ BOOST_AUTO_TEST_CASE(WellDims)
parseContext, cse.guard),
Opm::OpmInputError);
setWellDimsContext(Opm::InputError::DELAYED_EXIT1, parseContext);
setWellDimsContext(Opm::InputErrorAction::DELAYED_EXIT1, parseContext);
Opm::checkConsistentArrayDimensions(cse.es , cse.sched,
parseContext, cse.guard);
@ -458,7 +459,7 @@ BOOST_AUTO_TEST_CASE(WellDims)
BOOST_AUTO_TEST_CASE(WellDims_ManyChildGroups)
{
Opm::ParseContext parseContext;
setWellDimsContext(Opm::InputError::THROW_EXCEPTION, parseContext);
setWellDimsContext(Opm::InputErrorAction::THROW_EXCEPTION, parseContext);
auto cse = CaseObjects{ simCaseNodeGroupSizeFailure(), parseContext};
@ -470,7 +471,7 @@ BOOST_AUTO_TEST_CASE(WellDims_ManyChildGroups)
parseContext, cse.guard),
Opm::OpmInputError);
setWellDimsContext(Opm::InputError::DELAYED_EXIT1, parseContext);
setWellDimsContext(Opm::InputErrorAction::DELAYED_EXIT1, parseContext);
Opm::checkConsistentArrayDimensions(cse.es , cse.sched,
parseContext, cse.guard);