Extracting subspaces/subfunctions from product spaces


I am implementing the time-integration of some wave equation with the constraint \int_\Omega u\ dx = 0 by means of a Lagrange multiplier. My product space therefore is

mesh = UnitSquareMesh(50, 50)
V = FunctionSpace(mesh, FiniteElement('CG', mesh.ufl_cell(), 1) * FiniteElement('Real', mesh.ufl_cell(), 0))

However, due to time-integration I need to invoke (and update at each time step) a function u_ from the first factor of the product space which I believe to obtain by

V_ = V.sub(0).collapse()
  1. Is this correct?

Now, solving my equation at each time step I obtain a function w from V and I do

(u, alpha) = w.split()

However, trying to update


yields an error. It seems that u is NOT an element of V_. Indeed, u.vector()[:] has one entry more than u_.vector()[:].

  1. Why is that and how do I obtain an element of V_ instead?

I would suggest using a FunctionAssigner. The reason for your error is due to the fact that you Did not pass in the keyword argument deepcopy=True To the split function.

1 Like

Hi dokken! The deepcopy argument is sufficient for my purpose. Thank you.