All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
mimetic.h File Reference

Routines to assist mimetic discretisations of the flow equation. More...

Go to the source code of this file.

Functions

void mim_ip_span_nullspace (int nf, int nconn, int d, double *C, double *A, double *X, double *work, int lwork)
 Form linear operator to span the null space of the normal vectors of a grid cell. More...
 
void mim_ip_linpress_exact (int nf, int nconn, int d, double vol, double *K, double *N, double *Binv, double *work, int lwork)
 Form (inverse) mimetic inner product that reproduces linear pressure drops (constant velocity) on general polyhedral cells. More...
 
void mim_ip_simple (int nf, int nconn, int d, double v, double *K, double *C, double *A, double *N, double *Binv, double *work, int lwork)
 Convenience wrapper around the function pair mim_ip_span_nullspace() and mim_ip_linpress_exact(). More...
 
void mim_ip_simple_all (int ncells, int d, int max_ncf, int *pconn, int *conn, int *fneighbour, double *fcentroid, double *fnormal, double *farea, double *ccentroid, double *cvol, double *perm, double *Binv)
 Compute the mimetic inner products given a grid and cell-wise permeability tensors. More...
 
void mim_ip_compute_gpress (int nc, int d, const double *grav, const int *pconn, const int *conn, const double *fcentroid, const double *ccentroid, double *gpress)
 Compute local, static gravity pressure contributions to Darcy flow equation discretised using a mimetic finite-difference method. More...
 
void mim_ip_mobility_update (int nc, const int *pconn, const double *totmob, const double *Binv0, double *Binv)
 Incorporate effects of multiple phases in mimetic discretisation of flow equations. More...
 
void mim_ip_density_update (int nc, const int *pconn, const double *omega, const double *gpress0, double *gpress)
 Incorporate effects of multiple fluid phases into existing, local, static mimetic discretisations of gravity pressure. More...
 

Detailed Description

Routines to assist mimetic discretisations of the flow equation.

Function Documentation

void mim_ip_compute_gpress ( int  nc,
int  d,
const double *  grav,
const int *  pconn,
const int *  conn,
const double *  fcentroid,
const double *  ccentroid,
double *  gpress 
)

Compute local, static gravity pressure contributions to Darcy flow equation discretised using a mimetic finite-difference method.

The pressure contribution of local face $i$ in cell $c$ is

\[ \mathit{gpress}_{\mathit{pconn}_c + i} = \vec{g}\cdot (\Bar{x}_{\mathit{conn}_{\mathit{pconn}_c + i}} - \Bar{x}_c) \]

Parameters
[in]ncNumber of cells.
[in]dNumber of physcial dimensions.
[in]gravGravity vector. Array of size d.
[in]pconnStart pointers of cell-to-face topology mapping.
[in]connActual cell-to-face topology mapping.
[in]fcentroidFace centroids.
[in]ccentroidCell centroids.
[out]gpressGravity pressure result. Array of size at least pconn[nc].
void mim_ip_density_update ( int  nc,
const int *  pconn,
const double *  omega,
const double *  gpress0,
double *  gpress 
)

Incorporate effects of multiple fluid phases into existing, local, static mimetic discretisations of gravity pressure.

Specifically, update the result of mim_ip_compute_gpress() according to the rule

\[ \Tilde{G}_{\mathit{pconn}_c + i} = \omega_c\cdot G_{\mathit{pconn}_c + i}, \quad i=\mathit{pconn}_c, \dots, \mathit{pconn}_{c+1}-1, \quad c=0,\dots,\mathit{nc}-1 \]

in which $\omega_c = (\sum_\alpha \lambda_{\alpha,c} \rho_\alpha)/\lambda_{T,c}$ and $\Tilde{G}$ denotes the result of function mim_ip_compute_gpress().

Parameters
[in]ncNumber of cells.
[in]pconnStart pointers of cell-to-face topology mapping.
[in]omegaSum of phase densities weighted by fractional flow.
[in]gpress0Result of mim_ip_compute_gpress().
[out]gpressGravity pressure incorporating effects of multiple fluid phases.
void mim_ip_linpress_exact ( int  nf,
int  nconn,
int  d,
double  vol,
double *  K,
double *  N,
double *  Binv,
double *  work,
int  lwork 
)

Form (inverse) mimetic inner product that reproduces linear pressure drops (constant velocity) on general polyhedral cells.

Specifically

\[ B^{-1} = \frac{1}{v} \big(NKN^\mathsf{T} + \frac{6t}{d}\,X\big) \]

in which $t = \operatorname{tr}(K)$ is the trace of $K$ and $X$ is the result of function mim_ip_span_nullspace().

Parameters
[in]nfNumber of faces connected to single grid cell.
[in]nconnTotal number of grid cell connections. Typically equal to nf.
[in]dNumber of physical dimensions. Assumed less than four.
[in]volCell volume.
[in]KPermeability. A $d\times d$ matrix in column major (Fortran) order.
[in]NNormal vectors. An $\mathit{nf}\times d$ matrix in column major (Fortran) order.
[in,out]BinvInverse inner product result. An $\mathit{nconn}\times\mathit{nconn}$ matrix in column major format. On input, the result of mim_ip_span_nullspace(). On output, the upper left $\mathit{nf}\times\mathit{nf}$ sub-matrix will be overwritten with $B^{-1}$.
[in,out]workScratch array of size at least nf * d.
[in]lworkActual size of scratch array.
void mim_ip_mobility_update ( int  nc,
const int *  pconn,
const double *  totmob,
const double *  Binv0,
double *  Binv 
)

