Paraview Foam Reader - Decomposed case

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

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?

please share your data.

@mwestphal

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)

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

maybe @olesenm has an idea.

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

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

tk = GetTimeKeeper()
times = tk.TimestepValues

@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]’

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)

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.

# 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}')

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