Use shared SummaryState when instantiating WellsManager

This commit is contained in:
Joakim Hove 2019-05-29 07:44:23 +02:00
parent c6af5f11b6
commit a0aa7fcc2b
8 changed files with 33 additions and 22 deletions

View File

@ -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)

View File

@ -85,6 +85,7 @@ namespace Opm
template<class F2C, class FC>
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.

View File

@ -267,6 +267,7 @@ template <class C2F, class FC>
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,

View File

@ -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()),

View File

@ -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];

View File

@ -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<const Opm::WellsManager> wells_manager;
std::unique_ptr<const Opm::EclipseState> ecl_state;
std::unique_ptr<const Opm::Schedule> schedule;
Opm::SummaryState summaryState;
int current_timestep;
};

View File

@ -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);
}

View File

@ -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<double>(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),