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

Package Extension for VTKHDF format #125

Open
lucasbanting opened this issue May 16, 2023 · 0 comments
Open

Package Extension for VTKHDF format #125

lucasbanting opened this issue May 16, 2023 · 0 comments

Comments

@lucasbanting
Copy link

lucasbanting commented May 16, 2023

With the release of Julia 1.9, we can now use a package extension for supporting HDF5, instead of Requires.jl.

The VTKHDF format has been out for a while now: https://kitware.github.io/vtk-examples/site/VTKFileFormats/#hdf-file-formats
The format supports ImageData, UnstructuredGrids, and AMR datasets.

The format also supports time series in the master branch of vtk: https://gitlab.kitware.com/vtk/vtk/-/merge_requests/10094

Adding VTKHDF can also handle these issues: #24 and #77 .

An example of making a VTKHDF file using HDF5.jl is:

h5open("$file_name.hdf", "w") do file
        VTKHDF = create_group(file, "VTKHDF")
        HDF5.attributes(VTKHDF)["Version"] = [2,0]
        
        type = "UnstructuredGrid"
        dspace = HDF5.dataspace(type)
        dtype = HDF5.datatype(type)
        HDF5.h5t_set_cset(dtype, HDF5.H5T_CSET_ASCII)
        attr = create_attribute(VTKHDF, "Type", dtype, dspace)
        write_attribute(attr, dtype, type)

        VTKHDF["NumberOfConnectivityIds"] = [length(connectivity)]
        VTKHDF["NumberOfPoints"] = [size(points, 2)]
        VTKHDF["NumberOfCells"] = [size(connectivity, 2)]
        VTKHDF["Points"] = points
        VTKHDF["Types"] = types
        VTKHDF["Connectivity"] = connectivity[:] .- 1
        VTKHDF["Offsets"] = offsets # starting with 0 (Ncells+1)

        CellData = create_group(VTKHDF, "CellData")
        
        for i in eachindex(solution_coeffs)
                interpolation = Interpolator * solution_coeffs[i]
                name = @sprintf "%s_%03d" array_name i
                CellData[name] = interpolation  
        end
    end

As mentioned in: #24
An interface for the VTKHDF format could look like:

saved_files = vtk_grid(VTKHDF5(), filename, points..., [cells]; kws...) do vtk
    # add datasets here...
end

I have been trying to work with the VTK developers to get the time series format working, but have been struggling to get it to work so far.
The premise is to have flattened arrays for unstructured grids, with appropriate offsets in the VTKHDF/Steps group.

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

No branches or pull requests

2 participants