Support for VTKHDF Time Series data format
Reference issue: https://github.com/JuliaVTK/WriteVTK.jl/issues/125
This PR is a draft as the code is in a rough shape compared to the rest of the WriteVTK library. My implementations works in the following way:
dataset = vtk_grid(VTKHDF5(), "fields", points, cells)
E_data = vtkhdf_open_timeseries(dataset, "E", VTKCellData(), 3)
for t in times
# update cell_data for time t
# ...
# store data in vtkhdf file
vtkhdf_append_timeseries_dataset(E_data, t, cell_data)
end
close(dataset)
This procedure creates a file "field.vtkhdf", that has a time varying dataset "E" that stores CellData of vectors of dimension 3.
I started creating a package extension to move my code into, but couldn't get the package extension to build. I would appreciate feedback on the functions and structs I have used, and how they can be changed to better align with this library.
Thank you for this! I think we can figure out later how to move things to a package extension.
So I first tried to generate a file and open it in ParaView. For that I wrote this minimum example based on the code you provided:
using WriteVTK
N = 10
points = rand(3, N)
cells = [
MeshCell(VTKCellTypes.VTK_POLY_LINE, 1:5),
MeshCell(VTKCellTypes.VTK_POLY_LINE, 6:10),
]
dataset = vtk_grid(VTKHDF5(), "fields", points, cells)
E_data = vtkhdf_open_timeseries(dataset, "E", VTKCellData(), 3)
times = 0:0.1:2
for t in times
# update cell_data for time t
cell_data = rand(3, 2)
# store data in vtkhdf file
vtkhdf_append_timeseries_dataset(E_data, t, cell_data)
end
close(dataset)
With this I was able to generate a file, but ParaView complained because "File version: 2.0 is higher than this reader supports 1.0" (also, ParaView seems to prefer the .hdf extension to .vtkhdf). When I set the version to 1.0 by changing your code, the file opens correctly and the different timesteps are recognised, but cell data doesn't seem to change from one timestep to another. I'm using ParaView 5.11.2, which is the latest stable version. Maybe I need to use the 5.12 release candidate? Is there any specification for the VTKHDF formats and their versions?
Codecov Report
Attention: 113 lines in your changes are missing coverage. Please review.
Comparison is base (
c8b7097) 96.63% compared to head (f07c268) 85.07%.
| Files | Patch % | Lines |
|---|---|---|
| src/gridtypes/vtk_hdf.jl | 0.00% | 112 Missing :warning: |
| ext/WriteVTKHDFExt.jl | 0.00% | 1 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## master #130 +/- ##
===========================================
- Coverage 96.63% 85.07% -11.56%
===========================================
Files 15 17 +2
Lines 832 945 +113
===========================================
Hits 804 804
- Misses 28 141 +113
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
I think Paraview 5.12 is required for the time varying VTKHDF format, but 5.11 can handle the static VTKHDF format. What you might be seeing is paraview 5.11 isn't reading the Steps group, so you just get a static dataset.
The VTKHDF format is defined here: https://docs.vtk.org/en/latest/design_documents/VTKFileFormats.html#hdf-file-formats The format for transient data is shown here: https://docs.vtk.org/en/latest/design_documents/VTKFileFormats.html#transient-data