I am running a time-dependent simulation on M processors in parallel and would like to store my simulation results in each timestep in the HDF5 format. Subsequently, I would like to retrieve the results in a different script on N processors, typically N = 1. The TimeSeriesHDF5 class looks suitable for this, but at the moment my results seem to get scrambled upon either storing or retrieval.
My questions are
1) Is this supposed to work?
2) If yes, how?
3) If no, what is the preferred alternative approach for storing simulation results and eventually retrieving them as Functions?
Please see below for a minimal example. Consider the following two scripts: store.py:
from dolfin import *
mesh = UnitSquareMesh(12,12)
V = FunctionSpace(mesh, "CG", 1)
f = Expression("x[0]", degree=1)
f = project(f, V)
series = TimeSeriesHDF5(mesh.mpi_comm(), "f")
for i in range(1):
series.store(f.vector(), i)
plot(f, title="f_%g" % i)
and retrieve.py:
from dolfin import *
mesh = UnitSquareMesh(12,12)
V = FunctionSpace(mesh, "CG", 1)
f = Function(V)
series = TimeSeriesHDF5(mesh.mpi_comm(), "f")
times = series.vector_times()
for t in times:
series.retrieve(f.vector(), t, False)
plot(f, title="f_%g" % t)
Running
mpirun -n 2 python store.py
python retrieve.py
results in the resulting retrieved f looking scrambled.
My apologies if this question has been answered multiple times already, I couldn't find a detailed answer here in the Q&A.