Incorporate effects of multiple phases in mimetic discretisation of flow equations.

Specifically, update the (inverse) inner products $B^{-1}$ previously computed using function mim_ip_linpress_exact() according to the rule

\[ \Tilde{B}_c^{-1} = \frac{1}{\lambda_{T,c}} B_c^{-1}, \quad i=0,\dots,\mathit{nc}-1 \]

in which $B_c^{-1}$ denotes the result of mim_ip_linpress_exact() for cell $c$ and $\lambda_{T,c}$ denotes the total mobility of cell $c$.

Parameters
[in]ncNumber of cells.
[in]pconnStart pointers of cell-to-face topology mapping.
[in]totmobTotal mobility for all cells. Array of size nc.
[in]Binv0Inverse inner product results for all cells.
[out]BinvInverse inner product results incorporating effects of multiple fluid phases.
void mim_ip_simple ( int  nf,
int  nconn,
int  d,
double  v,
double *  K,
double *  C,
double *  A,
double *  N,
double *  Binv,
double *  work,
int  lwork 
)

Convenience wrapper around the function pair mim_ip_span_nullspace() and mim_ip_linpress_exact().

Parameters
[in]nfNumber of faces connected to single grid cell.
[in]nconnTotal number of grid cell connections. Typically equal to nf.
[in]dNumber of physical dimensions. Assumed less than four.
[in]vCell volume.
[in]KPermeability. A $d\times d$ matrix in column major (Fortran) order.
[in,out]CCentroid vectors. Specifically, $c_{ij} = \Bar{x}_{ij} - \Bar{x}_{cj}$. Array of size $\mathit{nf}\times d$ in column major (Fortran) order. Contents destroyed on output.
[in]AInterface areas.
[in]NOutward normal vectors. An $\mathit{nf}\times d$ matrix in column major (Fortran) order.
[out]BinvInverse inner product result. An $\mathit{nconn}\times\mathit{nconn}$ matrix in column major format. On output, the upper left $\mathit{nf}\times\mathit{nf}$ sub-matrix will be overwritten with $B^{-1}$ defined by function mim_ip_linpress_exact().
[in,out]workScratch array of size at least nf * d.
[in]lworkActual size of scratch array.
void mim_ip_simple_all ( int  ncells,
int  d,
int  max_ncf,
int *  pconn,
int *  conn,
int *  fneighbour,
double *  fcentroid,
double *  fnormal,
double *  farea,
double *  ccentroid,
double *  cvol,
double *  perm,
double *  Binv 
)

Compute the mimetic inner products given a grid and cell-wise permeability tensors.

This function applies mim_ip_simple() to all specified cells.

Parameters
[in]ncellsNumber of cells.
[in]dNumber of physical dimensions.
[in]max_ncfMaximum number of connections (faces) of any individual cell.
[in]pconnStart pointers of cell-to-face topology mapping.
[in]connActual cell-to-face topology mapping.
[in]fneighbourFace-to-cell mapping.
[in]fcentroidFace centroids.
[in]fnormalFace normals.
[in]fareaFace areas.
[in]ccentroidCell centroids.
[in]cvolCell volumes.
[in]permCell permeability.
[out]BinvInverse inner product result. Must point to an array of size at least $\sum_c n_c^2$ when $n_c$ denotes the number of connections (faces) of cell $c$.
void mim_ip_span_nullspace ( int  nf,
int  nconn,
int  d,
double *  C,
double *  A,
double *  X,
double *  work,
int  lwork 
)

Form linear operator to span the null space of the normal vectors of a grid cell.

Specifically,

\[ \begin{aligned} X &= \operatorname{diag}(A) (I - QQ^\mathsf{T}) \operatorname{diag}(A), \\ Q &= \operatorname{orth}(\operatorname{diag}(A) C) \end{aligned} \]

in which $\operatorname{orth}(M)$ denotes an orthonormal basis for the colum space (range) of the matrix $M$, represented as a matrix.

Parameters
[in]nfNumber of faces connected to single grid cell.
[in]nconnTotal number of grid cell connections. Typically equal to nf.
[in]dNumber of physical dimensions. Assumed less than four.
[in,out]CCentroid vectors. Specifically, $c_{ij} = \Bar{x}_{ij} - \Bar{x}_{cj}$. Array of size $\mathit{nf}\times d$ in column major (Fortran) order. Contents destroyed on output.
[in]AInterface areas.
[out]XNull space linear operator. Array of size $\mathit{nconn}\times\mathit{nconn}$ in column major (Fortran) order. On output, the upper left $\mathit{nf}\times\mathit{nf}$ sub-matrix contains the required null space linear operator.
[out]workScratch array of size at least nconn.
[in]lworkActual size of scratch array.