If you look at the documentation of split
Signature: u.split(deepcopy=False)
Docstring:
Extract any sub functions.
A sub function can be extracted from a discrete function that
is in a mixed, vector, or tensor FunctionSpace. The sub
function resides in the subspace of the mixed space.
*Arguments*
deepcopy
Copy sub function vector instead of sharing
File: /usr/local/lib/python3.6/dist-packages/dolfin/function/function.py
Type: method
you see that you can choose to copy the data or not. If you do not copy the data, it just uses a view into the full function space.
Similarly this holds for sub:
In [2]: u.sub?
Signature: u.sub(i, deepcopy=False)
Docstring:
Return a sub function.
The sub functions are numbered from i = 0..N-1, where N is the
total number of sub spaces.
*Arguments*
i : int
The number of the sub function
Thus running:
import dolfin as dl
nx = 5
mesh = dl.UnitSquareMesh(nx,nx)
P1 = dl.FiniteElement("CG", mesh.ufl_cell(), 1)
P2 = dl.FiniteElement("CG", mesh.ufl_cell(), 2)
Th = dl.MixedElement([P1, P2])
Vh = dl.FunctionSpace(mesh, Th)
Vh1 = dl.FunctionSpace(mesh, P1)
Vh2 = dl.FunctionSpace(mesh, P2)
print("dimension of linear FE space = ", Vh.sub(0).dim())
print("dimension of quadratic FE space = ", Vh.sub(1).dim())
print("dimension of mixed linear/quadratic FE product space = ", Vh.dim(), "\n")
# create a function on the mixed element product-space
u = dl.Function(Vh)
print("---- dimensions of FE spaces obtained by sub() method ----")
for deepcopy in [True, False]:
print(f"dimension of linear FE space (deepcopy={deepcopy}) = {u.sub(0, deepcopy=deepcopy).vector().size()}")
print(f"dimension of quadratic FE space (deepcopy={deepcopy})= {u.sub(1,deepcopy=deepcopy).vector().size()}\n")
print("---- dimensions of FE spaces obtained by split() method ----")
for deepcopy in [True, False]:
u1, u2 = u.split(deepcopy=deepcopy)
print(f"dimension of linear FE space (copy={deepcopy}) = {u1.vector().size()}")
print(f"dimension of quadratic FE space (copy={deepcopy})= {u2.vector().size()}")
produces
dimension of linear FE space = 36
dimension of quadratic FE space = 121
dimension of mixed linear/quadratic FE product space = 157
---- dimensions of FE spaces obtained by sub() method ----
dimension of linear FE space (deepcopy=True) = 36
dimension of quadratic FE space (deepcopy=True)= 121
dimension of linear FE space (deepcopy=False) = 157
dimension of quadratic FE space (deepcopy=False)= 157
---- dimensions of FE spaces obtained by split() method ----
dimension of linear FE space (copy=True) = 36
dimension of quadratic FE space (copy=True)= 121
dimension of linear FE space (copy=False) = 157
dimension of quadratic FE space (copy=False)= 157