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

How to continue a time dependent problem by using the previous output as an initial guess.

+1 vote

Say I run a time dependent problem and end it at some time "t". I come back later and wish to use those same results and run it for a longer time. I have saved the mesh in xml format and used the compute_vertex_value command to save the values of the solution as an array.

How do I implement this array as initial conditions in order to continue running the problem?

Would it be better to save the solution in some other format? How would I do that?

asked Sep 4, 2015 by aldenpack FEniCS User (1,450 points)

2 Answers

0 votes

This might help: http://fenicsproject.org/qa/53/loading-an-initial-condition-from-a-vtu-file

Once you've loaded the initial conditions from a file (see above) you might be able to apply it to the solution function on the original mesh like this:

u.vector()[:] = u_old.vector[:]
answered Sep 5, 2015 by benzwick FEniCS Novice (350 points)
+1 vote

If you have HDF5 support, that is a good way to save checkpoint data.

hdf5 = HDF5File(mesh.mpi_comm(), "a.h5", "w")
hdf5.write(mesh, "mesh")
hdf5.write(u, "potential_field")

You can reload with

hdf5 = HDF5File(mesh.mpi_comm(), "a.h5", "r")
mesh = Mesh()
hdf5.read(mesh, "mesh")
Q = FunctionSpace(mesh, "CG", 3) # or whatever it is
u = Function(Q)
hdf5.read(u, "potential_field")

or similar. There is also support for time series in HDF5 though it is not well documented yet.

answered Sep 5, 2015 by chris_richardson FEniCS Expert (31,740 points)
...