Merge pull request #1694 from joakim-hove/error-guard

Add ErrorGuard when parsing
This commit is contained in:
Joakim Hove 2019-01-08 07:49:39 +01:00 committed by GitHub
commit 5f8431703a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 50 additions and 70 deletions

View File

@ -40,6 +40,8 @@
#include <opm/parser/eclipse/Deck/Deck.hpp>
#include <opm/parser/eclipse/Parser/Parser.hpp>
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
#include <opm/parser/eclipse/Parser/ErrorGuard.hpp>
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
#include <opm/parser/eclipse/EclipseState/checkDeck.hpp>
@ -178,8 +180,9 @@ int main(int argc, char** argv)
tmp.push_back(ParseModePair(Opm::ParseContext::SUMMARY_UNKNOWN_WELL, Opm::InputError::WARN));
tmp.push_back(ParseModePair(Opm::ParseContext::SUMMARY_UNKNOWN_GROUP, Opm::InputError::WARN));
Opm::ParseContext parseContext(tmp);
Opm::ErrorGuard errorGuard;
std::shared_ptr<Opm::Deck> deck = std::make_shared< Opm::Deck >( parser.parseFile(deckFilename , parseContext) );
std::shared_ptr<Opm::Deck> deck = std::make_shared< Opm::Deck >( parser.parseFile(deckFilename , parseContext, errorGuard) );
if ( outputCout ) {
Opm::checkDeck(*deck, parser);
Opm::MissingFeatures::checkKeywords(*deck);
@ -187,7 +190,7 @@ int main(int argc, char** argv)
Opm::Runspec runspec( *deck );
const auto& phases = runspec.phases();
std::shared_ptr<Opm::EclipseState> eclipseState = std::make_shared< Opm::EclipseState > ( *deck, parseContext );
std::shared_ptr<Opm::EclipseState> eclipseState = std::make_shared< Opm::EclipseState > ( *deck, parseContext, errorGuard );
// run the actual simulator
//

View File

@ -41,7 +41,6 @@
#include <opm/parser/eclipse/Deck/Deck.hpp>
#include <opm/parser/eclipse/Parser/Parser.hpp>
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
#include <opm/parser/eclipse/EclipseState/IOConfig/IOConfig.hpp>
#include <opm/parser/eclipse/EclipseState/InitConfig/InitConfig.hpp>

View File

@ -32,6 +32,7 @@
#include <opm/parser/eclipse/Units/Units.hpp>
#include <opm/parser/eclipse/Parser/Parser.hpp>
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
#include <opm/parser/eclipse/Parser/ErrorGuard.hpp>
#include <opm/parser/eclipse/Deck/Deck.hpp>
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
#include <opm/parser/eclipse/EclipseState/Tables/TableManager.hpp>
@ -273,11 +274,12 @@ void verify_norne_oil_pvt_region2(const Opm::Deck& deck, const Opm::EclipseState
BOOST_AUTO_TEST_CASE( Test_Norne_PVT) {
Opm::ParseContext parseContext({{ ParseContext::PARSE_RANDOM_SLASH , InputError::IGNORE }});
Opm::ErrorGuard errorGuard;
Opm::Parser parser;
auto deck = parser.parseFile("norne_pvt.data", parseContext);
auto deck = parser.parseFile("norne_pvt.data", parseContext, errorGuard);
Opm::EclipseState eclState(deck, parseContext);
Opm::EclipseState eclState(deck, parseContext, errorGuard);
verify_norne_oil_pvt_region1( deck, eclState );
verify_norne_oil_pvt_region2( deck, eclState );

View File

@ -37,7 +37,6 @@
#include <opm/core/props/satfunc/RelpermDiagnostics.hpp>
#include <opm/parser/eclipse/Parser/Parser.hpp>
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
#include <opm/parser/eclipse/Deck/Deck.hpp>
BOOST_AUTO_TEST_SUITE ()
@ -46,10 +45,9 @@ BOOST_AUTO_TEST_CASE(diagnosis)
{
using namespace Opm;
Parser parser;
Opm::ParseContext parseContext;
Opm::Deck deck = parser.parseFile("../tests/relpermDiagnostics.DATA", parseContext);
EclipseState eclState(deck, parseContext);
Opm::Deck deck = parser.parseFile("../tests/relpermDiagnostics.DATA");
EclipseState eclState(deck);
GridManager gm(eclState.getInputGrid());
const UnstructuredGrid& grid = *gm.c_grid();
std::shared_ptr<CounterLog> counterLog = std::make_shared<CounterLog>(Log::DefaultMessageTypes);

View File

@ -23,7 +23,6 @@
#include <boost/test/unit_test.hpp>
#include <opm/parser/eclipse/Parser/Parser.hpp>
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
#include <opm/core/wells/WellsManager.hpp>
@ -38,16 +37,15 @@ using namespace Opm;
BOOST_AUTO_TEST_CASE(TestStoppedWells)
{
const std::string filename = "wells_stopped.data";
Opm::ParseContext parseContext;
Opm::Parser parser;
Opm::Deck deck(parser.parseFile(filename , parseContext));
Opm::EclipseState eclipseState(deck , parseContext);
Opm::Deck deck(parser.parseFile(filename));
Opm::EclipseState eclipseState(deck);
Opm::GridManager vanguard(eclipseState.getInputGrid());
const auto& grid = eclipseState.getInputGrid();
const TableManager table ( deck );
const Eclipse3DProperties eclipseProperties ( deck , table, grid);
const Opm::Runspec runspec (deck);
const Schedule sched(deck, grid, eclipseProperties, runspec, parseContext );
const Schedule sched(deck, grid, eclipseProperties, runspec);
double target_surfacerate_inj;

View File

@ -27,7 +27,6 @@
#include <opm/parser/eclipse/Deck/Deck.hpp>
#include <opm/parser/eclipse/Parser/Parser.hpp>
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
#include <opm/simulators/timestepping/SimulatorTimer.hpp>
#include <opm/parser/eclipse/Units/Units.hpp>
@ -39,9 +38,8 @@
BOOST_AUTO_TEST_CASE(CreateTimer)
{
const std::string filename1 = "TESTTIMER.DATA";
Opm::ParseContext parseContext;
Opm::Parser parser;
Opm::Deck parserDeck = parser.parseFile( filename1 , parseContext);
Opm::Deck parserDeck = parser.parseFile( filename1);
Opm::TimeMap timeMap( parserDeck );
Opm::SimulatorTimer simtimer;

View File

@ -35,7 +35,6 @@
#include <opm/common/utility/platform_dependent/reenable_warnings.h>
#include <opm/core/wells.h>
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
#include <opm/parser/eclipse/Parser/Parser.hpp>
#include <opm/parser/eclipse/EclipseState/checkDeck.hpp>
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
@ -592,8 +591,7 @@ VFPPROD \n\
auto units = Opm::UnitSystem::newFIELD();
Opm::Parser parser;
Opm::ParseContext parse_mode;
auto deck = parser.parseString(table_str, parse_mode);
auto deck = parser.parseString(table_str);
BOOST_REQUIRE(deck.hasKeyword("VFPPROD"));
BOOST_CHECK_EQUAL(deck.count("VFPPROD"), 1);
@ -651,10 +649,9 @@ BOOST_AUTO_TEST_CASE(ParseInterpolateRealisticVFPPROD)
auto units = Opm::UnitSystem::newMETRIC();
Opm::Parser parser;
Opm::ParseContext parse_mode;
boost::filesystem::path file("VFPPROD2");
auto deck = parser.parseFile(file.string(), parse_mode);
auto deck = parser.parseFile(file.string());
Opm::checkDeck(deck, parser);
BOOST_REQUIRE(deck.hasKeyword("VFPPROD"));

View File

@ -25,7 +25,6 @@
#include <boost/test/unit_test.hpp>
#include <opm/core/wells/WellCollection.hpp>
#include <opm/parser/eclipse/Parser/Parser.hpp>
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
#include <opm/parser/eclipse/Deck/Deck.hpp>
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Well.hpp>
@ -38,15 +37,14 @@ using namespace Opm;
BOOST_AUTO_TEST_CASE(AddWellsAndGroupToCollection) {
Parser parser;
std::string scheduleFile("wells_group.data");
ParseContext parseContext;
Deck deck = parser.parseFile(scheduleFile, parseContext);
EclipseState eclipseState(deck, parseContext);
Deck deck = parser.parseFile(scheduleFile);
EclipseState eclipseState(deck);
PhaseUsage pu = phaseUsageFromDeck(eclipseState);
const auto& grid = eclipseState.getInputGrid();
const TableManager table ( deck );
const Eclipse3DProperties eclipseProperties ( deck , table, grid);
const Runspec runspec(deck);
const Schedule sched(deck, grid, eclipseProperties, runspec, parseContext );
const Schedule sched(deck, grid, eclipseProperties, runspec);
WellCollection collection;
@ -78,15 +76,14 @@ BOOST_AUTO_TEST_CASE(AddWellsAndGroupToCollection) {
BOOST_AUTO_TEST_CASE(EfficiencyFactor) {
Parser parser;
std::string scheduleFile("wells_group.data");
ParseContext parseContext;
Deck deck = parser.parseFile(scheduleFile, parseContext);
EclipseState eclipseState(deck, parseContext);
Deck deck = parser.parseFile(scheduleFile);
EclipseState eclipseState(deck);
PhaseUsage pu = phaseUsageFromDeck(eclipseState);
const auto& grid = eclipseState.getInputGrid();
const TableManager table ( deck );
const Eclipse3DProperties eclipseProperties ( deck , table, grid);
const Runspec runspec(deck);
const Schedule sched(deck, grid, eclipseProperties, runspec, parseContext );
const Schedule sched(deck, grid, eclipseProperties, runspec);
size_t timestep = 2;
WellCollection collection;

View File

@ -29,7 +29,6 @@
#include <opm/common/utility/platform_dependent/reenable_warnings.h>
#include <opm/parser/eclipse/Parser/Parser.hpp>
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
#include <opm/parser/eclipse/Deck/Deck.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/ScheduleEnums.hpp>
@ -69,15 +68,14 @@ struct SetupTest {
SetupTest ()
{
Opm::ParseContext parse_context;
Opm::Parser parser;
auto deck = parser.parseFile("TESTWELLMODEL.DATA", parse_context);
ecl_state.reset(new Opm::EclipseState(deck , parse_context) );
auto deck = parser.parseFile("TESTWELLMODEL.DATA");
ecl_state.reset(new Opm::EclipseState(deck) );
{
const Opm::TableManager table ( deck );
const Opm::Eclipse3DProperties eclipseProperties ( deck , table, ecl_state->getInputGrid());
const Opm::Runspec runspec (deck);
schedule.reset( new Opm::Schedule(deck, ecl_state->getInputGrid(), eclipseProperties, runspec, parse_context ));
schedule.reset( new Opm::Schedule(deck, ecl_state->getInputGrid(), eclipseProperties, runspec));
}
// Create grid.

View File

@ -33,7 +33,6 @@
#include <opm/core/wells/WellsGroup.hpp>
#include <opm/parser/eclipse/Parser/Parser.hpp>
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Group.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/GroupTree.hpp>
@ -45,15 +44,14 @@ using namespace Opm;
BOOST_AUTO_TEST_CASE(ConstructGroupFromWell) {
std::string scheduleFile("wells_group.data");
ParseContext parseContext;
Parser parser;
Deck deck = parser.parseFile(scheduleFile, parseContext);
EclipseState eclipseState(deck , parseContext);
Deck deck = parser.parseFile(scheduleFile);
EclipseState eclipseState(deck);
const auto& grid = eclipseState.getInputGrid();
const TableManager table ( deck );
const Eclipse3DProperties eclipseProperties ( deck , table, grid);
const Opm::Runspec runspec (deck);
const Schedule sched(deck, grid, eclipseProperties, runspec, parseContext );
const Schedule sched(deck, grid, eclipseProperties, runspec);
PhaseUsage pu = phaseUsageFromDeck(eclipseState);
@ -84,16 +82,15 @@ BOOST_AUTO_TEST_CASE(ConstructGroupFromWell) {
BOOST_AUTO_TEST_CASE(ConstructGroupFromGroup) {
Parser parser;
ParseContext parseContext;
std::string scheduleFile("wells_group.data");
Deck deck = parser.parseFile(scheduleFile, parseContext);
EclipseState eclipseState(deck , parseContext);
Deck deck = parser.parseFile(scheduleFile);
EclipseState eclipseState(deck);
PhaseUsage pu = phaseUsageFromDeck(eclipseState);
const auto& grid = eclipseState.getInputGrid();
const TableManager table ( deck );
const Eclipse3DProperties eclipseProperties ( deck , table, grid);
const Opm::Runspec runspec (deck);
const Schedule sched(deck, grid, eclipseProperties, runspec, parseContext );
const Schedule sched(deck, grid, eclipseProperties, runspec);
const auto& nodes = sched.getGroupTree(2);
@ -122,16 +119,15 @@ BOOST_AUTO_TEST_CASE(ConstructGroupFromGroup) {
BOOST_AUTO_TEST_CASE(EfficiencyFactor) {
Parser parser;
ParseContext parseContext;
std::string scheduleFile("wells_group.data");
Deck deck = parser.parseFile(scheduleFile, parseContext);
EclipseState eclipseState(deck , parseContext);
Deck deck = parser.parseFile(scheduleFile);
EclipseState eclipseState(deck);
PhaseUsage pu = phaseUsageFromDeck(eclipseState);
const auto& grid = eclipseState.getInputGrid();
const TableManager table ( deck );
const Eclipse3DProperties eclipseProperties ( deck , table, grid);
const Opm::Runspec runspec (deck);
const Schedule sched(deck, grid, eclipseProperties, runspec, parseContext );
const Schedule sched(deck, grid, eclipseProperties, runspec);
const auto& nodes = sched.getGroupTree(2);

View File

@ -25,7 +25,6 @@
#include <boost/test/unit_test.hpp>
#include <opm/parser/eclipse/Parser/Parser.hpp>
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
#include <opm/parser/eclipse/EclipseState/Tables/TableManager.hpp>
@ -176,16 +175,15 @@ BOOST_AUTO_TEST_CASE(New_Constructor_Works) {
const std::string filename = "wells_manager_data.data";
Opm::Parser parser;
Opm::ParseContext parseContext;
Opm::Deck deck = parser.parseFile(filename, parseContext);
Opm::Deck deck = parser.parseFile(filename);
Opm::EclipseState eclipseState(deck, parseContext);
Opm::EclipseState eclipseState(deck);
Opm::GridManager vanguard(eclipseState.getInputGrid());
const auto& grid = eclipseState.getInputGrid();
const Opm::TableManager table ( deck );
const Opm::Eclipse3DProperties eclipseProperties ( deck , table, grid);
const Opm::Runspec runspec (deck);
const Opm::Schedule sched(deck, grid, eclipseProperties, runspec, parseContext );
const Opm::Schedule sched(deck, grid, eclipseProperties, runspec);
{
@ -218,16 +216,15 @@ BOOST_AUTO_TEST_CASE(New_Constructor_Works) {
BOOST_AUTO_TEST_CASE(WellsEqual) {
const std::string filename = "wells_manager_data.data";
Opm::ParseContext parseContext;
Opm::Parser parser;
Opm::Deck deck(parser.parseFile(filename, parseContext));
Opm::EclipseState eclipseState(deck, parseContext);
Opm::Deck deck(parser.parseFile(filename));
Opm::EclipseState eclipseState(deck);
Opm::GridManager vanguard(eclipseState.getInputGrid());
const auto& grid = eclipseState.getInputGrid();
const Opm::TableManager table ( deck );
const Opm::Eclipse3DProperties eclipseProperties ( deck , table, grid);
const Opm::Runspec runspec (deck);
const Opm::Schedule sched(deck, grid, eclipseProperties, runspec, parseContext );
const Opm::Schedule sched(deck, grid, eclipseProperties, runspec);
Opm::WellsManager wellsManager0(eclipseState, sched, 0, *vanguard.c_grid());
@ -239,16 +236,15 @@ BOOST_AUTO_TEST_CASE(WellsEqual) {
BOOST_AUTO_TEST_CASE(ControlsEqual) {
const std::string filename = "wells_manager_data.data";
Opm::ParseContext parseContext;
Opm::Parser parser;
Opm::Deck deck(parser.parseFile(filename, parseContext));
Opm::EclipseState eclipseState(deck, parseContext);
Opm::Deck deck(parser.parseFile(filename));
Opm::EclipseState eclipseState(deck);
Opm::GridManager vanguard(eclipseState.getInputGrid());
const auto& grid = eclipseState.getInputGrid();
const Opm::TableManager table ( deck );
const Opm::Eclipse3DProperties eclipseProperties ( deck , table, grid);
const Opm::Runspec runspec (deck);
const Opm::Schedule sched(deck, grid, eclipseProperties, runspec, parseContext );
const Opm::Schedule sched(deck, grid, eclipseProperties, runspec);
@ -268,16 +264,15 @@ BOOST_AUTO_TEST_CASE(ControlsEqual) {
BOOST_AUTO_TEST_CASE(WellShutOK) {
const std::string filename = "wells_manager_data.data";
Opm::ParseContext parseContext;
Opm::Parser parser;
Opm::Deck deck(parser.parseFile(filename, parseContext));
Opm::EclipseState eclipseState(deck, parseContext);
Opm::Deck deck(parser.parseFile(filename));
Opm::EclipseState eclipseState(deck);
Opm::GridManager vanguard(eclipseState.getInputGrid());
const auto& grid = eclipseState.getInputGrid();
const Opm::TableManager table ( deck );
const Opm::Eclipse3DProperties eclipseProperties ( deck , table, grid);
const Opm::Runspec runspec (deck);
const Opm::Schedule sched(deck, grid, eclipseProperties, runspec, parseContext );
const Opm::Schedule sched(deck, grid, eclipseProperties, runspec);
Opm::WellsManager wellsManager2(eclipseState, sched, 2, *vanguard.c_grid());
@ -290,16 +285,15 @@ BOOST_AUTO_TEST_CASE(WellShutOK) {
BOOST_AUTO_TEST_CASE(WellSTOPOK) {
const std::string filename = "wells_manager_data_wellSTOP.data";
Opm::ParseContext parseContext;
Opm::Parser parser;
Opm::Deck deck(parser.parseFile(filename, parseContext));
Opm::EclipseState eclipseState(deck, parseContext);
Opm::Deck deck(parser.parseFile(filename));
Opm::EclipseState eclipseState(deck);
Opm::GridManager vanguard(eclipseState.getInputGrid());
const auto& grid = eclipseState.getInputGrid();
const Opm::TableManager table ( deck );
const Opm::Eclipse3DProperties eclipseProperties ( deck , table, grid);
const Opm::Runspec runspec (deck);
const Opm::Schedule sched(deck, grid, eclipseProperties, runspec, parseContext );
const Opm::Schedule sched(deck, grid, eclipseProperties, runspec);