Might the problem be that the weak form in the code (definition of F
) is using the gradient, rather than the curl? Note that, although the UFL curl
operator is only defined for 3D vectors, you can conveniently define your own 2D scalar-to-vector curl as a Python function
def curl2D(v):
return as_vector((v.dx(1),-v.dx(0)))