From b3344a7b99e4706f0b28bbabf0b3b5d65fc0225a Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Fri, 11 Jan 2019 08:30:05 +0100 Subject: [PATCH 1/4] All objects which require ParseContext / ErrorGuard are created in flow --- flow/flow.cpp | 52 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 34 insertions(+), 18 deletions(-) diff --git a/flow/flow.cpp b/flow/flow.cpp index 4db369aa3..52b260ce3 100644 --- a/flow/flow.cpp +++ b/flow/flow.cpp @@ -44,6 +44,9 @@ #include #include #include +#include +#include + #if HAVE_DUNE_FEM #include @@ -171,26 +174,39 @@ int main(int argc, char** argv) std::cout << "Reading deck file '" << deckFilename << "'\n"; std::cout.flush(); } - Opm::Parser parser; - typedef std::pair ParseModePair; - typedef std::vector ParseModePairs; - ParseModePairs tmp; - tmp.push_back(ParseModePair(Opm::ParseContext::PARSE_RANDOM_SLASH, Opm::InputError::IGNORE)); - tmp.push_back(ParseModePair(Opm::ParseContext::PARSE_MISSING_DIMS_KEYWORD, Opm::InputError::WARN)); - 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 deck; + std::shared_ptr eclipseState; + std::shared_ptr schedule; + std::shared_ptr summaryConfig; + { + Opm::Parser parser; + Opm::ParseContext parseContext; + Opm::ErrorGuard errorGuard; - std::shared_ptr deck = std::make_shared< Opm::Deck >( parser.parseFile(deckFilename , parseContext, errorGuard) ); - if ( outputCout ) { - Opm::checkDeck(*deck, parser); - Opm::MissingFeatures::checkKeywords(*deck); + 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); + + + deck.reset( new Opm::Deck( parser.parseFile(deckFilename , parseContext, errorGuard))); + if ( outputCout ) { + Opm::checkDeck(*deck, parser); + Opm::MissingFeatures::checkKeywords(*deck); + } + + eclipseState.reset( new Opm::EclipseState(*deck, parseContext, errorGuard )); + schedule.reset(new Opm::Schedule(*deck, *eclipseState, parseContext, errorGuard)); + summaryConfig.reset( new Opm::SummaryConfig(*deck, *schedule, eclipseState->getTableManager(), parseContext, errorGuard)); + + if (errorGuard) { + errorGuard.dump(); + errorGuard.clear(); + + throw std::runtime_error("Unrecoverable errors were encountered while loading input."); + } } - Opm::Runspec runspec( *deck ); - const auto& phases = runspec.phases(); - - std::shared_ptr eclipseState = std::make_shared< Opm::EclipseState > ( *deck, parseContext, errorGuard ); + const auto& phases = Opm::Runspec(*deck).phases(); // run the actual simulator // From eedbafb8051de4426c042719ee9f71ddae98d799 Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Fri, 11 Jan 2019 08:33:44 +0100 Subject: [PATCH 2/4] Call Ewoms::setExternalSchedule() and Ewoms::setExternalSummaryConfig() --- flow/flow.cpp | 14 +++++++------- flow/flow_ebos_blackoil.cpp | 4 +++- flow/flow_ebos_blackoil.hpp | 5 +++-- flow/flow_ebos_energy.cpp | 4 +++- flow/flow_ebos_energy.hpp | 4 +++- flow/flow_ebos_gasoil.cpp | 4 +++- flow/flow_ebos_gasoil.hpp | 4 +++- flow/flow_ebos_oilwater.cpp | 4 +++- flow/flow_ebos_oilwater.hpp | 4 +++- flow/flow_ebos_oilwater_polymer.cpp | 4 +++- flow/flow_ebos_oilwater_polymer.hpp | 4 +++- flow/flow_ebos_polymer.cpp | 4 +++- flow/flow_ebos_polymer.hpp | 4 +++- flow/flow_ebos_solvent.cpp | 4 +++- flow/flow_ebos_solvent.hpp | 4 +++- 15 files changed, 49 insertions(+), 22 deletions(-) diff --git a/flow/flow.cpp b/flow/flow.cpp index 52b260ce3..1803bd4bc 100644 --- a/flow/flow.cpp +++ b/flow/flow.cpp @@ -218,13 +218,13 @@ int main(int argc, char** argv) // oil-gas if (phases.active( Opm::Phase::GAS )) { - Opm::flowEbosGasOilSetDeck(*deck, *eclipseState); + Opm::flowEbosGasOilSetDeck(*deck, *eclipseState, *schedule, *summaryConfig); return Opm::flowEbosGasOilMain(argc, argv); } // oil-water else if ( phases.active( Opm::Phase::WATER ) ) { - Opm::flowEbosOilWaterSetDeck(*deck, *eclipseState); + Opm::flowEbosOilWaterSetDeck(*deck, *eclipseState, *schedule, *summaryConfig); return Opm::flowEbosOilWaterMain(argc, argv); } else { @@ -252,26 +252,26 @@ int main(int argc, char** argv) } if ( phases.size() == 3 ) { // oil water polymer case - Opm::flowEbosOilWaterPolymerSetDeck(*deck, *eclipseState); + Opm::flowEbosOilWaterPolymerSetDeck(*deck, *eclipseState, *schedule, *summaryConfig); return Opm::flowEbosOilWaterPolymerMain(argc, argv); } else { - Opm::flowEbosPolymerSetDeck(*deck, *eclipseState); + Opm::flowEbosPolymerSetDeck(*deck, *eclipseState, *schedule, *summaryConfig); return Opm::flowEbosPolymerMain(argc, argv); } } // Solvent case else if ( phases.active( Opm::Phase::SOLVENT ) ) { - Opm::flowEbosSolventSetDeck(*deck, *eclipseState); + Opm::flowEbosSolventSetDeck(*deck, *eclipseState, *schedule, *summaryConfig); return Opm::flowEbosSolventMain(argc, argv); } // Energy case else if (eclipseState->getSimulationConfig().isThermal()) { - Opm::flowEbosEnergySetDeck(*deck, *eclipseState); + Opm::flowEbosEnergySetDeck(*deck, *eclipseState, *schedule, *summaryConfig); return Opm::flowEbosEnergyMain(argc, argv); } // Blackoil case else if( phases.size() == 3 ) { - Opm::flowEbosBlackoilSetDeck(*deck, *eclipseState); + Opm::flowEbosBlackoilSetDeck(*deck, *eclipseState, *schedule, *summaryConfig); return Opm::flowEbosBlackoilMain(argc, argv); } else diff --git a/flow/flow_ebos_blackoil.cpp b/flow/flow_ebos_blackoil.cpp index 1fbf2fc8e..d4ff3f996 100644 --- a/flow/flow_ebos_blackoil.cpp +++ b/flow/flow_ebos_blackoil.cpp @@ -34,12 +34,14 @@ namespace Opm { -void flowEbosBlackoilSetDeck(Deck &deck, EclipseState& eclState) +void flowEbosBlackoilSetDeck(Deck &deck, EclipseState& eclState, Schedule& schedule, SummaryConfig& summaryConfig) { typedef TTAG(EclFlowProblem) TypeTag; typedef GET_PROP_TYPE(TypeTag, Vanguard) Vanguard; Vanguard::setExternalDeck(&deck, &eclState); + Vanguard::setExternalSchedule(&schedule); + Vanguard::setExternalSummaryConfig(&summaryConfig); } // ----------------- Main program ----------------- diff --git a/flow/flow_ebos_blackoil.hpp b/flow/flow_ebos_blackoil.hpp index 69ace3071..78199fe45 100644 --- a/flow/flow_ebos_blackoil.hpp +++ b/flow/flow_ebos_blackoil.hpp @@ -19,10 +19,11 @@ #include #include - +#include +#include namespace Opm { -void flowEbosBlackoilSetDeck(Deck &deck, EclipseState& eclState); +void flowEbosBlackoilSetDeck(Deck &deck, EclipseState& eclState, Schedule& schedule, SummaryConfig& summaryConfig); int flowEbosBlackoilMain(int argc, char** argv); } diff --git a/flow/flow_ebos_energy.cpp b/flow/flow_ebos_energy.cpp index bc2b79da6..ec535186b 100644 --- a/flow/flow_ebos_energy.cpp +++ b/flow/flow_ebos_energy.cpp @@ -36,12 +36,14 @@ SET_BOOL_PROP(EclFlowEnergyProblem, EnableEnergy, true); }} namespace Opm { -void flowEbosEnergySetDeck(Deck &deck, EclipseState& eclState) +void flowEbosEnergySetDeck(Deck &deck, EclipseState& eclState, Schedule& schedule, SummaryConfig& summaryConfig) { typedef TTAG(EclFlowEnergyProblem) TypeTag; typedef GET_PROP_TYPE(TypeTag, Vanguard) Vanguard; Vanguard::setExternalDeck(&deck, &eclState); + Vanguard::setExternalSchedule(&schedule); + Vanguard::setExternalSummaryConfig(&summaryConfig); } // ----------------- Main program ----------------- diff --git a/flow/flow_ebos_energy.hpp b/flow/flow_ebos_energy.hpp index 32f41619d..50f95e08b 100644 --- a/flow/flow_ebos_energy.hpp +++ b/flow/flow_ebos_energy.hpp @@ -19,9 +19,11 @@ #include #include +#include +#include namespace Opm { -void flowEbosEnergySetDeck(Deck &deck, EclipseState& eclState); +void flowEbosEnergySetDeck(Deck &deck, EclipseState& eclState, Schedule& schedule, SummaryConfig& summaryConfig); int flowEbosEnergyMain(int argc, char** argv); } diff --git a/flow/flow_ebos_gasoil.cpp b/flow/flow_ebos_gasoil.cpp index 3484a5a7f..512e0a82a 100644 --- a/flow/flow_ebos_gasoil.cpp +++ b/flow/flow_ebos_gasoil.cpp @@ -58,12 +58,14 @@ public: }} namespace Opm { -void flowEbosGasOilSetDeck(Deck &deck, EclipseState& eclState) +void flowEbosGasOilSetDeck(Deck &deck, EclipseState& eclState, Schedule& schedule, SummaryConfig& summaryConfig) { typedef TTAG(EclFlowGasOilProblem) TypeTag; typedef GET_PROP_TYPE(TypeTag, Vanguard) Vanguard; Vanguard::setExternalDeck(&deck, &eclState); + Vanguard::setExternalSchedule(&schedule); + Vanguard::setExternalSummaryConfig(&summaryConfig); } diff --git a/flow/flow_ebos_gasoil.hpp b/flow/flow_ebos_gasoil.hpp index 53916b902..773173e2c 100644 --- a/flow/flow_ebos_gasoil.hpp +++ b/flow/flow_ebos_gasoil.hpp @@ -19,9 +19,11 @@ #include #include +#include +#include namespace Opm { -void flowEbosGasOilSetDeck(Deck &deck, EclipseState& eclState); +void flowEbosGasOilSetDeck(Deck &deck, EclipseState& eclState, Schedule& schedule, SummaryConfig& summaryConfig); int flowEbosGasOilMain(int argc, char** argv); } diff --git a/flow/flow_ebos_oilwater.cpp b/flow/flow_ebos_oilwater.cpp index a69d996b4..025e8e393 100644 --- a/flow/flow_ebos_oilwater.cpp +++ b/flow/flow_ebos_oilwater.cpp @@ -58,12 +58,14 @@ public: }} namespace Opm { -void flowEbosOilWaterSetDeck(Deck &deck, EclipseState& eclState) +void flowEbosOilWaterSetDeck(Deck &deck, EclipseState& eclState, Schedule& schedule, SummaryConfig& summaryConfig) { typedef TTAG(EclFlowOilWaterProblem) TypeTag; typedef GET_PROP_TYPE(TypeTag, Vanguard) Vanguard; Vanguard::setExternalDeck(&deck, &eclState); + Vanguard::setExternalSchedule(&schedule); + Vanguard::setExternalSummaryConfig(&summaryConfig); } // ----------------- Main program ----------------- diff --git a/flow/flow_ebos_oilwater.hpp b/flow/flow_ebos_oilwater.hpp index c1eb0ff18..61f887c90 100644 --- a/flow/flow_ebos_oilwater.hpp +++ b/flow/flow_ebos_oilwater.hpp @@ -19,9 +19,11 @@ #include #include +#include +#include namespace Opm { -void flowEbosOilWaterSetDeck(Deck &deck, EclipseState& eclState); +void flowEbosOilWaterSetDeck(Deck &deck, EclipseState& eclState, Schedule& schedule, SummaryConfig& summaryConfig); int flowEbosOilWaterMain(int argc, char** argv); } diff --git a/flow/flow_ebos_oilwater_polymer.cpp b/flow/flow_ebos_oilwater_polymer.cpp index dd465db8b..ae8d1c1c0 100644 --- a/flow/flow_ebos_oilwater_polymer.cpp +++ b/flow/flow_ebos_oilwater_polymer.cpp @@ -59,12 +59,14 @@ public: }} namespace Opm { -void flowEbosOilWaterPolymerSetDeck(Deck& deck, EclipseState& eclState) +void flowEbosOilWaterPolymerSetDeck(Deck& deck, EclipseState& eclState, Schedule& schedule, SummaryConfig& summaryConfig) { typedef TTAG(EclFlowOilWaterPolymerProblem) TypeTag; typedef GET_PROP_TYPE(TypeTag, Vanguard) Vanguard; Vanguard::setExternalDeck(&deck, &eclState); + Vanguard::setExternalSchedule(&schedule); + Vanguard::setExternalSummaryConfig(&summaryConfig); } // ----------------- Main program ----------------- diff --git a/flow/flow_ebos_oilwater_polymer.hpp b/flow/flow_ebos_oilwater_polymer.hpp index 778f41da0..9867798a2 100644 --- a/flow/flow_ebos_oilwater_polymer.hpp +++ b/flow/flow_ebos_oilwater_polymer.hpp @@ -19,9 +19,11 @@ #include #include +#include +#include namespace Opm { -void flowEbosOilWaterPolymerSetDeck(Deck& deck, EclipseState& eclState); +void flowEbosOilWaterPolymerSetDeck(Deck& deck, EclipseState& eclState, Schedule& schedule, SummaryConfig& summaryConfig); int flowEbosOilWaterPolymerMain(int argc, char** argv); } diff --git a/flow/flow_ebos_polymer.cpp b/flow/flow_ebos_polymer.cpp index 17fa846b8..2a2acc685 100644 --- a/flow/flow_ebos_polymer.cpp +++ b/flow/flow_ebos_polymer.cpp @@ -36,12 +36,14 @@ SET_BOOL_PROP(EclFlowPolymerProblem, EnablePolymer, true); }} namespace Opm { -void flowEbosPolymerSetDeck(Deck &deck, EclipseState& eclState) +void flowEbosPolymerSetDeck(Deck &deck, EclipseState& eclState, Schedule& schedule, SummaryConfig& summaryConfig) { typedef TTAG(EclFlowPolymerProblem) TypeTag; typedef GET_PROP_TYPE(TypeTag, Vanguard) Vanguard; Vanguard::setExternalDeck(&deck, &eclState); + Vanguard::setExternalSchedule(&schedule); + Vanguard::setExternalSummaryConfig(&summaryConfig); } // ----------------- Main program ----------------- diff --git a/flow/flow_ebos_polymer.hpp b/flow/flow_ebos_polymer.hpp index 7eb81939d..ee1696904 100644 --- a/flow/flow_ebos_polymer.hpp +++ b/flow/flow_ebos_polymer.hpp @@ -19,9 +19,11 @@ #include #include +#include +#include namespace Opm { -void flowEbosPolymerSetDeck(Deck &deck, EclipseState& eclState); +void flowEbosPolymerSetDeck(Deck &deck, EclipseState& eclState, Schedule& schedule, SummaryConfig& summaryConfig); int flowEbosPolymerMain(int argc, char** argv); } diff --git a/flow/flow_ebos_solvent.cpp b/flow/flow_ebos_solvent.cpp index a9bdb8cd3..29e6f966c 100644 --- a/flow/flow_ebos_solvent.cpp +++ b/flow/flow_ebos_solvent.cpp @@ -36,12 +36,14 @@ SET_BOOL_PROP(EclFlowSolventProblem, EnableSolvent, true); }} namespace Opm { -void flowEbosSolventSetDeck(Deck &deck, EclipseState& eclState) +void flowEbosSolventSetDeck(Deck &deck, EclipseState& eclState, Schedule& schedule, SummaryConfig& summaryConfig) { typedef TTAG(EclFlowSolventProblem) TypeTag; typedef GET_PROP_TYPE(TypeTag, Vanguard) Vanguard; Vanguard::setExternalDeck(&deck, &eclState); + Vanguard::setExternalSchedule(&schedule); + Vanguard::setExternalSummaryConfig(&summaryConfig); } diff --git a/flow/flow_ebos_solvent.hpp b/flow/flow_ebos_solvent.hpp index 45c562e2c..ae188232d 100644 --- a/flow/flow_ebos_solvent.hpp +++ b/flow/flow_ebos_solvent.hpp @@ -19,10 +19,12 @@ #include #include +#include +#include namespace Opm { -void flowEbosSolventSetDeck(Deck &deck, EclipseState& eclState); +void flowEbosSolventSetDeck(Deck &deck, EclipseState& eclState, Schedule& schedule, SummaryConfig& summaryConfig); int flowEbosSolventMain(int argc, char** argv); } From 71d4162a7e9027ead092d1974ec19ab2ffb8cef8 Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Fri, 11 Jan 2019 15:39:48 +0100 Subject: [PATCH 3/4] Add strict parsing option to flow --- flow/flow.cpp | 13 ++++++++----- opm/autodiff/SimulatorFullyImplicitBlackoilEbos.hpp | 4 ++++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/flow/flow.cpp b/flow/flow.cpp index 1803bd4bc..efa6f5bdb 100644 --- a/flow/flow.cpp +++ b/flow/flow.cpp @@ -183,11 +183,14 @@ int main(int argc, char** argv) Opm::ParseContext parseContext; Opm::ErrorGuard errorGuard; - 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); - + if (EWOMS_GET_PARAM(PreTypeTag, bool, EclStrictParsing)) + parseContext.update( Opm::InputError::DELAYED_EXIT1); + else { + 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); + } deck.reset( new Opm::Deck( parser.parseFile(deckFilename , parseContext, errorGuard))); if ( outputCout ) { diff --git a/opm/autodiff/SimulatorFullyImplicitBlackoilEbos.hpp b/opm/autodiff/SimulatorFullyImplicitBlackoilEbos.hpp index 07b5aecdd..c9dd4093b 100644 --- a/opm/autodiff/SimulatorFullyImplicitBlackoilEbos.hpp +++ b/opm/autodiff/SimulatorFullyImplicitBlackoilEbos.hpp @@ -40,10 +40,12 @@ BEGIN_PROPERTIES NEW_PROP_TAG(EnableTerminalOutput); NEW_PROP_TAG(EnableAdaptiveTimeStepping); NEW_PROP_TAG(EnableTuning); +NEW_PROP_TAG(EclStrictParsing); SET_BOOL_PROP(EclFlowProblem, EnableTerminalOutput, true); SET_BOOL_PROP(EclFlowProblem, EnableAdaptiveTimeStepping, true); SET_BOOL_PROP(EclFlowProblem, EnableTuning, false); +SET_BOOL_PROP(EclFlowProblem, EclStrictParsing, false); END_PROPERTIES @@ -124,6 +126,8 @@ public: "Use adaptive time stepping between report steps"); EWOMS_REGISTER_PARAM(TypeTag, bool, EnableTuning, "Honor some aspects of the TUNING keyword."); + EWOMS_REGISTER_PARAM(TypeTag, bool, EclStrictParsing, + "Handle input in strict mode - will terminate if any errors are found"); } /// Run the simulation. From 89a6afdba1a9bda768b5dacbeba1fc24264582cc Mon Sep 17 00:00:00 2001 From: Andreas Lauser Date: Mon, 14 Jan 2019 09:59:14 +0100 Subject: [PATCH 4/4] do not try to re-register the EclStrictParsing parameter this is already done by the eWoms side and for consistency reasons, parameters may only be registered once. --- opm/autodiff/SimulatorFullyImplicitBlackoilEbos.hpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/opm/autodiff/SimulatorFullyImplicitBlackoilEbos.hpp b/opm/autodiff/SimulatorFullyImplicitBlackoilEbos.hpp index c9dd4093b..07b5aecdd 100644 --- a/opm/autodiff/SimulatorFullyImplicitBlackoilEbos.hpp +++ b/opm/autodiff/SimulatorFullyImplicitBlackoilEbos.hpp @@ -40,12 +40,10 @@ BEGIN_PROPERTIES NEW_PROP_TAG(EnableTerminalOutput); NEW_PROP_TAG(EnableAdaptiveTimeStepping); NEW_PROP_TAG(EnableTuning); -NEW_PROP_TAG(EclStrictParsing); SET_BOOL_PROP(EclFlowProblem, EnableTerminalOutput, true); SET_BOOL_PROP(EclFlowProblem, EnableAdaptiveTimeStepping, true); SET_BOOL_PROP(EclFlowProblem, EnableTuning, false); -SET_BOOL_PROP(EclFlowProblem, EclStrictParsing, false); END_PROPERTIES @@ -126,8 +124,6 @@ public: "Use adaptive time stepping between report steps"); EWOMS_REGISTER_PARAM(TypeTag, bool, EnableTuning, "Honor some aspects of the TUNING keyword."); - EWOMS_REGISTER_PARAM(TypeTag, bool, EclStrictParsing, - "Handle input in strict mode - will terminate if any errors are found"); } /// Run the simulation.