[vtkusers] Choosing time for vtkOpenFOAMReader

Timofey Mukha timofey.mukha at it.uu.se
Wed Nov 2 12:43:47 EDT 2016


Hello!

I am trying to write a python script for doing some stuff with an 
OpenFOAM case. Everything works great, except that I can't choose the 
time-value that I want the reader to get the data for.

I have found the SetTimeValue() function which is supposed to do the job 
I think, but it doesn't -- the first availbale time-value is always 
used. Here is how I use the reader:

reader = vtk.vtkOpenFOAMReader()
reader.SetFileName(path)
reader.CreateCellToPointOff()
reader.DisableAllPointArrays()
reader.Update()
print(vtk_to_numpy(reader.GetTimeValues())) # Grab the available timesteps
reader.SetTimeValue(vtk_to_numpy(reader.GetTimeValues())[-1]) # Try to 
load the latest time
reader.Update()

I use the version provided by the Anaconda python disstro, 6.3.0 I believe.

Thanks in advance,

Timofey




More information about the vtkusers mailing list