Does PV accept a time-varying PolyData file (and how would that file look like)?

I have been looking at the examples in the documentation but I am unsure about this. What I want is to write a file containing points (X, Y, Z) and some scalar data associated to it. This is perfectly doable in a vtu or vtp file for a single dataset.

However my question is: is it possible to write various timesteps in the same .vt[u|p] file and have ParaView animate it? The point cloud XYZ values will change from one timestep to the next (the number of points can also change!). Data is not massive so ascii format is preferred.

For the purposes of the answer we could use this file (just add a second timestep where all points have moved 0.5 for example):

<?xml version="1.0"?>
<VTKFile type="PolyData" version="0.1" byte_order="LittleEndian">
   <PolyData>
     <Piece NumberOfPoints="8" NumberOfVerts="0" NumberOfLines="0"
            NumberOfStrips="0" NumberOfPolys="0">
   <Points>
     <DataArray type="Float32" NumberOfComponents="3" format="ascii">
       0 0 0 1 0 0 1 1 0 0 1 0 0 0 1 1 0 1 1 1 1 0 1 1
     </DataArray>
   <Points>
   <DataArray type="Float32" NumberOfComponents="3" format="ascii">
     0 0 0 1 0 0 1 1 0 0 1 0 0 0 1 1 0 1 1 1 1 0 1 1
   </DataArray>
 </Points>
 <PointData Scalars="my_scalars">
   <DataArray type="Float32" Name="my_scalars" format="ascii">
     0 1 2 3 4 5 6 7
  </DataArray>
 </PointData>
 </Piece>
 </PolyData>
</VTKFile>

(sorry about formatting)

EDIT: added info about the fact that nº of points can change from one timestep to the next (data is gathered from a sensor).

Yes, it should be able to. Here’s what you need to modify in your example to add time steps.

<PolyData> :arrow_right:
<PolyData TimeValues="0 0.1 0.2">

Now, in each <DataArray> element in your file, add the TimeStep attribute with the time for which that data is valid, e.g.,

<DataArray … TimeStep=“0”>
<DataArray … TimeStep=“0.1”>

and so on.

That’s about it AFAIK.

Maybe I should be explicit. There should be a separate DataArray for each timestep wherever your original file has DataArrays.

Thank you for the reply.

I guess that if the number of points varies too, it would be advisable to add the TimeStep field at the Piece level and add a Piece for each timestep? I forgot to say that (edited the OP now to reflect that).

Looking at the code, I don’t believe that it is possible to have a varying number of points, but you can try it.

Keep in mind that you can write a separate XML file for each timestep. That does support having a different number of points and cells at each time point. With this approach, to add a time value to a each XML file, add a field data array as follows:

<PolyData>
        <FieldData>
          <DataArray type="Float64" Name="TimeValue" NumberOfTuples="1">1.24
          </DataArray>
        </FieldData>
...
</PolyData>

Yes, I know that I can write a separate file for each timestep, but I was trying to avoid that as constantly opening and closing files is slow (as far as I know) and in my personal opinion, less tidy.

Thank you in any case, I will try to get this to work. Meanwhile I will keep visualizing with OSG, although I want to move to PV as soon as possible.