# Reading a previosly problem solution

**URL:** <https://fenicsproject.discourse.group/t/reading-a-previosly-problem-solution/646>\
**Category:** I/O\
**Created:** [April 22, 2019, 5:30pm UTC](https://fenicsproject.discourse.group/t/reading-a-previosly-problem-solution/646 "2019-04-22T17:30:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Evandro\_Gaio](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/evandro_gaio/32/78_2.png) [@Evandro\_Gaio](https://fenicsproject.discourse.group/u/Evandro_Gaio)\
**Post date:** [April 22, 2019, 5:30pm UTC](https://fenicsproject.discourse.group/t/reading-a-previosly-problem-solution/646/1 "2019-04-22T17:30:30Z")

</div>

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](mailto: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

---

<div class="post-metadata">

**Author:** ![Julius](https://avatars.discourse-cdn.com/v4/letter/j/ecd19e/32.png) [@Julius](https://fenicsproject.discourse.group/u/Julius)\
**Post date:** [April 23, 2019, 5:37pm UTC](https://fenicsproject.discourse.group/t/reading-a-previosly-problem-solution/646/2 "2019-04-23T17:37:13Z")

</div>

> [@Evandro\_Gaio](#):
>
> #output\_file.write(v1, “solution”)

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

---

<div class="post-metadata">

**Author:** ![Evandro\_Gaio](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/evandro_gaio/32/78_2.png) [@Evandro\_Gaio](https://fenicsproject.discourse.group/u/Evandro_Gaio)\
**Post date:** [April 23, 2019, 5:44pm UTC](https://fenicsproject.discourse.group/t/reading-a-previosly-problem-solution/646/3 "2019-04-23T17:44:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Julius](https://avatars.discourse-cdn.com/v4/letter/j/ecd19e/32.png) [@Julius](https://fenicsproject.discourse.group/u/Julius)\
**Post date:** [April 23, 2019, 6:03pm UTC](https://fenicsproject.discourse.group/t/reading-a-previosly-problem-solution/646/4 "2019-04-23T18:03:09Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![sebastkm](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/sebastkm/32/133_2.png) [@sebastkm](https://fenicsproject.discourse.group/u/sebastkm)\
**Post date:** [April 23, 2019, 6:12pm UTC](https://fenicsproject.discourse.group/t/reading-a-previosly-problem-solution/646/5 "2019-04-23T18:12:14Z")

</div>

Have you tried

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