Update of vector in dynamics time stepping

Hi here!

I am looking for the new syntax corresponding to this old fenics syntax:

Update (u_old ← u)

v_old.vector()[:], a_old.vector()[:] = v_vec, a_vec
u_old.vector()[:] = u.vector()

I need this when coding the time-stepping of an elato-dynamics problem, just as in

https://comet-fenics.readthedocs.io/en/latest/demo/elastodynamics/demo_elastodynamics.py.html

thanks!

sebastien

Are you talking about dolfinx?
Then you can call
u_old.x.array[:] = u.x.array

1 Like

Yes, thank you!

Corrado also showed me (to put u_source into u_target):

u_source.vector.copy(result=u_target.vector)

I guess, it’s exactly the same, right?

Well, with that kind of update you might need to update ghost values with a scatter forward afterwards, as petsc (the .vector object) does not necessarily do any communication of ghost values

1 Like