# discretize.TreeMesh.average_cell_to_face#

TreeMesh.average_cell_to_face#

Averaging operator from cell centers to faces (scalar quantities).

This property constructs an averaging operator that maps scalar quantities from cell centers to face. This averaging operator is used when a discrete scalar quantity defined cell centers must be projected to faces. Once constructed, the operator is stored permanently as a property of the mesh. See notes.

Returns
(n_faces, n_cells) scipy.sparse.csr_matrix

The scalar averaging operator from cell centers to faces

Notes

Let $$\boldsymbol{\phi_c}$$ be a discrete scalar quantity that lives at cell centers. average_cell_to_face constructs a discrete linear operator $$\mathbf{A_{cf}}$$ that projects $$\boldsymbol{\phi_c}$$ to faces, i.e.:

$\boldsymbol{\phi_f} = \mathbf{A_{cf}} \, \boldsymbol{\phi_c}$

where $$\boldsymbol{\phi_f}$$ approximates the value of the scalar quantity at the faces. For each face, we are performing a weighted average between the values at adjacent cell centers. In 1D, where adjacent cells $$i$$ and $$i+1$$ have widths $$h_i$$ and $$h_{i+1}$$, $$\phi$$ on face is approximated by:

$\phi_{i \! + \! 1/2} \approx \frac{h_{i+1} \phi_i + h_i \phi_{i+1}}{h_i + h_{i+1}}$

On boundary faces, nearest neighbour is used to extrapolate the value from the nearest cell center. Once the operator is construct, the averaging is implemented as a matrix vector product, i.e.:

phi_f = Acf @ phi_c