I want to project an expression to a 0th-degree DG subfunction (i.e. function of a "subspace" of a mixed space). Below is my attempt. However, it seems something goes wrong, perhaps the order of the DOFs is handled incorrectly. That is suggested by the plot of the resulting function. I have read about similar issues on the forums and tried FunctionAssigner, but without success.
from dolfin import *
mesh = UnitSquareMesh(10, 10)
RT = FunctionSpace(mesh, "RT", 1)
P = FunctionSpace(mesh, "DG", 0)
mixed = MixedFunctionSpace([RT, P, P])
psi0 = Function(mixed);
f = Expression("x[0]")
assign(psi0.sub(2), project(f, mixed.sub(2).collapse()))
plot(psi0.sub(2))
interactive()
I tried this with version 1.3.0 of Fenics.