Dear community,
I have a code working without problems, however, I found some un-intuitive parts. Here is my code for solving time-dependent multiphysics equations:
# Test functions
eta, psi = ufl.TestFunctions(V)
# Trial functions: 'up' will be our interst to be solved for each step
up = Function(V)
u, p = split(up) # By splitting, u and p is extracted
# Trial functions of the previous step: 'up_n' will store 'up' of previous step
up_n = Function(V)
up_n.sub(1).interpolate(lambda x : np.full((x.shape[1],), -trac0)) # Initial condition
u_n, p_n = split(up_n)
# Time
for (i, dt) in enumerate(np.diff(time_step)):
(...)
# Solve system
solver.solve(up)
up_n.x.array[:] = up.x.array[:]
The last line ALSO updates u_n
and p_n
during the for loop. How can it be? Am I missing something?
Thanks for reading!