Time support in VTK/Paraview

From my C++ code for a scientific simulation, I’m exporting .vtp files to be visualized with paraview. Until now, I was using a constant time step length so the task was easy: I just named my files as out_i.vtp, imported the whole series in Paraview and animated them. Now, however, I’ve implemented an adaptive time step length, so that it is not guaranteed anymore that the output files are equally spaced.

I’m aware of the existence of this page, and i’ve read Chapter 11 in the VTK User Guide, but still I can’t exactly figure out where in VTK I can specify a time step that can then be read by paraview.

Also, I’ve seen that one could basically also create a collection by writing a XML file like that:

<VTKFile type="Collection" version="0.1" byte_order="LittleEndian">
  <Collection>
<DataSet timestep="0.01" group="" part="0" file="Foo_001.vtu"/>
<DataSet timestep=“0.02" group="" part="0" file=“Foo_002.vtu"/>
<DataSet timestep=“0.03" group="" part="0" file=“Foo_003.vtu"/>
  </Collection>
</VTKFile>

but that left me with an empty renderview in paraview.

What is the actual best practice to import vtk files in paraview with time support?

Use a .series file

https://gitlab.kitware.com/paraview/paraview/blob/v5.5.0/Documentation/release/ParaView-5.5.0.md#json-based-new-meta-file-format-for-series-added

So there is no mechanism for storing integer iteration number and float time step in a a VTK XML file, and we need to make a separate file in JSON for that information?

Either that, or you can use a .pvd file.

JSON (file extension .series):

{
  "file-series-version" : "1.0",
  "files" : [
    { "name" : "foo1.vtk", "time" : 0 },
    { "name" : "foo2.vtk", "time" : 5.5 },
    { "name" : "foo3.vtk", "time" : 11.2 }
  ]
}

The above works with both VTK XML and Legacy VTK files.

PVD (file extension .pvd):

<VTKFile type="Collection" version="0.1" byte_order="LittleEndian">
    <Collection>
        <DataSet timestep="0"         file='file_0.vtu'/>
        <DataSet timestep="0.022608"  file='file_1.vtu'/>
        <DataSet timestep="0.73781"   file='file_2.vtu'/>
    </Collection>
</VTKFile>

The above works only with VTK XML files.

1 Like