[vtkusers] Solved: Storing multiple time-steps in a single .vt?-file

Johannes Strecha j.strecha at gmail.com
Fri Nov 2 06:45:14 EDT 2012


Dear all,

just for sharing, a method of how to store multiple time-steps in a
single .vt?-file (haven't found this yet, only statements that this is
either impossible or directions to use the EnSight format). I tested
this with the XML Polydata and Unstructured Grid writers from vtk 5.8
and the current 6.0 snapshot.

I have a series of vtk-files containing 1 time-step
each (N.B. from the CGNS-export of a proprietary CFD software
package). The python-script for Unstructured Grid Data:

> #!/usr/bin/env python
>
> from vtk import vtkXMLUnstructuredGridReader,vtkXMLUnstructuredGridWriter
> from glob import glob
>
> dt = delta_t
>
> reader = vtkXMLUnstructuredGridReader()
> filelist = sorted(glob('path/to/file/series-????.vtu'))
> # the '?' stands for a single character, numbers in my case
>
> writer = vtkXMLUnstructuredGridWriter()
> writer.SetFileName('outfile.vtu')
> writer.SetNumberOfTimeSteps(len(filelist))
> writer.SetTimeStepRange(0,len(filelist)-1)
> writer.SetInputConnection(reader.GetOutputPort())
>
> writer.Start()
>
> for file,i in zip(filelist,range(len(filelist))):
>     print(file)
>     reader.SetFileName(file)
>     reader.Modified()
>     writer.WriteNextTime(i*dt)
>
> writer.Stop()

Static information like cell connectivity seems to be written
just once. When reading the file in paraview only memory for one
time-step is consumed (this doesn't seem to be the case for
polydata, however). For no apparent reason Paraview fails to
display the correct time-values.

I hope that this will be useful.

Kind regards,
Johannes Strecha.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20121102/bf808030/attachment.htm>


More information about the vtkusers mailing list