This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

split function from mixed function space to allow copy(), assign

+1 vote

I have a function from a mixed function space à la

W_element = VectorElement('Lagrange', mesh.ufl_cell(), 2)
P_element = FiniteElement('Lagrange', mesh.ufl_cell(), 1)
WP = FunctionSpace(mesh, W_element * P_element)
up = Function(WP)

and I'd like to dissect it into two fully qualified functions u and p. Splitting like

u, p = up.split()

gives my something, but I can't copy/assign the function to another, i.e.,

W = u.function_space().collapse()
u2 = Function(W)
u2.assign(u0)  # fail
u2 = u.copy()  # fail

The error is

*** Error:   Unable to access vector of degrees of freedom.
*** Reason:  Cannot access a non-const vector from a subfunction.

How can I split up into u and p such that they can be copy()d?

asked Mar 31, 2017 by nschloe FEniCS User (7,120 points)

1 Answer

+1 vote
 
Best answer

Did you try

u, p = up.split(True)

?

answered Mar 31, 2017 by hernan_mella FEniCS Expert (19,460 points)
selected Mar 31, 2017 by nschloe
...