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

**URL:** https://discourse.paraview.org/t/does-pv-accept-a-time-varying-polydata-file-and-how-would-that-file-look-like/1735
**Category:** ParaView Support
**Created:** [April 29, 2019, 10:02am UTC](https://discourse.paraview.org/t/does-pv-accept-a-time-varying-polydata-file-and-how-would-that-file-look-like/1735 "2019-04-29T10:02:34Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Adrian](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/a/82dd89/32.png) [@Adrian](https://discourse.paraview.org/u/Adrian)
#### Post date: [April 29, 2019, 10:02am UTC](https://discourse.paraview.org/t/does-pv-accept-a-time-varying-polydata-file-and-how-would-that-file-look-like/1735/1 "2019-04-29T10:02:34Z")

</div>

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).

---

<div class="post-metadata">

### Author: ![cory.quammen](https://discourse.paraview.org/user_avatar/discourse.paraview.org/cory.quammen/32/11193_2.png) [@cory.quammen](https://discourse.paraview.org/u/cory.quammen)
#### Post date: [April 29, 2019, 1:49pm UTC](https://discourse.paraview.org/t/does-pv-accept-a-time-varying-polydata-file-and-how-would-that-file-look-like/1735/2 "2019-04-29T13:49:13Z")

</div>

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

`<PolyData>` ➡  
`<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.

---

<div class="post-metadata">

### Author: ![cory.quammen](https://discourse.paraview.org/user_avatar/discourse.paraview.org/cory.quammen/32/11193_2.png) [@cory.quammen](https://discourse.paraview.org/u/cory.quammen)
#### Post date: [April 29, 2019, 2:03pm UTC](https://discourse.paraview.org/t/does-pv-accept-a-time-varying-polydata-file-and-how-would-that-file-look-like/1735/3 "2019-04-29T14:03:45Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Adrian](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/a/82dd89/32.png) [@Adrian](https://discourse.paraview.org/u/Adrian)
#### Post date: [April 29, 2019, 2:41pm UTC](https://discourse.paraview.org/t/does-pv-accept-a-time-varying-polydata-file-and-how-would-that-file-look-like/1735/4 "2019-04-29T14:41:52Z")

</div>

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).

---

<div class="post-metadata">

### Author: ![cory.quammen](https://discourse.paraview.org/user_avatar/discourse.paraview.org/cory.quammen/32/11193_2.png) [@cory.quammen](https://discourse.paraview.org/u/cory.quammen)
#### Post date: [April 29, 2019, 2:55pm UTC](https://discourse.paraview.org/t/does-pv-accept-a-time-varying-polydata-file-and-how-would-that-file-look-like/1735/5 "2019-04-29T14:55:44Z")

</div>

> [@Adrian](#):
>
> 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?

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:

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

```

---

<div class="post-metadata">

### Author: ![Adrian](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/a/82dd89/32.png) [@Adrian](https://discourse.paraview.org/u/Adrian)
#### Post date: [April 30, 2019, 8:13am UTC](https://discourse.paraview.org/t/does-pv-accept-a-time-varying-polydata-file-and-how-would-that-file-look-like/1735/6 "2019-04-30T08:13:03Z")

</div>

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.
