Skip to content

Support for VTKHDF Time Series data format#130

Draft
lucasbanting wants to merge 4 commits into
JuliaVTK:masterfrom
lucasbanting:bantingl/vtkhdf
Draft

Support for VTKHDF Time Series data format#130
lucasbanting wants to merge 4 commits into
JuliaVTK:masterfrom
lucasbanting:bantingl/vtkhdf

Conversation

@lucasbanting

Copy link
Copy Markdown

Reference issue: #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.

@lucasbanting lucasbanting changed the title Support for VTKHDF Time Series data format Draft: Support for VTKHDF Time Series data format Dec 1, 2023
@lucasbanting lucasbanting marked this pull request as draft December 1, 2023 03:12
@lucasbanting lucasbanting changed the title Draft: Support for VTKHDF Time Series data format Support for VTKHDF Time Series data format Dec 1, 2023
@jipolanco

Copy link
Copy Markdown
Member

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

codecov Bot commented Dec 1, 2023

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 113 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.07%. Comparing base (c8b7097) to head (f07c268).
⚠️ Report is 37 commits behind head on master.

Files with missing lines Patch % Lines
src/gridtypes/vtk_hdf.jl 0.00% 112 Missing ⚠️
ext/WriteVTKHDFExt.jl 0.00% 1 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (c8b7097) and HEAD (f07c268). Click for more details.

HEAD has 3 uploads less than BASE
Flag BASE (c8b7097) HEAD (f07c268)
6 3
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     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lucasbanting

Copy link
Copy Markdown
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants