Skip to content

Package Extension for VTKHDF format #125

@lucasbanting

Description

@lucasbanting

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions