Skip to content

salvus.fem.derivatives

salvus.fem.derivatives salvus fem derivatives

Functions to compute derivatives of nodal fields.

Functions

compute_gradient()

def compute_gradient(
    nodes: _ElementNodes | npt.NDArray, nodal_fields: dict[str, npt.NDArray]
) -> dict[str, npt.NDArray]: ...

Compute the gradient of a field defined at the GLL points.

This function computes the derivatives of the N + 1 Lagrange polynomials (N being the polynomial order) to compute the derivative of a field that is defined at the GLL points.

Parameters
  • nodes _ElementNodes | npt.NDArray — Element nodes at which the gradient should be computed.
  • nodal_fields dict[str, npt.NDArray] — The fields defined at the element nodes for which the gradient should be computed.
Returns dict[str, npt.NDArray] — Dict containing the derivatives of the fields with respect to each dimension. Each derivative has the same shape as the input field.

compute_gradient_adjoint()

def compute_gradient_adjoint(
    nodes: _ElementNodes | npt.NDArray, gradient_fields: dict[str, npt.NDArray]
) -> dict[str, npt.NDArray]: ...

Apply the adjoint of the gradient operator to a set of fields.

The adjoint of compute_gradient with respect to the Euclidean inner product over all element nodes: sum_k <G_k f, q_k> == <f, sum_k G_k^T q_k>. Used to differentiate functionals of the spatial gradient of a field, e.g., regularization terms.

Parameters
  • nodes _ElementNodes | npt.NDArray — Element nodes at which the fields are defined.
  • gradient_fields dict[str, npt.NDArray] — Per-dimension fields keyed d{name}/d{x|y|z}, as returned by compute_gradient, with all dimensions of every name.
Returns dict[str, npt.NDArray] — The adjoint of the gradient summed over the dimensions, keyed by name.