Extracting individual solution vectors from mixed space

6 weeks ago by
I'm trying to extract the solution vector from a mixed space. I can get the total vector with sol.vector(), but not the individual components. Is it possible somehow to extract the individual solution vectors? Or can one be sure that they are stored sequentially in sol?

E0 = FiniteElement("P", mesh.ufl_cell(), 1)
E1 = FiniteElement("P", mesh.ufl_cell(), 2)
V = FunctionSpace(mesh, MixedElement([E1, E0]))
sol = Function(V)

# ...

u, u2 = sol.split()
u_h = u.vector().get_local()
# u_h = u.vector().array()
Community: FEniCS Project

1 Answer

6 weeks ago by
You have to perform a deepcopy in order to access the DOFs of the subspaces:
u, u2 = sol.split(deepcopy=True)
u_h = u.vector().get_local()​

Keep in mind that the resulting vector u_h loses its connection to sol.

Please login to add an answer/comment or follow this question.

Similar posts:
Search »