How ufl.nabla_grad works?

Hi Guys,

I am trying to understand a basic function - ufl.nabla_grad.

Can anyone tell me how it calculates the gradient of a function.

Thanks a lot

See for instance the old Q&A. To summarize:
No difference for scalars.

For vectors:

(grad v)_ij = dv_i / dx_j
(nabla_grad v)_ij = dv_j / dx_i

For matrices:

(div v)_i = dv_ij / dx_j
(nabla_div v)_j = dv_ij / dx_i

Thanks for the reply.

can you also clarify in which part of the source code the computation of the gradient is occurring.

I tried to look at the NablaGrad Class and its parent classes CoefficientDerivative, Derivative, Operator, but I couldn’t find where the computation is occurring.

Take a look at ufl.algorithms.apply_derivatives.