3.4
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
Dumux::FVPressureCompositional< TypeTag > Class Template Reference

The finite volume model for the solution of the compositional pressure equation. More...

#include <dumux/porousmediumflow/2p2c/sequential/fvpressurecompositional.hh>

Inheritance diagram for Dumux::FVPressureCompositional< TypeTag >:

Description

template<class TypeTag>
class Dumux::FVPressureCompositional< TypeTag >

The finite volume model for the solution of the compositional pressure equation.

Provides the common ground to solve compositional pressure equations of the form

\[ c_{total}\frac{\partial p}{\partial t} + \sum_{\kappa} \frac{\partial v_{total}}{\partial C^{\kappa}} \nabla \cdot \left( \sum_{\alpha} X^{\kappa}_{\alpha} \varrho_{\alpha} \bf{v}_{\alpha}\right) = \sum_{\kappa} \frac{\partial v_{total}}{\partial C^{\kappa}} q^{\kappa}, \]

where \(\bf{v}_{\alpha} = - \lambda_{\alpha} \bf{K} \left(\nabla p_{\alpha} + \rho_{\alpha} \bf{g} \right) \). \( c_{total} \) represents the total compressibility, for constant porosity this yields \( - \frac{\partial V_{total}}{\partial p_{\alpha}} \), \(p_{\alpha} \) denotes the phase pressure, \( \bf{K} \) the absolute permeability, \( \lambda_{\alpha} \) the phase mobility, \( \rho_{\alpha} \) the phase density and \( \bf{g} \) the gravity constant and \( C^{\kappa} \) the total Component concentration. See paper SPE 99619 or "Analysis of a Compositional Model for Fluid Flow in Porous Media" by Chen, Qin and Ewing for derivation.

Common functions such as output and the initialization procedure are provided here. Also, private vector (the update estimate for the volume derivatives) are stored in this class, as only derived classes (other compositional pressure models) need acess to it. The partial derivatives of the actual fluid volume \( v_{total} \) are gained by using a secant method.

Template Parameters
TypeTagThe Type Tag

Public Member Functions

void initialMaterialLaws (bool compositional)
 initializes the fluid distribution and hereby the variables container More...
 
void initialize (bool solveTwice=false)
 Initializes the simulation run. More...
 
void update ()
 Compositional pressure solution routine: update estimate for secants, assemble, solve. More...
 
void updateMaterialLaws (bool postTimeStep=false)
 Updates secondary variables. More...
 
void volumeDerivatives (const GlobalPosition &, const Element &ep)
 Partial derivatives of the volumes w.r.t. changes in total concentration and pressure. More...
 
const Scalar pressure (const int eIdxGlobal) const
 Public access function for the primary pressure variable. More...
 
void getSource (EntryType &entry, const Element &element, const CellData &cellData, const bool first)
 Function which calculates the source entry. More...
 
void getStorage (EntryType &entry, const Element &element, const CellData &cellData, const bool first)
 Function which calculates the storage entry. More...
 
void getFlux (EntryType &entry, const Intersection &intersection, const CellData &cellData, const bool first)
 Function which calculates the flux entry. More...
 
void getFluxOnBoundary (EntryType &entry, const Intersection &intersection, const CellData &cellData, const bool first)
 Function which calculates the boundary flux entry. More...
 
const Matrix & globalMatrix ()
 Returns the global matrix of the last pressure solution step. More...
 
const RHSVector & rightHandSide ()
 Returns the right hand side vector of the last pressure solution step. More...
 
void initialize ()
 Initialize pressure model. More...
 
void calculateVelocity ()
 
void updateVelocity ()
 
void serializeEntity (std::ostream &outstream, const Element &element)
 Function for serialization of the pressure field. More...
 
void deserializeEntity (std::istream &instream, const Element &element)
 Function for deserialization of the pressure field. More...
 
void setFixPressureAtIndex (Scalar pressure, int eIdxGlobal)
 Set a pressure to be fixed at a certain cell. More...
 
void unsetFixPressureAtIndex (int eIdxGlobal)
 Reset the fixed pressure state. More...
 
