Reading a previosly problem solution

Hello everyone.

I’m trying to read a solution from a problem to another.

In the previous problem, I’ve used:

timeseries_v1 = TimeSeries(‘velocity’)
timeseries_p1 = TimeSeries(‘pressure’)

while t<t_end:

Compute Fluid problem

print(‘\n\nSolving Fluid Problem’)
solve(F1 == 0, vp1, bcs=bcs_rigid, J=J, solver_parameters = par, form_compiler_parameters = {“quadrature_degree”: 3})

Extract solutions:

(v1, p1) = vp1.split(True)

Save solution to file (XDMF/HDF5)

#output_file.write(v1, “solution”)
#output_file.write(p1, “solution”)

timeseries_v1.store(v1.vector(), t)
timeseries_p1.store(p1.vector(), t)

#Fluid next step

vn.assign(v1)
t += dt

This save the files pressure.h5 and velocity.h5

An then, I tried to read using:

vr, pr = Function(W.sub(0).collapse()), Function(W.sub(1).collapse())

input_file = HDF5File(mesh.mpi_comm(), “velocity.h5”, “r”)
input_file.read(vr, “v1”)
input_file = HDF5File(mesh.mpi_comm(), “velocity.h5”, “r”)
input_file.read(vr, “p1”)

The problem is, a got the following error:

input_file.read(vr, “velocity”)
RuntimeError:

*** -------------------------------------------------------------------------
*** DOLFIN encountered an error. If you are not able to resolve this issue
*** using the information listed below, you can ask for help at


*** fenics-support@googlegroups.com


*** Remember to include the error message listed below and, if possible,
*** include a minimal running example to reproduce the error.


*** -------------------------------------------------------------------------
*** Error: Unable to read function from file.
*** Reason: Group with name “velocity” does not exist.
*** Where: This error was encountered inside HDF5File.cpp.
*** Process: 0


*** DOLFIN version: 2018.1.0
*** Git changeset: 948dc42cc4e06ed9227d0201ad50f94ac94cbf9f

I’ve tried change “velocity” for “v1” but the error is the same!

Any help?

Thanks

You named your dataset ‘solution’. Name it ‘velocity’ or use input_file.read(vr, “solution”)

Ty Julius. I’ve tried this but dosn’t work. I think the problem is in the saving part, because I tried to read the groups and didn’t find the group I need to read using:

h5ls -r pressure_series.h5

Ok, I overlooked that you use TimeSeries. Is it meant to write output to files? From what I saw I think it might not be suitable.

I rather think you should use HDF5File (name your dataset according to the time step) or XDMFFile (write_checkpoint).

Have you tried

timeseries_v1 = TimeSeries("velocity")
timeseries_v1.retrieve(vr.vector(), t)