HDF5 Utilities

To use HDF5 functionality,

pkg> add HDF5

julia> using Quaycle
julia> using HDF5

This package provides a bunch of utilities, such as storing simulation properties and writing ODE solution on the fly to HDF5 format file for postprocessing on different platform and package version. We currently don't support automatically saving green's function to HDF5 due to its limitation of natively storing complex number.

It's worth mention that JLD and JLD2 are also excellent alternatives but they storing the whole type information that may broke read when this package changes or remove certain type definitions. Users may choose them as auxiliary tools.

Public Interface

Quaycle.storeMethod
store(filename::AbstractString, p::AbstractProperty)

Store property in HDF5.

Arguments

  • filename::AbstractString: file name to be used
  • p::AbstractProperty: property to be saved
source
Quaycle.@getpropMacro
@getprop filename

Read property stored in HDF5.

Arguments

  • filename: file name. Assume it has one and only one kind of property group.
source
Quaycle.@storeMacro
@store filename::AbstractString p::AbstractProperty

Macro shortcut for storing property in HDF5.

Arguments

  • filename::AbstractString: file name to be used
  • p::AbstractProperty: property to be saved
source
Quaycle.h5trimsolutionMethod
h5trimsolution(fin::S, fout::S, tstr, ustrs::AbstractVector,
    predu::Function, predt::Function=(x)->true; nstep::Integer=10000) where S

Trim the solution in and HDF5 file fin, for instance by using wsolve, according to prediction functions predu and predt for fields specified by ustrs. Time data field is denoted by tstr. Outputs are stored in fout.

source
Quaycle.wsolveMethod
wsolve(prob::ODEProblem, alg::OrdinaryDiffEqAlgorithm,
    file, nstep, getu, ustrs, tstr; kwargs...)

Write the solution to HDF5 file while solving the ODE. The interface is exactly the same as solve an ODEProblem except a few more about the saving procedure. Notice, it will set save_everystep=false so to avoid memory blow up. The return code will be written as an attribute in tstr data group.

Extra Arguments

  • file::AbstractString: name of file to be saved
  • nstep::Integer: number of steps after which a saving operation will be performed
  • getu::Function: function handler to extract desired solution for saving
  • ustr::AbstractVector: list of names to be assigned for each components, whose length must equal the length of getu output
  • tstr::AbstractString: name of time data

KWARGS

  • stride::Integer=1: downsampling rate for saving outputs
  • append::Bool=false: if true then append solution after the end of file
  • force::Bool=false: force to overwrite the existing solution file
source
Quaycle.@h5savecallbackMacro
@h5savecallback(filename, tend, nsteps, usize, T)

Construct a FunctionCallingCallback for incrementally stored output into HDF5 file. This callback function only works for naive output arrays whose shape look like A[..., :, :, :, ...]. It is suggested to use this macro at top-level scope since it contains eval.

Arguments

  • filename: file name to be stored
  • tend: end time of simulation
  • nsteps: after nsteps steps, a saving operation is performed otherwise caching them
  • T: type of stored data
source