hybsys_global.h File Reference
Include dependency graph for hybsys_global.h:

Go to the source code of this file.

Functions

struct CSRMatrixhybsys_define_globconn (struct UnstructuredGrid *G, well_t *W)
 
void hybsys_global_assemble_cell (int nconn, int *l2g, const double *S, const double *r, struct CSRMatrix *A, double *b)
 
void hybsys_global_assemble_well_sym (int ngconn_tot, int ngconn, const int *gconn, int nwconn, const int *wconn, const double *r2w, const double *w2w, const double *r, struct CSRMatrix *A, double *b)
 

Detailed Description

Routines to assist in the formation and assembly of a global system of simultaneous linear equations derived from a Schur complement reduction of an original hybrid block system.

We assume that the original block system of linear equations is given by

\[ \begin{pmatrix} B & C & D \\ C^\mathsf{T} & 0 & 0 \\ D^\mathsf{T} & 0 & 0 \end{pmatrix} \begin{pmatrix} v \\ -p \\ \pi \end{pmatrix} = \begin{pmatrix} f \\ g \\ h \end{pmatrix} \]

in which the block matrices $C$ and $D$ are assumed to have a particularly simple structure and the matrix $B$ is block diagonal.

The Schur complement reduction process (a block Gaussian elimination) then produces the following block system of simultaneous linear equations

\[ \begin{pmatrix} B & C & D \\ 0 & -L & -F \\ 0 & 0 & A \end{pmatrix} \begin{pmatrix} v \\ -p \\ \pi \end{pmatrix} = \begin{pmatrix} f \\ g - C^\mathsf{T}B^{-1} f \\ b \end{pmatrix} \]

in which

\[ \begin{aligned} A &= D^\mathsf{T}B^{-1}D - F^\mathsf{T}L^{-1}F \text{ and} \\ b &= D^\mathsf{T}B^{-1}f + F^\mathsf{T}L^{-1} (g - C^\mathsf{T}B^{-1}f) - h. \end{aligned} \]

The component matrices $F$ and $L$ are given by

\[ \begin{aligned} L &= C^\mathsf{T} B^{-1} C \\ F &= C^\mathsf{T} B^{-1} D. \end{aligned} \]

The primary degrees of freedom, $\pi$, may then be recovered by solving the Schur complement system

\[A\pi = b\]

from which the derived quantities $p$ and $v$ may be computed through a back-substitution process.

The functions in this module assist in the creation of the sparsity pattern of matrix $A$ and in the global assembling of values into the matrix $A$ and the right-hand side vector $b$. Specifically, function hybsys_define_globconn() builds the sparsity pattern of $A$ while functions hybsys_global_assemble_cell() and hybsys_global_assemble_well_sym() perform the task of adding matrix and right-hand side values from local contributions.

Function Documentation

struct CSRMatrix* hybsys_define_globconn ( struct UnstructuredGrid G,
well_t W 
)

Construct sparse matrix capable of managing a (reduced) hybrid system of simultaneous linear equations with one degree of freedom for each grid interface and each well.

The return value is suitable for use in pressure solvers based on Schur-complement reductions such as the mimetic finite-difference or multiscale mixed finite-element classes of discretisations. In typical applications, the matrix will be cleared using function csrmatrix_zero() and then filled using an assembly process similar to the traditional finite-element algorithm.

Functions hybsys_global_assemble_cell() and hybsys_global_assemble_well_sys() may be used to assist such an assembly process.

Parameters
[in]GGrid.
[in]WWell topology. NULL in a model without wells.
Returns
Fully formed and structurally consistent sparse matrix whose number of rows (i.e., degrees-of-freedom) equals the number of grid faces (G->number_of_faces) plus the number of wells (W->number_of_wells).
void hybsys_global_assemble_cell ( int  nconn,
int *  l2g,
const double *  S,
const double *  r,
struct CSRMatrix A,
double *  b 
)

Assemble local contributions into global system of simultaneous linear equations.

The contributions will typically have been computed using function hybsys_schur_comp_symm() and function hybsys_cellcontrib_symm() or some of the related functions.

Parameters
[in]nconnNumber of cell faces.
[in]l2gLocal-to-global mapping of cell's primary degrees of freedom (i.e., the faces).
[in]SSingle cell local contribution to global coefficient matrix. An $\mathit{nconn}\times\mathit{nconn}$ dense matrix in column major (Fortran) order.
[in]rSingle cell local contribution to global system right-hand side. An $\mathit{nconn}\times 1$ dense vector.
[in,out]AGlobal coefficient matrix (of Schur complement system).
[in,out]bGlobal system right-hand side (of Schur complement system).
void hybsys_global_assemble_well_sym ( int  ngconn_tot,
int  ngconn,
const int *  gconn,
int  nwconn,
const int *  wconn,
const double *  r2w,
const double *  w2w,
const double *  r,
struct CSRMatrix A,
double *  b 
)

Assemble local contributions from single cell's well connections (perforations) into global system of simultaneous linear equations.

This function assumes that the connection strength from cell to well equals the connection strength from well to cell. In other words, that the numerical values of the well contributions are symmetric.

The contributions are typically computed using functions hybsys_well_schur_comp_symm() and hybsys_well_cellcontrib_symm().

Parameters
[in]ngconn_totTotal number of grid connections. Expected to equal G->number_of_faces when G is the grid used to form the original matrix in hybsys_define_globconn().
[in]ngconnNumber of grid connections referenced by given cell.
[in]gconnActual grid connections (DOFs) referenced by given cell. Pointer to ngconn consecutive DOF indices.
[in]nwconnNumber of well connections intersecting given cell. Typically $\mathit{ngconn} = 1$.
[in]wconnActual well connections (DOFs) intersecting given cell. Pointer to nwconn consecutive DOF indices.
[in]r2wReservoir-to-well connection strengths.
[in]w2wWell-to-well-connection strenghts.
[in]rSingle cell local contribution to global system right-hand side. An $(\mathit{ngconn} + \mathit{nwconn}) \times 1$ dense vector.
[in,out]AGlobal coefficient matrix (of Schur complement system).
[in,out]bGlobal system right-hand side (of Schur complement system).