discretize.TreeMesh.nodal_gradient#

TreeMesh.nodal_gradient#

Nodal gradient operator (nodes to edges)

This property constructs the 2nd order numerical gradient operator that maps from nodes to edges. The operator is a sparse matrix Gn that can be applied as a matrix-vector product to a discrete scalar quantity ϕ that lives on the nodes, i.e.:

grad_phi = Gn @ phi

Once constructed, the operator is stored permanently as a property of the mesh.

Returns:
(n_edges, n_nodes) scipy.sparse.csr_matrix

The numerical gradient operator from nodes to edges

Notes

In continuous space, the gradient operator is defined as:

u=ϕ=ϕxx^+ϕyy^+ϕzz^

Where ϕ is the discrete representation of the continuous variable ϕ on the nodes and u is the discrete representation of u on the edges, nodal_gradient constructs a discrete linear operator Gn such that:

u=Gnϕ

The Cartesian components of u are defined on their corresponding edges (x, y or z) as follows; e.g. the x-component of the gradient is defined on x-edges. For edge i which defines a straight path of length hi between adjacent nodes n1 and n2:

ui=ϕn2ϕn1hi

Note that uiu may correspond to a value on an x, y or z edge. See the example below.