This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Initial condition in mixed function spaces

0 votes

Hello,
I am trying to solve a 1d shallow water problem with mixed function spaces defined as

v_ele = FiniteElement("DG", mesh.ufl_cell(), 1) 
h_ele = FiniteElement("DG", mesh.ufl_cell(), 1)
W = FunctionSpace(mesh, MixedElement([v_ele, h_ele]))

I start defining the functions

solution_old = Function(W, name="SolutionOld")
functions_old = split(solution_old)
u_old = functions_old[0]
h_old = functions_old[1]

and then the conditions

h_initial = Expression(....)
u_initial = Constant(...)

Now I would like to assign these conditions to u_old and h_old, but I'm not able to do it.
If I try with u_old.assign(Function(W.sub(0)).interpolate(u_initial))
I receive the error

File "sw_DG.py", line 73, in
u_old.assign(Function(W.sub(0)).interpolate(u_initial))
AttributeError: 'Indexed' object has no attribute 'assign'

and another error if I try with u_old = interpolate(u_initial, W.sub(0))
I think it's a problem with the split of the space W, but I don't know how to solve it.

Thanks in advance

asked Jun 18, 2017 by sara_89 FEniCS Novice (230 points)

Hi, see e.g. here for answer.

1 Answer

+1 vote
 
Best answer

There are several questions with answers on this issue, see

Is there a reverse split command?
Interpolation on mixed functionspace - shapes not matching

answered Jun 19, 2017 by KristianE FEniCS Expert (12,900 points)
selected Jun 19, 2017 by sara_89
...