I don’t understand what derivative you want to calculate.
Is it a spatial derivative of a dolfinx.fem.Function
?
Is it a derivative of an ufl-Expression with respect to a variable?
If u
is a function in say a first order lagrange space, then its derivative in z
-direction is a piecewise continuous function on every cell, thus it is no longer continuous.
To get such derivatives, you can use u.dx(i)
and interpolate with dolfinx.fem.Expression
into a suitable function space (“DG” 0 in the case of u
being in P1).
See for instance:
https://jsdokken.com/fenics22-tutorial/heat_eq.html#post-processing-without-projections
and
https://fenics.readthedocs.io/projects/ufl/en/latest/manual/form_language.html?highlight=dx#basic-spatial-derivatives