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
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)
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]’
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}')