void resetFixPressureAtIndex ()
 

Protected Types

enum  { rhs = 1 , matrix = 0 }
 Indices of matrix and rhs entries. More...
 
enum  { pressEqIdx = Indices::pressureEqIdx }
 
using EntryType = Dune::FieldVector< Scalar, 2 >
 

Protected Member Functions

void initializeMatrix ()
 Initialize the global matrix of the system of equations to solve. More...
 
void initializeMatrixRowSize ()
 Initialize the global matrix of the system of equations to solve. More...
 
void initializeMatrixIndices ()
 Initialize the global matrix of the system of equations to solve. More...
 
void assemble (bool first)
 Function which assembles the system of equations to be solved. More...
 
void solve ()
 Solves the global system of equations to get the spatial distribution of the pressure. More...
 
PressureSolution & pressure ()
 Returns the vector containing the pressure solution. More...
 
const PressureSolution & pressure () const
 Returns the vector containing the pressure solution. More...
 
void initializePressure ()
 Initialization of the pressure solution vector: Initialization with meaningful values may. More...
 

Protected Attributes

Matrix A_
 Global stiffnes matrix (sparse matrix which is build by the initializeMatrix() function) More...
 
RHSVector f_
 Right hand side vector. More...
 

general methods for output

TransportSolutionType updateEstimate_
 Update estimate for changes in volume for the pressure equation. More...
 
Problem & problem_
 
VtkMultiWriter< GridView > initializationOutputWriter_
 output for the initialization procedure More...
 
Scalar maxError_
 Maximum volume error of all cells. More...
 
Scalar incp_
 Increment for the volume derivative w.r.t pressure. More...
 
Scalar ErrorTermFactor_
 Handling of error term: relaxation factor. More...
 
Scalar ErrorTermLowerBound_
 Handling of error term: lower bound for error dampening. More...
 
Scalar ErrorTermUpperBound_
 
static constexpr int pressureType = getPropValue<TypeTag, Properties::PressureFormulation>()
 gives kind of pressure used ( \( 0 = p_w \), \( 1 = p_n \), \( 2 = p_{global} \)) More...
 
template<class MultiWriter >
void addOutputVtkFields (MultiWriter &writer)
 Write data files. More...
 
void initializationOutput (double pseudoTS=0.)
 Write additional debug info in a special writer. More...
 
 FVPressureCompositional (Problem &problem)
 Constructs a FVPressureCompositional object. More...
 

Member Typedef Documentation

◆ EntryType

template<class TypeTag >
using Dumux::FVPressure< TypeTag >::EntryType = Dune::FieldVector<Scalar, 2>
protectedinherited

Type of the vector of entries

Contains the return values of the get*()-functions (matrix or right-hand side entry).

Member Enumeration Documentation

◆ anonymous enum

template<class TypeTag >
anonymous enum
protectedinherited

Indices of matrix and rhs entries.

During the assembling of the global system of equations get-functions are called (getSource(), getFlux(), etc.), which return global matrix or right hand side entries in a vector. These can be accessed using following indices:

Enumerator
rhs 

index for the right hand side entry

matrix 

index for the global matrix entry

◆ anonymous enum

template<class TypeTag >
anonymous enum
protectedinherited
Enumerator
pressEqIdx 

Constructor & Destructor Documentation

◆ FVPressureCompositional()

template<class TypeTag >
Dumux::FVPressureCompositional< TypeTag >::FVPressureCompositional ( Problem &  problem)
inline

Constructs a FVPressureCompositional object.

Parameters
problema problem class object

Member Function Documentation

◆ addOutputVtkFields()

template<class TypeTag >
template<class MultiWriter >
void Dumux::FVPressureCompositional< TypeTag >::addOutputVtkFields ( MultiWriter &  writer)
inline

Write data files.

Adds pressure-related quantities, including numerical things such as the volume Error entering the pressure equation. Verobosity of the output can be triggered by the property / parameter VtkOutputLevel, with 0 putting out only primary variables and 4 being very verbose.

