Difference between split() and sub() in mixed formulation

Hello everyone,

I am quite new to FEnicsx and I am confused between split() and sub() functions in mixed formulation. I want to create a mixed formulation. I have some understanding of the split() and sub() functions but not very clear about them. Here u is displacement and p is pressure.

u_el = ufl.VectorElement(“CG”, domain.ufl_cell(), 2) # u quad element
p_el = ufl.FiniteElement(“CG”, domain.ufl_cell(), 1) # p linear element
element = ufl.MixedElement([u_el, p_el]) # Mixed Element
V = fem.FunctionSpace(domain, element) # Mixed Function space
up = fem. Function(V)

Until this point is clear. However, I want to understand the difference between the following 3 cases for creating spaces:
Case 1

u_sp = fem.FunctionSpace(domain,u_el)
p_sp = fem.FunctionSpace(domain, p_el)

Case 2

u, p = ufl.split(up)

Case 3:

Vu, Vu_to_V = V.sub(0).collapse()
u_sub = fem. Function(Vu)
Vp, Vp_to_V = V.sub(1).collapse()
p_sub = fem. Function(Vp)

Also, if I want to define velocity using the time derivative of u, how does one obtain the value of u_n in (u - u_n)/dt.

Thank you in advance! :slight_smile:

Hi. Just a regular user here. You have no idea how many posts the managers of the forum have to answer (you could count them ; ) ). If I were you, I would be kind to them: carefully Read before posting: How do I get my question answered?

see Function.split() vs Split(Function)


For a time dependent problem, you have initial conditions. You start by assigning these to u_n. Then, secondly, you solve for the current time step and reassig the solution of the current step to u_n. See
for an example