Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for VTKHDF Time Series data format #130

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

lucasbanting
Copy link

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
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?

Copy link

codecov bot commented Dec 1, 2023

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 ⚠️
ext/WriteVTKHDFExt.jl 0.00% 1 Missing ⚠️
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 Sentry.
📢 Have feedback on the report? Share it here.

@lucasbanting
Copy link
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