For some reason, the following code
from dolfin import *
r = Rectangle(-1, -1, 1, 1)
mesh = Mesh(r, 10)
positions = mesh.coordinates()
V = FunctionSpace(mesh, "CG", 1)
f = Expression('sin(3.14159*x[0]) + cos(3.14159*x[1])')
u = interpolate(f,V)
cell_markers = CellFunction("bool", mesh)
cell_markers.set_all(True)
mesh_refined = refine(mesh, cell_markers)
u_refined = adapt(u, mesh_refined)
u_refined.set_parent(u)
plot(grad(u_refined))
interactive()
Fails with the following error code:
ufl.log.UFLException: Invalid type conversion: class
'dolfin.cpp.function.Function' can not be converted to any UFL type.
The representation of the object is: dolfin.cpp.function.Function;
proxy of Swig Object of type 'boost::shared_ptr dolfin::Function
*' at 0x108a0e5d0
What am I missing here?