Upon 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 ----")
print("dimension of linear FE space = ", u.sub(0).vector().size())
print("dimension of quadratic FE space = ", u.sub(1).vector().size(), "\n")
print("---- dimensions of FE spaces obtained by split() method ----")
u1, u2 = u.split()
print("dimension of linear FE space = ", u1.vector().size())
print("dimension of quadratic FE space = ", u2.vector().size())
I obtain the following results
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 = 157
dimension of quadratic FE space = 157
---- dimensions of FE spaces obtained by split() method ----
dimension of linear FE space = 157
dimension of quadratic FE space = 157
which is not at all what I had expected. For instance, I expected u.sub(0)
to be a function whose vector representation has length equal to elements of Vh.sub(0)
. I would like to know if this is expected behavior and if so, why is this a desirable feature. Thanks in advance.