diff --git a/examples/compute_tof.cpp b/examples/compute_tof.cpp index 4ba9dedd..b43452cc 100644 --- a/examples/compute_tof.cpp +++ b/examples/compute_tof.cpp @@ -181,8 +181,14 @@ try const UnstructuredGrid& grid = *grid_manager.c_grid(); // Rock and fluid init IncompPropertiesSinglePhase props(deck, eclipseState, grid); - // Wells init. - WellsManager wells_manager(eclipseState , 0, grid); + // Wells init.i + const auto& ecl_grid = eclipseState.getInputGrid(); + const TableManager table ( deck ); + const Eclipse3DProperties eclipseProperties ( deck , table, ecl_grid); + const Schedule sched(deck, ecl_grid, eclipseProperties, Phases(true, true, true), parseContext ); + + + WellsManager wells_manager(eclipseState , sched, 0, grid); std::shared_ptr my_wells(clone_wells(wells_manager.c_wells()), destroy_wells); setBhpWells(*my_wells); diff --git a/opm/core/wells/WellsManager.cpp b/opm/core/wells/WellsManager.cpp index 5b67cc15..ed05755a 100644 --- a/opm/core/wells/WellsManager.cpp +++ b/opm/core/wells/WellsManager.cpp @@ -327,6 +327,7 @@ namespace Opm /// Construct wells from deck. WellsManager::WellsManager(const Opm::EclipseState& eclipseState, + const Opm::Schedule& schedule, const size_t timeStep, const UnstructuredGrid& grid) : w_(0), is_parallel_run_(false) @@ -334,7 +335,7 @@ namespace Opm // TODO: not sure about the usage of this WellsManager constructor // TODO: not sure whether this is the correct thing to do here. DynamicListEconLimited dummy_list_econ_limited; - init(eclipseState, timeStep, UgGridHelpers::numCells(grid), + init(eclipseState, schedule, timeStep, UgGridHelpers::numCells(grid), UgGridHelpers::globalCell(grid), UgGridHelpers::cartDims(grid), UgGridHelpers::dimensions(grid), UgGridHelpers::cell2Faces(grid), UgGridHelpers::beginFaceCentroids(grid), diff --git a/opm/core/wells/WellsManager.hpp b/opm/core/wells/WellsManager.hpp index ce0d3bff..0901b5be 100644 --- a/opm/core/wells/WellsManager.hpp +++ b/opm/core/wells/WellsManager.hpp @@ -85,6 +85,7 @@ namespace Opm /// the wells handeled by another process. Defaults to empty set. template WellsManager(const Opm::EclipseState& eclipseState, + const Opm::Schedule& schedule, const size_t timeStep, int num_cells, const int* global_cell, @@ -97,6 +98,7 @@ namespace Opm const std::unordered_set& deactivated_wells = std::unordered_set ()); WellsManager(const Opm::EclipseState& eclipseState, + const Opm::Schedule& schedule, const size_t timeStep, const UnstructuredGrid& grid); /// Destructor. @@ -154,6 +156,7 @@ namespace Opm private: template void init(const Opm::EclipseState& eclipseState, + const Opm::Schedule& schedule, const size_t timeStep, int num_cells, const int* global_cell, diff --git a/opm/core/wells/WellsManager_impl.hpp b/opm/core/wells/WellsManager_impl.hpp index b0084c78..687fd212 100644 --- a/opm/core/wells/WellsManager_impl.hpp +++ b/opm/core/wells/WellsManager_impl.hpp @@ -309,6 +309,7 @@ void WellsManager::createWellsFromSpecs(std::vector& wells, size_t template WellsManager:: WellsManager(const Opm::EclipseState& eclipseState, + const Opm::Schedule& schedule, const size_t timeStep, int number_of_cells, const int* global_cell, @@ -321,7 +322,7 @@ WellsManager(const Opm::EclipseState& eclipseState, const std::unordered_set& deactivated_wells) : w_(0), is_parallel_run_(is_parallel_run) { - init(eclipseState, timeStep, number_of_cells, global_cell, + init(eclipseState, schedule, timeStep, number_of_cells, global_cell, cart_dims, dimensions, cell_to_faces, begin_face_centroids, list_econ_limited, deactivated_wells); } @@ -330,6 +331,7 @@ WellsManager(const Opm::EclipseState& eclipseState, template void WellsManager::init(const Opm::EclipseState& eclipseState, + const Opm::Schedule& schedule, const size_t timeStep, int number_of_cells, const int* global_cell, @@ -346,7 +348,7 @@ WellsManager::init(const Opm::EclipseState& eclipseState, "the corresponding grid is 3-dimensional."); } - if (eclipseState.getSchedule().numWells() == 0) { + if (schedule.numWells() == 0) { OPM_MESSAGE("No wells specified in Schedule section, " "initializing no wells"); return; @@ -368,7 +370,6 @@ WellsManager::init(const Opm::EclipseState& eclipseState, // For easy lookup: std::map well_names_to_index; - const auto& schedule = eclipseState.getSchedule(); auto wells = schedule.getWells(timeStep); std::vector wells_on_proc; diff --git a/tests/test_stoppedwells.cpp b/tests/test_stoppedwells.cpp index 73d847c0..697e0979 100644 --- a/tests/test_stoppedwells.cpp +++ b/tests/test_stoppedwells.cpp @@ -48,6 +48,11 @@ BOOST_AUTO_TEST_CASE(TestStoppedWells) Opm::Deck deck(parser.parseFile(filename , parseContext)); Opm::EclipseState eclipseState(deck , parseContext); Opm::GridManager gridManager(eclipseState.getInputGrid()); + const auto& grid = eclipseState.getInputGrid(); + const TableManager table ( deck ); + const Eclipse3DProperties eclipseProperties ( deck , table, grid); + const Schedule sched(deck, grid, eclipseProperties, Phases(true, true, true), parseContext ); + double target_surfacerate_inj; double target_surfacerate_prod; @@ -58,7 +63,7 @@ BOOST_AUTO_TEST_CASE(TestStoppedWells) // Both wells are open in the first schedule step { - Opm::WellsManager wellsManager(eclipseState , 0 , *gridManager.c_grid()); + Opm::WellsManager wellsManager(eclipseState , sched, 0, *gridManager.c_grid()); const Wells* wells = wellsManager.c_wells(); const struct WellControls* ctrls0 = wells->ctrls[0]; const struct WellControls* ctrls1 = wells->ctrls[1]; @@ -78,7 +83,7 @@ BOOST_AUTO_TEST_CASE(TestStoppedWells) // The injector is stopped { - Opm::WellsManager wellsManager(eclipseState , 1 , *gridManager.c_grid()); + Opm::WellsManager wellsManager(eclipseState, sched, 1 , *gridManager.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_wellcollection.cpp b/tests/test_wellcollection.cpp index d1097bf2..06b91ac6 100644 --- a/tests/test_wellcollection.cpp +++ b/tests/test_wellcollection.cpp @@ -46,15 +46,20 @@ BOOST_AUTO_TEST_CASE(AddWellsAndGroupToCollection) { Deck deck = parser.parseFile(scheduleFile, parseContext); EclipseState eclipseState(deck, parseContext); PhaseUsage pu = phaseUsageFromDeck(eclipseState); + const auto& grid = eclipseState.getInputGrid(); + const TableManager table ( deck ); + const Eclipse3DProperties eclipseProperties ( deck , table, grid); + const Schedule sched(deck, grid, eclipseProperties, Phases(true, true, true), parseContext ); + WellCollection collection; // Add groups to WellCollection - const auto& fieldGroup = eclipseState.getSchedule().getGroup("FIELD"); + const auto& fieldGroup = sched.getGroup("FIELD"); collection.addField(fieldGroup, 2, pu); - collection.addGroup( eclipseState.getSchedule().getGroup( "G1" ), fieldGroup.name(), 2, pu); - collection.addGroup( eclipseState.getSchedule().getGroup( "G2" ), fieldGroup.name(), 2, pu); + collection.addGroup( sched.getGroup( "G1" ), fieldGroup.name(), 2, pu); + collection.addGroup( sched.getGroup( "G2" ), fieldGroup.name(), 2, pu); BOOST_CHECK_EQUAL("FIELD", collection.findNode("FIELD")->name()); BOOST_CHECK_EQUAL("FIELD", collection.findNode("G1")->getParent()->name()); @@ -62,7 +67,7 @@ BOOST_AUTO_TEST_CASE(AddWellsAndGroupToCollection) { // Add wells to WellCollection WellCollection wellCollection; - auto wells = eclipseState.getSchedule().getWells(); + auto wells = sched.getWells(); for (size_t i=0; iname() ) ) continue; const auto& group = *grp; diff --git a/tests/test_wellsmanager.cpp b/tests/test_wellsmanager.cpp index 38d6c68e..2f278ddb 100644 --- a/tests/test_wellsmanager.cpp +++ b/tests/test_wellsmanager.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -183,21 +184,26 @@ BOOST_AUTO_TEST_CASE(New_Constructor_Works) { Opm::EclipseState eclipseState(deck, parseContext); Opm::GridManager gridManager(eclipseState.getInputGrid()); + const auto& grid = eclipseState.getInputGrid(); + const Opm::TableManager table ( deck ); + const Opm::Eclipse3DProperties eclipseProperties ( deck , table, grid); + const Opm::Schedule sched(deck, grid, eclipseProperties, Opm::Phases(true, true, true), parseContext ); + { - Opm::WellsManager wellsManager(eclipseState, 0, *gridManager.c_grid()); + Opm::WellsManager wellsManager(eclipseState, sched, 0, *gridManager.c_grid()); wells_static_check(wellsManager.c_wells()); check_controls_epoch0(wellsManager.c_wells()->ctrls); } { - Opm::WellsManager wellsManager(eclipseState, 1, *gridManager.c_grid()); + Opm::WellsManager wellsManager(eclipseState, sched, 1, *gridManager.c_grid()); wells_static_check(wellsManager.c_wells()); check_controls_epoch1(wellsManager.c_wells()->ctrls); } { - Opm::WellsManager wellsManager(eclipseState, 3, *gridManager.c_grid()); + Opm::WellsManager wellsManager(eclipseState, sched, 3, *gridManager.c_grid()); const Wells* wells = wellsManager.c_wells(); // There is 3 wells in total in the deck at the 3rd schedule step. @@ -219,9 +225,14 @@ BOOST_AUTO_TEST_CASE(WellsEqual) { Opm::Deck deck(parser.parseFile(filename, parseContext)); Opm::EclipseState eclipseState(deck, parseContext); Opm::GridManager gridManager(eclipseState.getInputGrid()); + const auto& grid = eclipseState.getInputGrid(); + const Opm::TableManager table ( deck ); + const Opm::Eclipse3DProperties eclipseProperties ( deck , table, grid); + const Opm::Schedule sched(deck, grid, eclipseProperties, Opm::Phases(true, true, true), parseContext ); - Opm::WellsManager wellsManager0(eclipseState, 0, *gridManager.c_grid()); - Opm::WellsManager wellsManager1(eclipseState, 1, *gridManager.c_grid()); + + Opm::WellsManager wellsManager0(eclipseState, sched, 0, *gridManager.c_grid()); + Opm::WellsManager wellsManager1(eclipseState, sched, 1, *gridManager.c_grid()); BOOST_CHECK(wells_equal( wellsManager0.c_wells() , wellsManager0.c_wells(),false)); BOOST_CHECK(!wells_equal( wellsManager0.c_wells() , wellsManager1.c_wells(),false)); @@ -234,9 +245,15 @@ BOOST_AUTO_TEST_CASE(ControlsEqual) { Opm::Deck deck(parser.parseFile(filename, parseContext)); Opm::EclipseState eclipseState(deck, parseContext); Opm::GridManager gridManager(eclipseState.getInputGrid()); + const auto& grid = eclipseState.getInputGrid(); + const Opm::TableManager table ( deck ); + const Opm::Eclipse3DProperties eclipseProperties ( deck , table, grid); + const Opm::Schedule sched(deck, grid, eclipseProperties, Opm::Phases(true, true, true), parseContext ); - Opm::WellsManager wellsManager0(eclipseState, 0, *gridManager.c_grid()); - Opm::WellsManager wellsManager1(eclipseState, 1, *gridManager.c_grid()); + + + Opm::WellsManager wellsManager0(eclipseState, sched, 0, *gridManager.c_grid()); + Opm::WellsManager wellsManager1(eclipseState, sched, 1, *gridManager.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)); @@ -256,8 +273,13 @@ BOOST_AUTO_TEST_CASE(WellShutOK) { Opm::Deck deck(parser.parseFile(filename, parseContext)); Opm::EclipseState eclipseState(deck, parseContext); Opm::GridManager gridManager(eclipseState.getInputGrid()); + const auto& grid = eclipseState.getInputGrid(); + const Opm::TableManager table ( deck ); + const Opm::Eclipse3DProperties eclipseProperties ( deck , table, grid); + const Opm::Schedule sched(deck, grid, eclipseProperties, Opm::Phases(true, true, true), parseContext ); - Opm::WellsManager wellsManager2(eclipseState, 2, *gridManager.c_grid()); + + Opm::WellsManager wellsManager2(eclipseState, sched, 2, *gridManager.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); @@ -272,8 +294,14 @@ BOOST_AUTO_TEST_CASE(WellSTOPOK) { Opm::Deck deck(parser.parseFile(filename, parseContext)); Opm::EclipseState eclipseState(deck, parseContext); Opm::GridManager gridManager(eclipseState.getInputGrid()); + const auto& grid = eclipseState.getInputGrid(); + const Opm::TableManager table ( deck ); + const Opm::Eclipse3DProperties eclipseProperties ( deck , table, grid); + const Opm::Schedule sched(deck, grid, eclipseProperties, Opm::Phases(true, true, true), parseContext ); - Opm::WellsManager wellsManager(eclipseState, 0, *gridManager.c_grid()); + + + Opm::WellsManager wellsManager(eclipseState, sched, 0, *gridManager.c_grid()); const Wells* wells = wellsManager.c_wells(); const struct WellControls* ctrls0 = wells->ctrls[0];