Loading initial conditions from previous run

Hi all,
I’m very new at working with these pvd/vtu formats, if I’m integrating a PDE on time and I output to a pvd file like this

file = File("output.pvd")
t = 0
for n in range(num_timesteps):
     t += dt
    ...
    file << (f, t)

If I then stop a simulation and I have the pvd output files plus all the vtu files with each configuration of the function f, how can I load the last timestep that I have an output for and use it as an initial condition?

Thanks!

Try XDMFFile::write_checkpoint and XDMFFile::read_checkpoint, respectively.