Is there a way to get the partial derivative for a gradient vector?

You can do that by callinggrad_u.dx(0) or grad_u.dx(1).

Please be clear on how you want to do this comparison.
As the examples you have shown has been simple, analytic expressions, you could simply interpolate the analytical expression into the function space you want to work with. See for instance

As pointed out in the previous part of the question, what I have described gives you a symbolic expression that you can evaluate when integrating. Thus I chose an L2 norm, as it Seems natural in this setting

1 Like