u be the solution to a given problem solved using FEniCS, on a function space
from fenics import * ... u = Function(V) solve(a==L, u, bcs)
x be a
Point object. How do I evaluate the gradient of u at x ?
g = grad(u) g(x)
which raises an error about dimensions :
UFLException: Expecting dim to match the geometric dimension, got dim=1 and gdim=2.
Projecting the gradient on the function space doesn’t give encouraging results either:
h = project(grad(u), V)
also raises an error
UFLException: Shape mismatch.
I guess you have dimensions problems, while projecting a function in a scalar function space. you might need to do something like this:
V_vec = VectorFunctionSpace(mesh, "CG", 1) h = project(grad(u),V_vec)