I have three functions w, p, q from function spaces W, P, Q, all of different type and order.
w
p
q
W
P
Q
How can I stitch them together to a function wpq from MixedFunctionSpace([W, P, Q])?
wpq
MixedFunctionSpace([W, P, Q])
You can't stitch them together. You need to start from a mixed space and extract the subspaces.
This may have been indirectly answered by Mikael previously …
I haven't tried this, but what he had suggested in the link above was something like this:
M = MixedFunctionSpace([V,Q,L]) u_m = Function(M) u_m0 = project(some_function, V) # V is M.sub(0) assign(u_m.sub(0), u_m0)
This is not working correctly. MWE:
from dolfin import * mesh = UnitSquareMesh(1, 1) #mesh = UnitSquareMesh(10, 10) W = VectorFunctionSpace(mesh, 'CG', 1) P = FunctionSpace(mesh, 'CG', 1) WP = MixedFunctionSpace([W, P]) WP0 = WP.sub(0).collapse() WP1 = WP.sub(1).collapse() u = Function(WP0) p = Function(WP1) p.assign(project(Expression('sin(6 * x[0])'), WP1)) plot(p, title='in') up = Function(WP) assign(up.sub(0), u) assign(up.sub(1), p) u, p = up.split() plot(p, title='out') interactive()
See https://bitbucket.org/fenics-project/dolfin/issue/210/subfunction-assignment-with.