mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Simulator, Model: add everthing which is required by the polymer simulators
basically, this adds some hooks to the SimulatorBase class and the model and introduces a few types to the SimulatorTraits.
This commit is contained in:
parent
45fb80f547
commit
a154c8394d
@ -74,13 +74,22 @@
|
|||||||
|
|
||||||
namespace Opm
|
namespace Opm
|
||||||
{
|
{
|
||||||
|
template<class Simulator>
|
||||||
|
struct SimulatorTraits;
|
||||||
|
|
||||||
/// Class collecting all necessary components for a two-phase simulation.
|
/// Class collecting all necessary components for a two-phase simulation.
|
||||||
template<class GridT, class Implementation>
|
template<class Implementation>
|
||||||
class SimulatorBase
|
class SimulatorBase
|
||||||
{
|
{
|
||||||
|
typedef SimulatorTraits<Implementation> Traits;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// \brief The type of the grid that we use.
|
typedef typename Traits::ReservoirState ReservoirState;
|
||||||
typedef GridT Grid;
|
typedef typename Traits::WellState WellState;
|
||||||
|
typedef typename Traits::OutputWriter OutputWriter;
|
||||||
|
typedef typename Traits::Grid Grid;
|
||||||
|
typedef typename Traits::Model Model;
|
||||||
|
|
||||||
/// Initialise from parameters and objects to observe.
|
/// Initialise from parameters and objects to observe.
|
||||||
/// \param[in] param parameters, this class accepts the following:
|
/// \param[in] param parameters, this class accepts the following:
|
||||||
/// parameter (default) effect
|
/// parameter (default) effect
|
||||||
@ -118,7 +127,7 @@ namespace Opm
|
|||||||
const bool disgas,
|
const bool disgas,
|
||||||
const bool vapoil,
|
const bool vapoil,
|
||||||
std::shared_ptr<EclipseState> eclipse_state,
|
std::shared_ptr<EclipseState> eclipse_state,
|
||||||
BlackoilOutputWriter& output_writer,
|
OutputWriter& output_writer,
|
||||||
const std::vector<double>& threshold_pressures_by_face);
|
const std::vector<double>& threshold_pressures_by_face);
|
||||||
|
|
||||||
/// Run the simulation.
|
/// Run the simulation.
|
||||||
@ -129,17 +138,39 @@ namespace Opm
|
|||||||
/// \param[in,out] well_state state of wells: bhp, perforation rates
|
/// \param[in,out] well_state state of wells: bhp, perforation rates
|
||||||
/// \return simulation report, with timing data
|
/// \return simulation report, with timing data
|
||||||
SimulatorReport run(SimulatorTimer& timer,
|
SimulatorReport run(SimulatorTimer& timer,
|
||||||
BlackoilState& state);
|
ReservoirState& state);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Implementation& asImp_() { return *static_cast<Implementation*>(this); }
|
Implementation& asImp_() { return *static_cast<Implementation*>(this); }
|
||||||
const Implementation& asImp_() const { return *static_cast<const Implementation*>(this); }
|
const Implementation& asImp_() const { return *static_cast<const Implementation*>(this); }
|
||||||
|
|
||||||
|
void handleAdditionalWellInflow(SimulatorTimer& timer,
|
||||||
|
WellsManager& wells_manager,
|
||||||
|
WellState& well_state,
|
||||||
|
const Wells* wells)
|
||||||
|
{};
|
||||||
|
|
||||||
|
std::shared_ptr<Model> createModel(const typename Model::ModelParameters &modelParams,
|
||||||
|
const Wells* wells)
|
||||||
|
|
||||||
|
{
|
||||||
|
return std::make_shared<Model>(modelParams,
|
||||||
|
grid_,
|
||||||
|
props_,
|
||||||
|
geo_,
|
||||||
|
rock_comp_props_,
|
||||||
|
wells,
|
||||||
|
solver_,
|
||||||
|
has_disgas_,
|
||||||
|
has_vapoil_,
|
||||||
|
terminal_output_);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
computeRESV(const std::size_t step,
|
computeRESV(const std::size_t step,
|
||||||
const Wells* wells,
|
const Wells* wells,
|
||||||
const BlackoilState& x,
|
const BlackoilState& x,
|
||||||
WellStateFullyImplicitBlackoil& xw);
|
WellState& xw);
|
||||||
|
|
||||||
// Data.
|
// Data.
|
||||||
typedef RateConverter::
|
typedef RateConverter::
|
||||||
@ -164,7 +195,7 @@ namespace Opm
|
|||||||
// eclipse_state
|
// eclipse_state
|
||||||
std::shared_ptr<EclipseState> eclipse_state_;
|
std::shared_ptr<EclipseState> eclipse_state_;
|
||||||
// output_writer
|
// output_writer
|
||||||
BlackoilOutputWriter& output_writer_;
|
OutputWriter& output_writer_;
|
||||||
RateConverterType rateConverter_;
|
RateConverterType rateConverter_;
|
||||||
// Threshold pressures.
|
// Threshold pressures.
|
||||||
std::vector<double> threshold_pressures_by_face_;
|
std::vector<double> threshold_pressures_by_face_;
|
||||||
|
@ -20,20 +20,19 @@
|
|||||||
|
|
||||||
namespace Opm
|
namespace Opm
|
||||||
{
|
{
|
||||||
template<class GridT, class Implementation>
|
template<class Implementation>
|
||||||
SimulatorBase<GridT, Implementation>::SimulatorBase(const parameter::ParameterGroup& param,
|
SimulatorBase<Implementation>::SimulatorBase(const parameter::ParameterGroup& param,
|
||||||
const Grid& grid,
|
const Grid& grid,
|
||||||
const DerivedGeology& geo,
|
const DerivedGeology& geo,
|
||||||
BlackoilPropsAdInterface& props,
|
BlackoilPropsAdInterface& props,
|
||||||
const RockCompressibility* rock_comp_props,
|
const RockCompressibility* rock_comp_props,
|
||||||
NewtonIterationBlackoilInterface& linsolver,
|
NewtonIterationBlackoilInterface& linsolver,
|
||||||
const double* gravity,
|
const double* gravity,
|
||||||
const bool has_disgas,
|
const bool has_disgas,
|
||||||
const bool has_vapoil,
|
const bool has_vapoil,
|
||||||
std::shared_ptr<EclipseState> eclipse_state,
|
std::shared_ptr<EclipseState> eclipse_state,
|
||||||
BlackoilOutputWriter& output_writer,
|
OutputWriter& output_writer,
|
||||||
const std::vector<double>& threshold_pressures_by_face)
|
const std::vector<double>& threshold_pressures_by_face)
|
||||||
|
|
||||||
: param_(param),
|
: param_(param),
|
||||||
grid_(grid),
|
grid_(grid),
|
||||||
props_(props),
|
props_(props),
|
||||||
@ -69,11 +68,11 @@ namespace Opm
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class GridT, class Implementation>
|
template<class Implementation>
|
||||||
SimulatorReport SimulatorBase<GridT, Implementation>::run(SimulatorTimer& timer,
|
SimulatorReport SimulatorBase<Implementation>::run(SimulatorTimer& timer,
|
||||||
BlackoilState& state)
|
ReservoirState& state)
|
||||||
{
|
{
|
||||||
WellStateFullyImplicitBlackoil prev_well_state;
|
WellState prev_well_state;
|
||||||
|
|
||||||
// Create timers and file for writing timing info.
|
// Create timers and file for writing timing info.
|
||||||
Opm::time::StopWatch solver_timer;
|
Opm::time::StopWatch solver_timer;
|
||||||
@ -84,8 +83,6 @@ namespace Opm
|
|||||||
std::string tstep_filename = output_writer_.outputDirectory() + "/step_timing.txt";
|
std::string tstep_filename = output_writer_.outputDirectory() + "/step_timing.txt";
|
||||||
std::ofstream tstep_os(tstep_filename.c_str());
|
std::ofstream tstep_os(tstep_filename.c_str());
|
||||||
|
|
||||||
typedef GridT Grid;
|
|
||||||
typedef BlackoilModel<Grid> Model;
|
|
||||||
typedef typename Model::ModelParameters ModelParams;
|
typedef typename Model::ModelParameters ModelParams;
|
||||||
ModelParams modelParams( param_ );
|
ModelParams modelParams( param_ );
|
||||||
typedef NewtonSolver<Model> Solver;
|
typedef NewtonSolver<Model> Solver;
|
||||||
@ -134,9 +131,12 @@ namespace Opm
|
|||||||
props_.permeability(),
|
props_.permeability(),
|
||||||
is_parallel_run_);
|
is_parallel_run_);
|
||||||
const Wells* wells = wells_manager.c_wells();
|
const Wells* wells = wells_manager.c_wells();
|
||||||
WellStateFullyImplicitBlackoil well_state;
|
WellState well_state;
|
||||||
well_state.init(wells, state, prev_well_state);
|
well_state.init(wells, state, prev_well_state);
|
||||||
|
|
||||||
|
// give the polymer and surfactant simulators the chance to do their stuff
|
||||||
|
asImp_().handleAdditionalWellInflow(timer, wells_manager, well_state, wells);
|
||||||
|
|
||||||
// write simulation state at the report stage
|
// write simulation state at the report stage
|
||||||
output_writer_.writeTimeStep( timer, state, well_state );
|
output_writer_.writeTimeStep( timer, state, well_state );
|
||||||
|
|
||||||
@ -145,16 +145,16 @@ namespace Opm
|
|||||||
props_.updateSatHyst(state.saturation(), allcells_);
|
props_.updateSatHyst(state.saturation(), allcells_);
|
||||||
|
|
||||||
// Compute reservoir volumes for RESV controls.
|
// Compute reservoir volumes for RESV controls.
|
||||||
computeRESV(timer.currentStepNum(), wells, state, well_state);
|
asImp_().computeRESV(timer.currentStepNum(), wells, state, well_state);
|
||||||
|
|
||||||
// Run a multiple steps of the solver depending on the time step control.
|
// Run a multiple steps of the solver depending on the time step control.
|
||||||
solver_timer.start();
|
solver_timer.start();
|
||||||
|
|
||||||
Model model(modelParams, grid_, props_, geo_, rock_comp_props_, wells, solver_, has_disgas_, has_vapoil_, terminal_output_);
|
auto model = asImp_().createModel(modelParams, wells);
|
||||||
if (!threshold_pressures_by_face_.empty()) {
|
if (!threshold_pressures_by_face_.empty()) {
|
||||||
model.setThresholdPressures(threshold_pressures_by_face_);
|
model->setThresholdPressures(threshold_pressures_by_face_);
|
||||||
}
|
}
|
||||||
Solver solver(solverParams, model);
|
Solver solver(solverParams, *model);
|
||||||
|
|
||||||
// If sub stepping is enabled allow the solver to sub cycle
|
// If sub stepping is enabled allow the solver to sub cycle
|
||||||
// in case the report steps are to large for the solver to converge
|
// in case the report steps are to large for the solver to converge
|
||||||
@ -327,11 +327,11 @@ namespace Opm
|
|||||||
}
|
}
|
||||||
} // namespace SimFIBODetails
|
} // namespace SimFIBODetails
|
||||||
|
|
||||||
template <class GridT, class Implementation>
|
template <class Implementation>
|
||||||
void SimulatorBase<GridT, Implementation>::computeRESV(const std::size_t step,
|
void SimulatorBase<Implementation>::computeRESV(const std::size_t step,
|
||||||
const Wells* wells,
|
const Wells* wells,
|
||||||
const BlackoilState& x,
|
const BlackoilState& x,
|
||||||
WellStateFullyImplicitBlackoil& xw)
|
WellState& xw)
|
||||||
{
|
{
|
||||||
typedef SimFIBODetails::WellMap WellMap;
|
typedef SimFIBODetails::WellMap WellMap;
|
||||||
|
|
||||||
|
@ -23,13 +23,25 @@
|
|||||||
#include "SimulatorBase.hpp"
|
#include "SimulatorBase.hpp"
|
||||||
|
|
||||||
namespace Opm {
|
namespace Opm {
|
||||||
|
template<class GridT>
|
||||||
|
class SimulatorFullyImplicitBlackoil;
|
||||||
|
|
||||||
|
template<class GridT>
|
||||||
|
struct SimulatorTraits<SimulatorFullyImplicitBlackoil<GridT> >
|
||||||
|
{
|
||||||
|
typedef WellStateFullyImplicitBlackoil WellState;
|
||||||
|
typedef BlackoilState ReservoirState;
|
||||||
|
typedef BlackoilOutputWriter OutputWriter;
|
||||||
|
typedef GridT Grid;
|
||||||
|
typedef BlackoilModel<Grid> Model;
|
||||||
|
};
|
||||||
|
|
||||||
/// a simulator for the blackoil model
|
/// a simulator for the blackoil model
|
||||||
template<class GridT>
|
template<class GridT>
|
||||||
class SimulatorFullyImplicitBlackoil
|
class SimulatorFullyImplicitBlackoil
|
||||||
: public SimulatorBase<GridT, SimulatorFullyImplicitBlackoil<GridT> >
|
: public SimulatorBase<SimulatorFullyImplicitBlackoil<GridT> >
|
||||||
{
|
{
|
||||||
typedef SimulatorBase<GridT, SimulatorFullyImplicitBlackoil<GridT> > Base;
|
typedef SimulatorBase<SimulatorFullyImplicitBlackoil<GridT> > Base;
|
||||||
public:
|
public:
|
||||||
// forward the constructor to the base class
|
// forward the constructor to the base class
|
||||||
SimulatorFullyImplicitBlackoil(const parameter::ParameterGroup& param,
|
SimulatorFullyImplicitBlackoil(const parameter::ParameterGroup& param,
|
||||||
|
Loading…
Reference in New Issue
Block a user