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.
Can Function.split() and split(Function) all be used to assemble the bilinear form and linear form in variational formulation?
The reason why I guess this is that in my code, both methods can work.
You should not use Function.split() in a variational form. ufl.split should be used in variational forms. Function.split should be used for interpolation etc.
Hi, Dokken. I have an additional question.
the u and p in
u, p = split(w)
are references for components of w according to a fenics official demo fenics demo: Cahn-Hilliard equation.
What about the u and p in u, p = w.split()? Are they references or copies for the components of w?
Thank you very much in advance.
Hi, Dokken. Sorry to bother you again. I have another related question. Do you know how to assign a value to the component of w? I used the following code:
u, p = split(w)
p.interpolate(Constant(5))
But I got an error:
AttributeError: 'Indexed' object has no attribute 'interpolate'
Could you please tell me how to do it correctly? Thank you very much in advance.