OpenFOAM guide/Matrix coefficients
The matrix coefficients are coefficients that result from the discretization process. They are closely related to the discretization coefficients. OpenFOAM uses matrix coefficients in its source code.
The matrix coefficients have the form:
- A are the matrix coefficients;
- is the matrix vector of variables being solved for; and
- i and j are cell indices.
2 Coefficient matrix
The coefficient matrix is:
- an N x N square matrix, where N is the number of cells in the mesh;
- sparse; and
- diagonally dominant.
For example, given a simple 3 x 3 orthogonal mesh (in 2-dimensions):
The coefficient matrix might look like:
- X indicates diagonal cells; and
- O and N indicate non-zero off-diagonal cells.
Since the matrix is sparse, only the non-zero entries need to be stored, something that is achieved by lduAddressing used by the matrices in OpenFOAM. lduAddressing works by recognizing that:
- Every cell has a diagonal coefficient; and
- Every cell has off-diagonal coefficients for each of their neighbours.
Therefore the diagonal coefficients are stored in an N-long vector array, where N is the number of cells. The number of off-diagonal coefficients is equal to the number of cell-pairs that directly influence one another in the linearized equations. At the matrix level in OpenFOAM, this only includes adjacent cells. Therefore the number of off-diagonal coefficients is equal to the number of shared faces in the mesh.
2.1 Storage in OpenFOAM
- diagonal coefficients as a scalar field, indexed by cell volume; and
- off-diagonal coefficients as two scalar fields, indexed by face centres.
lduAddressing is used to related the two indexing methods.
3 Relationship with discretization coefficients
Every matrix coefficient has a corresponding discretization coefficient. They are related according to:
That is, the off-diagonal matrix coefficients are opposite in sign to their corresponding discretization coefficient; whereas the diagonal has the same sign as its corresponding discretization coefficient.