From a0aa7fcc2b04bb6e0e233c396349344f428d47f5 Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Wed, 29 May 2019 07:44:23 +0200 Subject: [PATCH 1/3] Use shared SummaryState when instantiating WellsManager --- opm/core/wells/WellsManager.cpp | 1 + opm/core/wells/WellsManager.hpp | 2 ++ opm/core/wells/WellsManager_impl.hpp | 1 + .../wells/BlackoilWellModel_impl.hpp | 4 +++ tests/test_stoppedwells.cpp | 6 ++-- tests/test_wellmodel.cpp | 2 ++ tests/test_wellsmanager.cpp | 33 ++++++++++--------- tests/test_wellstatefullyimplicitblackoil.cpp | 6 ++-- 8 files changed, 33 insertions(+), 22 deletions(-) diff --git a/opm/core/wells/WellsManager.cpp b/opm/core/wells/WellsManager.cpp index f9415d6d1..b28d5405d 100644 --- a/opm/core/wells/WellsManager.cpp +++ b/opm/core/wells/WellsManager.cpp @@ -200,6 +200,7 @@ namespace Opm /// Construct wells from deck. WellsManager::WellsManager(const Opm::EclipseState& eclipseState, const Opm::Schedule& schedule, + const SummaryState& summaryState, const size_t timeStep, const UnstructuredGrid& grid) : w_(create_wells(0,0,0)), is_parallel_run_(false) diff --git a/opm/core/wells/WellsManager.hpp b/opm/core/wells/WellsManager.hpp index ff9a931f0..ecdcdaf98 100644 --- a/opm/core/wells/WellsManager.hpp +++ b/opm/core/wells/WellsManager.hpp @@ -85,6 +85,7 @@ namespace Opm template WellsManager(const Opm::EclipseState& eclipseState, const Opm::Schedule& schedule, + const SummaryState& summaryState, const size_t timeStep, int num_cells, const int* global_cell, @@ -97,6 +98,7 @@ namespace Opm WellsManager(const Opm::EclipseState& eclipseState, const Opm::Schedule& schedule, + const Opm::SummaryState& summaryState, const size_t timeStep, const UnstructuredGrid& grid); /// Destructor. diff --git a/opm/core/wells/WellsManager_impl.hpp b/opm/core/wells/WellsManager_impl.hpp index 36e509992..79b5dbb50 100644 --- a/opm/core/wells/WellsManager_impl.hpp +++ b/opm/core/wells/WellsManager_impl.hpp @@ -267,6 +267,7 @@ template WellsManager:: WellsManager(const Opm::EclipseState& eclipseState, const Opm::Schedule& schedule, + const Opm::SummaryState& summaryState, const size_t timeStep, int number_of_cells, const int* global_cell, diff --git a/opm/simulators/wells/BlackoilWellModel_impl.hpp b/opm/simulators/wells/BlackoilWellModel_impl.hpp index 8eb328d7d..dc621ae91 100644 --- a/opm/simulators/wells/BlackoilWellModel_impl.hpp +++ b/opm/simulators/wells/BlackoilWellModel_impl.hpp @@ -212,11 +212,13 @@ namespace Opm { const Grid& grid = ebosSimulator_.vanguard().grid(); const auto& defunct_well_names = ebosSimulator_.vanguard().defunctWellNames(); const auto& eclState = ebosSimulator_.vanguard().eclState(); + const auto& summaryState = ebosSimulator_.vanguard().summaryState(); wells_ecl_ = schedule().getWells2(timeStepIdx); // Create wells and well state. wells_manager_.reset( new WellsManager (eclState, schedule(), + summaryState, timeStepIdx, Opm::UgGridHelpers::numCells(grid), Opm::UgGridHelpers::globalCell(grid), @@ -478,9 +480,11 @@ namespace Opm { // will not be present in a restart file. Use the previous time step to retrieve // wells that have information written to the restart file. const int report_step = std::max(eclState().getInitConfig().getRestartStep() - 1, 0); + const auto& summaryState = ebosSimulator_.vanguard().summaryState(); WellsManager wellsmanager(eclState(), schedule(), + summaryState, report_step, Opm::UgGridHelpers::numCells(grid()), Opm::UgGridHelpers::globalCell(grid()), diff --git a/tests/test_stoppedwells.cpp b/tests/test_stoppedwells.cpp index 2d09597e2..34b512e9e 100644 --- a/tests/test_stoppedwells.cpp +++ b/tests/test_stoppedwells.cpp @@ -46,7 +46,7 @@ BOOST_AUTO_TEST_CASE(TestStoppedWells) const Eclipse3DProperties eclipseProperties ( deck , table, grid); const Opm::Runspec runspec (deck); const Schedule sched(deck, grid, eclipseProperties, runspec); - + Opm::SummaryState summaryState; double target_surfacerate_inj; double target_surfacerate_prod; @@ -55,7 +55,7 @@ BOOST_AUTO_TEST_CASE(TestStoppedWells) // Both wells are open in the first schedule step { - Opm::WellsManager wellsManager(eclipseState , sched, 0, *vanguard.c_grid()); + Opm::WellsManager wellsManager(eclipseState , sched, summaryState, 0, *vanguard.c_grid()); const Wells* wells = wellsManager.c_wells(); const struct WellControls* ctrls0 = wells->ctrls[0]; const struct WellControls* ctrls1 = wells->ctrls[1]; @@ -75,7 +75,7 @@ BOOST_AUTO_TEST_CASE(TestStoppedWells) // The injector is stopped { - Opm::WellsManager wellsManager(eclipseState, sched, 1 , *vanguard.c_grid()); + Opm::WellsManager wellsManager(eclipseState, sched, summaryState, 1 , *vanguard.c_grid()); const Wells* wells = wellsManager.c_wells(); const struct WellControls* ctrls0 = wells->ctrls[0]; const struct WellControls* ctrls1 = wells->ctrls[1]; diff --git a/tests/test_wellmodel.cpp b/tests/test_wellmodel.cpp index f4a9f24b3..70a2942fe 100644 --- a/tests/test_wellmodel.cpp +++ b/tests/test_wellmodel.cpp @@ -93,6 +93,7 @@ struct SetupTest { // Create wells. wells_manager.reset(new Opm::WellsManager(*ecl_state, *schedule, + summaryState, current_timestep, Opm::UgGridHelpers::numCells(grid), Opm::UgGridHelpers::globalCell(grid), @@ -108,6 +109,7 @@ struct SetupTest { std::unique_ptr wells_manager; std::unique_ptr ecl_state; std::unique_ptr schedule; + Opm::SummaryState summaryState; int current_timestep; }; diff --git a/tests/test_wellsmanager.cpp b/tests/test_wellsmanager.cpp index ba068755b..7611a52ff 100644 --- a/tests/test_wellsmanager.cpp +++ b/tests/test_wellsmanager.cpp @@ -184,22 +184,22 @@ BOOST_AUTO_TEST_CASE(New_Constructor_Works) { const Opm::Eclipse3DProperties eclipseProperties ( deck , table, grid); const Opm::Runspec runspec (deck); const Opm::Schedule sched(deck, grid, eclipseProperties, runspec); + Opm::SummaryState summaryState; - { - Opm::WellsManager wellsManager(eclipseState, sched, 0, *vanguard.c_grid()); + Opm::WellsManager wellsManager(eclipseState, sched, summaryState, 0, *vanguard.c_grid()); wells_static_check(wellsManager.c_wells()); check_controls_epoch0(wellsManager.c_wells()->ctrls); } { - Opm::WellsManager wellsManager(eclipseState, sched, 1, *vanguard.c_grid()); + Opm::WellsManager wellsManager(eclipseState, sched, summaryState, 1, *vanguard.c_grid()); wells_static_check(wellsManager.c_wells()); check_controls_epoch1(wellsManager.c_wells()->ctrls); } { - Opm::WellsManager wellsManager(eclipseState, sched, 3, *vanguard.c_grid()); + Opm::WellsManager wellsManager(eclipseState, sched, summaryState, 3, *vanguard.c_grid()); const Wells* wells = wellsManager.c_wells(); // There is 3 wells in total in the deck at the 3rd schedule step. @@ -225,10 +225,11 @@ BOOST_AUTO_TEST_CASE(WellsEqual) { const Opm::Eclipse3DProperties eclipseProperties ( deck , table, grid); const Opm::Runspec runspec (deck); const Opm::Schedule sched(deck, grid, eclipseProperties, runspec); + Opm::SummaryState summaryState; - Opm::WellsManager wellsManager0(eclipseState, sched, 0, *vanguard.c_grid()); - Opm::WellsManager wellsManager1(eclipseState, sched, 1, *vanguard.c_grid()); + Opm::WellsManager wellsManager0(eclipseState, sched, summaryState, 0, *vanguard.c_grid()); + Opm::WellsManager wellsManager1(eclipseState, sched, summaryState, 1, *vanguard.c_grid()); BOOST_CHECK(wells_equal( wellsManager0.c_wells() , wellsManager0.c_wells(),false)); BOOST_CHECK(!wells_equal( wellsManager0.c_wells() , wellsManager1.c_wells(),false)); @@ -245,11 +246,11 @@ BOOST_AUTO_TEST_CASE(ControlsEqual) { const Opm::Eclipse3DProperties eclipseProperties ( deck , table, grid); const Opm::Runspec runspec (deck); const Opm::Schedule sched(deck, grid, eclipseProperties, runspec); + Opm::SummaryState summaryState; - - Opm::WellsManager wellsManager0(eclipseState, sched, 0, *vanguard.c_grid()); - Opm::WellsManager wellsManager1(eclipseState, sched, 1, *vanguard.c_grid()); + Opm::WellsManager wellsManager0(eclipseState, sched, summaryState, 0, *vanguard.c_grid()); + Opm::WellsManager wellsManager1(eclipseState, sched, summaryState, 1, *vanguard.c_grid()); BOOST_CHECK(well_controls_equal( wellsManager0.c_wells()->ctrls[0] , wellsManager0.c_wells()->ctrls[0] , false)); BOOST_CHECK(well_controls_equal( wellsManager0.c_wells()->ctrls[1] , wellsManager0.c_wells()->ctrls[1] , false)); @@ -273,9 +274,9 @@ BOOST_AUTO_TEST_CASE(WellShutOK) { const Opm::Eclipse3DProperties eclipseProperties ( deck , table, grid); const Opm::Runspec runspec (deck); const Opm::Schedule sched(deck, grid, eclipseProperties, runspec); + Opm::SummaryState summaryState; - - Opm::WellsManager wellsManager2(eclipseState, sched, 2, *vanguard.c_grid()); + Opm::WellsManager wellsManager2(eclipseState, sched, summaryState, 2, *vanguard.c_grid()); // Shut wells are not added to the deck. i.e number of wells should be 2-1 BOOST_CHECK(wellsManager2.c_wells()->number_of_wells == 1); @@ -294,10 +295,10 @@ BOOST_AUTO_TEST_CASE(WellSTOPOK) { const Opm::Eclipse3DProperties eclipseProperties ( deck , table, grid); const Opm::Runspec runspec (deck); const Opm::Schedule sched(deck, grid, eclipseProperties, runspec); + Opm::SummaryState summaryState; - - Opm::WellsManager wellsManager(eclipseState, sched, 0, *vanguard.c_grid()); + Opm::WellsManager wellsManager(eclipseState, sched, summaryState, 0, *vanguard.c_grid()); const Wells* wells = wellsManager.c_wells(); const struct WellControls* ctrls0 = wells->ctrls[0]; @@ -318,13 +319,13 @@ BOOST_AUTO_TEST_CASE(removeWellWithNoPerforation) { const Opm::Eclipse3DProperties eclipseProperties ( deck , table, inputGrid); const Opm::Runspec runspec (deck); Opm::Schedule sched(deck, inputGrid, eclipseProperties, runspec); - + Opm::SummaryState summaryState; const auto eclipseGrid = Opm::UgGridHelpers::createEclipseGrid(*gridManager.c_grid(), inputGrid); sched.filterConnections(eclipseGrid); - Opm::WellsManager wellsManager0(eclipseState, sched, 0, *gridManager.c_grid()); + Opm::WellsManager wellsManager0(eclipseState, sched, summaryState, 0, *gridManager.c_grid()); BOOST_CHECK_EQUAL( wellsManager0.c_wells()->number_of_wells, 1); - Opm::WellsManager wellsManager5(eclipseState, sched, 5, *gridManager.c_grid()); + Opm::WellsManager wellsManager5(eclipseState, sched, summaryState, 5, *gridManager.c_grid()); BOOST_CHECK_EQUAL( wellsManager5.c_wells()->number_of_wells, 1); } diff --git a/tests/test_wellstatefullyimplicitblackoil.cpp b/tests/test_wellstatefullyimplicitblackoil.cpp index 95941aa0e..a55cce18b 100644 --- a/tests/test_wellstatefullyimplicitblackoil.cpp +++ b/tests/test_wellstatefullyimplicitblackoil.cpp @@ -51,12 +51,14 @@ struct Setup , pu (Opm::phaseUsageFromDeck(es)) , grid (es.getInputGrid()) , sched(deck, es) + , st() {} Opm::EclipseState es; Opm::PhaseUsage pu; Opm::GridManager grid; Opm::Schedule sched; + Opm::SummaryState st; }; namespace { @@ -69,9 +71,7 @@ namespace { std::vector(setup.grid.c_grid()->number_of_cells, 100.0*Opm::unit::barsa); - const Opm::WellsManager wmgr{ - setup.es, setup.sched, timeStep, *setup.grid.c_grid() - }; + const Opm::WellsManager wmgr{setup.es, setup.sched, setup.st, timeStep, *setup.grid.c_grid()}; state.init(wmgr.c_wells(), cpress, setup.sched, setup.sched.getWells2(timeStep), From 6edba5d94e5b16b6100fd6dce6fd6e0c3754b175 Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Wed, 29 May 2019 07:45:58 +0200 Subject: [PATCH 2/3] Use shared SummaryState in eclwellmanager --- ebos/eclwellmanager.hh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ebos/eclwellmanager.hh b/ebos/eclwellmanager.hh index d88bc1f5b..31ca71213 100644 --- a/ebos/eclwellmanager.hh +++ b/ebos/eclwellmanager.hh @@ -104,7 +104,7 @@ public: void init() { const Opm::Schedule& deckSchedule = simulator_.vanguard().schedule(); - Opm::SummaryState summaryState; + const auto& summaryState = simulator_.vanguard().summaryState(); // create the wells which intersect with the current process' grid for (size_t deckWellIdx = 0; deckWellIdx < deckSchedule.numWells(); ++deckWellIdx) { @@ -135,8 +135,8 @@ public: { const Opm::EclipseState& eclState = simulator_.vanguard().eclState(); const Opm::Schedule& deckSchedule = simulator_.vanguard().schedule(); + const auto& summaryState = simulator_.vanguard().summaryState(); unsigned episodeIdx = simulator_.episodeIndex(); - Opm::SummaryState summaryState; WellConnectionsMap wellCompMap; computeWellConnectionsMap_(episodeIdx, wellCompMap); From b129a10362ff58413e678fbfadc5a68e9ab0ed65 Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Wed, 29 May 2019 07:52:17 +0200 Subject: [PATCH 3/3] Use shared SummaryState in BlackoilWellModel --- opm/simulators/wells/BlackoilWellModel_impl.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/opm/simulators/wells/BlackoilWellModel_impl.hpp b/opm/simulators/wells/BlackoilWellModel_impl.hpp index dc621ae91..ea2bc69c3 100644 --- a/opm/simulators/wells/BlackoilWellModel_impl.hpp +++ b/opm/simulators/wells/BlackoilWellModel_impl.hpp @@ -1092,7 +1092,7 @@ namespace Opm { computeAverageFormationFactor(B_avg); const Opm::SummaryConfig& summaryConfig = ebosSimulator_.vanguard().summaryConfig(); - Opm::SummaryState summaryState; + const auto& summaryState = ebosSimulator_.vanguard().summaryState(); int exception_thrown = 0; try { for (const auto& well : well_container_copy) { @@ -1653,7 +1653,7 @@ namespace Opm { { const std::vector& resv_wells = SimFIBODetails::resvWells(wells()); - Opm::SummaryState summaryState; + const auto& summaryState = ebosSimulator_.vanguard().summaryState(); int global_number_resv_wells = resv_wells.size(); global_number_resv_wells = ebosSimulator_.gridView().comm().sum(global_number_resv_wells);