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

Version 2016.1.0, split() for new MixedElement

+2 votes

I have in the past been able to use the syntax

u,v,w = U.split()

to get at the individual components of a 3-way mixed element U.

With version 2016.1.0, split() still works, but now I am confused what is being output. For example, there appears to be a hierarchy of mixed elements now :

from fenics import *

mesh = UnitCubeMesh(2,2,2)
Q    = FiniteElement("CG", mesh.ufl_cell(), 1)
M    = FunctionSpace(mesh, Q*Q*Q)
U    = Function(M)

out  = U.split()
out2 = out[0].split()

v    = out[0]
w    = out[1]
x    = out2[0]
y    = out2[1]

print id(v), id(w), id(x), id(y)

I can't seem to find the documentation on this, can anyone help?

Thanks again,
Evan

EDIT:

To clarify why I need this, I'd like to rename the individual components, and extract their functionspaces. This was possible with the old way and split().

asked Aug 10, 2016 by pf4d FEniCS User (2,970 points)
edited Aug 10, 2016 by pf4d

1 Answer

0 votes
 
Best answer

Q*Q*Q means (Q*Q)*Q in Python because * is binary operator. Did you want to do

M    = FunctionSpace(mesh, MixedElement([Q, Q, Q]))

? Then you will get

len(u.split()) == 3
answered Aug 10, 2016 by Jan Blechta FEniCS Expert (51,420 points)
selected Aug 13, 2016 by pf4d

Ah ha! Yes, perfect, thanks again.

...