# Function.split() vs Split(Function)

Hi I was trying to understand what the difference between the two splits. In particular I would really appreciate an example of different use cases.

For example if I have the following:

``````U2 = ufl.VectorElement("Lagrange", domain.ufl_cell(), 2) # For displacement
P1 = ufl.FiniteElement("Lagrange", domain.ufl_cell(), 1) # For  pressure
TH = ufl.MixedElement([U2, P1])     # Taylor-Hood style mixed element
ME = FunctionSpace(domain, TH)    # Total space for all DOFs

w = Function(ME)

``````

I understand `u, p = split(w)` would give me the functions for the two subelements

However I don’t understand what `u, p = w.split()` would output.

Thanks again for the help.

1 Like

`ufl.split` splits it into `ufl` representations of the sub function, i.e.

``````u, p = ufl.split(w)
print(type(u), type(p)))
``````

returns

``````<class 'ufl.tensors.ListTensor'> <class 'ufl.indexed.Indexed'>
``````

while
`u,p = w.split()`
returns dolfinx functions, which can in turn be collapsed to give contiguous views into dof data

So just to confirm my understanding `u,p = ufl.split(w)` is normally used when creating the variational forms to then put into a solver.

Meanwhile `u,p = w.split()`` is the same as calling ` u = w.sub(0) p = w.sub(1)``` and would be used when post processing data.

1 Like

Yes. You can also `w.split` to access things such as interpolation into a component of a Mixed space