Starting with a vector identity,

= + ^{ . } ,

where is the scalar variable to be diffused and is an arbitrary vector, integrate over a cell volume:

d*V* = d*V* + ^{ . } d*V* .

Each colored term in the equation above will be treated separately.

Aside: note that, if inner products for scalars and vectors are defined by

and if = 0 on the boundary, such that the Green term vanishes, then this equation becomes the definition of an adjoint,

- , = , ,

which shows that the divergence is the negative adjoint of the gradient.

The Green term can be transformed via Gauss's Theorem into a surface integral,

d*V* = ^{ . } .

This is discretized into values defined on each face of the hexahedral cell,

The summation over faces ( ) includes six faces (+

dV |
dV , |
||

= | ^{ . } , |
||

^{ . } . |

Turning to the final Blue term, insert the definition of the flux

= - *D* ,

to get

Note that by defining the flux in terms of the remainder of the equation, the gradient is being defined in terms of the divergence.

The Blue term is discretized by evaluating the integrand at each of the cell nodes (octants in 3-D) and summing:

- *D*^{-1}^{ . } d*V* - *D*^{-1}_{n}^{ . }*V*_{n} .

Combining all of the discretized terms of the colored equation and changing to a linear algebra representation gives

Rearranging terms gives

Note that the right hand side is a sum over the six faces, but the left hand side is a sum over the eight nodes.

where *f*1
, *f*2
, and *f*3
are the faces adjacent to node *n*
and the Jacobian matrix is the square matrix given by

Using this definition for the node-centered vectors
**W**_{n}
and
**F**_{n}
and performing some algebraic manipulations results in

where the sum over faces has been written as a dot product of and , which are defined by

= , = .

*N*_{lf}
is the total number of local faces, which is equal to 6 in 3-D.

To convert the short vectors involving the faces adjacent to a particular
node into sparse long vectors involving all of the faces of the cell, define
permutation matrices for each node,
**P**_{n}
, such that

= **P**_{n} ,

where, for example,

Note that
**P**_{n}
is rectangular, with a size of
*N*_{d} `x` *N*_{lf}
(
3 `x` 6
for 3-D,
2 `x` 4
for 2-D, 1 `x` 2
for 1-D).

Using the permutation matrices, and defining
in a
fashion similar to
(
is a vector
of
**F**^{T}_{f}**A**_{f}
for each cell face), gives

or

or

where

The original vector (on which

which can easily be inverted to give the fluxes (dotted into the areas) in terms of the -differences, =