Opm::BlackoilModelBase< Grid, WellModel, Implementation > Class Template Reference

A model implementation for three-phase black oil. More...

#include <BlackoilModelBase.hpp>

List of all members.

Classes

struct  ReservoirResidualQuant
struct  SimulatorData

Public Types

typedef AutoDiffBlock< double > ADB
typedef ADB::V V
typedef ADB::M M
typedef Opm::FIPData FIPDataType
typedef ModelTraits
< Implementation >
::ReservoirState 
ReservoirState
typedef ModelTraits
< Implementation >::WellState 
WellState
typedef ModelTraits
< Implementation >
::ModelParameters 
ModelParameters
typedef ModelTraits
< Implementation >
::SolutionState 
SolutionState
typedef FluidSystems::BlackOil
< double > 
FluidSystem

Public Member Functions

 BlackoilModelBase (const ModelParameters &param, const Grid &grid, const BlackoilPropsAdFromDeck &fluid, const DerivedGeology &geo, const RockCompressibility *rock_comp_props, const WellModel &well_model, const NewtonIterationBlackoilInterface &linsolver, std::shared_ptr< const EclipseState > eclState, const bool has_disgas, const bool has_vapoil, const bool terminal_output)
 Construct the model.
void setThresholdPressures (const std::vector< double > &threshold_pressures_by_face)
 Set threshold pressures that prevent or reduce flow.
void prepareStep (const SimulatorTimerInterface &timer, const ReservoirState &reservoir_state, const WellState &well_state)
 Called once before each time step.
template<class NonlinearSolverType >
SimulatorReport nonlinearIteration (const int iteration, const SimulatorTimerInterface &timer, NonlinearSolverType &nonlinear_solver, ReservoirState &reservoir_state, WellState &well_state)
 Called once per nonlinear iteration.
void afterStep (const SimulatorTimerInterface &timer, ReservoirState &reservoir_state, WellState &well_state)
 Called once after each time step.
SimulatorReport assemble (const ReservoirState &reservoir_state, WellState &well_state, const bool initial_assembly)
 Assemble the residual and Jacobian of the nonlinear system.
std::vector< double > computeResidualNorms () const
 Compute the residual norms of the mass balance for each phase, the well flux, and the well equation.
double relativeChange (const SimulationDataContainer &previous, const SimulationDataContainer &current) const
 compute the relative change between to simulation states
int sizeNonLinear () const
 The size (number of unknowns) of the nonlinear system of equations.
int linearIterationsLastSolve () const
 Number of linear iterations used in last call to solveJacobianSystem().
solveJacobianSystem () const
 Solve the Jacobian system Jx = r where J is the Jacobian and r is the residual.
void updateState (const V &dx, ReservoirState &reservoir_state, WellState &well_state)
 Apply an update to the primary variables, chopped if appropriate.
bool isParallel () const
 Return true if this is a parallel run.
bool terminalOutputEnabled () const
 Return true if output to cout is wanted.
bool getConvergence (const SimulatorTimerInterface &timer, const int iteration)
 Compute convergence based on total mass balance (tol_mb) and maximum residual mass balance (tol_cnv).
int numPhases () const
 The number of active fluid phases in the model.
int numMaterials () const
 The number of active materials in the model.
const std::string & materialName (int material_index) const
 The name of an active material in the model.
void updateEquationsScaling ()
 Update the scaling factors for mass balance equations.
WellModel & wellModel ()
 return the WellModel object
const WellModel & wellModel () const
const SimulatorDatagetSimulatorData (const SimulationDataContainer &) const
 Return reservoir simulation data (for output functionality).
FIPDataType getFIPData () const
 Return fluid-in-place data (for output functionality).
std::vector< std::vector
< double > > 
computeFluidInPlace (const ReservoirState &x, const std::vector< int > &fipnum)
 Compute fluid in place.
void computeWellVoidageRates (const ReservoirState &reservoir_state, const WellState &well_state, std::vector< double > &well_voidage_rates, std::vector< double > &voidage_conversion_coeffs)
 Function to compute the resevoir voidage for the production wells.
