diff --git a/examples/sim_2p_comp_reorder.cpp b/examples/sim_2p_comp_reorder.cpp index 6ad7709cf..b22475b1e 100644 --- a/examples/sim_2p_comp_reorder.cpp +++ b/examples/sim_2p_comp_reorder.cpp @@ -94,7 +94,6 @@ try Parser parser; - std::shared_ptr< Deck > deck; // bool check_well_controls = false; // int max_well_control_iterations = 0; @@ -102,8 +101,8 @@ try if (use_deck) { ParseContext parseContext; std::string deck_filename = param.get("deck_filename"); - *deck = parser.parseFile(deck_filename , parseContext); - eclipseState.reset(new EclipseState(*deck, parseContext)); + auto deck = parser.parseFile(deck_filename , parseContext); + eclipseState.reset(new EclipseState(deck, parseContext)); // Grid init grid.reset(new GridManager(eclipseState->getInputGrid())); @@ -111,18 +110,18 @@ try const UnstructuredGrid& ug_grid = *(grid->c_grid()); state.reset( new BlackoilState( UgGridHelpers::numCells( ug_grid ) , UgGridHelpers::numFaces( ug_grid ) ,2)); // Rock and fluid init - props.reset(new BlackoilPropertiesFromDeck(*deck, *eclipseState, ug_grid, param)); + props.reset(new BlackoilPropertiesFromDeck(deck, *eclipseState, ug_grid, param)); // check_well_controls = param.getDefault("check_well_controls", false); // max_well_control_iterations = param.getDefault("max_well_control_iterations", 10); // Rock compressibility. - rock_comp.reset(new RockCompressibility(*deck, *eclipseState)); + rock_comp.reset(new RockCompressibility(deck, *eclipseState)); // Gravity. - gravity[2] = deck->hasKeyword("NOGRAV") ? 0.0 : unit::gravity; + gravity[2] = deck.hasKeyword("NOGRAV") ? 0.0 : unit::gravity; // Init state variables (saturation and pressure). if (param.has("init_saturation")) { initStateBasic(ug_grid, *props, param, gravity[2], *state); } else { - initStateFromDeck(ug_grid, *props, *deck, gravity[2], *state); + initStateFromDeck(ug_grid, *props, deck, gravity[2], *state); } initBlackoilSurfvol(ug_grid, *props, *state); } @@ -240,7 +239,7 @@ try int step = 0; SimulatorTimer simtimer; // Use timer for last epoch to obtain total time. - Opm::TimeMap timeMap(*deck); + const auto& timeMap = eclipseState->getSchedule().getTimeMap(); simtimer.init(timeMap); const double total_time = simtimer.totalTime(); for (size_t reportStepIdx = 0; reportStepIdx < timeMap.numTimesteps(); ++reportStepIdx) { diff --git a/examples/sim_2p_incomp.cpp b/examples/sim_2p_incomp.cpp index 9e72efb03..84835e21f 100644 --- a/examples/sim_2p_incomp.cpp +++ b/examples/sim_2p_incomp.cpp @@ -101,7 +101,6 @@ try bool use_deck = param.has("deck_filename"); std::shared_ptr< EclipseState > eclipseState; - std::shared_ptr< Deck > deck; std::unique_ptr grid; std::unique_ptr props; std::unique_ptr rock_comp; @@ -112,28 +111,29 @@ try if (use_deck) { Parser parser; ParseContext parseContext; + parseContext.update(ParseContext::PARSE_MISSING_DIMS_KEYWORD, InputError::WARN); std::string deck_filename = param.get("deck_filename"); - *deck = parser.parseFile(deck_filename , parseContext); - eclipseState.reset( new EclipseState(*deck, parseContext)); + auto deck = parser.parseFile(deck_filename , parseContext); + eclipseState.reset( new EclipseState(deck, parseContext)); // Grid init grid.reset(new GridManager(eclipseState->getInputGrid())); { const UnstructuredGrid& ug_grid = *(grid->c_grid()); // Rock and fluid init - props.reset(new IncompPropertiesFromDeck(*deck, *eclipseState, ug_grid)); + props.reset(new IncompPropertiesFromDeck(deck, *eclipseState, ug_grid)); state.reset( new TwophaseState( UgGridHelpers::numCells( ug_grid ) , UgGridHelpers::numFaces( ug_grid ))); // Rock compressibility. - rock_comp.reset(new RockCompressibility(*deck, *eclipseState)); + rock_comp.reset(new RockCompressibility(deck, *eclipseState)); // Gravity. - gravity[2] = deck->hasKeyword("NOGRAV") ? 0.0 : unit::gravity; + gravity[2] = deck.hasKeyword("NOGRAV") ? 0.0 : unit::gravity; // Init state variables (saturation and pressure). if (param.has("init_saturation")) { initStateBasic(ug_grid, *props, param, gravity[2], *state); } else { - initStateFromDeck(ug_grid, *props, *deck, gravity[2], *state); + initStateFromDeck(ug_grid, *props, deck, gravity[2], *state); } } } else { diff --git a/examples/sim_2p_incomp_ad.cpp b/examples/sim_2p_incomp_ad.cpp index c4cb0f0de..536624670 100644 --- a/examples/sim_2p_incomp_ad.cpp +++ b/examples/sim_2p_incomp_ad.cpp @@ -101,7 +101,6 @@ try // If we have a "deck_filename", grid and props will be read from that. bool use_deck = param.has("deck_filename"); Opm::Parser parser; - std::shared_ptr< Opm::Deck > deck; std::unique_ptr grid; std::unique_ptr props; std::unique_ptr rock_comp; @@ -114,8 +113,8 @@ try if (use_deck) { std::string deck_filename = param.get("deck_filename"); Opm::ParseContext parseContext; - *deck = parser.parseFile(deck_filename, parseContext); - eclipseState.reset(new EclipseState(*deck , parseContext)); + auto deck = parser.parseFile(deck_filename, parseContext); + eclipseState.reset(new EclipseState(deck , parseContext)); // Grid init grid.reset(new GridManager(eclipseState->getInputGrid())); @@ -123,20 +122,20 @@ try const UnstructuredGrid& ug_grid = *(grid->c_grid()); // Rock and fluid init - props.reset(new IncompPropertiesFromDeck(*deck, *eclipseState, ug_grid)); + props.reset(new IncompPropertiesFromDeck(deck, *eclipseState, ug_grid)); // check_well_controls = param.getDefault("check_well_controls", false); // max_well_control_iterations = param.getDefault("max_well_control_iterations", 10); state.reset( new TwophaseState( UgGridHelpers::numCells( ug_grid ) , UgGridHelpers::numFaces( ug_grid ))); // Rock compressibility. - rock_comp.reset(new RockCompressibility(*deck, *eclipseState)); + rock_comp.reset(new RockCompressibility(deck, *eclipseState)); // Gravity. - gravity[2] = deck->hasKeyword("NOGRAV") ? 0.0 : unit::gravity; + gravity[2] = deck.hasKeyword("NOGRAV") ? 0.0 : unit::gravity; // Init state variables (saturation and pressure). if (param.has("init_saturation")) { initStateBasic(ug_grid, *props, param, gravity[2], *state); } else { - initStateFromDeck(ug_grid, *props, *deck, gravity[2], *state); + initStateFromDeck(ug_grid, *props, deck, gravity[2], *state); } } } else { @@ -254,7 +253,7 @@ try } else { // With a deck, we may have more report steps etc. WellState well_state; - Opm::TimeMap timeMap(*deck); + const auto& timeMap = eclipseState->getSchedule().getTimeMap(); SimulatorTimer simtimer; for (size_t reportStepIdx = 0; reportStepIdx < timeMap.numTimesteps(); ++reportStepIdx) { // Report on start of report step. diff --git a/examples/sim_poly2p_incomp_reorder.cpp b/examples/sim_poly2p_incomp_reorder.cpp index e565e760a..d1bcf2083 100644 --- a/examples/sim_poly2p_incomp_reorder.cpp +++ b/examples/sim_poly2p_incomp_reorder.cpp @@ -87,7 +87,7 @@ try // If we have a "deck_filename", grid and props will be read from that. bool use_deck = param.has("deck_filename"); - std::shared_ptr< Deck > deck; + Deck deck; boost::scoped_ptr grid; boost::scoped_ptr props; boost::scoped_ptr rock_comp; @@ -101,32 +101,32 @@ try std::string deck_filename = param.get("deck_filename"); Opm::ParseContext parseContext({{ ParseContext::PARSE_RANDOM_SLASH , InputError::IGNORE }}); Parser parser; - *deck = parser.parseFile(deck_filename , parseContext); + deck = parser.parseFile(deck_filename , parseContext); - eclipseState.reset(new Opm::EclipseState(*deck , parseContext)); + eclipseState.reset(new Opm::EclipseState(deck , parseContext)); // Grid init grid.reset(new GridManager(eclipseState->getInputGrid())); { const UnstructuredGrid& ug_grid = *(grid->c_grid()); // Rock and fluid init - props.reset(new IncompPropertiesFromDeck(*deck, *eclipseState, ug_grid )); + props.reset(new IncompPropertiesFromDeck(deck, *eclipseState, ug_grid )); // check_well_controls = param.getDefault("check_well_controls", false); // max_well_control_iterations = param.getDefault("max_well_control_iterations", 10); state.reset( new PolymerState( UgGridHelpers::numCells( ug_grid ) , UgGridHelpers::numFaces( ug_grid ), 2)); // Rock compressibility. - rock_comp.reset(new RockCompressibility(*deck, *eclipseState)); + rock_comp.reset(new RockCompressibility(deck, *eclipseState)); // Gravity. - gravity[2] = deck->hasKeyword("NOGRAV") ? 0.0 : unit::gravity; + gravity[2] = deck.hasKeyword("NOGRAV") ? 0.0 : unit::gravity; // Init state variables (saturation and pressure). if (param.has("init_saturation")) { initStateBasic(ug_grid, *props, param, gravity[2], *state); } else { - initStateFromDeck(ug_grid, *props, *deck, gravity[2], *state); + initStateFromDeck(ug_grid, *props, deck, gravity[2], *state); } // Init polymer properties. - poly_props.readFromDeck(*deck, *eclipseState); + poly_props.readFromDeck(deck, *eclipseState); } } else { // Grid init. @@ -299,12 +299,12 @@ try WellState well_state; int step = 0; - TimeMap timeMap(*deck); + const auto& timeMap = eclipseState->getSchedule().getTimeMap(); SimulatorTimer simtimer; simtimer.init(timeMap); // Check for WPOLYMER presence in last epoch to decide // polymer injection control type. - const bool use_wpolymer = deck->hasKeyword("WPOLYMER"); + const bool use_wpolymer = deck.hasKeyword("WPOLYMER"); if (use_wpolymer) { if (param.has("poly_start_days")) { OPM_MESSAGE("Warning: Using WPOLYMER to control injection since it was found in deck. " diff --git a/examples/sim_poly_fi2p_comp_ad.cpp b/examples/sim_poly_fi2p_comp_ad.cpp index 2be72276d..7aed7b172 100644 --- a/examples/sim_poly_fi2p_comp_ad.cpp +++ b/examples/sim_poly_fi2p_comp_ad.cpp @@ -151,12 +151,12 @@ try Opm::OpmLog::addBackend( "COUNTER" , counterLog ); } - std::shared_ptr< Deck > deck; + Deck deck; std::shared_ptr eclipseState; try { - *deck = parser.parseFile(deck_filename , parseContext); - Opm::checkDeck(*deck, parser); - eclipseState.reset(new Opm::EclipseState(*deck , parseContext)); + deck = parser.parseFile(deck_filename , parseContext); + Opm::checkDeck(deck, parser); + eclipseState.reset(new Opm::EclipseState(deck , parseContext)); } catch (const std::invalid_argument& e) { std::cerr << "Failed to create valid ECLIPSESTATE object. See logfile: " << logFile << std::endl; @@ -173,7 +173,7 @@ try grid.reset(new GridManager(eclipseState->getInputGrid())); } auto &cGrid = *grid->c_grid(); - const PhaseUsage pu = Opm::phaseUsageFromDeck(*deck); + const PhaseUsage pu = Opm::phaseUsageFromDeck(deck); // Rock and fluid init @@ -182,31 +182,31 @@ try typedef BlackoilPropsAdFromDeck::MaterialLawManager MaterialLawManager; auto materialLawManager = std::make_shared(); - materialLawManager->initFromDeck(*deck, *eclipseState, compressedToCartesianIdx); + materialLawManager->initFromDeck(deck, *eclipseState, compressedToCartesianIdx); - props.reset(new BlackoilPropertiesFromDeck( *deck, *eclipseState, materialLawManager, + props.reset(new BlackoilPropertiesFromDeck( deck, *eclipseState, materialLawManager, Opm::UgGridHelpers::numCells(cGrid), Opm::UgGridHelpers::globalCell(cGrid), Opm::UgGridHelpers::cartDims(cGrid), param)); state.reset( new PolymerBlackoilState( Opm::UgGridHelpers::numCells(cGrid), Opm::UgGridHelpers::numFaces(cGrid), 2)); - new_props.reset(new BlackoilPropsAdFromDeck(*deck, *eclipseState, materialLawManager, cGrid)); - PolymerProperties polymer_props(*deck, *eclipseState); + new_props.reset(new BlackoilPropsAdFromDeck(deck, *eclipseState, materialLawManager, cGrid)); + PolymerProperties polymer_props(deck, *eclipseState); PolymerPropsAd polymer_props_ad(polymer_props); // Rock compressibility. - rock_comp.reset(new RockCompressibility(*deck, *eclipseState)); + rock_comp.reset(new RockCompressibility(deck, *eclipseState)); // Gravity. - gravity[2] = deck->hasKeyword("NOGRAV") ? 0.0 : unit::gravity; + gravity[2] = deck.hasKeyword("NOGRAV") ? 0.0 : unit::gravity; // Init state variables (saturation and pressure). if (param.has("init_saturation")) { initStateBasic(*grid->c_grid(), *props, param, gravity[2], *state); initBlackoilSurfvol(*grid->c_grid(), *props, *state); } else { - initStateFromDeck(*grid->c_grid(), *props, *deck, gravity[2], *state); + initStateFromDeck(*grid->c_grid(), *props, deck, gravity[2], *state); } bool use_gravity = (gravity[0] != 0.0 || gravity[1] != 0.0 || gravity[2] != 0.0); @@ -229,7 +229,7 @@ try WellState well_state; // Check for WPOLYMER presence in last epoch to decide // polymer injection control type. - const bool use_wpolymer = deck->hasKeyword("WPOLYMER"); + const bool use_wpolymer = deck.hasKeyword("WPOLYMER"); if (use_wpolymer) { if (param.has("poly_start_days")) { OPM_MESSAGE("Warning: Using WPOLYMER to control injection since it was found in deck. " diff --git a/opm/polymer/fullyimplicit/SimulatorFullyImplicitCompressiblePolymer.hpp b/opm/polymer/fullyimplicit/SimulatorFullyImplicitCompressiblePolymer.hpp index af9755e1d..560760d7c 100644 --- a/opm/polymer/fullyimplicit/SimulatorFullyImplicitCompressiblePolymer.hpp +++ b/opm/polymer/fullyimplicit/SimulatorFullyImplicitCompressiblePolymer.hpp @@ -109,7 +109,7 @@ namespace Opm const RockCompressibility* rock_comp_props, std::shared_ptr eclipse_state, BlackoilOutputWriter& output_writer, - std::shared_ptr< const Deck > deck, + const Deck& deck, NewtonIterationBlackoilInterface& linsolver, const double* gravity); @@ -127,7 +127,7 @@ namespace Opm const WellState& well_state, DynamicListEconLimited& list_econ_limited) const; private: - std::shared_ptr< const Deck > deck_; + const Deck& deck_; const PolymerPropsAd& polymer_props_; }; diff --git a/opm/polymer/fullyimplicit/SimulatorFullyImplicitCompressiblePolymer_impl.hpp b/opm/polymer/fullyimplicit/SimulatorFullyImplicitCompressiblePolymer_impl.hpp index 890c848e9..025379ed7 100644 --- a/opm/polymer/fullyimplicit/SimulatorFullyImplicitCompressiblePolymer_impl.hpp +++ b/opm/polymer/fullyimplicit/SimulatorFullyImplicitCompressiblePolymer_impl.hpp @@ -34,7 +34,7 @@ SimulatorFullyImplicitCompressiblePolymer(const parameter::ParameterGroup& param const RockCompressibility* rock_comp_props, std::shared_ptr eclipse_state, BlackoilOutputWriter& output_writer, - std::shared_ptr< const Deck > deck, + const Deck& deck, NewtonIterationBlackoilInterface& linsolver, const double* gravity) : BaseType(param, @@ -82,7 +82,7 @@ handleAdditionalWellInflow(SimulatorTimer& timer, { // compute polymer inflow std::unique_ptr polymer_inflow_ptr; - if (deck_->hasKeyword("WPOLYMER")) { + if (deck_.hasKeyword("WPOLYMER")) { if (wells_manager.c_wells() == 0) { OPM_THROW(std::runtime_error, "Cannot control polymer injection via WPOLYMER without wells."); }