diff --git a/examples/opm_init_check.cpp b/examples/opm_init_check.cpp index 0a26b7f7f..34fd117d7 100644 --- a/examples/opm_init_check.cpp +++ b/examples/opm_init_check.cpp @@ -207,9 +207,9 @@ public: /*****************************************************************/ -void initOPMTrans(TransGraph& opmTrans, DeckConstPtr deck, std::shared_ptr eclipseState) { - std::shared_ptr grid = std::make_shared( *eclipseState->getInputGrid(), - eclipseState->get3DProperties().getDoubleGridProperty( "PORV" ).getData() ); +void initOPMTrans(TransGraph& opmTrans, const Deck& deck, const EclipseState& eclipseState) { + std::shared_ptr grid = std::make_shared( eclipseState.getInputGrid(), + eclipseState.get3DProperties().getDoubleGridProperty( "PORV" ).getData() ); const struct UnstructuredGrid * cGrid = grid->c_grid(); std::shared_ptr props; @@ -317,7 +317,7 @@ void initEclipseTrans(TransGraph& eclipseTrans , const ecl_grid_type * ecl_grid -void dump_transGraph( DeckConstPtr deck , std::shared_ptr eclipseState , const ecl_grid_type * ecl_grid , const ecl_file_type * ecl_init) { +void dump_transGraph( const Deck& deck , const EclipseState& eclipseState , const ecl_grid_type * ecl_grid , const ecl_file_type * ecl_init) { int nx = ecl_grid_get_nx( ecl_grid ); int ny = ecl_grid_get_ny( ecl_grid ); int nz = ecl_grid_get_nz( ecl_grid ); @@ -344,12 +344,12 @@ int main(int argc, char** argv) { std::string init_file = argv[2]; std::string grid_file = argv[3]; - ParserPtr parser(new Parser()); + Parser parser; ParseContext parseContext; std::cout << "Parsing input file ............: " << input_file << std::endl; - DeckConstPtr deck = parser->parseFile(input_file, parseContext); - std::shared_ptr state = std::make_shared( *deck , parseContext ); + const Deck& deck = parser.parseFile(input_file, parseContext); + EclipseState state( deck , parseContext ); std::cout << "Loading eclipse INIT file .....: " << init_file << std::endl; ecl_file_type * ecl_init = ecl_file_open( init_file.c_str() , 0 ); diff --git a/examples/sim_2p_comp_reorder.cpp b/examples/sim_2p_comp_reorder.cpp index c70866870..6ad7709cf 100644 --- a/examples/sim_2p_comp_reorder.cpp +++ b/examples/sim_2p_comp_reorder.cpp @@ -86,15 +86,15 @@ try // If we have a "deck_filename", grid and props will be read from that. bool use_deck = param.has("deck_filename"); - EclipseStateConstPtr eclipseState; + std::shared_ptr< EclipseState > eclipseState; std::unique_ptr grid; std::unique_ptr props; std::unique_ptr rock_comp; std::unique_ptr state; - ParserPtr parser(new Opm::Parser()); - Opm::DeckConstPtr deck; + Parser parser; + std::shared_ptr< Deck > deck; // bool check_well_controls = false; // int max_well_control_iterations = 0; @@ -102,27 +102,27 @@ try if (use_deck) { ParseContext parseContext; std::string deck_filename = param.get("deck_filename"); - deck = parser->parseFile(deck_filename , parseContext); + *deck = parser.parseFile(deck_filename , parseContext); eclipseState.reset(new EclipseState(*deck, parseContext)); // Grid init - grid.reset(new GridManager(*eclipseState->getInputGrid())); + grid.reset(new GridManager(eclipseState->getInputGrid())); { 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; // 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,10 +240,10 @@ try int step = 0; SimulatorTimer simtimer; // Use timer for last epoch to obtain total time. - Opm::TimeMapPtr timeMap(new Opm::TimeMap(deck)); + Opm::TimeMap timeMap(*deck); simtimer.init(timeMap); const double total_time = simtimer.totalTime(); - for (size_t reportStepIdx = 0; reportStepIdx < timeMap->numTimesteps(); ++reportStepIdx) { + for (size_t reportStepIdx = 0; reportStepIdx < timeMap.numTimesteps(); ++reportStepIdx) { simtimer.setCurrentStepNum(step); simtimer.setTotalTime(total_time); @@ -253,7 +253,7 @@ try << simtimer.numSteps() - step << ")\n\n" << std::flush; // Create new wells, well_state - WellsManager wells(eclipseState , reportStepIdx , *grid->c_grid(), props->permeability()); + WellsManager wells(*eclipseState , reportStepIdx , *grid->c_grid(), props->permeability()); // @@@ HACK: we should really make a new well state and // properly transfer old well state to it every report step, // since number of wells may change etc. diff --git a/examples/sim_2p_incomp.cpp b/examples/sim_2p_incomp.cpp index 760991b84..9e72efb03 100644 --- a/examples/sim_2p_incomp.cpp +++ b/examples/sim_2p_incomp.cpp @@ -99,9 +99,9 @@ try // If we have a "deck_filename", grid and props will be read from that. bool use_deck = param.has("deck_filename"); - EclipseStateConstPtr eclipseState; + std::shared_ptr< EclipseState > eclipseState; - Opm::DeckConstPtr deck; + std::shared_ptr< Deck > deck; std::unique_ptr grid; std::unique_ptr props; std::unique_ptr rock_comp; @@ -110,30 +110,30 @@ try // int max_well_control_iterations = 0; double gravity[3] = { 0.0 }; if (use_deck) { - ParserPtr parser(new Opm::Parser()); + Parser parser; ParseContext parseContext; std::string deck_filename = param.get("deck_filename"); - deck = parser->parseFile(deck_filename , parseContext); + *deck = parser.parseFile(deck_filename , parseContext); eclipseState.reset( new EclipseState(*deck, parseContext)); // Grid init - grid.reset(new GridManager(*eclipseState->getInputGrid())); + 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; // 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 { @@ -249,11 +249,11 @@ try rep = simulator.run(simtimer, *state, well_state); } else { // With a deck, we may have more epochs etc. - Opm::TimeMapConstPtr timeMap = eclipseState->getSchedule()->getTimeMap(); + const auto& timeMap = eclipseState->getSchedule().getTimeMap(); std::cout << "\n\n================ Starting main simulation loop ===============\n" << " (number of report steps: " - << timeMap->numTimesteps() << ")\n\n" << std::flush; + << timeMap.numTimesteps() << ")\n\n" << std::flush; WellState well_state; int step = 0; SimulatorTimer simtimer; @@ -273,7 +273,7 @@ try // << simtimer.numSteps() - step << ")\n\n" << std::flush; // Create new wells, well_state - WellsManager wells(eclipseState , reportStepIdx , *grid->c_grid(), props->permeability()); + WellsManager wells(*eclipseState , reportStepIdx , *grid->c_grid(), props->permeability()); // @@@ HACK: we should really make a new well state and // properly transfer old well state to it every report step, // since number of wells may change etc. diff --git a/examples/sim_2p_incomp_ad.cpp b/examples/sim_2p_incomp_ad.cpp index c6cc6e998..c4cb0f0de 100644 --- a/examples/sim_2p_incomp_ad.cpp +++ b/examples/sim_2p_incomp_ad.cpp @@ -100,13 +100,13 @@ try // If we have a "deck_filename", grid and props will be read from that. bool use_deck = param.has("deck_filename"); - Opm::ParserPtr parser(new Opm::Parser()); - Opm::DeckConstPtr deck; + Opm::Parser parser; + std::shared_ptr< Opm::Deck > deck; std::unique_ptr grid; std::unique_ptr props; std::unique_ptr rock_comp; std::unique_ptr state; - EclipseStateConstPtr eclipseState; + std::shared_ptr< EclipseState > eclipseState; // bool check_well_controls = false; // int max_well_control_iterations = 0; @@ -114,29 +114,29 @@ try if (use_deck) { std::string deck_filename = param.get("deck_filename"); Opm::ParseContext parseContext; - deck = parser->parseFile(deck_filename, parseContext); + *deck = parser.parseFile(deck_filename, parseContext); eclipseState.reset(new EclipseState(*deck , parseContext)); // Grid init - grid.reset(new GridManager(*eclipseState->getInputGrid())); + 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 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; // 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,16 +254,16 @@ try } else { // With a deck, we may have more report steps etc. WellState well_state; - Opm::TimeMapPtr timeMap(new Opm::TimeMap(deck)); + Opm::TimeMap timeMap(*deck); SimulatorTimer simtimer; - for (size_t reportStepIdx = 0; reportStepIdx < timeMap->numTimesteps(); ++reportStepIdx) { + for (size_t reportStepIdx = 0; reportStepIdx < timeMap.numTimesteps(); ++reportStepIdx) { // Report on start of report step. std::cout << "\n\n-------------- Starting report step " << reportStepIdx << " --------------" << "\n (number of steps left: " - << timeMap->numTimesteps() - reportStepIdx << ")\n\n" << std::flush; + << timeMap.numTimesteps() - reportStepIdx << ")\n\n" << std::flush; // Create new wells, well_state - WellsManager wells(eclipseState , reportStepIdx , *grid->c_grid(), props->permeability()); + WellsManager wells(*eclipseState , reportStepIdx , *grid->c_grid(), props->permeability()); // @@@ HACK: we should really make a new well state and // properly transfer old well state to it every report step, // since number of wells may change etc. diff --git a/examples/sim_poly2p_comp_reorder.cpp b/examples/sim_poly2p_comp_reorder.cpp index b0f05c1fa..e6fb73f9b 100644 --- a/examples/sim_poly2p_comp_reorder.cpp +++ b/examples/sim_poly2p_comp_reorder.cpp @@ -90,35 +90,35 @@ try boost::scoped_ptr grid; boost::scoped_ptr props; boost::scoped_ptr rock_comp; - Opm::DeckConstPtr deck; - EclipseStateConstPtr eclipseState; std::unique_ptr state; Opm::PolymerProperties poly_props; + Opm::Deck deck; + std::unique_ptr< EclipseState > eclipseState; // bool check_well_controls = false; // int max_well_control_iterations = 0; double gravity[3] = { 0.0 }; if (use_deck) { std::string deck_filename = param.get("deck_filename"); - ParserPtr parser(new Opm::Parser()); + Parser parser; Opm::ParseContext parseContext({{ ParseContext::PARSE_RANDOM_SLASH , InputError::IGNORE }}); - deck = parser->parseFile(deck_filename , parseContext); - eclipseState.reset(new Opm::EclipseState(*deck , parseContext)); + deck = parser.parseFile(deck_filename , parseContext); + eclipseState.reset( new EclipseState(deck , parseContext) ); // Grid init - grid.reset(new GridManager(*eclipseState->getInputGrid())); + grid.reset(new GridManager(eclipseState->getInputGrid())); { const UnstructuredGrid& ug_grid = *(grid->c_grid()); // Rock and fluid init - props.reset(new BlackoilPropertiesFromDeck(deck, eclipseState, ug_grid)); + props.reset(new BlackoilPropertiesFromDeck(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 PolymerBlackoilState( 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); @@ -127,7 +127,7 @@ try } initBlackoilSurfvol(ug_grid, *props, *state); // Init polymer properties. - poly_props.readFromDeck(deck, eclipseState); + poly_props.readFromDeck(deck, *eclipseState); } } else { // Grid init. @@ -264,19 +264,19 @@ try // With a deck, we may have more epochs etc. WellState well_state; int step = 0; - Opm::TimeMapPtr timeMap(new Opm::TimeMap(deck)); + Opm::TimeMap timeMap(deck); SimulatorTimer simtimer; simtimer.init(timeMap); // Check for WPOLYMER presence in last report step 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. " "You seem to be trying to control it via parameter poly_start_days (etc.) as well."); } } - for (size_t reportStepIdx = 0; reportStepIdx < timeMap->numTimesteps(); ++reportStepIdx) { + for (size_t reportStepIdx = 0; reportStepIdx < timeMap.numTimesteps(); ++reportStepIdx) { simtimer.setCurrentStepNum(reportStepIdx); // Report on start of report step. @@ -285,13 +285,14 @@ try << simtimer.numSteps() - step << ")\n\n" << std::flush; // Create new wells, polymer inflow controls. - WellsManager wells(eclipseState , reportStepIdx , *grid->c_grid(), props->permeability()); + eclipseState.reset( new EclipseState( deck ) ); + WellsManager wells(*eclipseState , reportStepIdx , *grid->c_grid(), props->permeability()); boost::scoped_ptr polymer_inflow; if (use_wpolymer) { if (wells.c_wells() == 0) { OPM_THROW(std::runtime_error, "Cannot control polymer injection via WPOLYMER without wells."); } - polymer_inflow.reset(new PolymerInflowFromDeck(eclipseState, *wells.c_wells(), props->numCells(), simtimer.currentStepNum())); + polymer_inflow.reset(new PolymerInflowFromDeck(*eclipseState, *wells.c_wells(), props->numCells(), simtimer.currentStepNum())); } else { polymer_inflow.reset(new PolymerInflowBasic(param.getDefault("poly_start_days", 300.0)*Opm::unit::day, param.getDefault("poly_end_days", 800.0)*Opm::unit::day, diff --git a/examples/sim_poly2p_incomp_reorder.cpp b/examples/sim_poly2p_incomp_reorder.cpp index 14afd4f3b..e565e760a 100644 --- a/examples/sim_poly2p_incomp_reorder.cpp +++ b/examples/sim_poly2p_incomp_reorder.cpp @@ -87,11 +87,11 @@ try // If we have a "deck_filename", grid and props will be read from that. bool use_deck = param.has("deck_filename"); - Opm::DeckConstPtr deck; + std::shared_ptr< Deck > deck; boost::scoped_ptr grid; boost::scoped_ptr props; boost::scoped_ptr rock_comp; - EclipseStateConstPtr eclipseState; + std::shared_ptr< EclipseState > eclipseState; std::unique_ptr state; Opm::PolymerProperties poly_props; // bool check_well_controls = false; @@ -100,33 +100,33 @@ try if (use_deck) { std::string deck_filename = param.get("deck_filename"); Opm::ParseContext parseContext({{ ParseContext::PARSE_RANDOM_SLASH , InputError::IGNORE }}); - ParserPtr parser(new Opm::Parser()); - deck = parser->parseFile(deck_filename , parseContext); + Parser parser; + *deck = parser.parseFile(deck_filename , parseContext); eclipseState.reset(new Opm::EclipseState(*deck , parseContext)); // Grid init - grid.reset(new GridManager(*eclipseState->getInputGrid())); + 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; // 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,7 +299,7 @@ try WellState well_state; int step = 0; - Opm::TimeMapPtr timeMap(new Opm::TimeMap(deck)); + TimeMap timeMap(*deck); SimulatorTimer simtimer; simtimer.init(timeMap); // Check for WPOLYMER presence in last epoch to decide @@ -311,7 +311,7 @@ try "You seem to be trying to control it via parameter poly_start_days (etc.) as well."); } } - for (size_t reportStepIdx = 0; reportStepIdx < timeMap->numTimesteps(); ++reportStepIdx) { + for (size_t reportStepIdx = 0; reportStepIdx < timeMap.numTimesteps(); ++reportStepIdx) { simtimer.setCurrentStepNum(reportStepIdx); // Report on start of report step. @@ -320,13 +320,13 @@ try << simtimer.numSteps() - step << ")\n\n" << std::flush; // Create new wells, polymer inflow controls. - WellsManager wells(eclipseState , reportStepIdx , *grid->c_grid(), props->permeability()); + WellsManager wells(*eclipseState , reportStepIdx , *grid->c_grid(), props->permeability()); boost::scoped_ptr polymer_inflow; if (use_wpolymer) { if (wells.c_wells() == 0) { OPM_THROW(std::runtime_error, "Cannot control polymer injection via WPOLYMER without wells."); } - polymer_inflow.reset(new PolymerInflowFromDeck(eclipseState, *wells.c_wells(), props->numCells(), simtimer.currentStepNum())); + polymer_inflow.reset(new PolymerInflowFromDeck(*eclipseState, *wells.c_wells(), props->numCells(), simtimer.currentStepNum())); } else { polymer_inflow.reset(new PolymerInflowBasic(param.getDefault("poly_start_days", 300.0)*Opm::unit::day, param.getDefault("poly_end_days", 800.0)*Opm::unit::day, diff --git a/examples/sim_poly_fi2p_comp_ad.cpp b/examples/sim_poly_fi2p_comp_ad.cpp index 9cad0018f..17bc8bfa6 100644 --- a/examples/sim_poly_fi2p_comp_ad.cpp +++ b/examples/sim_poly_fi2p_comp_ad.cpp @@ -142,7 +142,7 @@ try std::string logFile = output_dir + "/LOGFILE.txt"; Opm::ParseContext parseContext({{ ParseContext::PARSE_RANDOM_SLASH , InputError::IGNORE }}); - Opm::ParserPtr parser(new Opm::Parser()); + Opm::Parser parser; { std::shared_ptr streamLog = std::make_shared(logFile , Opm::Log::DefaultMessageTypes); std::shared_ptr counterLog = std::make_shared(Opm::Log::DefaultMessageTypes); @@ -151,11 +151,11 @@ try Opm::OpmLog::addBackend( "COUNTER" , counterLog ); } - Opm::DeckConstPtr deck; + std::shared_ptr< Deck > deck; std::shared_ptr eclipseState; try { - deck = parser->parseFile(deck_filename , parseContext); - Opm::checkDeck(deck, parser); + *deck = parser.parseFile(deck_filename , parseContext); + Opm::checkDeck(*deck, parser); eclipseState.reset(new Opm::EclipseState(*deck , parseContext)); } catch (const std::invalid_argument& e) { @@ -168,12 +168,12 @@ try if (eclipseState->get3DProperties().hasDeckDoubleGridProperty("PORV")) { const auto& porv = eclipseState->get3DProperties().getDoubleGridProperty("PORV").getData(); - grid.reset(new GridManager(*eclipseState->getInputGrid(), porv)); + grid.reset(new GridManager(eclipseState->getInputGrid(), porv)); } else { - grid.reset(new GridManager(*eclipseState->getInputGrid())); + 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,21 +182,21 @@ 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; @@ -206,7 +206,7 @@ try 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); @@ -219,7 +219,7 @@ try fis_solver.reset(new NewtonIterationBlackoilSimple(param)); } - Opm::TimeMapConstPtr timeMap(eclipseState->getSchedule()->getTimeMap()); + const auto timeMap = eclipseState->getSchedule().getTimeMap(); SimulatorTimer simtimer; simtimer.init(timeMap); @@ -240,12 +240,12 @@ try << std::flush; Opm::BlackoilOutputWriter - outputWriter(cGrid, param, eclipseState, pu, + outputWriter(cGrid, param, *eclipseState, pu, new_props->permeability() ); SimulatorReport fullReport; // Create and run simulator. - Opm::DerivedGeology geology(*grid->c_grid(), *new_props, eclipseState, grav); + Opm::DerivedGeology geology(*grid->c_grid(), *new_props, *eclipseState, grav); SimulatorFullyImplicitCompressiblePolymer simulator(param, *grid->c_grid(), diff --git a/opm/autodiff/BlackoilModel.hpp b/opm/autodiff/BlackoilModel.hpp index ebdc351ed..a1ea98c47 100644 --- a/opm/autodiff/BlackoilModel.hpp +++ b/opm/autodiff/BlackoilModel.hpp @@ -67,7 +67,7 @@ namespace Opm { const RockCompressibility* rock_comp_props, const StandardWells& std_wells, const NewtonIterationBlackoilInterface& linsolver, - Opm::EclipseStateConstPtr eclState, + std::shared_ptr< const Opm::EclipseState > eclState, const bool has_disgas, const bool has_vapoil, const bool terminal_output) diff --git a/opm/autodiff/BlackoilModelBase.hpp b/opm/autodiff/BlackoilModelBase.hpp index 95da59289..c4bac4a6b 100644 --- a/opm/autodiff/BlackoilModelBase.hpp +++ b/opm/autodiff/BlackoilModelBase.hpp @@ -137,7 +137,7 @@ namespace Opm { const RockCompressibility* rock_comp_props, const WellModel& well_model, const NewtonIterationBlackoilInterface& linsolver, - Opm::EclipseStateConstPtr eclState, + std::shared_ptr< const EclipseState > eclState, const bool has_disgas, const bool has_vapoil, const bool terminal_output); diff --git a/opm/autodiff/BlackoilModelBase_impl.hpp b/opm/autodiff/BlackoilModelBase_impl.hpp index f2438e394..90c5c4e2c 100644 --- a/opm/autodiff/BlackoilModelBase_impl.hpp +++ b/opm/autodiff/BlackoilModelBase_impl.hpp @@ -103,7 +103,7 @@ typedef Eigen::Array eclState, const bool has_disgas, const bool has_vapoil, const bool terminal_output) diff --git a/opm/autodiff/BlackoilModelEbos.hpp b/opm/autodiff/BlackoilModelEbos.hpp index 1a83b7046..998218f81 100644 --- a/opm/autodiff/BlackoilModelEbos.hpp +++ b/opm/autodiff/BlackoilModelEbos.hpp @@ -51,6 +51,7 @@ #include #include #include +#include #include #include #include diff --git a/opm/autodiff/BlackoilMultiSegmentModel.hpp b/opm/autodiff/BlackoilMultiSegmentModel.hpp index 68798b590..92881bb45 100644 --- a/opm/autodiff/BlackoilMultiSegmentModel.hpp +++ b/opm/autodiff/BlackoilMultiSegmentModel.hpp @@ -88,7 +88,7 @@ namespace Opm { const RockCompressibility* rock_comp_props, const MultisegmentWells& well_model, const NewtonIterationBlackoilInterface& linsolver, - Opm::EclipseStateConstPtr eclState, + std::shared_ptr< const EclipseState > eclState, const bool has_disgas, const bool has_vapoil, const bool terminal_output); diff --git a/opm/autodiff/BlackoilMultiSegmentModel_impl.hpp b/opm/autodiff/BlackoilMultiSegmentModel_impl.hpp index 41dae5915..1cff7a75c 100644 --- a/opm/autodiff/BlackoilMultiSegmentModel_impl.hpp +++ b/opm/autodiff/BlackoilMultiSegmentModel_impl.hpp @@ -64,7 +64,7 @@ namespace Opm { const RockCompressibility* rock_comp_props, const MultisegmentWells& well_model, const NewtonIterationBlackoilInterface& linsolver, - Opm::EclipseStateConstPtr eclState, + std::shared_ptr< const EclipseState > eclState, const bool has_disgas, const bool has_vapoil, const bool terminal_output) diff --git a/opm/autodiff/BlackoilPressureModel.hpp b/opm/autodiff/BlackoilPressureModel.hpp index 716705fb6..3aab0a2a0 100644 --- a/opm/autodiff/BlackoilPressureModel.hpp +++ b/opm/autodiff/BlackoilPressureModel.hpp @@ -71,7 +71,7 @@ namespace Opm { const RockCompressibility* rock_comp_props, const StandardWells& std_wells, const NewtonIterationBlackoilInterface& linsolver, - Opm::EclipseStateConstPtr eclState, + std::shared_ptr< const EclipseState> eclState, const bool has_disgas, const bool has_vapoil, const bool terminal_output) diff --git a/opm/autodiff/BlackoilPropsAdFromDeck.cpp b/opm/autodiff/BlackoilPropsAdFromDeck.cpp index 2e7f87c85..bafa400ca 100644 --- a/opm/autodiff/BlackoilPropsAdFromDeck.cpp +++ b/opm/autodiff/BlackoilPropsAdFromDeck.cpp @@ -44,8 +44,8 @@ namespace Opm typedef Eigen::Array Block; /// Constructor wrapping an opm-core black oil interface. - BlackoilPropsAdFromDeck::BlackoilPropsAdFromDeck(Opm::DeckConstPtr deck, - Opm::EclipseStateConstPtr eclState, + BlackoilPropsAdFromDeck::BlackoilPropsAdFromDeck(const Opm::Deck& deck, + const Opm::EclipseState& eclState, std::shared_ptr materialLawManager, const UnstructuredGrid& grid, const bool init_rock) @@ -56,8 +56,8 @@ namespace Opm #ifdef HAVE_OPM_GRID /// Constructor wrapping an opm-core black oil interface. - BlackoilPropsAdFromDeck::BlackoilPropsAdFromDeck(Opm::DeckConstPtr deck, - Opm::EclipseStateConstPtr eclState, + BlackoilPropsAdFromDeck::BlackoilPropsAdFromDeck(const Opm::Deck& deck, + const Opm::EclipseState& eclState, const Dune::CpGrid& grid, const bool init_rock ) { @@ -75,8 +75,8 @@ namespace Opm #endif /// Constructor wrapping an opm-core black oil interface. - BlackoilPropsAdFromDeck::BlackoilPropsAdFromDeck(Opm::DeckConstPtr deck, - Opm::EclipseStateConstPtr eclState, + BlackoilPropsAdFromDeck::BlackoilPropsAdFromDeck(const Opm::Deck& deck, + const Opm::EclipseState& eclState, const UnstructuredGrid& grid, const bool init_rock) { @@ -97,8 +97,8 @@ namespace Opm #ifdef HAVE_OPM_GRID /// Constructor wrapping an opm-core black oil interface. - BlackoilPropsAdFromDeck::BlackoilPropsAdFromDeck(Opm::DeckConstPtr deck, - Opm::EclipseStateConstPtr eclState, + BlackoilPropsAdFromDeck::BlackoilPropsAdFromDeck(const Opm::Deck& deck, + const Opm::EclipseState& eclState, std::shared_ptr materialLawManager, const Dune::CpGrid& grid, const bool init_rock ) @@ -141,8 +141,8 @@ BlackoilPropsAdFromDeck::BlackoilPropsAdFromDeck(const BlackoilPropsAdFromDeck& } /// Initializes the properties. - void BlackoilPropsAdFromDeck::init(Opm::DeckConstPtr deck, - Opm::EclipseStateConstPtr eclState, + void BlackoilPropsAdFromDeck::init(const Opm::Deck& deck, + const Opm::EclipseState& eclState, std::shared_ptr materialLawManager, int number_of_cells, const int* global_cell, @@ -170,9 +170,9 @@ BlackoilPropsAdFromDeck::BlackoilPropsAdFromDeck(const BlackoilPropsAdFromDeck& waterPvt_->initFromDeck(deck, eclState); // Surface densities. Accounting for different orders in eclipse and our code. - const auto& densityKeyword = deck->getKeyword("DENSITY"); + const auto& densityKeyword = deck.getKeyword("DENSITY"); int numRegions = densityKeyword.size(); - auto tables = eclState->getTableManager(); + auto tables = eclState.getTableManager(); surfaceDensity_.resize(numRegions); for (int regionIdx = 0; regionIdx < numRegions; ++regionIdx) { @@ -192,11 +192,11 @@ BlackoilPropsAdFromDeck::BlackoilPropsAdFromDeck(const BlackoilPropsAdFromDeck& // Oil vaporization controls (kw VAPPARS) vap1_ = vap2_ = 0.0; - if (deck->hasKeyword("VAPPARS") && deck->hasKeyword("VAPOIL") && deck->hasKeyword("DISGAS")) { - vap1_ = deck->getKeyword("VAPPARS").getRecord(0).getItem(0).get< double >(0); - vap2_ = deck->getKeyword("VAPPARS").getRecord(0).getItem(1).get< double >(0); + if (deck.hasKeyword("VAPPARS") && deck.hasKeyword("VAPOIL") && deck.hasKeyword("DISGAS")) { + vap1_ = deck.getKeyword("VAPPARS").getRecord(0).getItem(0).get< double >(0); + vap2_ = deck.getKeyword("VAPPARS").getRecord(0).getItem(1).get< double >(0); satOilMax_.resize(number_of_cells, 0.0); - } else if (deck->hasKeyword("VAPPARS")) { + } else if (deck.hasKeyword("VAPPARS")) { OPM_THROW(std::runtime_error, "Input has VAPPARS, but missing VAPOIL and/or DISGAS\n"); } diff --git a/opm/autodiff/BlackoilPropsAdFromDeck.hpp b/opm/autodiff/BlackoilPropsAdFromDeck.hpp index a8c854761..96187c733 100644 --- a/opm/autodiff/BlackoilPropsAdFromDeck.hpp +++ b/opm/autodiff/BlackoilPropsAdFromDeck.hpp @@ -85,8 +85,8 @@ namespace Opm /// \param grid The grid upon which the simulation is run on. /// \param init_rock If true the rock properties (rock compressibility and /// reference pressure) are read from the deck - BlackoilPropsAdFromDeck(Opm::DeckConstPtr deck, - Opm::EclipseStateConstPtr eclState, + BlackoilPropsAdFromDeck(const Opm::Deck& deck, + const Opm::EclipseState& eclState, std::shared_ptr materialLawManager, const UnstructuredGrid& grid, const bool init_rock = true ); @@ -106,8 +106,8 @@ namespace Opm /// \param grid The grid upon which the simulation is run on. /// \param init_rock If true the rock properties (rock compressibility and /// reference pressure) are read from the deck - BlackoilPropsAdFromDeck(Opm::DeckConstPtr deck, - Opm::EclipseStateConstPtr eclState, + BlackoilPropsAdFromDeck(const Opm::Deck& deck, + const Opm::EclipseState& eclState, std::shared_ptr materialLawManager, const Dune::CpGrid& grid, const bool init_rock = true ); @@ -120,8 +120,8 @@ namespace Opm /// \param grid The grid upon which the simulation is run on. /// \param init_rock If true the rock properties (rock compressibility and /// reference pressure) are read from the deck - BlackoilPropsAdFromDeck(Opm::DeckConstPtr deck, - Opm::EclipseStateConstPtr eclState, + BlackoilPropsAdFromDeck(const Opm::Deck& deck, + const Opm::EclipseState& eclState, const UnstructuredGrid& grid, const bool init_rock = true ); @@ -133,8 +133,8 @@ namespace Opm /// \param grid The grid upon which the simulation is run on. /// \param init_rock If true the rock properties (rock compressibility and /// reference pressure) are read from the deck - BlackoilPropsAdFromDeck(Opm::DeckConstPtr deck, - Opm::EclipseStateConstPtr eclState, + BlackoilPropsAdFromDeck(const Opm::Deck& deck, + const Opm::EclipseState& eclState, const Dune::CpGrid& grid, const bool init_rock = true ); #endif @@ -383,8 +383,8 @@ namespace Opm private: /// Initializes the properties. - void init(Opm::DeckConstPtr deck, - Opm::EclipseStateConstPtr eclState, + void init(const Opm::Deck& deck, + const Opm::EclipseState& eclState, std::shared_ptr materialLawManager, int number_of_cells, const int* global_cell, diff --git a/opm/autodiff/BlackoilSequentialModel.hpp b/opm/autodiff/BlackoilSequentialModel.hpp index 01727e067..23f9ec6ab 100644 --- a/opm/autodiff/BlackoilSequentialModel.hpp +++ b/opm/autodiff/BlackoilSequentialModel.hpp @@ -79,7 +79,7 @@ namespace Opm { const RockCompressibility* rock_comp_props, const WellModel well_model, const NewtonIterationBlackoilInterface& linsolver, - Opm::EclipseStateConstPtr eclState, + std::shared_ptr< const EclipseState > eclState, const bool has_disgas, const bool has_vapoil, const bool terminal_output) diff --git a/opm/autodiff/BlackoilSolventModel.hpp b/opm/autodiff/BlackoilSolventModel.hpp index 8afcb2b7e..9a089a4c1 100644 --- a/opm/autodiff/BlackoilSolventModel.hpp +++ b/opm/autodiff/BlackoilSolventModel.hpp @@ -73,7 +73,7 @@ namespace Opm { const SolventPropsAdFromDeck& solvent_props, const StandardWellsSolvent& well_model, const NewtonIterationBlackoilInterface& linsolver, - const EclipseStateConstPtr eclState, + std::shared_ptr< const EclipseState > eclState, const bool has_disgas, const bool has_vapoil, const bool terminal_output, diff --git a/opm/autodiff/BlackoilSolventModel_impl.hpp b/opm/autodiff/BlackoilSolventModel_impl.hpp index cdacc2249..5398a100e 100644 --- a/opm/autodiff/BlackoilSolventModel_impl.hpp +++ b/opm/autodiff/BlackoilSolventModel_impl.hpp @@ -78,7 +78,7 @@ namespace Opm { const SolventPropsAdFromDeck& solvent_props, const StandardWellsSolvent& well_model, const NewtonIterationBlackoilInterface& linsolver, - const EclipseStateConstPtr eclState, + std::shared_ptr< const EclipseState > eclState, const bool has_disgas, const bool has_vapoil, const bool terminal_output, diff --git a/opm/autodiff/BlackoilTransportModel.hpp b/opm/autodiff/BlackoilTransportModel.hpp index 614b851b2..a4bb68dc0 100644 --- a/opm/autodiff/BlackoilTransportModel.hpp +++ b/opm/autodiff/BlackoilTransportModel.hpp @@ -64,7 +64,7 @@ namespace Opm { const RockCompressibility* rock_comp_props, const StandardWells& std_wells, const NewtonIterationBlackoilInterface& linsolver, - Opm::EclipseStateConstPtr eclState, + std::shared_ptr eclState, const bool has_disgas, const bool has_vapoil, const bool terminal_output) diff --git a/opm/autodiff/FlowMain.hpp b/opm/autodiff/FlowMain.hpp index c704072a9..efbac9d8f 100644 --- a/opm/autodiff/FlowMain.hpp +++ b/opm/autodiff/FlowMain.hpp @@ -205,7 +205,7 @@ namespace Opm bool output_to_files_ = false; std::string output_dir_ = std::string("."); // readDeckInput() - std::shared_ptr deck_; + std::shared_ptr deck_; std::shared_ptr eclipse_state_; // setupGridAndProps() std::unique_ptr> grid_init_; @@ -473,13 +473,13 @@ namespace Opm std::string deck_filename = param_.get("deck_filename"); // Create Parser - ParserPtr parser(new Parser()); + Parser parser; // Create Deck and EclipseState. try { ParseContext parseContext({{ ParseContext::PARSE_RANDOM_SLASH , InputError::IGNORE }}); - deck_ = parser->parseFile(deck_filename, parseContext); - checkDeck(deck_, parser); + deck_ = std::make_shared< Deck >( parser.parseFile(deck_filename, parseContext) ); + checkDeck(*deck_, parser); if ( output_cout_) { @@ -487,8 +487,8 @@ namespace Opm } eclipse_state_.reset(new EclipseState(*deck_, parseContext)); - auto ioConfig = eclipse_state_->getIOConfig(); - ioConfig->setOutputDir(output_dir_); + auto& ioConfig = eclipse_state_->getIOConfig(); + ioConfig.setOutputDir(output_dir_); } catch (const std::invalid_argument& e) { std::cerr << "Failed to create valid EclipseState object. See logfile: " << logFile_ << std::endl; @@ -505,8 +505,8 @@ namespace Opm // Possible to force initialization only behavior (NOSIM). if (param_.has("nosim")) { const bool nosim = param_.get("nosim"); - IOConfigPtr ioConfig = eclipse_state_->getIOConfig(); - ioConfig->overrideNOSIM( nosim ); + auto& ioConfig = eclipse_state_->getIOConfig(); + ioConfig.overrideNOSIM( nosim ); } } @@ -528,20 +528,20 @@ namespace Opm // Create grid. const std::vector& porv = eclipse_state_->get3DProperties().getDoubleGridProperty("PORV").getData(); - grid_init_.reset(new GridInit(eclipse_state_, porv)); + grid_init_.reset(new GridInit(*eclipse_state_, porv)); const Grid& grid = grid_init_->grid(); // Create material law manager. std::vector compressedToCartesianIdx; Opm::createGlobalCellArray(grid, compressedToCartesianIdx); material_law_manager_.reset(new MaterialLawManager()); - material_law_manager_->initFromDeck(deck_, eclipse_state_, compressedToCartesianIdx); + material_law_manager_->initFromDeck(*deck_, *eclipse_state_, compressedToCartesianIdx); // Rock and fluid properties. - fluidprops_.reset(new BlackoilPropsAdFromDeck(deck_, eclipse_state_, material_law_manager_, grid)); + fluidprops_.reset(new BlackoilPropsAdFromDeck(*deck_, *eclipse_state_, material_law_manager_, grid)); // Rock compressibility. - rock_comp_.reset(new RockCompressibility(deck_, eclipse_state_)); + rock_comp_.reset(new RockCompressibility(*deck_, *eclipse_state_)); // Gravity. assert(UgGridHelpers::dimensions(grid) == 3); @@ -552,7 +552,7 @@ namespace Opm // Geological properties use_local_perm_ = param_.getDefault("use_local_perm", use_local_perm_); - geoprops_.reset(new DerivedGeology(grid, *fluidprops_, eclipse_state_, use_local_perm_, gravity_.data())); + geoprops_.reset(new DerivedGeology(grid, *fluidprops_, *eclipse_state_, use_local_perm_, gravity_.data())); } @@ -566,11 +566,11 @@ namespace Opm // fluidprops_ (if SWATINIT is used) void setupState() { - const PhaseUsage pu = Opm::phaseUsageFromDeck(deck_); + const PhaseUsage pu = Opm::phaseUsageFromDeck(*deck_); const Grid& grid = grid_init_->grid(); // Need old-style fluid object for init purposes (only). - BlackoilPropertiesFromDeck props( deck_, eclipse_state_, material_law_manager_, + BlackoilPropertiesFromDeck props( *deck_, *eclipse_state_, material_law_manager_, Opm::UgGridHelpers::numCells(grid), Opm::UgGridHelpers::globalCell(grid), Opm::UgGridHelpers::cartDims(grid), @@ -614,7 +614,7 @@ namespace Opm Opm::UgGridHelpers::numFaces(grid), props.numPhases())); - initStateEquil(grid, props, deck_, eclipse_state_, gravity_[2], *state_); + initStateEquil(grid, props, *deck_, *eclipse_state_, gravity_[2], *state_); //state_.faceflux().resize(Opm::UgGridHelpers::numFaces(grid), 0.0); } else { state_.reset( new ReservoirState( Opm::UgGridHelpers::numCells(grid), @@ -627,14 +627,14 @@ namespace Opm Opm::UgGridHelpers::beginFaceCentroids(grid), Opm::UgGridHelpers::beginCellCentroids(grid), Opm::UgGridHelpers::dimensions(grid), - props, deck_, gravity_[2], *state_); + props, *deck_, gravity_[2], *state_); } // Threshold pressures. std::map, double> maxDp; - computeMaxDp(maxDp, deck_, eclipse_state_, grid_init_->grid(), *state_, props, gravity_[2]); - threshold_pressures_ = thresholdPressures(deck_, eclipse_state_, grid, maxDp); - std::vector threshold_pressures_nnc = thresholdPressuresNNC(eclipse_state_, geoprops_->nnc(), maxDp); + computeMaxDp(maxDp, *deck_, *eclipse_state_, grid_init_->grid(), *state_, props, gravity_[2]); + threshold_pressures_ = thresholdPressures(*deck_, *eclipse_state_, grid, maxDp); + std::vector threshold_pressures_nnc = thresholdPressuresNNC(*eclipse_state_, geoprops_->nnc(), maxDp); threshold_pressures_.insert(threshold_pressures_.end(), threshold_pressures_nnc.begin(), threshold_pressures_nnc.end()); // The capillary pressure is scaled in fluidprops_ to match the scaled capillary pressure in props. @@ -670,7 +670,7 @@ namespace Opm // and initilialize new properties and states for it. if (must_distribute_) { defunct_well_names_ = - distributeGridAndData(grid_init_->grid(), deck_, eclipse_state_, + distributeGridAndData(grid_init_->grid(), *deck_, *eclipse_state_, *state_, *fluidprops_, *geoprops_, material_law_manager_, threshold_pressures_, parallel_information_, use_local_perm_); @@ -728,7 +728,7 @@ namespace Opm // Run relperm diagnostics RelpermDiagnostics diagnostic; - diagnostic.diagnosis(eclipse_state_, deck_, grid_init_->grid()); + diagnostic.diagnosis(*eclipse_state_, *deck_, grid_init_->grid()); } @@ -739,8 +739,8 @@ namespace Opm const Grid& grid = grid_init_->grid(); if( output && output_ecl && output_cout_) { - const EclipseGrid& inputGrid = *eclipse_state_->getInputGrid(); - EclipseWriter writer(eclipse_state_, UgGridHelpers::createEclipseGrid( grid , inputGrid )); + const EclipseGrid& inputGrid = eclipse_state_->getInputGrid(); + EclipseWriter writer(*eclipse_state_, UgGridHelpers::createEclipseGrid( grid , inputGrid )); writer.writeInitAndEgrid(geoprops_->simProps(grid), geoprops_->nonCartesianConnections()); } @@ -757,8 +757,8 @@ namespace Opm // the global view output_writer_.reset(new OutputWriter(grid_init_->grid(), param_, - eclipse_state_, - Opm::phaseUsageFromDeck(deck_), + *eclipse_state_, + Opm::phaseUsageFromDeck(*deck_), fluidprops_->permeability())); } @@ -803,16 +803,16 @@ namespace Opm // Returns EXIT_SUCCESS if it does not throw. int runSimulator() { - Opm::ScheduleConstPtr schedule = eclipse_state_->getSchedule(); - Opm::TimeMapConstPtr timeMap(schedule->getTimeMap()); - std::shared_ptr ioConfig = eclipse_state_->getIOConfig(); + const auto& schedule = eclipse_state_->getSchedule(); + const auto& timeMap = schedule.getTimeMap(); + auto& ioConfig = eclipse_state_->getIOConfig(); SimulatorTimer simtimer; // initialize variables const auto& initConfig = eclipse_state_->getInitConfig(); simtimer.init(timeMap, (size_t)initConfig.getRestartStep()); - if (!ioConfig->initOnly()) { + if (!ioConfig.initOnly()) { if (output_cout_) { std::string msg; msg = "\n\n================ Starting main simulation loop ===============\n"; diff --git a/opm/autodiff/FlowMainEbos.hpp b/opm/autodiff/FlowMainEbos.hpp index 0b2af6a5f..04902d929 100644 --- a/opm/autodiff/FlowMainEbos.hpp +++ b/opm/autodiff/FlowMainEbos.hpp @@ -60,8 +60,8 @@ namespace Opm Base::deck_ = ebosSimulator_->gridManager().deck(); Base::eclipse_state_ = ebosSimulator_->gridManager().eclState(); - auto ioConfig = Base::eclipse_state_->getIOConfig(); - ioConfig->setOutputDir(Base::output_dir_); + IOConfig& ioConfig = Base::eclipse_state_->getIOConfig(); + ioConfig.setOutputDir(Base::output_dir_); // Possibly override IOConfig setting (from deck) for how often RESTART files should get written to disk (every N report step) if (Base::param_.has("output_interval")) { @@ -73,8 +73,7 @@ namespace Opm // Possible to force initialization only behavior (NOSIM). if (Base::param_.has("nosim")) { const bool nosim = Base::param_.get("nosim"); - IOConfigPtr ioConfig = Base::eclipse_state_->getIOConfig(); - ioConfig->overrideNOSIM( nosim ); + ioConfig.overrideNOSIM( nosim ); } } diff --git a/opm/autodiff/FlowMainPolymer.hpp b/opm/autodiff/FlowMainPolymer.hpp index 129cd5a9c..898c7bef0 100644 --- a/opm/autodiff/FlowMainPolymer.hpp +++ b/opm/autodiff/FlowMainPolymer.hpp @@ -84,7 +84,7 @@ namespace Opm Base::setupGridAndProps(); if (Base::deck_->hasKeyword("POLYMER")) { - polymer_props_legacy_.reset(new PolymerProperties(Base::deck_, Base::eclipse_state_)); + polymer_props_legacy_.reset(new PolymerProperties(*Base::deck_, *Base::eclipse_state_)); polymer_props_.reset(new PolymerPropsAd(*polymer_props_legacy_)); } } diff --git a/opm/autodiff/FlowMainSolvent.hpp b/opm/autodiff/FlowMainSolvent.hpp index 4715f7c77..62bff1ba5 100644 --- a/opm/autodiff/FlowMainSolvent.hpp +++ b/opm/autodiff/FlowMainSolvent.hpp @@ -74,8 +74,8 @@ namespace Opm Base::setupGridAndProps(); const Grid& grid = Base::grid_init_->grid(); - solvent_props_.reset(new SolventPropsAdFromDeck(Base::deck_, - Base::eclipse_state_, + solvent_props_.reset(new SolventPropsAdFromDeck(*Base::deck_, + *Base::eclipse_state_, UgGridHelpers::numCells(grid), UgGridHelpers::globalCell(grid))); } diff --git a/opm/autodiff/GeoProps.hpp b/opm/autodiff/GeoProps.hpp index 2fdba1b87..d769306e5 100644 --- a/opm/autodiff/GeoProps.hpp +++ b/opm/autodiff/GeoProps.hpp @@ -66,7 +66,7 @@ namespace Opm template DerivedGeology(const Grid& grid, const Props& props , - Opm::EclipseStateConstPtr eclState, + const EclipseState& eclState, const bool use_local_perm, const double* grav = 0 @@ -84,7 +84,7 @@ namespace Opm template void update(const Grid& grid, const Props& props , - Opm::EclipseStateConstPtr eclState, + const EclipseState& eclState, const double* grav) { @@ -98,7 +98,7 @@ namespace Opm // get the pore volume multipliers from the EclipseState std::vector multpv(numCartesianCells, 1.0); - const auto& eclProps = eclState->get3DProperties(); + const auto& eclProps = eclState.get3DProperties(); if (eclProps.hasDeckDoubleGridProperty("MULTPV")) { multpv = eclProps.getDoubleGridProperty("MULTPV").getData(); } @@ -110,13 +110,13 @@ namespace Opm } // Get grid from parser. - EclipseGridConstPtr eclgrid = eclState->getInputGrid(); + const auto& eclgrid = eclState.getInputGrid(); // update the pore volume of all active cells in the grid computePoreVolume_(grid, eclState); // Non-neighbour connections. - nnc_ = eclState->getInputNNC(); + nnc_ = eclState.getInputNNC(); // Transmissibility Vector htrans(AutoDiffGrid::numCellFaces(grid)); @@ -134,7 +134,7 @@ namespace Opm // for MINPV. Note that the change does not effect the pore volume calculations // as the pore volume is currently defaulted to be comparable to ECLIPSE, but // only the transmissibility calculations. - bool opmfil = eclgrid->getMinpvMode() == MinpvMode::ModeEnum::OpmFIL; + bool opmfil = eclgrid.getMinpvMode() == MinpvMode::ModeEnum::OpmFIL; // opmfil is hardcoded to be true. i.e the volume weighting is always used opmfil = true; if (opmfil) { @@ -144,9 +144,9 @@ namespace Opm std::vector mult; multiplyHalfIntersections_(grid, eclState, ntg, htrans, mult); - if (!opmfil && eclgrid->isPinchActive()) { + if (!opmfil && eclgrid.isPinchActive()) { // opmfil is hardcoded to be true. i.e the pinch processor is never used - pinchProcess_(grid, *eclState, htrans, numCells); + pinchProcess_(grid, eclState, htrans, numCells); } // combine the half-face transmissibilites into the final face @@ -273,40 +273,40 @@ namespace Opm private: template void multiplyHalfIntersections_(const Grid &grid, - Opm::EclipseStateConstPtr eclState, + const EclipseState& eclState, const std::vector &ntg, Vector &halfIntersectTransmissibility, std::vector &intersectionTransMult); template void tpfa_loc_trans_compute_(const Grid &grid, - Opm::EclipseGridConstPtr eclGrid, + const EclipseGrid& eclGrid, const double* perm, Vector &hTrans); template void minPvFillProps_(const Grid &grid, - Opm::EclipseStateConstPtr eclState, + const EclipseState& eclState, std::vector &ntg); template void computePoreVolume_(const GridType &grid, - Opm::EclipseStateConstPtr eclState) + const EclipseState& eclState) { int numCells = Opm::AutoDiffGrid::numCells(grid); const int* globalCell = Opm::UgGridHelpers::globalCell(grid); - EclipseGridConstPtr eclGrid = eclState->getInputGrid(); - const int nx = eclGrid->getNX(); - const int ny = eclGrid->getNY(); + const auto& eclGrid = eclState.getInputGrid(); + const int nx = eclGrid.getNX(); + const int ny = eclGrid.getNY(); // the "raw" pore volume. const std::vector& porvData = - eclState->get3DProperties().getDoubleGridProperty("PORV").getData(); + eclState.get3DProperties().getDoubleGridProperty("PORV").getData(); pvol_.resize(numCells); // the "activation number" grid property const std::vector& actnumData = - eclState->get3DProperties().getIntGridProperty("ACTNUM").getData(); + eclState.get3DProperties().getIntGridProperty("ACTNUM").getData(); for (int cellIdx = 0; cellIdx < numCells; ++cellIdx) { @@ -314,20 +314,20 @@ namespace Opm double cellPoreVolume = porvData[cellCartIdx]; - if (eclGrid->getMinpvMode() == MinpvMode::ModeEnum::OpmFIL) { + if (eclGrid.getMinpvMode() == MinpvMode::ModeEnum::OpmFIL) { // Sum the pore volumes of the cells above which have been deactivated // because their volume less is less than the MINPV threshold for (int aboveCellCartIdx = cellCartIdx - nx*ny; aboveCellCartIdx >= 0; aboveCellCartIdx -= nx*ny) { - if (porvData[aboveCellCartIdx] >= eclGrid->getMinpvValue()) { + if (porvData[aboveCellCartIdx] >= eclGrid.getMinpvValue()) { // stop if we encounter a cell which has a pore volume which is // at least as large as the minimum one break; } - const double aboveCellVolume = eclGrid->getCellVolume(aboveCellCartIdx); + const double aboveCellVolume = eclGrid.getCellVolume(aboveCellCartIdx); if (actnumData[aboveCellCartIdx] == 0 && aboveCellVolume > 1e-6) { // stop at explicitly disabled cells, but only if their volume is // greater than 10^-6 m^3 @@ -411,22 +411,22 @@ namespace Opm template inline void DerivedGeology::minPvFillProps_(const GridType &grid, - Opm::EclipseStateConstPtr eclState, + const EclipseState& eclState, std::vector &ntg) { int numCells = Opm::AutoDiffGrid::numCells(grid); const int* global_cell = Opm::UgGridHelpers::globalCell(grid); const int* cartdims = Opm::UgGridHelpers::cartDims(grid); - EclipseGridConstPtr eclgrid = eclState->getInputGrid(); - const auto& porv = eclState->get3DProperties().getDoubleGridProperty("PORV").getData(); - const auto& actnum = eclState->get3DProperties().getIntGridProperty("ACTNUM").getData(); + const auto& eclgrid = eclState.getInputGrid(); + const auto& porv = eclState.get3DProperties().getDoubleGridProperty("PORV").getData(); + const auto& actnum = eclState.get3DProperties().getIntGridProperty("ACTNUM").getData(); for (int cellIdx = 0; cellIdx < numCells; ++cellIdx) { const int nx = cartdims[0]; const int ny = cartdims[1]; const int cartesianCellIdx = global_cell[cellIdx]; - const double cellVolume = eclgrid->getCellVolume(cartesianCellIdx); + const double cellVolume = eclgrid.getCellVolume(cartesianCellIdx); ntg[cartesianCellIdx] *= cellVolume; double totalCellVolume = cellVolume; @@ -435,10 +435,10 @@ namespace Opm int cartesianCellIdxAbove = cartesianCellIdx - nx*ny; while ( cartesianCellIdxAbove >= 0 && actnum[cartesianCellIdxAbove] > 0 && - porv[cartesianCellIdxAbove] < eclgrid->getMinpvValue() ) { + porv[cartesianCellIdxAbove] < eclgrid.getMinpvValue() ) { // Volume weighted arithmetic average of NTG - const double cellAboveVolume = eclgrid->getCellVolume(cartesianCellIdxAbove); + const double cellAboveVolume = eclgrid.getCellVolume(cartesianCellIdxAbove); totalCellVolume += cellAboveVolume; ntg[cartesianCellIdx] += ntg[cartesianCellIdxAbove]*cellAboveVolume; cartesianCellIdxAbove -= nx*ny; @@ -460,17 +460,17 @@ namespace Opm // opmfil being hardcoded to be true. auto eclgrid = eclState.getInputGrid(); auto& eclProps = eclState.get3DProperties(); - const double minpv = eclgrid->getMinpvValue(); - const double thickness = eclgrid->getPinchThresholdThickness(); - auto transMode = eclgrid->getPinchOption(); - auto multzMode = eclgrid->getMultzOption(); + const double minpv = eclgrid.getMinpvValue(); + const double thickness = eclgrid.getPinchThresholdThickness(); + auto transMode = eclgrid.getPinchOption(); + auto multzMode = eclgrid.getMultzOption(); PinchProcessor pinch(minpv, thickness, transMode, multzMode); std::vector htrans_copy(htrans.size()); std::copy_n(htrans.data(), htrans.size(), htrans_copy.begin()); std::vector actnum; - eclgrid->exportACTNUM(actnum); + eclgrid.exportACTNUM(actnum); const auto& transMult = eclState.getTransMult(); std::vector multz(numCells, 0.0); @@ -490,7 +490,7 @@ namespace Opm template inline void DerivedGeology::multiplyHalfIntersections_(const GridType &grid, - Opm::EclipseStateConstPtr eclState, + const EclipseState& eclState, const std::vector &ntg, Vector &halfIntersectTransmissibility, std::vector &intersectionTransMult) @@ -501,7 +501,7 @@ namespace Opm intersectionTransMult.resize(numIntersections); std::fill(intersectionTransMult.begin(), intersectionTransMult.end(), 1.0); - const TransMult& multipliers = eclState->getTransMult(); + const TransMult& multipliers = eclState.getTransMult(); auto cell2Faces = Opm::UgGridHelpers::cell2Faces(grid); auto faceCells = Opm::AutoDiffGrid::faceCells(grid); const int* global_cell = Opm::UgGridHelpers::globalCell(grid); @@ -579,7 +579,7 @@ namespace Opm template inline void DerivedGeology::tpfa_loc_trans_compute_(const GridType& grid, - Opm::EclipseGridConstPtr eclGrid, + const EclipseGrid& eclGrid, const double* perm, Vector& hTrans){ @@ -631,7 +631,7 @@ namespace Opm #endif int cartesianCellIdx = AutoDiffGrid::globalCell(grid)[cellIdx]; - auto cellCenter = eclGrid->getCellCenter(cartesianCellIdx); + auto cellCenter = eclGrid.getCellCenter(cartesianCellIdx); for (int indx = 0; indx < dim; ++indx) { const double Ci = Opm::UgGridHelpers::faceCentroid(grid, faceIdx)[indx] - cellCenter[indx]; dist += Ci*Ci; diff --git a/opm/autodiff/GridInit.hpp b/opm/autodiff/GridInit.hpp index 1401a4073..5b900ba22 100644 --- a/opm/autodiff/GridInit.hpp +++ b/opm/autodiff/GridInit.hpp @@ -40,7 +40,7 @@ namespace Opm { public: /// Initialize from a deck and/or an eclipse state and (logical cartesian) specified pore volumes. - GridInit(EclipseStateConstPtr, const std::vector&) + GridInit(const EclipseState&, const std::vector&) { OPM_THROW(std::logic_error, "Found no specialization for GridInit for the requested Grid class."); } @@ -53,8 +53,8 @@ namespace Opm { public: /// Initialize from a deck and/or an eclipse state and (logical cartesian) specified pore volumes. - GridInit(EclipseStateConstPtr eclipse_state, const std::vector& porv) - : grid_manager_(*eclipse_state->getInputGrid(), porv) + GridInit(const EclipseState& eclipse_state, const std::vector& porv) + : grid_manager_(eclipse_state.getInputGrid(), porv) { } /// Access the created grid. @@ -74,9 +74,9 @@ namespace Opm { public: /// Initialize from a deck and/or an eclipse state and (logical cartesian) specified pore volumes. - GridInit(EclipseStateConstPtr eclipse_state, const std::vector& porv) + GridInit(const EclipseState& eclipse_state, const std::vector& porv) { - grid_.processEclipseFormat(*eclipse_state->getInputGrid(), false, false, false, porv); + grid_.processEclipseFormat(eclipse_state.getInputGrid(), false, false, false, porv); } /// Access the created grid. Note that mutable access may be required for load balancing. Dune::CpGrid& grid() diff --git a/opm/autodiff/ParallelDebugOutput.hpp b/opm/autodiff/ParallelDebugOutput.hpp index f9b3f4c8c..5fc184128 100644 --- a/opm/autodiff/ParallelDebugOutput.hpp +++ b/opm/autodiff/ParallelDebugOutput.hpp @@ -73,7 +73,7 @@ namespace Opm public: ParallelDebugOutput ( const GridImpl& grid, - Opm::EclipseStateConstPtr /* eclipseState */, + const EclipseState& /* eclipseState */, const int, const double* ) : grid_( grid ) {} @@ -229,7 +229,7 @@ namespace Opm enum { ioRank = 0 }; ParallelDebugOutput( const Dune::CpGrid& otherGrid, - Opm::EclipseStateConstPtr eclipseState, + const EclipseState& eclipseState, const int numPhases, const double* permeability ) : grid_(), @@ -593,7 +593,7 @@ namespace Opm protected: std::unique_ptr< Dune::CpGrid > grid_; - Opm::EclipseStateConstPtr eclipseState_; + const EclipseState& eclipseState_; const double* permeability_; P2PCommunicatorType toIORankComm_; IndexMapType globalIndex_; diff --git a/opm/autodiff/RedistributeDataHandles.hpp b/opm/autodiff/RedistributeDataHandles.hpp index e7ac81307..c430a7885 100644 --- a/opm/autodiff/RedistributeDataHandles.hpp +++ b/opm/autodiff/RedistributeDataHandles.hpp @@ -38,8 +38,8 @@ namespace Opm template inline std::unordered_set distributeGridAndData( Grid& , - Opm::DeckConstPtr , - EclipseStateConstPtr , + const Opm::Deck& , + const EclipseState& , BlackoilState& , BlackoilPropsAdFromDeck& , DerivedGeology&, @@ -420,8 +420,8 @@ private: inline std::unordered_set distributeGridAndData( Dune::CpGrid& grid, - Opm::DeckConstPtr deck, - EclipseStateConstPtr eclipseState, + const Opm::Deck& deck, + const EclipseState& eclipseState, BlackoilState& state, BlackoilPropsAdFromDeck& properties, DerivedGeology& geology, @@ -435,7 +435,7 @@ distributeGridAndData( Dune::CpGrid& grid, // distribute the grid and switch to the distributed view using std::get; - auto my_defunct_wells = get<1>(grid.loadBalance(eclipseState, + auto my_defunct_wells = get<1>(grid.loadBalance(&eclipseState, geology.transmissibility().data())); grid.switchToDistributedView(); std::vector compressedToCartesianIdx; diff --git a/opm/autodiff/SimulatorBase.hpp b/opm/autodiff/SimulatorBase.hpp index ee82cd25b..8bfabaa3a 100644 --- a/opm/autodiff/SimulatorBase.hpp +++ b/opm/autodiff/SimulatorBase.hpp @@ -174,7 +174,7 @@ namespace Opm std::vector& well_potentials); void updateListEconLimited(const std::unique_ptr& solver, - ScheduleConstPtr schedule, + const Schedule& schedule, const int current_step, const Wells* wells, const WellState& well_state, diff --git a/opm/autodiff/SimulatorBase_impl.hpp b/opm/autodiff/SimulatorBase_impl.hpp index 06588e8fd..3566424b6 100644 --- a/opm/autodiff/SimulatorBase_impl.hpp +++ b/opm/autodiff/SimulatorBase_impl.hpp @@ -106,7 +106,7 @@ namespace Opm std::ofstream tstep_os(tstep_filename.c_str()); const auto& schedule = eclipse_state_->getSchedule(); - const auto& events = schedule->getEvents(); + const auto& events = schedule.getEvents(); // adaptive time stepping std::unique_ptr< AdaptiveTimeStepping > adaptiveTimeStepping; @@ -114,7 +114,7 @@ namespace Opm { if (param_.getDefault("use_TUNING", false)) { - adaptiveTimeStepping.reset( new AdaptiveTimeStepping( schedule->getTuning(), timer.currentStepNum(), param_, terminal_output_ ) ); + adaptiveTimeStepping.reset( new AdaptiveTimeStepping( schedule.getTuning(), timer.currentStepNum(), param_, terminal_output_ ) ); } else { adaptiveTimeStepping.reset( new AdaptiveTimeStepping( param_, terminal_output_ ) ); } @@ -164,7 +164,7 @@ namespace Opm } // Create wells and well state. - WellsManager wells_manager(eclipse_state_, + WellsManager wells_manager(*eclipse_state_, timer.currentStepNum(), Opm::UgGridHelpers::numCells(grid_), Opm::UgGridHelpers::globalCell(grid_), @@ -260,9 +260,9 @@ namespace Opm // section // // TODO (?): handle the parallel case (maybe this works out of the box) - DeckConstPtr miniDeck = schedule->getModifierDeck(nextTimeStepIdx); + const auto& miniDeck = schedule.getModifierDeck(nextTimeStepIdx); eclipse_state_->applyModifierDeck(*miniDeck); - geo_.update(grid_, props_, eclipse_state_, gravity_); + geo_.update(grid_, props_, *eclipse_state_, gravity_); } // take time that was used to solve system for this reportStep @@ -516,7 +516,7 @@ namespace Opm { typedef SimFIBODetails::WellMap WellMap; - const auto w_ecl = eclipse_state_->getSchedule()->getWells(step); + const auto w_ecl = eclipse_state_->getSchedule().getWells(step); const WellMap& wmap = SimFIBODetails::mapWells(w_ecl); const std::vector& resv_wells = SimFIBODetails::resvWells(wells, step, wmap); @@ -803,7 +803,7 @@ namespace Opm void SimulatorBase:: updateListEconLimited(const std::unique_ptr& solver, - ScheduleConstPtr schedule, + const Schedule& schedule, const int current_step, const Wells* wells, const WellState& well_state, diff --git a/opm/autodiff/SimulatorFullyImplicitBlackoilEbos.hpp b/opm/autodiff/SimulatorFullyImplicitBlackoilEbos.hpp index 2a24c3364..0ddae0666 100644 --- a/opm/autodiff/SimulatorFullyImplicitBlackoilEbos.hpp +++ b/opm/autodiff/SimulatorFullyImplicitBlackoilEbos.hpp @@ -324,7 +324,7 @@ public: computeWellPotentials(wells, well_state, well_potentials); } - updateListEconLimited(solver, eclState()->getSchedule(), timer.currentStepNum(), wells, + updateListEconLimited(solver, eclState().getSchedule(), timer.currentStepNum(), wells, well_state, dynamic_list_econ_limited); } @@ -371,7 +371,7 @@ protected: { typedef SimFIBODetails::WellMap WellMap; - const auto w_ecl = eclState()->getSchedule()->getWells(step); + const auto w_ecl = eclState().getSchedule().getWells(step); const WellMap& wmap = SimFIBODetails::mapWells(w_ecl); const std::vector& resv_wells = SimFIBODetails::resvWells(wells, step, wmap); @@ -549,7 +549,7 @@ protected: void updateListEconLimited(const std::unique_ptr& solver, - ScheduleConstPtr schedule, + const Schedule& schedule, const int current_step, const Wells* wells, const WellState& well_state, @@ -559,11 +559,11 @@ protected: well_state, list_econ_limited); } - EclipseStateConstPtr eclState() const - { return ebosSimulator_.gridManager().eclState(); } + const EclipseState& eclState() const + { return *ebosSimulator_.gridManager().eclState(); } - EclipseStatePtr eclState() - { return ebosSimulator_.gridManager().eclState(); } + EclipseState& eclState() + { return *ebosSimulator_.gridManager().eclState(); } // Data. Simulator& ebosSimulator_; diff --git a/opm/autodiff/SimulatorFullyImplicitBlackoilMultiSegment_impl.hpp b/opm/autodiff/SimulatorFullyImplicitBlackoilMultiSegment_impl.hpp index efadd3e0e..d44508444 100644 --- a/opm/autodiff/SimulatorFullyImplicitBlackoilMultiSegment_impl.hpp +++ b/opm/autodiff/SimulatorFullyImplicitBlackoilMultiSegment_impl.hpp @@ -98,7 +98,7 @@ namespace Opm } // Create wells and well state. - WellsManager wells_manager(eclipse_state_, + WellsManager wells_manager(*eclipse_state_, timer.currentStepNum(), Opm::UgGridHelpers::numCells(grid_), Opm::UgGridHelpers::globalCell(grid_), @@ -119,7 +119,7 @@ namespace Opm WellState well_state; // well_state.init(wells, state, prev_well_state); - const auto wells_ecl = eclipse_state_->getSchedule()->getWells(timer.currentStepNum()); + const auto wells_ecl = eclipse_state_->getSchedule().getWells(timer.currentStepNum()); const int current_time_step = timer.currentStepNum(); const WellModel well_model(wells, wells_ecl, current_time_step); diff --git a/opm/autodiff/SimulatorFullyImplicitBlackoilOutput.cpp b/opm/autodiff/SimulatorFullyImplicitBlackoilOutput.cpp index 30e8c6fc2..77624075b 100644 --- a/opm/autodiff/SimulatorFullyImplicitBlackoilOutput.cpp +++ b/opm/autodiff/SimulatorFullyImplicitBlackoilOutput.cpp @@ -370,7 +370,7 @@ namespace Opm // ECL output if ( eclWriter_ ) { - const auto& initConfig = eclipseState_->getInitConfig(); + const auto& initConfig = eclipseState_.getInitConfig(); if (initConfig.restartRequested() && ((initConfig.getRestartStep()) == (timer.currentStepNum()))) { std::cout << "Skipping restart write in start of step " << timer.currentStepNum() << std::endl; } else { @@ -486,7 +486,7 @@ namespace Opm bool BlackoilOutputWriter::isRestart() const { - const auto& initconfig = eclipseState_->getInitConfig(); + const auto& initconfig = eclipseState_.getInitConfig(); return initconfig.restartRequested(); } } diff --git a/opm/autodiff/SimulatorFullyImplicitBlackoilOutput.hpp b/opm/autodiff/SimulatorFullyImplicitBlackoilOutput.hpp index 68e15beed..2becfdd38 100644 --- a/opm/autodiff/SimulatorFullyImplicitBlackoilOutput.hpp +++ b/opm/autodiff/SimulatorFullyImplicitBlackoilOutput.hpp @@ -213,7 +213,7 @@ namespace Opm template BlackoilOutputWriter(const Grid& grid, const parameter::ParameterGroup& param, - Opm::EclipseStateConstPtr eclipseState, + const Opm::EclipseState& eclipseState, const Opm::PhaseUsage &phaseUsage, const double* permeability ); @@ -311,7 +311,7 @@ namespace Opm std::unique_ptr< BlackoilSubWriter > vtkWriter_; std::unique_ptr< BlackoilSubWriter > matlabWriter_; std::unique_ptr< EclipseWriter > eclWriter_; - EclipseStateConstPtr eclipseState_; + const EclipseState& eclipseState_; std::unique_ptr< ThreadHandle > asyncOutput_; }; @@ -327,7 +327,7 @@ namespace Opm BlackoilOutputWriter:: BlackoilOutputWriter(const Grid& grid, const parameter::ParameterGroup& param, - Opm::EclipseStateConstPtr eclipseState, + const Opm::EclipseState& eclipseState, const Opm::PhaseUsage &phaseUsage, const double* permeability ) : output_( param.getDefault("output", true) ), @@ -343,7 +343,7 @@ namespace Opm new BlackoilMatlabWriter< Grid >( grid, outputDir_ ) : 0 ), eclWriter_( output_ && parallelOutput_->isIORank() && param.getDefault("output_ecl", true) ? - new EclipseWriter(eclipseState,UgGridHelpers::createEclipseGrid( grid , *eclipseState->getInputGrid())) + new EclipseWriter(eclipseState,UgGridHelpers::createEclipseGrid( grid , eclipseState.getInputGrid())) : 0 ), eclipseState_(eclipseState), asyncOutput_() @@ -396,7 +396,7 @@ namespace Opm // gives a dummy dynamic_list_econ_limited DynamicListEconLimited dummy_list_econ_limited; WellsManager wellsmanager(eclipseState_, - eclipseState_->getInitConfig().getRestartStep(), + eclipseState_.getInitConfig().getRestartStep(), Opm::UgGridHelpers::numCells(grid), Opm::UgGridHelpers::globalCell(grid), Opm::UgGridHelpers::cartDims(grid), @@ -416,7 +416,7 @@ namespace Opm const Wells* wells = wellsmanager.c_wells(); wellstate.resize(wells, simulatorstate); //Resize for restart step auto restarted = Opm::init_from_restart_file( - *eclipseState_, + eclipseState_, Opm::UgGridHelpers::numCells(grid) ); solutionToSim( restarted.first, phaseusage, simulatorstate ); @@ -770,8 +770,8 @@ namespace Opm const Model& physicalModel, bool substep) { - const RestartConfig& restartConfig = eclipseState_->getRestartConfig(); - const SummaryConfig& summaryConfig = eclipseState_->getSummaryConfig(); + const RestartConfig& restartConfig = eclipseState_.getRestartConfig(); + const SummaryConfig& summaryConfig = eclipseState_.getSummaryConfig(); const int reportStepNum = timer.reportStepNum(); bool logMessages = output_ && parallelOutput_->isIORank(); diff --git a/opm/autodiff/SimulatorFullyImplicitBlackoilOutputEbos.cpp b/opm/autodiff/SimulatorFullyImplicitBlackoilOutputEbos.cpp index 01c2e686b..e8bb4b498 100644 --- a/opm/autodiff/SimulatorFullyImplicitBlackoilOutputEbos.cpp +++ b/opm/autodiff/SimulatorFullyImplicitBlackoilOutputEbos.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -157,7 +158,7 @@ namespace Opm // ECL output if ( eclWriter_ ) { - const auto& initConfig = eclipseState_->getInitConfig(); + const auto& initConfig = eclipseState_.getInitConfig(); if (initConfig.restartRequested() && ((initConfig.getRestartStep()) == (timer.currentStepNum()))) { std::cout << "Skipping restart write in start of step " << timer.currentStepNum() << std::endl; } else { @@ -273,7 +274,7 @@ namespace Opm bool BlackoilOutputWriterEbos::isRestart() const { - const auto& initconfig = eclipseState_->getInitConfig(); + const auto& initconfig = eclipseState_.getInitConfig(); return initconfig.restartRequested(); } } diff --git a/opm/autodiff/SimulatorFullyImplicitBlackoilOutputEbos.hpp b/opm/autodiff/SimulatorFullyImplicitBlackoilOutputEbos.hpp index 97572226a..42cf45120 100644 --- a/opm/autodiff/SimulatorFullyImplicitBlackoilOutputEbos.hpp +++ b/opm/autodiff/SimulatorFullyImplicitBlackoilOutputEbos.hpp @@ -68,7 +68,7 @@ namespace Opm template BlackoilOutputWriterEbos(const Grid& grid, const parameter::ParameterGroup& param, - Opm::EclipseStateConstPtr eclipseState, + const Opm::EclipseState& eclipseState, const Opm::PhaseUsage &phaseUsage, const double* permeability ); @@ -155,7 +155,7 @@ namespace Opm std::ofstream backupfile_; Opm::PhaseUsage phaseUsage_; std::unique_ptr< EclipseWriter > eclWriter_; - EclipseStateConstPtr eclipseState_; + const EclipseState& eclipseState_; std::unique_ptr< ThreadHandle > asyncOutput_; }; @@ -171,7 +171,7 @@ namespace Opm BlackoilOutputWriterEbos:: BlackoilOutputWriterEbos(const Grid& grid, const parameter::ParameterGroup& param, - Opm::EclipseStateConstPtr eclipseState, + const Opm::EclipseState& eclipseState, const Opm::PhaseUsage &phaseUsage, const double* permeability ) : output_( param.getDefault("output", true) ), @@ -182,7 +182,7 @@ namespace Opm phaseUsage_( phaseUsage ), eclWriter_( output_ && parallelOutput_->isIORank() && param.getDefault("output_ecl", true) ? - new EclipseWriter(eclipseState,UgGridHelpers::createEclipseGrid( grid , *eclipseState->getInputGrid())) + new EclipseWriter(eclipseState,UgGridHelpers::createEclipseGrid( grid , eclipseState.getInputGrid())) : 0 ), eclipseState_(eclipseState), asyncOutput_() @@ -235,7 +235,7 @@ namespace Opm // gives a dummy dynamic_list_econ_limited DynamicListEconLimited dummy_list_econ_limited; WellsManager wellsmanager(eclipseState_, - eclipseState_->getInitConfig().getRestartStep(), + eclipseState_.getInitConfig().getRestartStep(), Opm::UgGridHelpers::numCells(grid), Opm::UgGridHelpers::globalCell(grid), Opm::UgGridHelpers::cartDims(grid), @@ -248,7 +248,7 @@ namespace Opm const Wells* wells = wellsmanager.c_wells(); wellstate.resize(wells, simulatorstate); //Resize for restart step auto restarted = Opm::init_from_restart_file( - *eclipseState_, + eclipseState_, Opm::UgGridHelpers::numCells(grid) ); solutionToSim( restarted.first, phaseusage, simulatorstate ); @@ -538,7 +538,7 @@ namespace Opm const Model& physicalModel, bool substep) { - const RestartConfig& restartConfig = eclipseState_->getRestartConfig(); + const RestartConfig& restartConfig = eclipseState_.getRestartConfig(); const int reportStepNum = timer.reportStepNum(); Opm::data::Solution sol = detail::getOutputDataEbos( phaseUsage_, physicalModel, restartConfig, reportStepNum ); writeTimeStepWithCellProperties(timer, localState, localWellState, sol, substep); diff --git a/opm/autodiff/SimulatorFullyImplicitBlackoilSolvent.hpp b/opm/autodiff/SimulatorFullyImplicitBlackoilSolvent.hpp index a789c5c15..d49158934 100644 --- a/opm/autodiff/SimulatorFullyImplicitBlackoilSolvent.hpp +++ b/opm/autodiff/SimulatorFullyImplicitBlackoilSolvent.hpp @@ -121,7 +121,7 @@ namespace Opm const bool vapoil, std::shared_ptr eclipse_state, BlackoilOutputWriter& output_writer, - Opm::DeckConstPtr& deck, + std::shared_ptr< Deck > deck, const std::vector& threshold_pressures_by_face, const bool solvent); @@ -134,7 +134,7 @@ namespace Opm private: bool has_solvent_; - DeckConstPtr deck_; + std::shared_ptr< Deck > deck_; SolventPropsAdFromDeck solvent_props_; bool is_miscible_; diff --git a/opm/autodiff/SimulatorFullyImplicitBlackoilSolvent_impl.hpp b/opm/autodiff/SimulatorFullyImplicitBlackoilSolvent_impl.hpp index 80fb780b9..de50a72d6 100644 --- a/opm/autodiff/SimulatorFullyImplicitBlackoilSolvent_impl.hpp +++ b/opm/autodiff/SimulatorFullyImplicitBlackoilSolvent_impl.hpp @@ -36,7 +36,7 @@ namespace Opm const bool has_vapoil, std::shared_ptr eclipse_state, BlackoilOutputWriter& output_writer, - Opm::DeckConstPtr& deck, + std::shared_ptr< Deck > deck, const std::vector& threshold_pressures_by_face, const bool has_solvent) : BaseType(param, @@ -105,9 +105,9 @@ namespace Opm std::vector perfcells_fraction(wells->well_connpos[nw], 0.0); size_t currentStep = timer.currentStepNum(); - ScheduleConstPtr schedule = BaseType::eclipse_state_->getSchedule(); + const auto& schedule = BaseType::eclipse_state_->getSchedule(); - for (const auto& well_solvent : schedule->getWells( currentStep )) { + for (const auto& well_solvent : schedule.getWells( currentStep )) { if (well_solvent->getStatus( currentStep ) == WellCommon::SHUT) { continue; } diff --git a/opm/autodiff/SolventPropsAdFromDeck.cpp b/opm/autodiff/SolventPropsAdFromDeck.cpp index c9304e8a6..394f8cdb9 100644 --- a/opm/autodiff/SolventPropsAdFromDeck.cpp +++ b/opm/autodiff/SolventPropsAdFromDeck.cpp @@ -39,20 +39,20 @@ typedef Eigen::DiagonalMatrix D; typedef SolventPropsAdFromDeck::V V; typedef Eigen::Array Block; -SolventPropsAdFromDeck::SolventPropsAdFromDeck(DeckConstPtr deck, - EclipseStateConstPtr eclState, +SolventPropsAdFromDeck::SolventPropsAdFromDeck(const Deck& deck, + const EclipseState& eclState, const int number_of_cells, const int* global_cell) { - if (deck->hasKeyword("SOLVENT")) { + if (deck.hasKeyword("SOLVENT")) { // retrieve the cell specific PVT table index from the deck // and using the grid... extractPvtTableIndex(cellPvtRegionIdx_, eclState, number_of_cells, global_cell); extractTableIndex("SATNUM", eclState, number_of_cells, global_cell, cellSatNumRegionIdx_); // surface densities - if (deck->hasKeyword("SDENSITY")) { - const auto& densityKeyword = deck->getKeyword("SDENSITY"); + if (deck.hasKeyword("SDENSITY")) { + const auto& densityKeyword = deck.getKeyword("SDENSITY"); int numRegions = densityKeyword.size(); solvent_surface_densities_.resize(numRegions); for (int regionIdx = 0; regionIdx < numRegions; ++regionIdx) { @@ -63,7 +63,7 @@ SolventPropsAdFromDeck::SolventPropsAdFromDeck(DeckConstPtr deck, OPM_THROW(std::runtime_error, "SDENSITY must be specified in SOLVENT runs\n"); } - const auto& tables = eclState->getTableManager(); + const auto& tables = eclState.getTableManager(); // pvt const TableContainer& pvdsTables = tables.getPvdsTables(); if (!pvdsTables.empty()) { @@ -123,7 +123,7 @@ SolventPropsAdFromDeck::SolventPropsAdFromDeck(DeckConstPtr deck, } - if (deck->hasKeyword("MISCIBLE") ) { + if (deck.hasKeyword("MISCIBLE") ) { // retrieve the cell specific Misc table index from the deck @@ -254,14 +254,14 @@ SolventPropsAdFromDeck::SolventPropsAdFromDeck(DeckConstPtr deck, } } - if (deck->hasKeyword("TLMIXPAR")) { - const int numRegions = deck->getKeyword("TLMIXPAR").size(); + if (deck.hasKeyword("TLMIXPAR")) { + const int numRegions = deck.getKeyword("TLMIXPAR").size(); // resize the attributes of the object mix_param_viscosity_.resize(numRegions); mix_param_density_.resize(numRegions); for (int regionIdx = 0; regionIdx < numRegions; ++regionIdx) { - const auto& tlmixparRecord = deck->getKeyword("TLMIXPAR").getRecord(regionIdx); + const auto& tlmixparRecord = deck.getKeyword("TLMIXPAR").getRecord(regionIdx); const auto& mix_params_viscosity = tlmixparRecord.getItem("TL_VISCOSITY_PARAMETER").getSIDoubleData(); mix_param_viscosity_[regionIdx] = mix_params_viscosity[0]; const auto& mix_params_density = tlmixparRecord.getItem("TL_DENSITY_PARAMETER").getSIDoubleData(); @@ -276,7 +276,7 @@ SolventPropsAdFromDeck::SolventPropsAdFromDeck(DeckConstPtr deck, } } - if (deck->hasKeyword("TLPMIXPA")) { + if (deck.hasKeyword("TLPMIXPA")) { const TableContainer& tlpmixparTables = tables.getTlpmixpaTables(); if (!tlpmixparTables.empty()) { @@ -492,12 +492,12 @@ ADB SolventPropsAdFromDeck::pressureMixingParameter(const ADB& po, } void SolventPropsAdFromDeck::extractTableIndex(const std::string& keyword, - Opm::EclipseStateConstPtr eclState, + const Opm::EclipseState& eclState, size_t numCompressed, const int* compressedToCartesianCellIdx, std::vector& tableIdx) const { //Get the Region data - const auto& regionData = eclState->get3DProperties().getIntGridProperty(keyword).getData(); + const auto& regionData = eclState.get3DProperties().getIntGridProperty(keyword).getData(); // Convert this into an array of compressed cells // Eclipse uses Fortran-style indices which start at 1 // instead of 0, we subtract 1. diff --git a/opm/autodiff/SolventPropsAdFromDeck.hpp b/opm/autodiff/SolventPropsAdFromDeck.hpp index 0b22361c8..94500e926 100644 --- a/opm/autodiff/SolventPropsAdFromDeck.hpp +++ b/opm/autodiff/SolventPropsAdFromDeck.hpp @@ -37,8 +37,8 @@ namespace Opm class SolventPropsAdFromDeck { public: - SolventPropsAdFromDeck(DeckConstPtr deck, - EclipseStateConstPtr eclipseState, + SolventPropsAdFromDeck(const Deck& deck, + const EclipseState& eclipseState, const int number_of_cells, const int* global_cell); @@ -170,7 +170,7 @@ private: /// \param[in] compressedToCartesianCellIdx cartesianCellIdx for each cell in the grid /// \param[out] tableIdx table index for each compressed cell void extractTableIndex(const std::string& keyword, - Opm::EclipseStateConstPtr eclState, + const Opm::EclipseState& eclState, size_t numCompressed, const int* compressedToCartesianCellIdx, std::vector& tableIdx) const; diff --git a/opm/autodiff/StandardWells.hpp b/opm/autodiff/StandardWells.hpp index 52030526f..0c2792fef 100644 --- a/opm/autodiff/StandardWells.hpp +++ b/opm/autodiff/StandardWells.hpp @@ -185,7 +185,7 @@ namespace Opm { /// upate the dynamic lists related to economic limits template void - updateListEconLimited(ScheduleConstPtr schedule, + updateListEconLimited(const Schedule& schedule, const int current_step, const Wells* wells, const WellState& well_state, diff --git a/opm/autodiff/StandardWellsDense.hpp b/opm/autodiff/StandardWellsDense.hpp index 271982afe..8af6731f9 100644 --- a/opm/autodiff/StandardWellsDense.hpp +++ b/opm/autodiff/StandardWellsDense.hpp @@ -1270,7 +1270,7 @@ namespace Opm { /// upate the dynamic lists related to economic limits template void - updateListEconLimited(ScheduleConstPtr schedule, + updateListEconLimited(const Schedule& schedule, const int current_step, const Wells* wells_struct, const WellState& well_state, @@ -1282,7 +1282,7 @@ namespace Opm { // flag to check if the mim oil/gas rate limit is violated bool rate_limit_violated = false; const std::string& well_name = wells_struct->name[w]; - const Well* well_ecl = schedule->getWell(well_name); + const Well* well_ecl = schedule.getWell(well_name); const WellEconProductionLimits& econ_production_limits = well_ecl->getEconProductionLimits(current_step); // economic limits only apply for production wells. diff --git a/opm/autodiff/StandardWells_impl.hpp b/opm/autodiff/StandardWells_impl.hpp index 719aa97fa..fd2b45a1b 100644 --- a/opm/autodiff/StandardWells_impl.hpp +++ b/opm/autodiff/StandardWells_impl.hpp @@ -1258,7 +1258,7 @@ StandardWells::StandardWells(const Wells* wells_arg) template void StandardWells:: - updateListEconLimited(ScheduleConstPtr schedule, + updateListEconLimited(const Schedule& schedule, const int current_step, const Wells* wells_struct, const WellState& well_state, @@ -1270,7 +1270,7 @@ StandardWells::StandardWells(const Wells* wells_arg) // flag to check if the mim oil/gas rate limit is violated bool rate_limit_violated = false; const std::string& well_name = wells_struct->name[w]; - const Well* well_ecl = schedule->getWell(well_name); + const Well* well_ecl = schedule.getWell(well_name); const WellEconProductionLimits& econ_production_limits = well_ecl->getEconProductionLimits(current_step); // economic limits only apply for production wells. diff --git a/opm/autodiff/WellMultiSegment.cpp b/opm/autodiff/WellMultiSegment.cpp index dcf367306..5e8e4704c 100644 --- a/opm/autodiff/WellMultiSegment.cpp +++ b/opm/autodiff/WellMultiSegment.cpp @@ -38,14 +38,14 @@ namespace Opm void WellMultiSegment::initMultiSegmentWell(const Well* well, size_t time_step, const Wells* wells) { - CompletionSetConstPtr completion_set = well->getCompletions(time_step); + const auto& completion_set = well->getCompletions(time_step); m_is_multi_segment_ = true; - SegmentSetConstPtr segment_set = well->getSegmentSet(time_step); - m_number_of_segments_ = segment_set->numberSegment(); - m_number_of_perforations_ = completion_set->size(); - m_comp_pressure_drop_ = segment_set->compPressureDrop(); - m_multiphase_model_ = segment_set->multiPhaseModel(); + const auto& segment_set = well->getSegmentSet(time_step); + m_number_of_segments_ = segment_set.numberSegment(); + m_number_of_perforations_ = completion_set.size(); + m_comp_pressure_drop_ = segment_set.compPressureDrop(); + m_multiphase_model_ = segment_set.multiPhaseModel(); m_outlet_segment_.resize(m_number_of_segments_); m_inlet_segments_.resize(m_number_of_segments_); @@ -60,13 +60,13 @@ namespace Opm // we change the ID to location now for easier use later. for (int i = 0; i < m_number_of_segments_; ++i) { // The segment number for top segment is 0, the segment number of its outlet segment will be -1 - m_outlet_segment_[i] = segment_set->numberToLocation((*segment_set)[i]->outletSegment()); - m_segment_length_[i] = (*segment_set)[i]->totalLength(); - m_segment_depth_[i] = (*segment_set)[i]->depth(); - m_segment_internal_diameter_[i] = (*segment_set)[i]->internalDiameter(); - m_segment_roughness_[i] = (*segment_set)[i]->roughness(); - m_segment_cross_area_[i] = (*segment_set)[i]->crossArea(); - m_segment_volume_[i] = (*segment_set)[i]->volume(); + m_outlet_segment_[i] = segment_set.numberToLocation(segment_set[i].outletSegment()); + m_segment_length_[i] = segment_set[i].totalLength(); + m_segment_depth_[i] = segment_set[i].depth(); + m_segment_internal_diameter_[i] = segment_set[i].internalDiameter(); + m_segment_roughness_[i] = segment_set[i].roughness(); + m_segment_cross_area_[i] = segment_set[i].crossArea(); + m_segment_volume_[i] = segment_set[i].volume(); } // update the completion related information @@ -107,13 +107,13 @@ namespace Opm std::vector temp_perf_depth; temp_perf_depth.resize(m_number_of_perforations_); - for (int i = 0; i < (int)completion_set->size(); ++i) { - int i_segment = completion_set->get(i)->getSegmentNumber(); + for (int i = 0; i < (int)completion_set.size(); ++i) { + int i_segment = completion_set.get(i).getSegmentNumber(); // using the location of the segment in the array as the segment number/id. // TODO: it can be helpful for output or postprocessing if we can keep the original number. - i_segment = segment_set->numberToLocation(i_segment); + i_segment = segment_set.numberToLocation(i_segment); m_segment_perforations_[i_segment].push_back(i); - temp_perf_depth[i] = completion_set->get(i)->getCenterDepth(); + temp_perf_depth[i] = completion_set.get(i).getCenterDepth(); } // reordering the perforation related informations @@ -171,7 +171,7 @@ namespace Opm void WellMultiSegment::initNonMultiSegmentWell(const Well* well, size_t time_step, const Wells* wells) { - CompletionSetConstPtr completion_set = well->getCompletions(time_step); + const auto& completion_set = well->getCompletions(time_step); m_is_multi_segment_ = false; m_number_of_segments_ = 1; @@ -225,7 +225,7 @@ namespace Opm for (int i = 0; i < m_number_of_perforations_; ++i) { m_segment_perforations_[0][i] = i; - m_perf_depth_[i] = completion_set->get(i)->getCenterDepth(); + m_perf_depth_[i] = completion_set.get(i).getCenterDepth(); } m_inlet_segments_.resize(m_number_of_segments_); diff --git a/opm/polymer/PolymerInflow.cpp b/opm/polymer/PolymerInflow.cpp index 9e1a7b2b4..4fe146e41 100644 --- a/opm/polymer/PolymerInflow.cpp +++ b/opm/polymer/PolymerInflow.cpp @@ -68,11 +68,11 @@ namespace Opm void - PolymerInflowFromDeck::setInflowValues(Opm::EclipseStateConstPtr eclipseState, + PolymerInflowFromDeck::setInflowValues(const Opm::EclipseState& eclipseState, size_t currentStep) { - ScheduleConstPtr schedule = eclipseState->getSchedule(); - for (const auto& well : schedule->getWells(currentStep)) { + const auto& schedule = eclipseState.getSchedule(); + for (const auto& well : schedule.getWells(currentStep)) { WellInjectionProperties injection = well->getInjectionProperties(currentStep); WellPolymerProperties polymer = well->getPolymerProperties(currentStep); if (well->isInjector(currentStep)) { @@ -99,7 +99,7 @@ namespace Opm /// Constructor. /// @param[in] deck Input deck expected to contain WPOLYMER. - PolymerInflowFromDeck::PolymerInflowFromDeck(Opm::EclipseStateConstPtr eclipseState, + PolymerInflowFromDeck::PolymerInflowFromDeck(const Opm::EclipseState& eclipseState, const Wells& wells, const int num_cells, size_t currentStep) diff --git a/opm/polymer/PolymerInflow.hpp b/opm/polymer/PolymerInflow.hpp index b49899da8..094e072ba 100644 --- a/opm/polymer/PolymerInflow.hpp +++ b/opm/polymer/PolymerInflow.hpp @@ -93,7 +93,7 @@ namespace Opm /// \param[in] wells Wells structure. /// \param[in] num_cells Number of cells in grid. /// \param[in] currentStep Number of current simulation step. - PolymerInflowFromDeck(Opm::EclipseStateConstPtr eclipseState, + PolymerInflowFromDeck(const Opm::EclipseState& eclipseState, const Wells& wells, const int num_cells, size_t currentStep); @@ -110,7 +110,7 @@ namespace Opm SparseVector sparse_inflow_; std::unordered_map wellPolymerRate_; - void setInflowValues(Opm::EclipseStateConstPtr eclipseState, + void setInflowValues(const Opm::EclipseState& eclipseState, size_t currentStep); }; diff --git a/opm/polymer/PolymerProperties.hpp b/opm/polymer/PolymerProperties.hpp index 41a0a3857..4553581ae 100644 --- a/opm/polymer/PolymerProperties.hpp +++ b/opm/polymer/PolymerProperties.hpp @@ -92,7 +92,7 @@ namespace Opm { } - PolymerProperties(Opm::DeckConstPtr deck, Opm::EclipseStateConstPtr eclipseState) + PolymerProperties(const Opm::Deck& deck, const Opm::EclipseState& eclipseState) { readFromDeck(deck, eclipseState); } @@ -127,12 +127,12 @@ namespace Opm shear_vrf_vals_ = shear_vrf_vals; } - void readFromDeck(Opm::DeckConstPtr deck, Opm::EclipseStateConstPtr eclipseState) + void readFromDeck(const Opm::Deck& deck, const Opm::EclipseState& eclipseState) { // We assume NTMISC=1 - const auto& tables = eclipseState->getTableManager(); + const auto& tables = eclipseState.getTableManager(); const auto& plymaxTable = tables.getPlymaxTables().getTable(0); - const auto& plmixparRecord = deck->getKeyword("PLMIXPAR").getRecord(0); + const auto& plmixparRecord = deck.getKeyword("PLMIXPAR").getRecord(0); // We also assume that each table has exactly one row... assert(plymaxTable.numRows() == 1); @@ -165,8 +165,8 @@ namespace Opm c_vals_ads_ = plyadsTable.getPolymerConcentrationColumn().vectorCopy( ); ads_vals_ = plyadsTable.getAdsorbedPolymerColumn().vectorCopy( ); - has_plyshlog_ = deck->hasKeyword("PLYSHLOG"); - has_shrate_ = deck->hasKeyword("SHRATE"); + has_plyshlog_ = deck.hasKeyword("PLYSHLOG"); + has_shrate_ = deck.hasKeyword("SHRATE"); if (has_plyshlog_) { // Assuming NTPVT == 1 always @@ -176,11 +176,11 @@ namespace Opm shear_vrf_vals_ = plyshlogTable.getShearMultiplierColumn().vectorCopy( ); // do the unit version here for the water_vel_vals_ - Opm::UnitSystem unitSystem = deck->getActiveUnitSystem(); + Opm::UnitSystem unitSystem = deck.getActiveUnitSystem(); double siFactor; if (has_shrate_) { - siFactor = unitSystem.parse("1/Time")->getSIScaling(); - const auto& shrateKeyword = deck->getKeyword("SHRATE"); + siFactor = unitSystem.parse("1/Time").getSIScaling(); + const auto& shrateKeyword = deck.getKeyword("SHRATE"); std::vector shrate_readin = shrateKeyword.getSIDoubleData(); if (shrate_readin.size() == 1) { shrate_ = shrate_readin[0]; @@ -190,7 +190,7 @@ namespace Opm OPM_THROW(std::logic_error, "Only NTPVT == 1 is allowed for SHRATE keyword now !\n"); } } else { - siFactor = unitSystem.parse("Length/Time")->getSIScaling(); + siFactor = unitSystem.parse("Length/Time").getSIScaling(); } for (size_t i = 0; i < water_vel_vals_.size(); ++i) { diff --git a/opm/polymer/fullyimplicit/BlackoilPolymerModel.hpp b/opm/polymer/fullyimplicit/BlackoilPolymerModel.hpp index fa76bf78b..4076c3d50 100644 --- a/opm/polymer/fullyimplicit/BlackoilPolymerModel.hpp +++ b/opm/polymer/fullyimplicit/BlackoilPolymerModel.hpp @@ -82,7 +82,7 @@ namespace Opm { const PolymerPropsAd& polymer_props_ad, const StandardWells& well_model, const NewtonIterationBlackoilInterface& linsolver, - EclipseStateConstPtr eclipse_state, + std::shared_ptr< const EclipseState > eclipseState, const bool has_disgas, const bool has_vapoil, const bool has_polymer, diff --git a/opm/polymer/fullyimplicit/BlackoilPolymerModel_impl.hpp b/opm/polymer/fullyimplicit/BlackoilPolymerModel_impl.hpp index 32bd0982c..5ccfa441f 100644 --- a/opm/polymer/fullyimplicit/BlackoilPolymerModel_impl.hpp +++ b/opm/polymer/fullyimplicit/BlackoilPolymerModel_impl.hpp @@ -82,7 +82,7 @@ namespace Opm { const PolymerPropsAd& polymer_props_ad, const StandardWells& well_model, const NewtonIterationBlackoilInterface& linsolver, - EclipseStateConstPtr eclipse_state, + std::shared_ptr< const EclipseState > eclipse_state, const bool has_disgas, const bool has_vapoil, const bool has_polymer, diff --git a/opm/polymer/fullyimplicit/SimulatorFullyImplicitBlackoilPolymer.hpp b/opm/polymer/fullyimplicit/SimulatorFullyImplicitBlackoilPolymer.hpp index 1cb3fb510..cb0e21f0c 100644 --- a/opm/polymer/fullyimplicit/SimulatorFullyImplicitBlackoilPolymer.hpp +++ b/opm/polymer/fullyimplicit/SimulatorFullyImplicitBlackoilPolymer.hpp @@ -124,7 +124,7 @@ namespace Opm const bool shrate, std::shared_ptr eclipse_state, BlackoilOutputWriter& output_writer, - Opm::DeckConstPtr& deck, + std::shared_ptr< Deck > deck, const std::vector& threshold_pressures_by_face); std::unique_ptr createSolver(const WellModel& well_model); @@ -143,7 +143,7 @@ namespace Opm bool has_plyshlog_; // flag for SHRATE keyword bool has_shrate_; - DeckConstPtr deck_; + std::shared_ptr< Deck > deck_; std::vector wells_rep_radius_; std::vector wells_perf_length_; @@ -158,7 +158,7 @@ namespace Opm // and store the wellbore diameters // it will be used in the shear-thinning calcluation only. void - computeRepRadiusPerfLength(const Opm::EclipseStateConstPtr eclipseState, + computeRepRadiusPerfLength(const EclipseState& eclipseState, const size_t timeStep, const GridT& grid, std::vector& wells_rep_radius, diff --git a/opm/polymer/fullyimplicit/SimulatorFullyImplicitBlackoilPolymer_impl.hpp b/opm/polymer/fullyimplicit/SimulatorFullyImplicitBlackoilPolymer_impl.hpp index ff8c1bf4e..30f28d858 100644 --- a/opm/polymer/fullyimplicit/SimulatorFullyImplicitBlackoilPolymer_impl.hpp +++ b/opm/polymer/fullyimplicit/SimulatorFullyImplicitBlackoilPolymer_impl.hpp @@ -38,7 +38,7 @@ namespace Opm const bool has_shrate, std::shared_ptr eclipse_state, BlackoilOutputWriter& output_writer, - Opm::DeckConstPtr& deck, + std::shared_ptr< Deck > deck, const std::vector& threshold_pressures_by_face) : BaseType(param, grid, @@ -112,7 +112,7 @@ namespace Opm if (wells_manager.c_wells() == 0) { OPM_THROW(std::runtime_error, "Cannot control polymer injection via WPOLYMER without wells."); } - polymer_inflow_ptr.reset(new PolymerInflowFromDeck(BaseType::eclipse_state_, *wells, Opm::UgGridHelpers::numCells(BaseType::grid_), timer.currentStepNum())); + polymer_inflow_ptr.reset(new PolymerInflowFromDeck(*BaseType::eclipse_state_, *wells, Opm::UgGridHelpers::numCells(BaseType::grid_), timer.currentStepNum())); } else { OPM_MESSAGE("Warning: simulating with no WPOLYMER in deck (no polymer will be injected)."); polymer_inflow_ptr.reset(new PolymerInflowBasic(0.0*Opm::unit::day, @@ -126,7 +126,7 @@ namespace Opm well_state.polymerInflow() = polymer_inflow_c; if (has_plyshlog_) { - computeRepRadiusPerfLength(BaseType::eclipse_state_, timer.currentStepNum(), BaseType::grid_, wells_rep_radius_, wells_perf_length_, wells_bore_diameter_); + computeRepRadiusPerfLength(*BaseType::eclipse_state_, timer.currentStepNum(), BaseType::grid_, wells_rep_radius_, wells_perf_length_, wells_bore_diameter_); } } @@ -152,7 +152,7 @@ namespace Opm template void SimulatorFullyImplicitBlackoilPolymer:: - computeRepRadiusPerfLength(const Opm::EclipseStateConstPtr eclipseState, + computeRepRadiusPerfLength(const Opm::EclipseState& eclipseState, const size_t timeStep, const GridT& grid, std::vector& wells_rep_radius, @@ -168,7 +168,7 @@ namespace Opm auto cell_to_faces = Opm::UgGridHelpers::cell2Faces(grid); auto begin_face_centroids = Opm::UgGridHelpers::beginFaceCentroids(grid); - if (eclipseState->getSchedule()->numWells() == 0) { + if (eclipseState.getSchedule().numWells() == 0) { OPM_MESSAGE("No wells specified in Schedule section, " "initializing no wells"); return; @@ -189,8 +189,8 @@ namespace Opm setupCompressedToCartesian(global_cell, number_of_cells, cartesian_to_compressed); - ScheduleConstPtr schedule = eclipseState->getSchedule(); - auto wells = schedule->getWells(timeStep); + const auto& schedule = eclipseState.getSchedule(); + auto wells = schedule.getWells(timeStep); int well_index = 0; @@ -201,13 +201,13 @@ namespace Opm continue; } { // COMPDAT handling - CompletionSetConstPtr completionSet = well->getCompletions(timeStep); - for (size_t c=0; csize(); c++) { - CompletionConstPtr completion = completionSet->get(c); - if (completion->getState() == WellCompletion::OPEN) { - int i = completion->getI(); - int j = completion->getJ(); - int k = completion->getK(); + const auto& completionSet = well->getCompletions(timeStep); + for (size_t c=0; csecond; { - double radius = 0.5*completion->getDiameter(); + double radius = 0.5*completion.getDiameter(); if (radius <= 0.0) { radius = 0.5*unit::feet; OPM_MESSAGE("**** Warning: Well bore internal radius set to " << radius); @@ -228,7 +228,7 @@ namespace Opm const std::array cubical = WellsManagerDetail::getCubeDim<3>(cell_to_faces, begin_face_centroids, cell); - WellCompletion::DirectionEnum direction = completion->getDirection(); + WellCompletion::DirectionEnum direction = completion.getDirection(); double re; // area equivalent radius of the grid block double perf_length; // the length of the well perforation @@ -256,8 +256,8 @@ namespace Opm wells_bore_diameter.push_back(2. * radius); } } else { - if (completion->getState() != WellCompletion::SHUT) { - OPM_THROW(std::runtime_error, "Completion state: " << WellCompletion::StateEnum2String( completion->getState() ) << " not handled"); + if (completion.getState() != WellCompletion::SHUT) { + OPM_THROW(std::runtime_error, "Completion state: " << WellCompletion::StateEnum2String( completion.getState() ) << " not handled"); } } diff --git a/opm/polymer/fullyimplicit/SimulatorFullyImplicitCompressiblePolymer.hpp b/opm/polymer/fullyimplicit/SimulatorFullyImplicitCompressiblePolymer.hpp index 011c1c4e1..af9755e1d 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, - Opm::DeckConstPtr& deck, + std::shared_ptr< const Deck > deck, NewtonIterationBlackoilInterface& linsolver, const double* gravity); @@ -121,13 +121,13 @@ namespace Opm const Wells* wells); void updateListEconLimited(const std::unique_ptr& solver, - ScheduleConstPtr schedule, + const Schedule& schedule, const int current_step, const Wells* wells, const WellState& well_state, DynamicListEconLimited& list_econ_limited) const; private: - Opm::DeckConstPtr deck_; + std::shared_ptr< const Deck > deck_; const PolymerPropsAd& polymer_props_; }; diff --git a/opm/polymer/fullyimplicit/SimulatorFullyImplicitCompressiblePolymer_impl.hpp b/opm/polymer/fullyimplicit/SimulatorFullyImplicitCompressiblePolymer_impl.hpp index c817cc473..890c848e9 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, - Opm::DeckConstPtr& deck, + std::shared_ptr< const Deck > deck, NewtonIterationBlackoilInterface& linsolver, const double* gravity) : BaseType(param, @@ -86,7 +86,7 @@ handleAdditionalWellInflow(SimulatorTimer& timer, if (wells_manager.c_wells() == 0) { OPM_THROW(std::runtime_error, "Cannot control polymer injection via WPOLYMER without wells."); } - polymer_inflow_ptr.reset(new PolymerInflowFromDeck( BaseType::eclipse_state_, *wells, Opm::UgGridHelpers::numCells(BaseType::grid_), timer.currentStepNum())); + polymer_inflow_ptr.reset(new PolymerInflowFromDeck( *BaseType::eclipse_state_, *wells, Opm::UgGridHelpers::numCells(BaseType::grid_), timer.currentStepNum())); } else { polymer_inflow_ptr.reset(new PolymerInflowBasic(0.0*Opm::unit::day, 1.0*Opm::unit::day, @@ -107,7 +107,7 @@ template void SimulatorFullyImplicitCompressiblePolymer:: updateListEconLimited(const std::unique_ptr& /*solver*/, - ScheduleConstPtr /*schedule*/, + const Schedule& /*schedule*/, const int /*current_step*/, const Wells* /*wells*/, const WellState& /*well_state*/, diff --git a/opm/simulators/thresholdPressures.hpp b/opm/simulators/thresholdPressures.hpp index 6c7b5ff09..ac6d42275 100644 --- a/opm/simulators/thresholdPressures.hpp +++ b/opm/simulators/thresholdPressures.hpp @@ -45,8 +45,8 @@ namespace Opm /// \param[in] gravity The gravity constant template void computeMaxDp(std::map, double>& maxDp, - const DeckConstPtr& deck, - EclipseStateConstPtr eclipseState, + const Deck& deck, + const EclipseState& eclipseState, const Grid& grid, const BlackoilState& initialState, const BlackoilPropertiesFromDeck& props, @@ -55,12 +55,12 @@ void computeMaxDp(std::map, double>& maxDp, const PhaseUsage& pu = props.phaseUsage(); - const auto& eqlnum = eclipseState->get3DProperties().getIntGridProperty("EQLNUM"); + const auto& eqlnum = eclipseState.get3DProperties().getIntGridProperty("EQLNUM"); const auto& eqlnumData = eqlnum.getData(); const int numPhases = initialState.numPhases(); const int numCells = UgGridHelpers::numCells(grid); - const int numPvtRegions = deck->getKeyword("TABDIMS").getRecord(0).getItem("NTPVT").get< int >(0); + const int numPvtRegions = deck.getKeyword("TABDIMS").getRecord(0).getItem("NTPVT").get< int >(0); // retrieve the minimum (residual!?) and the maximum saturations for all cells std::vector minSat(numPhases*numCells); @@ -73,7 +73,7 @@ void computeMaxDp(std::map, double>& maxDp, // retrieve the surface densities std::vector > surfaceDensity(numPvtRegions); - const auto& densityKw = deck->getKeyword("DENSITY"); + const auto& densityKw = deck.getKeyword("DENSITY"); for (int regionIdx = 0; regionIdx < numPvtRegions; ++regionIdx) { surfaceDensity[regionIdx].resize(numPhases); @@ -100,7 +100,7 @@ void computeMaxDp(std::map, double>& maxDp, // Fortran indices. const int* gc = UgGridHelpers::globalCell(grid); std::vector pvtRegion(numCells); - const auto& cartPvtRegion = eclipseState->get3DProperties().getIntGridProperty("PVTNUM").getData(); + const auto& cartPvtRegion = eclipseState.get3DProperties().getIntGridProperty("PVTNUM").getData(); for (int cellIdx = 0; cellIdx < numCells; ++cellIdx) { const int cartCellIdx = gc ? gc[cellIdx] : cellIdx; pvtRegion[cellIdx] = std::max(0, cartPvtRegion[cartCellIdx] - 1); @@ -318,16 +318,16 @@ void computeMaxDp(std::map, double>& maxDp, template - std::vector thresholdPressures(const DeckConstPtr& /* deck */, - EclipseStateConstPtr eclipseState, + std::vector thresholdPressures(const Deck& /* deck */, + const EclipseState& eclipseState, const Grid& grid, const std::map, double>& maxDp) { - const SimulationConfig& simulationConfig = eclipseState->getSimulationConfig(); + const SimulationConfig& simulationConfig = eclipseState.getSimulationConfig(); std::vector thpres_vals; if (simulationConfig.hasThresholdPressure()) { - std::shared_ptr thresholdPressure = simulationConfig.getThresholdPressure(); - const auto& eqlnum = eclipseState->get3DProperties().getIntGridProperty("EQLNUM"); + const ThresholdPressure& thresholdPressure = simulationConfig.getThresholdPressure(); + const auto& eqlnum = eclipseState.get3DProperties().getIntGridProperty("EQLNUM"); const auto& eqlnumData = eqlnum.getData(); // Set threshold pressure values for each cell face. @@ -347,9 +347,9 @@ void computeMaxDp(std::map, double>& maxDp, const int eq1 = eqlnumData[gc1]; const int eq2 = eqlnumData[gc2]; - if (thresholdPressure->hasRegionBarrier(eq1,eq2)) { - if (thresholdPressure->hasThresholdPressure(eq1,eq2)) { - thpres_vals[face] = thresholdPressure->getThresholdPressure(eq1,eq2); + if (thresholdPressure.hasRegionBarrier(eq1,eq2)) { + if (thresholdPressure.hasThresholdPressure(eq1,eq2)) { + thpres_vals[face] = thresholdPressure.getThresholdPressure(eq1,eq2); } else { // set the threshold pressure for faces of PVT regions where the third item @@ -380,15 +380,15 @@ void computeMaxDp(std::map, double>& maxDp, /// particular connection. An empty vector is /// returned if there is no THPRES /// feature used in the deck. - std::vector thresholdPressuresNNC(EclipseStateConstPtr eclipseState, + std::vector thresholdPressuresNNC(const EclipseState& eclipseState, const NNC& nnc, const std::map, double>& maxDp) { - const SimulationConfig& simulationConfig = eclipseState->getSimulationConfig(); + const SimulationConfig& simulationConfig = eclipseState.getSimulationConfig(); std::vector thpres_vals; if (simulationConfig.hasThresholdPressure()) { - std::shared_ptr thresholdPressure = simulationConfig.getThresholdPressure(); - const auto& eqlnum = eclipseState->get3DProperties().getIntGridProperty("EQLNUM"); + const ThresholdPressure& thresholdPressure = simulationConfig.getThresholdPressure(); + const auto& eqlnum = eclipseState.get3DProperties().getIntGridProperty("EQLNUM"); const auto& eqlnumData = eqlnum.getData(); // Set values for each NNC @@ -400,9 +400,9 @@ void computeMaxDp(std::map, double>& maxDp, const int eq1 = eqlnumData[gc1]; const int eq2 = eqlnumData[gc2]; - if (thresholdPressure->hasRegionBarrier(eq1,eq2)) { - if (thresholdPressure->hasThresholdPressure(eq1,eq2)) { - thpres_vals[i] = thresholdPressure->getThresholdPressure(eq1,eq2); + if (thresholdPressure.hasRegionBarrier(eq1,eq2)) { + if (thresholdPressure.hasThresholdPressure(eq1,eq2)) { + thpres_vals[i] = thresholdPressure.getThresholdPressure(eq1,eq2); } else { // set the threshold pressure for NNC of PVT regions where the third item // has been defaulted to the maximum pressure potential difference between diff --git a/tests/test_boprops_ad.cpp b/tests/test_boprops_ad.cpp index 64fa259bd..a59dccf1f 100644 --- a/tests/test_boprops_ad.cpp +++ b/tests/test_boprops_ad.cpp @@ -46,13 +46,10 @@ struct SetupSimple { - SetupSimple() + SetupSimple() : + deck( Opm::Parser{}.parseFile("fluid.data") ), + eclState( deck, Opm::ParseContext() ) { - Opm::ParseContext parseContext; - Opm::ParserPtr parser(new Opm::Parser()); - deck = parser->parseFile("fluid.data", parseContext); - eclState.reset(new Opm::EclipseState(*deck , parseContext)); - param.disableOutput(); param.insertParameter("init_rock" , "false" ); param.insertParameter("threephase_model", "simple"); @@ -61,8 +58,8 @@ struct SetupSimple { } Opm::parameter::ParameterGroup param; - Opm::DeckConstPtr deck; - Opm::EclipseStateConstPtr eclState; + Opm::Deck deck; + Opm::EclipseState eclState; }; @@ -71,7 +68,7 @@ struct TestFixture : public Setup { TestFixture() : Setup() - , grid (*eclState->getInputGrid()) + , grid (eclState.getInputGrid()) , boprops_ad(deck, eclState, *grid.c_grid(), param.getDefault("init_rock", false)) { } @@ -89,7 +86,7 @@ struct TestFixtureAd : public Setup { TestFixtureAd() : Setup() - , grid (*eclState->getInputGrid()) + , grid (eclState.getInputGrid()) , props(deck, eclState, *grid.c_grid(), param.getDefault("init_rock", false)) { diff --git a/tests/test_multisegmentwells.cpp b/tests/test_multisegmentwells.cpp index 6483635ff..6e1fe9947 100644 --- a/tests/test_multisegmentwells.cpp +++ b/tests/test_multisegmentwells.cpp @@ -72,13 +72,13 @@ struct SetupMSW { SetupMSW() { Opm::ParseContext parse_context; - Opm::ParserPtr parser(new Opm::Parser()); - Opm::DeckConstPtr deck = parser->parseFile("msw.data", parse_context); - Opm::EclipseStateConstPtr ecl_state(new Opm::EclipseState(*deck , parse_context)); + Opm::Parser parser; + auto deck = parser.parseFile("msw.data", parse_context); + Opm::EclipseState ecl_state(deck , parse_context); // Create grid. const std::vector& porv = - ecl_state->get3DProperties().getDoubleGridProperty("PORV").getData(); + ecl_state.get3DProperties().getDoubleGridProperty("PORV").getData(); std::unique_ptr grid_init(new GridInit(ecl_state, porv)); const Grid& grid = grid_init->grid(); @@ -117,7 +117,7 @@ struct SetupMSW { std::unordered_set()); const Wells* wells = wells_manager.c_wells(); - const auto wells_ecl = ecl_state->getSchedule()->getWells(current_timestep); + const auto wells_ecl = ecl_state.getSchedule().getWells(current_timestep); ms_wells.reset(new Opm::MultisegmentWells(wells, wells_ecl, current_timestep)); }; diff --git a/tests/test_rateconverter.cpp b/tests/test_rateconverter.cpp index a7c3c87da..16015977b 100644 --- a/tests/test_rateconverter.cpp +++ b/tests/test_rateconverter.cpp @@ -46,13 +46,10 @@ struct SetupSimple { - SetupSimple() + SetupSimple() : + deck( Opm::Parser{}.parseFile( "fluid.data" ) ), + eclState( deck, Opm::ParseContext() ) { - Opm::ParserPtr parser(new Opm::Parser()); - Opm::ParseContext parseContext; - deck = parser->parseFile("fluid.data" , parseContext); - eclState.reset(new Opm::EclipseState(*deck , parseContext)); - param.disableOutput(); param.insertParameter("init_rock" , "false" ); param.insertParameter("threephase_model", "simple"); @@ -61,8 +58,8 @@ struct SetupSimple { } Opm::parameter::ParameterGroup param; - Opm::DeckConstPtr deck; - Opm::EclipseStateConstPtr eclState; + Opm::Deck deck; + Opm::EclipseState eclState; }; @@ -71,7 +68,7 @@ struct TestFixture : public Setup { TestFixture() : Setup() - , grid (*eclState->getInputGrid()) + , grid (eclState.getInputGrid()) , ad_props(deck, eclState, *grid.c_grid(), param.getDefault("init_rock", false)) { } diff --git a/tests/test_solventprops_ad.cpp b/tests/test_solventprops_ad.cpp index 23bc72ef4..f66568453 100644 --- a/tests/test_solventprops_ad.cpp +++ b/tests/test_solventprops_ad.cpp @@ -91,10 +91,9 @@ SOF2 \n\ BOOST_AUTO_TEST_CASE(Construction) { Opm::ParseContext parseContext; - Opm::ParserPtr parser(new Opm::Parser()); - Opm::DeckPtr deck = parser->parseString(deckData + solventData, parseContext); - Opm::EclipseStateConstPtr eclState; - eclState.reset(new Opm::EclipseState(*deck , parseContext)); + Opm::Parser parser; + auto deck = parser.parseString(deckData + solventData, parseContext); + Opm::EclipseState eclState(deck , parseContext); std::vector global_ind = {0 , 1 , 2}; Opm::SolventPropsAdFromDeck solventprops(deck, eclState, 3, global_ind.data()); } @@ -102,10 +101,9 @@ BOOST_AUTO_TEST_CASE(Construction) BOOST_AUTO_TEST_CASE(SolventData) { Opm::ParseContext parseContext; - Opm::ParserPtr parser(new Opm::Parser()); - Opm::DeckPtr deck = parser->parseString(deckData + solventData, parseContext); - Opm::EclipseStateConstPtr eclState; - eclState.reset(new Opm::EclipseState(*deck , parseContext)); + Opm::Parser parser; + auto deck = parser.parseString(deckData + solventData, parseContext); + Opm::EclipseState eclState(deck , parseContext); std::vector global_ind = {0 , 1 , 2}; Opm::SolventPropsAdFromDeck solventprops(deck, eclState, 3, global_ind.data()); @@ -128,10 +126,9 @@ PMISC\n\ BOOST_AUTO_TEST_CASE(PMISC) { Opm::ParseContext parseContext; - Opm::ParserPtr parser(new Opm::Parser()); - Opm::DeckPtr deck = parser->parseString(deckData + solventData + pmiscData, parseContext); - Opm::EclipseStateConstPtr eclState; - eclState.reset(new Opm::EclipseState(*deck , parseContext)); + Opm::Parser parser; + auto deck = parser.parseString(deckData + solventData + pmiscData, parseContext); + Opm::EclipseState eclState(deck , parseContext); const Opm::SolventPropsAdFromDeck::Cells cells(3, 0); typedef Opm::SolventPropsAdFromDeck::V V; std::vector global_ind = {0 , 1 , 2}; @@ -161,10 +158,9 @@ TLPMIXPA\n\ BOOST_AUTO_TEST_CASE(TLPMIXPA) { Opm::ParseContext parseContext; - Opm::ParserPtr parser(new Opm::Parser()); - Opm::DeckPtr deck = parser->parseString(deckData + solventData + tlpmixpaData, parseContext); - Opm::EclipseStateConstPtr eclState; - eclState.reset(new Opm::EclipseState(*deck , parseContext)); + Opm::Parser parser; + auto deck = parser.parseString(deckData + solventData + tlpmixpaData, parseContext); + Opm::EclipseState eclState(deck , parseContext); const Opm::SolventPropsAdFromDeck::Cells cells(3, 0); typedef Opm::SolventPropsAdFromDeck::V V; const int* global_ind = new int[3] {0 , 1 , 2}; @@ -185,11 +181,10 @@ BOOST_AUTO_TEST_CASE(TLPMIXPA) BOOST_AUTO_TEST_CASE(TLPMIXPA_NOT_SPECIFIED) { Opm::ParseContext parseContext; - Opm::ParserPtr parser(new Opm::Parser()); + Opm::Parser parser; // no pmisc data and default tlpmixdata i.e it should throw - Opm::DeckPtr deck = parser->parseString(deckData + solventData, parseContext); - Opm::EclipseStateConstPtr eclState; - eclState.reset(new Opm::EclipseState(*deck , parseContext)); + auto deck = parser.parseString(deckData + solventData, parseContext); + Opm::EclipseState eclState(deck , parseContext); const Opm::SolventPropsAdFromDeck::Cells cells(3, 0); const int* global_ind = new int[3] {0 , 1 , 2}; Opm::SolventPropsAdFromDeck solventprops(deck, eclState, 3, global_ind); @@ -215,10 +210,9 @@ TLPMIXPA\n\ BOOST_AUTO_TEST_CASE(TLPMIXPA_DEFAULT) { Opm::ParseContext parseContext; - Opm::ParserPtr parser(new Opm::Parser()); - Opm::DeckPtr deck = parser->parseString(deckData + solventData + pmiscData + tlpmixpaDataDefault, parseContext); - Opm::EclipseStateConstPtr eclState; - eclState.reset(new Opm::EclipseState(*deck , parseContext)); + Opm::Parser parser; + auto deck = parser.parseString(deckData + solventData + pmiscData + tlpmixpaDataDefault, parseContext); + Opm::EclipseState eclState(deck , parseContext); const Opm::SolventPropsAdFromDeck::Cells cells(3, 0); typedef Opm::SolventPropsAdFromDeck::V V; const int* global_ind = new int[3] {0 , 1 , 2}; @@ -239,11 +233,10 @@ BOOST_AUTO_TEST_CASE(TLPMIXPA_DEFAULT) BOOST_AUTO_TEST_CASE(TLPMIXPA_DEFAULT_NOPMISC) { Opm::ParseContext parseContext; - Opm::ParserPtr parser(new Opm::Parser()); + Opm::Parser parser; // no pmisc data and default tlpmixdata i.e it should throw - Opm::DeckPtr deck = parser->parseString(deckData + solventData + tlpmixpaDataDefault, parseContext); - Opm::EclipseStateConstPtr eclState; - eclState.reset(new Opm::EclipseState(*deck , parseContext)); + auto deck = parser.parseString(deckData + solventData + tlpmixpaDataDefault, parseContext); + Opm::EclipseState eclState(deck , parseContext); const Opm::SolventPropsAdFromDeck::Cells cells(3, 0); const int* global_ind = new int[3] {0 , 1 , 2}; BOOST_CHECK_THROW(Opm::SolventPropsAdFromDeck solventprops(deck, eclState, 3, global_ind), std::invalid_argument); diff --git a/tests/test_transmissibilitymultipliers.cpp b/tests/test_transmissibilitymultipliers.cpp index 6b71ceeac..f56a06613 100644 --- a/tests/test_transmissibilitymultipliers.cpp +++ b/tests/test_transmissibilitymultipliers.cpp @@ -157,15 +157,15 @@ void checkTransmissibilityValues(const G& grid, BOOST_AUTO_TEST_CASE(TransmissibilityMultipliersLegacyGridInterface) { Opm::parameter::ParameterGroup param; - Opm::ParserPtr parser(new Opm::Parser() ); + Opm::Parser parser; Opm::ParseContext parseContext; ///// // create a DerivedGeology object without any multipliers involved - Opm::DeckConstPtr origDeck = parser->parseString(origDeckString, parseContext); - Opm::EclipseStateConstPtr origEclipseState(new Opm::EclipseState(*origDeck , parseContext)); + auto origDeck = parser.parseString(origDeckString, parseContext); + Opm::EclipseState origEclipseState(origDeck , parseContext); - auto origGridManager = std::make_shared(*origEclipseState->getInputGrid()); + auto origGridManager = std::make_shared(origEclipseState.getInputGrid()); auto origProps = std::make_shared(origDeck, origEclipseState, *(origGridManager->c_grid())); Opm::DerivedGeology origGeology(*(origGridManager->c_grid()), *origProps, origEclipseState, false); @@ -173,10 +173,10 @@ BOOST_AUTO_TEST_CASE(TransmissibilityMultipliersLegacyGridInterface) ///// // create a DerivedGeology object _with_ transmissibility multipliers involved - Opm::DeckConstPtr multDeck = parser->parseString(multDeckString, parseContext); - Opm::EclipseStateConstPtr multEclipseState(new Opm::EclipseState(*multDeck, parseContext)); + auto multDeck = parser.parseString(multDeckString, parseContext); + Opm::EclipseState multEclipseState(multDeck, parseContext); - auto multGridManager = std::make_shared(*multEclipseState->getInputGrid()); + auto multGridManager = std::make_shared(multEclipseState.getInputGrid()); auto multProps = std::make_shared(multDeck, multEclipseState, *(multGridManager->c_grid())); Opm::DerivedGeology multGeology(*(multGridManager->c_grid()), *multProps, multEclipseState, false); @@ -185,10 +185,10 @@ BOOST_AUTO_TEST_CASE(TransmissibilityMultipliersLegacyGridInterface) ///// // create a DerivedGeology object _with_ transmissibility multipliers involved for // the negative faces - Opm::DeckConstPtr multMinusDeck = parser->parseString(multMinusDeckString, parseContext); - Opm::EclipseStateConstPtr multMinusEclipseState(new Opm::EclipseState(*multMinusDeck , parseContext)); + auto multMinusDeck = parser.parseString(multMinusDeckString, parseContext); + Opm::EclipseState multMinusEclipseState(multMinusDeck , parseContext); - auto multMinusGridManager = std::make_shared(*multMinusEclipseState->getInputGrid()); + auto multMinusGridManager = std::make_shared(multMinusEclipseState.getInputGrid()); auto multMinusProps = std::make_shared(multMinusDeck, multMinusEclipseState, *(multMinusGridManager->c_grid())); Opm::DerivedGeology multMinusGeology(*(multMinusGridManager->c_grid()), *multMinusProps, multMinusEclipseState, false); @@ -196,10 +196,10 @@ BOOST_AUTO_TEST_CASE(TransmissibilityMultipliersLegacyGridInterface) ///// // create a DerivedGeology object with the NTG keyword involved - Opm::DeckConstPtr ntgDeck = parser->parseString(ntgDeckString, parseContext); - Opm::EclipseStateConstPtr ntgEclipseState(new Opm::EclipseState(*ntgDeck, parseContext)); + auto ntgDeck = parser.parseString(ntgDeckString, parseContext); + Opm::EclipseState ntgEclipseState(ntgDeck, parseContext); - auto ntgGridManager = std::make_shared(*ntgEclipseState->getInputGrid()); + auto ntgGridManager = std::make_shared(ntgEclipseState.getInputGrid()); auto ntgProps = std::make_shared(ntgDeck, ntgEclipseState, *(ntgGridManager->c_grid())); Opm::DerivedGeology ntgGeology(*(ntgGridManager->c_grid()), *ntgProps, ntgEclipseState, false); @@ -272,16 +272,16 @@ BOOST_AUTO_TEST_CASE(TransmissibilityMultipliersCpGrid) Dune::MPIHelper::instance(argc, argv); Opm::parameter::ParameterGroup param; - Opm::ParserPtr parser(new Opm::Parser() ); + Opm::Parser parser; Opm::ParseContext parseContext; ///// // create a DerivedGeology object without any multipliers involved - Opm::DeckConstPtr origDeck = parser->parseString(origDeckString , parseContext); - Opm::EclipseStateConstPtr origEclipseState(new Opm::EclipseState(*origDeck , parseContext)); + auto origDeck = parser.parseString(origDeckString , parseContext); + Opm::EclipseState origEclipseState(origDeck , parseContext); auto origGrid = std::make_shared(); - origGrid->processEclipseFormat(*origEclipseState->getInputGrid(), 0.0, false); + origGrid->processEclipseFormat(origEclipseState.getInputGrid(), 0.0, false); auto origProps = std::make_shared(origDeck, origEclipseState, @@ -292,11 +292,11 @@ BOOST_AUTO_TEST_CASE(TransmissibilityMultipliersCpGrid) ///// // create a DerivedGeology object _with_ transmissibility multipliers involved - Opm::DeckConstPtr multDeck = parser->parseString(multDeckString,parseContext); - Opm::EclipseStateConstPtr multEclipseState(new Opm::EclipseState(*multDeck, parseContext)); + auto multDeck = parser.parseString(multDeckString,parseContext); + Opm::EclipseState multEclipseState(multDeck, parseContext); auto multGrid = std::make_shared(); - multGrid->processEclipseFormat(*multEclipseState->getInputGrid(), 0.0, false); + multGrid->processEclipseFormat(multEclipseState.getInputGrid(), 0.0, false); auto multProps = std::make_shared(multDeck, multEclipseState, *multGrid); @@ -306,11 +306,11 @@ BOOST_AUTO_TEST_CASE(TransmissibilityMultipliersCpGrid) ///// // create a DerivedGeology object _with_ transmissibility multipliers involved for // the negative faces - Opm::DeckConstPtr multMinusDeck = parser->parseString(multMinusDeckString , parseContext); - Opm::EclipseStateConstPtr multMinusEclipseState(new Opm::EclipseState(*multMinusDeck, parseContext)); + const auto& multMinusDeck = parser.parseString(multMinusDeckString , parseContext); + Opm::EclipseState multMinusEclipseState(multMinusDeck, parseContext); auto multMinusGrid = std::make_shared(); - multMinusGrid->processEclipseFormat(*multMinusEclipseState->getInputGrid(), 0.0, false); + multMinusGrid->processEclipseFormat(multMinusEclipseState.getInputGrid(), 0.0, false); auto multMinusProps = std::make_shared(multMinusDeck, multMinusEclipseState, *multMinusGrid); @@ -320,11 +320,11 @@ BOOST_AUTO_TEST_CASE(TransmissibilityMultipliersCpGrid) ///// // create a DerivedGeology object with the NTG keyword involved - Opm::DeckConstPtr ntgDeck = parser->parseString(ntgDeckString, parseContext); - Opm::EclipseStateConstPtr ntgEclipseState(new Opm::EclipseState(*ntgDeck, parseContext)); + auto ntgDeck = parser.parseString(ntgDeckString, parseContext); + Opm::EclipseState ntgEclipseState(ntgDeck, parseContext); auto ntgGrid = std::make_shared(); - ntgGrid->processEclipseFormat(*ntgEclipseState->getInputGrid(), 0.0, false); + ntgGrid->processEclipseFormat(ntgEclipseState.getInputGrid(), 0.0, false); auto ntgProps = std::make_shared(ntgDeck, ntgEclipseState, *ntgGrid); diff --git a/tests/test_vfpproperties.cpp b/tests/test_vfpproperties.cpp index e8e1d9415..7b17d1e66 100644 --- a/tests/test_vfpproperties.cpp +++ b/tests/test_vfpproperties.cpp @@ -1043,18 +1043,16 @@ VFPPROD \n\ 2 1 1 1 1.0 / \n\ "; - Opm::DeckConstPtr deck; - std::shared_ptr units(Opm::UnitSystem::newFIELD()); - - Opm::ParserPtr parser(new Opm::Parser()); + auto units = Opm::UnitSystem::newFIELD(); + Opm::Parser parser; Opm::ParseContext parse_mode; - deck = parser->parseString(table_str, parse_mode); + auto deck = parser.parseString(table_str, parse_mode); - BOOST_REQUIRE(deck->hasKeyword("VFPPROD")); - BOOST_CHECK_EQUAL(deck->count("VFPPROD"), 1); + BOOST_REQUIRE(deck.hasKeyword("VFPPROD")); + BOOST_CHECK_EQUAL(deck.count("VFPPROD"), 1); Opm::VFPProdTable table; - table.init(deck->getKeyword("VFPPROD", 0), *units); + table.init(deck.getKeyword("VFPPROD", 0), units); Opm::VFPProdProperties properties(&table); @@ -1104,21 +1102,20 @@ VFPPROD \n\ */ BOOST_AUTO_TEST_CASE(ParseInterpolateRealisticVFPPROD) { - Opm::DeckConstPtr deck; - std::shared_ptr units(Opm::UnitSystem::newMETRIC()); + auto units = Opm::UnitSystem::newMETRIC(); - Opm::ParserPtr parser(new Opm::Parser()); + Opm::Parser parser; Opm::ParseContext parse_mode; boost::filesystem::path file("VFPPROD2"); - deck = parser->parseFile(file.string(), parse_mode); + auto deck = parser.parseFile(file.string(), parse_mode); Opm::checkDeck(deck, parser); - BOOST_REQUIRE(deck->hasKeyword("VFPPROD")); - BOOST_CHECK_EQUAL(deck->count("VFPPROD"), 1); + BOOST_REQUIRE(deck.hasKeyword("VFPPROD")); + BOOST_CHECK_EQUAL(deck.count("VFPPROD"), 1); Opm::VFPProdTable table; - table.init(deck->getKeyword("VFPPROD", 0), *units); + table.init(deck.getKeyword("VFPPROD", 0), units); Opm::VFPProdProperties properties(&table);