Note that in r
you have a trial function (u). This has to be replaced by your solution to the problem, using
For instance ufl.replace
. See Derivative function has no attribute 'subs' - #2 by dokken on how to use replace. If there are no test or trial functions in the residual, the assembly (r*dx) simply becomes a scalar value.
If you want to look at the spatial variation of the residual, you should project it into a suitable function space and save the result to pvd or xdmf