Understanding the VTK format in Paraview

Hi guys, it’s my first time posting on this forum so please excuse any faults I might make.

I’m currently working on implementing a “flow-induced” fluid-structure interaction model using the immersed boundary method in foam-extend 4.0. Work is going well however, my simulations are producing far too much data, specifically stl files of the immersed boundary.

From what I’ve been told, the function which writes these files out (writeVTK) needs to be updated and this is where you guys can help me.

I need to gain a better understanding of the VTK format from Paraview and would appreciate any resources you can point me too so that I may do this.

Specifically I need to know

  1. Can the VTK reader in Paraview take a floating point argument to the file name
  2. Can the VTK format from Paraview read multiple (point or face?) data, and MAY in fact have the possibility of specifying a time index.

Any help you guys can give is much appreciated.

I’m confused by this question. Can you elaborate ?

The VTK format supports multiples point and cell data arrays.
The VTK format does not support timesteps within. However, time series (multiple VTK files) are supported.

1 Like

Hi Mathieu

Thanks for the very quick response, I’ll try to clarify my first question.

My understanding is that Paraview will only accept an int in the file name and not a floating point value. This is to say that option 1. below is currently acceptable while option 2. is not.

  1. filename_1.stl, filename_2.stl, etc… (int in the filename (time index))
  2. filename_0.1.stl, filename_0.2.stl, etc… (floating point in the filename (time value))

This is with the legacy VTK format which FOAM currently uses. Unfortunately this is leading to a sync issue but perhaps it is possible with the “newer” VTK format?

So ultimately I need to know if there is a way to encode the time-step value (not the time index value) into a VTK file.

This would resolve a lot of issues and any help you can give is much appreciated.

Afaik, this is not supported. However, it would be possible to create a filter that reads a secondary file as a parameters (similar to AddFieldArrays filter) in order to provide time values to the pipeline. Not an easy task though.

1 Like

Thanks for clearing that up Matheiu

Can this not be done with a .pvd file?

https://www.paraview.org/Wiki/ParaView/Data_formats

I thought it worked with legacy vtk files but the above suggests not. You could write a simple script to convert your files to .vtp’s Then you can specify timesteps in a pvd file:

<?xml version="1.0"?>
<VTKFile type="Collection" version="0.1"
     byte_order="LittleEndian"
     compressor="vtkZLibDataCompressor">
  <Collection>
<DataSet timestep="0" group="" part="0"
         file="examplePVD/examplePVD_T0000.vtp"/>
<DataSet timestep="1" group="" part="0"
         file="examplePVD/examplePVD_T0001.vtp"/>
<DataSet timestep="2" group="" part="0"
         file="examplePVD/examplePVD_T0002.vtp"/>
<DataSet timestep="3" group="" part="0"
         file="examplePVD/examplePVD_T0003.vtp"/>
<DataSet timestep="4" group="" part="0"
         file="examplePVD/examplePVD_T0004.vtp"/>
  </Collection>
</VTKFile>

DJ

1 Like

Hi Duncan,

This looks really promising, I’ll talk with my colleagues and test this out.

Thanks for your input

Yes, but the .vtk format is not supported inside a .pvd file.

Not completely what was asked, but when generating VTK files (legacy and XML) we often generate an additional TimeValue as a FieldData. Since it is field-data, it only adds a few bytes to the file.
The choice of the field name comes from what Catalyst uses. Can extract and display in ParaView.

For human documentation, we sometimes add in an additional XML comment:

<!-- time='...' index='...' -->

This lets you scrape the file header and extract values. Eg, with a shell script to assemble other content.

For associating a series of files (legacy or xml) with time values, the JSON series file is extremenly convenient.
For example,

{
    "file-series-version" : "1.0",
    "files": [
      { "name" : "file1.vtk", "time" : 10 },
      { "name" : "file2.vtk", "time" : 20 },
      { "name" : "file3.vtk", "time" : 30 },
    ]
}

The only minor drawback with the series file is that it probably still does not support a sub-directory structure for its names.

1 Like