pearu/pyvtk

Time series

pclausen opened this issue · 2 comments

Thanks for a very useful package.

It might be that I dont understand VTK correctly but I cannot get pyvtk to write results as a time series in a single vtk-file. I have a number of CELL_DATA fields which I would like to see in Paraview as a time series. The only way I can currently make this work is by writing out one vtk-file per field, ie

model_with_field_0.vtk
model_with_field_1.vtk
model_with_field_2.vtk

This duplicates my UnstructuredGrid data which I think is unnecessary (?). Is there a way in pyvtk to get multiple CELL_DATA fields into a single vtk file, or is this not possible in legacy vtk file format? Or is there a way to split UnstructuredGrid-data in one file and then CELL_DATA in separate files?

Thank you and sorry if this is the wrong forum to ask this.

See this example

https://github.com/pearu/pyvtk/blob/master/examples/unstructured.py

PyVTK lets you specify multiple cell_data entries when constructing the vtk object.

vtk = pyvtk.VtkData(\
  pyvtk.UnstructuredGrid(points,
    triangle=tri.simplices
    ),
  pyvtk.PointData(pyvtk.Scalars(pointPressure,name='Pressure')),
  pyvtk.CellData(pyvtk.Scalars(cellTemp,name='Temperature')),
  '2D Delaunay Example'
  )

The CellData line can be given multiple pyvtk.Scalars objects.
i.e.

pyvtk.CellData(pyvtk.Scalars(cellTemp,name='Temperature'), pyvtk.Scalars(otherValues, name='Pressure')),

This should do what you want. I don't think you can have separate files for geometry and cell data information in vtk.

Sorry for not getting back on this one but your answer was very helpful and I suggest to close this issue.