# Paraview Foam Reader - Decomposed case

**URL:** https://discourse.paraview.org/t/paraview-foam-reader-decomposed-case/12157
**Category:** ParaView Support
**Tags:** python
**Created:** [May 25, 2023, 11:59pm UTC](https://discourse.paraview.org/t/paraview-foam-reader-decomposed-case/12157 "2023-05-25T23:59:54Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![vrkssai](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/v/e19b73/32.png) [@vrkssai](https://discourse.paraview.org/u/vrkssai)
#### Post date: [May 25, 2023, 11:59pm UTC](https://discourse.paraview.org/t/paraview-foam-reader-decomposed-case/12157/1 "2023-05-25T23:59:54Z")

</div>

I’m trying to load openfoam data using openfoamreader pvpython/paraview package in python. It seems to work for reconstructed but not for decomposed case. I’m unable to step in time to probe a location value with time. This is the code I’m using

```auto
import vtk
import numpy as np
from paraview.simple import *

data = OpenFOAMReader(FileName='./dummy.foam')

data.SkipZeroTime = 1
data.CaseType = 'Decomposed Case'
data.LabelSize = '32-bit'
data.ScalarSize = '64-bit (DP)'
data.Createcelltopointfiltereddata = 1
data.Adddimensionalunitstoarraynames = 0
data.MeshRegions = ['internalMesh']
data.CellArrays = ['U']
data.PointArrays = []
data.LagrangianArrays = []
data.Cachemesh = 0
data.Decomposepolyhedra = 0
data.ListtimestepsaccordingtocontrolDict = 0
data.Lagrangianpositionswithoutextradata = 0
data.Readzones = 0
data.Copydatatocellzones = 0
#data.UpdatePipeline()

tk = GetTimeKeeper()
times = tk.TimestepValues

```

The “times” returns “[0.0]”. What am I missing?

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [May 26, 2023, 7:14am UTC](https://discourse.paraview.org/t/paraview-foam-reader-decomposed-case/12157/2 "2023-05-26T07:14:57Z")

</div>

please share your data.

---

<div class="post-metadata">

### Author: ![vrkssai](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/v/e19b73/32.png) [@vrkssai](https://discourse.paraview.org/u/vrkssai)
#### Post date: [May 26, 2023, 7:50am UTC](https://discourse.paraview.org/t/paraview-foam-reader-decomposed-case/12157/3 "2023-05-26T07:50:43Z")

</div>

@mwestphal

> **[pitzDailyPulse.tar](https://drive.google.com/file/d/1rmQrPml6D8AMpCCbo4039sKoXZbsoRLY/view?usp=sharing)**
>
> Google Drive file.

I’ve recreated it with an example. The data is computed for may timesteps after 0 (you can see that if you navigate to processor0 or processor1 folders). I want to change time steps and probe a location, say (0.15,0,0) on the ‘decomposed case’ without the need to reconstruct the data. Script also included in the folder (extract-pointdata.py)

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [May 26, 2023, 8:29am UTC](https://discourse.paraview.org/t/paraview-foam-reader-decomposed-case/12157/4 "2023-05-26T08:29:40Z")

</div>

Afaics the reader reports that there is not timesteps in this data apart from the first one.

maybe @olesenm has an idea.

---

<div class="post-metadata">

### Author: ![Kenichiro-Yoshimi](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/k/ecc23a/32.png) [@Kenichiro-Yoshimi](https://discourse.paraview.org/u/Kenichiro-Yoshimi)
#### Post date: [May 26, 2023, 9:09am UTC](https://discourse.paraview.org/t/paraview-foam-reader-decomposed-case/12157/5 "2023-05-26T09:09:44Z")

</div>

Adding `UpdateAnimationUsingDataTimeSteps()` before `GetTimeKeeper()` in the script file (extract-pointdata.py) seems to recognize time steps. (Ver 5.11.1)

```python
# get animation scene
animationScene1 = GetAnimationScene()
animationScene1.UpdateAnimationUsingDataTimeSteps()

tk = GetTimeKeeper()
times = tk.TimestepValues

```

---

<div class="post-metadata">

### Author: ![vrkssai](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/v/e19b73/32.png) [@vrkssai](https://discourse.paraview.org/u/vrkssai)
#### Post date: [May 28, 2023, 2:29am UTC](https://discourse.paraview.org/t/paraview-foam-reader-decomposed-case/12157/6 "2023-05-28T02:29:46Z")

</div>

@Kenichiro-Yoshimi Thank you!, I’m able to get the list of timesteps. But how do I change the timestep and extract point data? I’m trying it with the below code but the value doesn’t change as I change ‘tk.Time()’. It always seem to get the values corresponding to ‘times[0]’

```auto
tk.Time = times[10]
tk.UpdateTimeInformation()
data.UpdatePipeline()

probeLocation1 = ProbeLocation(registrationName='Probe1', Input=data, ProbeType='Fixed Radius Point Source')
probeLocation1.ProbeType.Center = [0.1347,0, 0]
probeLocation1.ProbeType.NumberOfPoints = 1
probeLocation1.ProbeType.Radius = 0.0

polyData = servermanager.Fetch(probeLocation1)
pointData = polyData.GetPointData()
uArray = pointData.GetArray('U')
value = np.array(uArray.GetTuple(0))

print(value)

```

---

<div class="post-metadata">

### Author: ![Kenichiro-Yoshimi](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/k/ecc23a/32.png) [@Kenichiro-Yoshimi](https://discourse.paraview.org/u/Kenichiro-Yoshimi)
#### Post date: [May 28, 2023, 4:48am UTC](https://discourse.paraview.org/t/paraview-foam-reader-decomposed-case/12157/7 "2023-05-28T04:48:38Z")

</div>

If described as follows, the value seems to change at each time step. If there is no “Show()” line, the value does not change, so Show() may be the key.

```python
# get animation scene
animationScene1 = GetAnimationScene()
animationScene1.UpdateAnimationUsingDataTimeSteps()

tk = GetTimeKeeper()
times = tk.TimestepValues

probeLocation1 = ProbeLocation(registrationName='Probe1', Input=data, ProbeType='Fixed Radius Point Source')
probeLocation1.ProbeType.Center = [0.1347,0, 0]
probeLocation1.ProbeType.NumberOfPoints = 1
probeLocation1.ProbeType.Radius = 0.0
Show()

for time in times:

    animationScene1.AnimationTime = time

    polyData = servermanager.Fetch(probeLocation1)
    pointData = polyData.GetPointData()
    uArray = pointData.GetArray('U')
    value = np.array(uArray.GetTuple(0))

    print(f'{time}\tsec:\tU{value}')

```

---

<div class="post-metadata">

### Author: ![vrkssai](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/v/e19b73/32.png) [@vrkssai](https://discourse.paraview.org/u/vrkssai)
#### Post date: [May 30, 2023, 7:06pm UTC](https://discourse.paraview.org/t/paraview-foam-reader-decomposed-case/12157/8 "2023-05-30T19:06:17Z")

</div>

> [@Kenichiro-Yoshimi](#):
>
> ```auto
> probeLocation1 = ProbeLocation(registrationName='Probe1', Input=data, ProbeType='Fixed Radius Point Source')
> probeLocation1.ProbeType.Center = [0.1347,0, 0]
> probeLocation1.ProbeType.NumberOfPoints = 1
> probeLocation1.ProbeType.Radius = 0.0
> Show()
> 
> for time in times:
> 
> animationScene1.AnimationTime = time
> 
> polyData = servermanager.Fetch(probeLocation1)
> pointData = polyData.GetPointData()
> uArray = pointData.GetArray('U')
> value = np.array(uArray.GetTuple(0))
> 
> print(f'{time}\tsec:\tU{value}')
> 
> ```

Thank you @Kenichiro-Yoshimi !, this seems to work.