void applyVREPGroupControl (const ReservoirState &reservoir_state, WellState &well_state)
const SimulatorReport & failureReport () const
 return the statistics if the nonlinearIteration() method failed.

Protected Types

typedef Eigen::Array< double,
Eigen::Dynamic, Eigen::Dynamic,
Eigen::RowMajor > 
DataBlock

Protected Member Functions

Implementation & asImpl ()
 Access the most-derived class used for static polymorphism (CRTP).
const Implementation & asImpl () const
 Access the most-derived class used for static polymorphism (CRTP).
const Wells & wells () const
 return the Well struct in the WellModel
bool wellsActive () const
 return true if wells are available in the reservoir
bool localWellsActive () const
 return true if wells are available on this process
void makeConstantState (SolutionState &state) const
SolutionState variableState (const ReservoirState &x, const WellState &xw) const
std::vector< V > variableStateInitials (const ReservoirState &x, const WellState &xw) const
void variableReservoirStateInitials (const ReservoirState &x, std::vector< V > &vars0) const
std::vector< int > variableStateIndices () const
SolutionState variableStateExtractVars (const ReservoirState &x, const std::vector< int > &indices, std::vector< ADB > &vars) const
void computeAccum (const SolutionState &state, const int aix)
void assembleMassBalanceEq (const SolutionState &state)
SimulatorReport solveWellEq (const std::vector< ADB > &mob_perfcells, const std::vector< ADB > &b_perfcells, const ReservoirState &reservoir_state, SolutionState &state, WellState &well_state)
void addWellContributionToMassBalanceEq (const std::vector< ADB > &cq_s, const SolutionState &state, const WellState &xw)
bool getWellConvergence (const int iteration)
bool isVFPActive () const
std::vector< ADBcomputePressures (const ADB &po, const ADB &sw, const ADB &so, const ADB &sg) const
computeGasPressure (const V &po, const V &sw, const V &so, const V &sg) const
std::vector< ADBcomputeRelPerm (const SolutionState &state) const
void computeMassFlux (const int actph, const V &transi, const ADB &kr, const ADB &mu, const ADB &rho, const ADB &p, const SolutionState &state)
void applyThresholdPressures (ADB &dp)
ADB fluidViscosity (const int phase, const ADB &p, const ADB &temp, const ADB &rs, const ADB &rv, const std::vector< PhasePresence > &cond) const
ADB fluidReciprocFVF (const int phase, const ADB &p, const ADB &temp, const ADB &rs, const ADB &rv, const std::vector< PhasePresence > &cond) const
ADB fluidDensity (const int phase, const ADB &b, const ADB &rs, const ADB &rv) const
fluidRsSat (const V &p, const V &so, const std::vector< int > &cells) const
ADB fluidRsSat (const ADB &p, const ADB &so, const std::vector< int > &cells) const
fluidRvSat (const V &p, const V &so, const std::vector< int > &cells) const
ADB fluidRvSat (const ADB &p, const ADB &so, const std::vector< int > &cells) const
ADB poroMult (const ADB &p) const
ADB transMult (const ADB &p) const
const std::vector< PhasePresence > phaseCondition () const
void classifyCondition (const ReservoirState &state)
void updatePrimalVariableFromState (const ReservoirState &state)
 update the primal variable for Sg, Rv or Rs.
void updatePhaseCondFromPrimalVariable (const ReservoirState &state)
 Update the phaseCondition_ member based on the primalVariable_ member.
void computeWellConnectionPressures (const SolutionState &state, const WellState &well_state)
double convergenceReduction (const Eigen::Array< double, Eigen::Dynamic, Eigen::Dynamic > &B, const Eigen::Array< double, Eigen::Dynamic, Eigen::Dynamic > &tempV, const Eigen::Array< double, Eigen::Dynamic, Eigen::Dynamic > &R, std::vector< double > &R_sum, std::vector< double > &maxCoeff, std::vector< double > &B_avg, std::vector< double > &maxNormWell, int nc) const
 Compute the reduction within the convergence check.
void setupGroupControl (const ReservoirState &reservoir_state, WellState &well_state)
 Set up the group control related at the beginning of each time step.
double dpMaxRel () const
double dbhpMaxRel () const
double dsMax () const
double drMaxRel () const
double maxResidualAllowed () const

Protected Attributes

SimulatorReport failureReport_
const Grid & grid_
const BlackoilPropsAdFromDeckfluid_
const DerivedGeologygeo_
const RockCompressibility * rock_comp_props_
VFPProperties vfp_properties_
const
NewtonIterationBlackoilInterface
linsolver_
const std::vector< bool > active_
const std::vector< int > canph_
const std::vector< int > cells_
HelperOps ops_
const bool has_disgas_
const bool has_vapoil_
ModelParameters param_
bool use_threshold_pressure_
threshold_pressures_by_connection_
SimulatorData sd_
std::vector< PhasePresence > phaseCondition_
WellModel well_model_
isRs_
isRv_
isSg_
LinearisedBlackoilResidual residual_
bool terminal_output_
 Whether we print something to std::cout.
int global_nc_
 The number of cells of the global grid.
pvdt_
std::vector< std::string > material_name_
std::vector< std::vector
< double > > 
residual_norms_history_
double current_relaxation_
dx_old_
RateConverterType rate_converter_

Detailed Description

template<class Grid, class WellModel, class Implementation>
class Opm::BlackoilModelBase< Grid, WellModel, Implementation >

A model implementation for three-phase black oil.

The simulator is capable of handling three-phase problems where gas can be dissolved in oil and vice versa. It uses an industry-standard TPFA discretization with per-phase upwind weighting of mobilities.

It uses automatic differentiation via the class AutoDiffBlock to simplify assembly of the jacobian matrix.

Template Parameters:
Grid UnstructuredGrid or CpGrid.
WellModel WellModel employed.
Implementation Provides concrete state types.

Constructor & Destructor Documentation

template<class Grid, class WellModel, class Implementation>
Opm::BlackoilModelBase< Grid, WellModel, Implementation >::BlackoilModelBase ( const ModelParameters &  param,
const Grid &  grid,
const BlackoilPropsAdFromDeck fluid,
const DerivedGeology geo,
const RockCompressibility *  rock_comp_props,
const WellModel &  well_model,
const NewtonIterationBlackoilInterface linsolver,
std::shared_ptr< const EclipseState >  eclState,
const bool  has_disgas,
const bool  has_vapoil,
const bool  terminal_output 
)

Construct the model.

It will retain references to the arguments of this functions, and they are expected to remain in scope for the lifetime of the solver.

Parameters:
[in] param parameters
[in] grid grid data structure
[in] fluid fluid properties
[in] geo rock properties
[in] rock_comp_props if non-null, rock compressibility properties
[in] wells well structure
[in] vfp_properties Vertical flow performance tables
[in] linsolver linear solver
[in] eclState eclipse state
[in] has_disgas turn on dissolved gas
[in] has_vapoil turn on vaporized oil feature
[in] terminal_output request output to cout/cerr

Member Function Documentation

template<class Grid , class WellModel , class Implementation >
void Opm::BlackoilModelBase< Grid, WellModel, Implementation >::afterStep ( const SimulatorTimerInterface timer,
ReservoirState &  reservoir_state,
WellState &  well_state 
) [inline]

Called once after each time step.

In this class, this function does nothing.

Parameters:
[in] timer simulation timer
[in,out] reservoir_state reservoir state variables
[in,out] well_state well state variables
template<class Grid, class WellModel, class Implementation>
const Implementation& Opm::BlackoilModelBase< Grid, WellModel, Implementation >::asImpl (  )  const [inline, protected]

Access the most-derived class used for static polymorphism (CRTP).

template<class Grid, class WellModel, class Implementation>
Implementation& Opm::BlackoilModelBase< Grid, WellModel, Implementation >::asImpl (  )  [inline, protected]

Access the most-derived class used for static polymorphism (CRTP).

template<class Grid , class WellModel , class Implementation >
SimulatorReport Opm::BlackoilModelBase< Grid, WellModel, Implementation >::assemble ( const ReservoirState &  reservoir_state,
WellState &  well_state,
const bool  initial_assembly 
) [inline]

Assemble the residual and Jacobian of the nonlinear system.

Parameters:
[in] reservoir_state reservoir state variables
[in,out] well_state well state variables
[in] initial_assembly pass true if this is the first call to assemble() in this timestep
template<class Grid , class WellModel , class Implementation >
std::vector< std::vector< double > > Opm::BlackoilModelBase< Grid, WellModel, Implementation >::computeFluidInPlace ( const ReservoirState &  x,
const std::vector< int > &  fipnum 
) [inline]

Compute fluid in place.

Parameters:
[in] ReservoirState 
[in] FIPNUM for active cells not global cells.
Returns:
fluid in place, number of fip regions, each region contains 5 values which are liquid, vapour, water, free gas and dissolved gas.
template<class Grid , class WellModel , class Implementation >
std::vector< double > Opm::BlackoilModelBase< Grid, WellModel, Implementation >::computeResidualNorms (  )  const [inline]

Compute the residual norms of the mass balance for each phase, the well flux, and the well equation.

Returns:
a vector that contains for each phase the norm of the mass balance and afterwards the norm of the residual of the well flux and the well equation.
template<class Grid , class WellModel , class Implementation >
void Opm::BlackoilModelBase< Grid, WellModel, Implementation >::computeWellVoidageRates ( const ReservoirState &  reservoir_state,
const WellState &  well_state,
std::vector< double > &  well_voidage_rates,
std::vector< double > &  voidage_conversion_coeffs 
) [inline]

Function to compute the resevoir voidage for the production wells.

TODO: Probably should go to well model, while we then have duplications there for two Well Models. With time, it looks like probably we will introduce a base class for Well Models.

template<class Grid , class WellModel , class Implementation >
double Opm::BlackoilModelBase< Grid, WellModel, Implementation >::convergenceReduction ( const Eigen::Array< double, Eigen::Dynamic, Eigen::Dynamic > &  B,
const Eigen::Array< double, Eigen::Dynamic, Eigen::Dynamic > &  tempV,
const Eigen::Array< double, Eigen::Dynamic, Eigen::Dynamic > &  R,
std::vector< double > &  R_sum,
std::vector< double > &  maxCoeff,
std::vector< double > &  B_avg,
std::vector< double > &  maxNormWell,
int  nc 
) const [inline, protected]

Compute the reduction within the convergence check.

Parameters:
[in] B A matrix with MaxNumPhases columns and the same number rows as the number of cells of the grid. B.col(i) contains the values for phase i.
[in] tempV A matrix with MaxNumPhases columns and the same number rows as the number of cells of the grid. tempV.col(i) contains the values for phase i.
[in] R A matrix with MaxNumPhases columns and the same number rows as the number of cells of the grid. B.col(i) contains the values for phase i.
[out] R_sum An array of size MaxNumPhases where entry i contains the sum of R for the phase i.
[out] maxCoeff An array of size MaxNumPhases where entry i contains the maximum of tempV for the phase i.
[out] B_avg An array of size MaxNumPhases where entry i contains the average of B for the phase i.
[out] maxNormWell The maximum of the well flux equations for each phase.
[in] nc The number of cells of the local grid.
Returns:
The total pore volume over all cells.
template<class Grid, class WellModel, class Implementation>
const SimulatorReport& Opm::BlackoilModelBase< Grid, WellModel, Implementation >::failureReport (  )  const [inline]

return the statistics if the nonlinearIteration() method failed.

NOTE: for the flow_legacy simulator family this method is a stub, i.e. the failure report object will *not* contain any meaningful data.

template<class Grid , class WellModel , class Implementation >
bool Opm::BlackoilModelBase< Grid, WellModel, Implementation >::getConvergence ( const SimulatorTimerInterface timer,
const int  iteration 
) [inline]

Compute convergence based on total mass balance (tol_mb) and maximum residual mass balance (tol_cnv).

Parameters:
[in] timer simulation timer
[in] iteration current iteration number

Reimplemented in Opm::BlackoilPressureModel< Grid, WellModel >, and Opm::BlackoilTransportModel< Grid, WellModel >.

template<class Grid , class WellModel , class Implementation >
const std::string & Opm::BlackoilModelBase< Grid, WellModel, Implementation >::materialName ( int  material_index  )  const [inline]

The name of an active material in the model.

It is required that material_index < numMaterials().

template<class Grid , class WellModel , class Implementation >
template<class NonlinearSolverType >
SimulatorReport Opm::BlackoilModelBase< Grid, WellModel, Implementation >::nonlinearIteration ( const int  iteration,
const SimulatorTimerInterface timer,
NonlinearSolverType &  nonlinear_solver,
ReservoirState &  reservoir_state,
WellState &  well_state 
) [inline]

Called once per nonlinear iteration.

This model will perform a Newton-Raphson update, changing reservoir_state and well_state. It will also use the nonlinear_solver to do relaxation of updates if necessary.

Parameters:
[in] iteration should be 0 for the first call of a new timestep
[in] timer simulation timer
[in] nonlinear_solver nonlinear solver used (for oscillation/relaxation control)
[in,out] reservoir_state reservoir state variables
[in,out] well_state well state variables
template<class Grid , class WellModel , class Implementation >
int Opm::BlackoilModelBase< Grid, WellModel, Implementation >::numMaterials (  )  const [inline]

The number of active materials in the model.

This should be equal to the number of material balance equations.

template<class Grid , class WellModel , class Implementation >
void Opm::BlackoilModelBase< Grid, WellModel, Implementation >::prepareStep ( const SimulatorTimerInterface timer,
const ReservoirState &  reservoir_state,
const WellState &  well_state 
) [inline]

Called once before each time step.

Parameters:
[in] timer simulation timer
[in,out] reservoir_state reservoir state variables
[in,out] well_state well state variables
template<class Grid , class WellModel , class Implementation >
void Opm::BlackoilModelBase< Grid, WellModel, Implementation >::setThresholdPressures ( const std::vector< double > &  threshold_pressures_by_face  )  [inline]

Set threshold pressures that prevent or reduce flow.

This prevents flow across faces if the potential difference is less than the threshold. If the potential difference is greater, the threshold value is subtracted before calculating flow. This is treated symmetrically, so flow is prevented or reduced in both directions equally.

Parameters:
[in] threshold_pressures_by_face array of size equal to the number of faces of the grid passed in the constructor.
template<class Grid , class WellModel , class Implementation >
V Opm::BlackoilModelBase< Grid, WellModel, Implementation >::solveJacobianSystem (  )  const [inline]

Solve the Jacobian system Jx = r where J is the Jacobian and r is the residual.

Reimplemented in Opm::BlackoilTransportModel< Grid, WellModel >.

template<class Grid , class WellModel , class Implementation >
void Opm::BlackoilModelBase< Grid, WellModel, Implementation >::updatePhaseCondFromPrimalVariable ( const ReservoirState &  state  )  [inline, protected]

Update the phaseCondition_ member based on the primalVariable_ member.

Also updates isRs_, isRv_ and isSg_;

template<class Grid , class WellModel , class Implementation >
void Opm::BlackoilModelBase< Grid, WellModel, Implementation >::updatePrimalVariableFromState ( const ReservoirState &  state  )  [inline, protected]

update the primal variable for Sg, Rv or Rs.

The Gas phase must be active to call this method.

template<class Grid , class WellModel , class Implementation >
void Opm::BlackoilModelBase< Grid, WellModel, Implementation >::updateState ( const V &  dx,
ReservoirState &  reservoir_state,
WellState &  well_state 
) [inline]

Apply an update to the primary variables, chopped if appropriate.

Parameters:
[in] dx updates to apply to primary variables
[in,out] reservoir_state reservoir state variables
[in,out] well_state well state variables

The documentation for this class was generated from the following files:

Generated on 26 Mar 2018 by  doxygen 1.6.1