Should a UFL statement be updated with adaptive time-stepping?

5 months ago by
Most examples online solve time-dependent PDE's using a static Δt. For example:

dt = 0.1
u = TrialFunction(V)
u_m = #... some initial condition
v = TestFunction(V)
a = u*v*dx + dt*inner(nabla_grad(u), nabla_grad(v))*dx
L = (u_m + 2*dt)*v*dx
u = Function(V)
T = 2
t = dt

while t <= T:
    solve(a == L, u)
    t += dt

Consider the case where Δt is not a constant, but based on some heuristic and changed every iteration. Do the variables `a` and `L` have to be reformed every iteration as well?

Community: FEniCS Project
Short answer: yep. Technical answer: yep, but you can be clever to make your computation more efficient.
written 5 months ago by Nate  
Thank you for your response. Can you expand on that last point?
written 5 months ago by Matt  

1 Answer

5 months ago by
You can try this

dt = Constant(0.0)
a = u*v*dx + dt*inner(nabla_grad(u), nabla_grad(v))*dx
a.dt = 1.0​
# Now solve

Later on you just set a.dt before solve if you want to change dt.
Please login to add an answer/comment or follow this question.

Similar posts:
Search »