Template Parameters
MultiWriterClass defining the output writer
Parameters
writerThe output writer (usually a VTKMultiWriter object)

◆ assemble()

template<class TypeTag >
void Dumux::FVPressure< TypeTag >::assemble ( bool  first)
protectedinherited

Function which assembles the system of equations to be solved.

This function assembles the Matrix and the right hand side (RHS) vector to solve for a pressure field with a Finite-Volume (FV) discretization. Implementations of this base class have to provide the methods getSource(), getStorage(), getFlux() and getFluxOnBoundary() if the assemble() method is called!

Parameters
firstIndicates if function is called at the initialization step or during the simulation (If first is true, no pressure field of previous iterations is required)

◆ calculateVelocity()

template<class TypeTag >
void Dumux::FVPressure< TypeTag >::calculateVelocity ( )
inlineinherited

◆ deserializeEntity()

template<class TypeTag >
void Dumux::FVPressure< TypeTag >::deserializeEntity ( std::istream &  instream,
const Element &  element 
)
inlineinherited

Function for deserialization of the pressure field.

Function needed for restart option. Reads the pressure of a grid element from a restart file.

Parameters
instreamStream from the restart file.
elementGrid element

◆ getFlux()

template<class TypeTag >
void Dumux::FVPressure< TypeTag >::getFlux ( EntryType entry,
const Intersection &  intersection,
const CellData &  cellData,
const bool  first 
)
inherited

Function which calculates the flux entry.

Function computes the inter-cell flux term and writes it to the corresponding entry of the entry vector

Parameters
entryVector containing return values of the function
intersectionIntersection of two grid elements
cellDataObject containing all model relevant cell data
firstIndicates if function is called in the initialization step or during the simulation

◆ getFluxOnBoundary()

template<class TypeTag >
void Dumux::FVPressure< TypeTag >::getFluxOnBoundary ( EntryType entry,
const Intersection &  intersection,
const CellData &  cellData,
const bool  first 
)
inherited

Function which calculates the boundary flux entry.

Function computes the boundary-flux term and writes it to the corresponding entry of the entry vector

Parameters
entryVector containing return values of the function
intersectionIntersection of two grid elements
cellDataObject containing all model relevant cell data
firstIndicates if function is called in the initialization step or during the simulation

◆ getSource()

template<class TypeTag >
void Dumux::FVPressure< TypeTag >::getSource ( EntryType entry,
const Element &  element,
const CellData &  cellData,
const bool  first 
)
inherited

Function which calculates the source entry.

Function computes the source term and writes it to the corresponding entry of the entry vector

Parameters
entryVector containing return values of the function
elementGrid element
cellDataObject containing all model relevant cell data
firstIndicates if function is called in the initialization step or during the simulation

◆ getStorage()

template<class TypeTag >
void Dumux::FVPressure< TypeTag >::getStorage ( EntryType entry,
const Element &  element,
const CellData &  cellData,
const bool  first 
)
inherited

Function which calculates the storage entry.

Function computes the storage term and writes it to the corresponding entry of the entry vector

Parameters
entryVector containing return values of the function
elementGrid element
cellDataObject containing all model relevant cell data
firstIndicates if function is called in the initialization step or during the simulation

◆ globalMatrix()

template<class TypeTag >
const Matrix & Dumux::FVPressure< TypeTag >::globalMatrix ( )
inlineinherited

Returns the global matrix of the last pressure solution step.

◆ initializationOutput()

template<class TypeTag >
void Dumux::FVPressureCompositional< TypeTag >::initializationOutput ( double  pseudoTS = 0.)
inline

Write additional debug info in a special writer.

To visualize the different steps through the initialization procedure, we use very small pseudo time steps only for the writer! This is only for debugging of the initialization procedure.

Parameters
pseudoTSTime steps that only appear in the writer, not real.

◆ initialize() [1/2]

template<class TypeTag >
void Dumux::FVPressure< TypeTag >::initialize ( )
inlineinherited

Initialize pressure model.

Function initializes the sparse matrix to solve the global system of equations and sets/calculates the initial pressure

◆ initialize() [2/2]

template<class TypeTag >
void Dumux::FVPressureCompositional< TypeTag >::initialize ( bool  solveTwice = false)

Initializes the simulation run.

Initializes the simulation to gain the initial pressure field. Output throughout initialization procedure is only done in debug mode.

Parameters
solveTwiceflag to determine possible iterations of the initialization process

◆ initializeMatrix()

template<class TypeTag >
void Dumux::FVPressure< TypeTag >::initializeMatrix
protectedinherited

Initialize the global matrix of the system of equations to solve.

◆ initializeMatrixIndices()

template<class TypeTag >
void Dumux::FVPressure< TypeTag >::initializeMatrixIndices
protectedinherited

Initialize the global matrix of the system of equations to solve.

◆ initializeMatrixRowSize()

template<class TypeTag >
void Dumux::FVPressure< TypeTag >::initializeMatrixRowSize
protectedinherited

Initialize the global matrix of the system of equations to solve.

◆ initializePressure()

template<class TypeTag >
void Dumux::FVPressure< TypeTag >::initializePressure ( )
inlineprotectedinherited

Initialization of the pressure solution vector: Initialization with meaningful values may.

◆ initialMaterialLaws()

template<class TypeTag >
void Dumux::FVPressureCompositional< TypeTag >::initialMaterialLaws ( bool  compositional)

initializes the fluid distribution and hereby the variables container

It differs from updateMaterialLaws() because there are two possible initial conditions: saturations and concentration.

Parameters
compositionalflag that determines if compositional effects are regarded, i.e. a reasonable pressure field is known with which compositions can be calculated.

◆ pressure() [1/3]

template<class TypeTag >
PressureSolution & Dumux::FVPressure< TypeTag >::pressure ( )
inlineprotectedinherited

Returns the vector containing the pressure solution.

◆ pressure() [2/3]

template<class TypeTag >
const PressureSolution & Dumux::FVPressure< TypeTag >::pressure ( ) const
inlineprotectedinherited

Returns the vector containing the pressure solution.

◆ pressure() [3/3]

template<class TypeTag >
const Scalar Dumux::FVPressure< TypeTag >::pressure ( const int  eIdxGlobal) const
inlineinherited

Public access function for the primary pressure variable.

Function returns the cell pressure value at index eIdxGlobal

Parameters
eIdxGlobalGlobal index of a grid cell

◆ resetFixPressureAtIndex()

template<class TypeTag >
void Dumux::FVPressure< TypeTag >::resetFixPressureAtIndex ( )
inlineinherited

◆ rightHandSide()

template<class TypeTag >
const RHSVector & Dumux::FVPressure< TypeTag >::rightHandSide ( )
inlineinherited

Returns the right hand side vector of the last pressure solution step.

◆ serializeEntity()

template<class TypeTag >
void Dumux::FVPressure< TypeTag >::serializeEntity ( std::ostream &  outstream,
const Element &  element 
)
inlineinherited

Function for serialization of the pressure field.

Function needed for restart option. Writes the pressure of a grid element to a restart file.

Parameters
outstreamStream into the restart file.
elementGrid element

◆ setFixPressureAtIndex()

template<class TypeTag >
void Dumux::FVPressure< TypeTag >::setFixPressureAtIndex ( Scalar  pressure,
int  eIdxGlobal 
)
inlineinherited

Set a pressure to be fixed at a certain cell.

Allows to fix a pressure somewhere (at one certain cell) in the domain. This can be necessary e.g. if only Neumann boundary conditions are defined. The pressure is fixed until the unsetFixPressureAtIndex() function is called

Parameters
pressurePressure value at eIdxGlobal
eIdxGlobalGlobal index of a grid cell

◆ solve()

template<class TypeTag >
void Dumux::FVPressure< TypeTag >::solve
protectedinherited

Solves the global system of equations to get the spatial distribution of the pressure.

◆ unsetFixPressureAtIndex()

template<class TypeTag >
void Dumux::FVPressure< TypeTag >::unsetFixPressureAtIndex ( int  eIdxGlobal)
inlineinherited

Reset the fixed pressure state.

No pressure is fixed inside the domain until setFixPressureAtIndex() function is called again.

Parameters
eIdxGlobalGlobal index of a grid cell

◆ update()

template<class TypeTag >
void Dumux::FVPressureCompositional< TypeTag >::update ( )
inline

Compositional pressure solution routine: update estimate for secants, assemble, solve.

An update estime (transport step acoording to old pressure field) determines changes in mass, composition, which is used to calculate volume derivatives entering the pressure equation, as well as an approximate guess for time step size for the storage terms in the p.e. Afterwards, the system is assembled and solved for pressure.

◆ updateMaterialLaws()

template<class TypeTag >
void Dumux::FVPressureCompositional< TypeTag >::updateMaterialLaws ( bool  postTimeStep = false)

Updates secondary variables.

A loop through all elements updates the secondary variables stored in the variableclass by using the updated primary variables.

Parameters
postTimeStepFlag indicating method is called from Problem::postTimeStep()

◆ updateVelocity()

template<class TypeTag >
void Dumux::FVPressure< TypeTag >::updateVelocity ( )
inlineinherited

◆ volumeDerivatives()

template<class TypeTag >
void Dumux::FVPressureCompositional< TypeTag >::volumeDerivatives ( const GlobalPosition &  globalPos,
const Element &  element 
)

Partial derivatives of the volumes w.r.t. changes in total concentration and pressure.

This method calculates the volume derivatives via a secant method, where the secants are gained in a pre-computational step via the transport equation and the last TS size. The partial derivatives w.r.t. mass are defined as \( \frac{\partial v}{\partial C^{\kappa}} = \frac{\partial V}{\partial m^{\kappa}}\)

Parameters
globalPosThe global position of the current element
elementThe current element

Member Data Documentation

◆ A_

template<class TypeTag >
Matrix Dumux::FVPressure< TypeTag >::A_
protectedinherited

Global stiffnes matrix (sparse matrix which is build by the initializeMatrix() function)

◆ ErrorTermFactor_

template<class TypeTag >
Scalar Dumux::FVPressureCompositional< TypeTag >::ErrorTermFactor_
protected

Handling of error term: relaxation factor.

◆ ErrorTermLowerBound_

template<class TypeTag >
Scalar Dumux::FVPressureCompositional< TypeTag >::ErrorTermLowerBound_
protected

Handling of error term: lower bound for error dampening.

◆ ErrorTermUpperBound_

template<class TypeTag >
Scalar Dumux::FVPressureCompositional< TypeTag >::ErrorTermUpperBound_
protected

Handling of error term: upper bound for error dampening

◆ f_

template<class TypeTag >
RHSVector Dumux::FVPressure< TypeTag >::f_
protectedinherited

Right hand side vector.

◆ incp_

template<class TypeTag >
Scalar Dumux::FVPressureCompositional< TypeTag >::incp_
protected

Increment for the volume derivative w.r.t pressure.

◆ initializationOutputWriter_

template<class TypeTag >
VtkMultiWriter<GridView> Dumux::FVPressureCompositional< TypeTag >::initializationOutputWriter_
protected

output for the initialization procedure

◆ maxError_

template<class TypeTag >
Scalar Dumux::FVPressureCompositional< TypeTag >::maxError_
protected

Maximum volume error of all cells.

◆ pressureType

template<class TypeTag >
constexpr int Dumux::FVPressureCompositional< TypeTag >::pressureType = getPropValue<TypeTag, Properties::PressureFormulation>()
staticconstexprprotected

gives kind of pressure used ( \( 0 = p_w \), \( 1 = p_n \), \( 2 = p_{global} \))

◆ problem_

template<class TypeTag >
Problem& Dumux::FVPressureCompositional< TypeTag >::problem_
protected

◆ updateEstimate_

template<class TypeTag >
TransportSolutionType Dumux::FVPressureCompositional< TypeTag >::updateEstimate_
protected

Update estimate for changes in volume for the pressure equation.


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