pass wells manager from sim_poly_fibo to Simulator class, instead of directly

create it in Simulator class, since polymer inflow need deck and wells.
This commit is contained in:
Liu Ming 2014-10-24 14:04:57 +08:00
parent 61c76c4294
commit ba6fef4fbd
3 changed files with 68 additions and 39 deletions

View File

@ -218,19 +218,35 @@ try
std::cout << "\n\n================ Starting main simulation loop ===============\n"
<< std::flush;
SimulatorReport fullReport;
WellStateFullyImplicitBlackoil prev_well_state;
for (size_t reportStepIdx = 0; reportStepIdx < timeMap->numTimesteps(); ++reportStepIdx) {
simtimer.setCurrentStepNum(reportStepIdx);
Opm::DerivedGeology geology(*grid->c_grid(), *new_props, eclipseState, grav);
std::vector<double> threshold_pressures = thresholdPressures(deck, eclipseState, *grid->c_grid());
//Create new wells, polymer inflow controls.
WellsManager wells(eclipseState, reportStepIdx, *grid->c_grid(), props->permeability());
WellsManager wells_manager(eclipseState,
simtimer.currentStepNum(),
Opm::UgGridHelpers::numCells(*grid->c_grid()),
Opm::UgGridHelpers::globalCell(*grid->c_grid()),
Opm::UgGridHelpers::cartDims(*grid->c_grid()),
Opm::UgGridHelpers::dimensions(*grid->c_grid()),
Opm::UgGridHelpers::beginCellCentroids(*grid->c_grid()),
Opm::UgGridHelpers::cell2Faces(*grid->c_grid()),
Opm::UgGridHelpers::beginFaceCentroids(*grid->c_grid()),
props->permeability());
WellStateFullyImplicitBlackoil well_state;
well_state.init(wells_manager.c_wells(), state.blackoilState());
if (reportStepIdx != 0) {
// Transfer previous well state to current.
well_state.partialCopy(prev_well_state, *wells_manager.c_wells(), prev_well_state.numWells());
}
std::unique_ptr<PolymerInflowInterface> polymer_inflow;
if (use_wpolymer) {
if (wells.c_wells() == 0) {
if (wells_manager.c_wells() == 0) {
OPM_THROW(std::runtime_error, "Cannot control polymer injection via WPOLYMER without wells.");
}
polymer_inflow.reset(new PolymerInflowFromDeck(deck, *wells.c_wells(), props->numCells()));
polymer_inflow.reset(new PolymerInflowFromDeck(deck, *wells_manager.c_wells(), props->numCells()));
} else {
polymer_inflow.reset(new PolymerInflowBasic(0.0*Opm::unit::day,
1.0*Opm::unit::day,
@ -244,6 +260,7 @@ try
rock_comp->isActive() ? rock_comp.get() : 0,
*fis_solver,
*polymer_inflow,
wells_manager,
grav,
deck->hasKeyword("DISGAS"),
deck->hasKeyword("VAPOIL"),
@ -253,7 +270,8 @@ try
threshold_pressures);
fullReport = simulator.run(simtimer, state);
fullReport = simulator.run(simtimer, state, well_state);
prev_well_state = well_state;
}
std::cout << "\n\n================ End of simulation ===============\n\n";
fullReport.report(std::cout);

View File

@ -37,6 +37,7 @@ namespace Opm
class SimulatorTimer;
class PolymerBlackoilState;
class WellStateFullyImplicitBlackoil;
class WellsManager;
class EclipseState;
class EclipseWriter;
class PolymerPropsAd;
@ -86,6 +87,7 @@ namespace Opm
const RockCompressibility* rock_comp_props,
NewtonIterationBlackoilInterface& linsolver,
const PolymerInflowInterface& polymer_inflow,
WellsManager& well_manager,
const double* gravity,
const bool disgas,
const bool vapoil,
@ -102,7 +104,8 @@ namespace Opm
/// \param[in,out] well_state state of wells: bhp, perforation rates
/// \return simulation report, with timing data
SimulatorReport run(SimulatorTimer& timer,
PolymerBlackoilState& state);
PolymerBlackoilState& state,
WellStateFullyImplicitBlackoil& well_state);
private:
class Impl;

View File

@ -83,6 +83,7 @@ namespace Opm
const RockCompressibility* rock_comp_props,
NewtonIterationBlackoilInterface& linsolver,
const PolymerInflowInterface& polymer_inflow,
WellsManager& wells_manager,
const double* gravity,
bool has_disgas,
bool has_vapoil,
@ -92,7 +93,8 @@ namespace Opm
const std::vector<double>& threshold_pressures_by_face);
SimulatorReport run(SimulatorTimer& timer,
PolymerBlackoilState& state);
PolymerBlackoilState& state,
WellStateFullyImplicitBlackoil& well_state);
private:
// Data.
@ -117,6 +119,7 @@ namespace Opm
const DerivedGeology& geo_;
NewtonIterationBlackoilInterface& solver_;
const PolymerInflowInterface& polymer_inflow_;
WellsManager& wells_manager_;
// Misc. data
std::vector<int> allcells_;
const bool has_disgas_;
@ -149,6 +152,7 @@ namespace Opm
const RockCompressibility* rock_comp_props,
NewtonIterationBlackoilInterface& linsolver,
const PolymerInflowInterface& polymer_inflow,
WellsManager& wells_manager,
const double* gravity,
const bool has_disgas,
const bool has_vapoil,
@ -158,7 +162,7 @@ namespace Opm
const std::vector<double>& threshold_pressures_by_face)
{
pimpl_.reset(new Impl(param, grid, geo, props, polymer_props, rock_comp_props, linsolver, polymer_inflow, gravity, has_disgas,
pimpl_.reset(new Impl(param, grid, geo, props, polymer_props, rock_comp_props, linsolver, polymer_inflow, wells_manager, gravity, has_disgas,
has_vapoil, has_polymer, eclipse_state, output_writer, threshold_pressures_by_face));
}
@ -168,9 +172,10 @@ namespace Opm
template<class T>
SimulatorReport SimulatorFullyImplicitBlackoilPolymer<T>::run(SimulatorTimer& timer,
PolymerBlackoilState& state)
PolymerBlackoilState& state,
WellStateFullyImplicitBlackoil& well_state)
{
return pimpl_->run(timer, state);
return pimpl_->run(timer, state, well_state);
}
@ -242,6 +247,7 @@ namespace Opm
const RockCompressibility* rock_comp_props,
NewtonIterationBlackoilInterface& linsolver,
const PolymerInflowInterface& polymer_inflow,
WellsManager& wells_manager,
const double* gravity,
const bool has_disgas,
const bool has_vapoil,
@ -258,6 +264,7 @@ namespace Opm
geo_(geo),
solver_(linsolver),
polymer_inflow_(polymer_inflow),
wells_manager_(wells_manager),
has_disgas_(has_disgas),
has_vapoil_(has_vapoil),
has_polymer_(has_polymer),
@ -295,7 +302,8 @@ namespace Opm
template<class T>
SimulatorReport SimulatorFullyImplicitBlackoilPolymer<T>::Impl::run(SimulatorTimer& timer,
PolymerBlackoilState& state)
PolymerBlackoilState& state,
WellStateFullyImplicitBlackoil& well_state)
{
WellStateFullyImplicitBlackoil prev_well_state;
@ -309,29 +317,29 @@ namespace Opm
std::ofstream tstep_os(tstep_filename.c_str());
// Main simulation loop.
while (!timer.done()) {
// while (!timer.done()) {
// Report timestep.
step_timer.start();
timer.report(std::cout);
// Create wells and well state.
WellsManager wells_manager(eclipse_state_,
timer.currentStepNum(),
Opm::UgGridHelpers::numCells(grid_),
Opm::UgGridHelpers::globalCell(grid_),
Opm::UgGridHelpers::cartDims(grid_),
Opm::UgGridHelpers::dimensions(grid_),
Opm::UgGridHelpers::beginCellCentroids(grid_),
Opm::UgGridHelpers::cell2Faces(grid_),
Opm::UgGridHelpers::beginFaceCentroids(grid_),
props_.permeability());
const Wells* wells = wells_manager.c_wells();
WellStateFullyImplicitBlackoil well_state;
well_state.init(wells, state.blackoilState());
if (timer.currentStepNum() != 0) {
// Transfer previous well state to current.
well_state.partialCopy(prev_well_state, *wells, prev_well_state.numWells());
}
// WellsManager wells_manager(eclipse_state_,
// timer.currentStepNum(),
// Opm::UgGridHelpers::numCells(grid_),
// Opm::UgGridHelpers::globalCell(grid_),
// Opm::UgGridHelpers::cartDims(grid_),
// Opm::UgGridHelpers::dimensions(grid_),
// Opm::UgGridHelpers::beginCellCentroids(grid_),
// Opm::UgGridHelpers::cell2Faces(grid_),
// Opm::UgGridHelpers::beginFaceCentroids(grid_),
// props_.permeability());
const Wells* wells = wells_manager_.c_wells();
// WellStateFullyImplicitBlackoil well_state;
// well_state.init(wells, state.blackoilState());
// if (timer.currentStepNum() != 0) {
// // Transfer previous well state to current.
// well_state.partialCopy(prev_well_state, *wells, prev_well_state.numWells());
// }
// Output state at start of time step.
if (output_ && (timer.currentStepNum() % output_interval_ == 0)) {
@ -383,19 +391,19 @@ namespace Opm
}
// Increment timer, remember well state.
++timer;
prev_well_state = well_state;
}
// ++timer;
// prev_well_state = well_state;
// }
// Write final simulation state.
if (output_) {
if (output_vtk_) {
outputStateVtk(grid_, state, timer.currentStepNum(), output_dir_);
}
outputStateMatlab(grid_, state, timer.currentStepNum(), output_dir_);
outputWellStateMatlab(prev_well_state, timer.currentStepNum(), output_dir_);
output_writer_.writeTimeStep(timer, state.blackoilState(), prev_well_state.basicWellState());
}
// if (output_) {
// if (output_vtk_) {
// outputStateVtk(grid_, state, timer.currentStepNum(), output_dir_);
// }
// outputStateMatlab(grid_, state, timer.currentStepNum(), output_dir_);
// outputWellStateMatlab(prev_well_state, timer.currentStepNum(), output_dir_);
// output_writer_.writeTimeStep(timer, state.blackoilState(), prev_well_state.basicWellState());
// }
// Stop timer and create timing report
total_timer.stop();