This property constructs a 2nd order z-derivative operator which maps
from z-faces to cell centers. The operator is a sparse matrix
\(\mathbf{D_z}\) that can be applied as a matrix-vector product
to a discrete scalar quantity \(\boldsymbol{\phi}\) that lives on
z-faces; i.e.:
dphi_dz=Dz@phi
For a discrete vector whose z-component lives on z-faces, this operator
can also be used to compute the contribution of the z-component toward
the divergence.
The numerical z-derivative operator from z-faces to cell centers
Examples
Below, we demonstrate 2) how to apply the face-z divergence operator,
and 2) the mapping of the face-z divergence operator and its sparsity.
Our example is carried out on a 3D mesh.
We start by importing the necessary packages and modules.
For a discrete scalar quantity \(\boldsymbol{\phi}\) defined on the
z-faces, we take the z-derivative by constructing the face-z divergence
operator and multiplying as a matrix-vector product.
Construct the z-divergence operator and apply to vector
>>> Dz=mesh.face_z_divergence>>> dphi_dz=Dz@phi
Plot the original function and the z-divergence
Expand to show scripting for plot
>>> fig=plt.figure(figsize=(13,6))>>> ax1=fig.add_subplot(121)>>> w=np.r_[np.ones(mesh.nFx+mesh.nFz),phi]# Need vector on all faces for image plot>>> mesh.plot_slice(w,ax=ax1,v_type="Fz",normal='Y',ind=20)>>> ax1.set_title("Scalar on z-faces (y-slice)",fontsize=14)>>> ax2=fig.add_subplot(122)>>> mesh.plot_slice(dphi_dz,ax=ax2,normal='Y',ind=20)>>> ax2.set_yticks([])>>> ax2.set_ylabel("")>>> ax2.set_title("Z-derivative at cell center (y-slice)",fontsize=14)>>> plt.show()
The discrete z-face divergence operator is a sparse matrix that maps
from z-faces to cell centers. To demonstrate this, we construct
a small 3D mesh. We then show the ordering of the elements in
the original discrete quantity \(\boldsymbol{\phi}\) and its
z-derivative \(\partial \boldsymbol{\phi}/ \partial z\) as well as a
spy plot.