discretize.utils.av_extrap#

discretize.utils.av_extrap(n)[source]#

Create 1D averaging operator from cell-centers to nodes.

For n cells, the 1D averaging operator from cell centers to nodes is sparse and has shape (n+1, n). Values at the outmost nodes are extrapolated from the nearest cell center value. Thus the operator takes the form:

\[\begin{split}\begin{bmatrix} 1 & & & & \\ 1/2 & 1/2 & & & \\ & 1/2 & 1/2 & & & \\ & & \ddots & \ddots & \\ & & & 1/2 & 1/2 \\ & & & & 1 \end{bmatrix}\end{split}\]
Parameters:
nint

Number of cells

Returns:
(n+1, n) scipy.sparse.csr_matrix

The 1D averaging operator from cell-centers to nodes.