Find gradient of solution in dolfinx

Hello,

I’m trying to find the gradient of the solution in dolfin-x.

This is easily done in dolfin using the following:

res = project(grad(u))

I was wondering how this is done in dolfin-x?

Cheers,

H

A projection of grad(f) is simply solving a(u,v)=inner(u,v)*dx=inner(grad(f),v)*dx=l(v)
were u,v are Trial and test functions for the space you want to project into. See for instance: Implementation — FEniCSx tutorial
Or
dolfiny/projection.py at master · michalhabera/dolfiny · GitHub

Thanks for the prompt response Jorgen. This solves my problem.