2013/10/12 Chris Richardson <[email protected]>
> It has been suggested to enhance the HDF5File interface.
>
> I am collecting ideas and comments by the mailing list. Please reply if
> you have any opinions about this
> at all.
>
> HDF5 files are like filesystems, and can contain groups (like directories)
> and datasets (like files).
> Each group or dataset can also have attributes, which may be string,
> double, or vector<double> for example.
>
> Currently, HDF5File in dolfin allows the following:
>
> read and write of Vector, Function, MeshFunction, Mesh and
> MeshValueCollection objects,
> via simple write(object, "dataset_name") or read(object, "dataset_name")
> methods, see HDF5File.h
>
> Complex objects, such as Functions are saved as HDF5 groups, containing
> datasets for e.g. dofmap, vector etc.
>
> Proposal
> --------
> Allow time-series of any of the usual objects listed above. This could
> also be used to reorganise
> TimeSeriesHDF5 (in dolfin/adaptivity)
>
> Implementation
> --------------
> Rather than just writing once, a Function or Vector may be written many
> times, perhaps with timestamp
> information.
>
> u = Function(Q)
> hdf = HDF5File("example.h5", "w")
>
> # Suggestions for better object names are welcome...
> hdf_u = HDF5FunctionHandle("/my_**function", u)
> hdf_u.write(0.0)
> ...
> # later time
> hdf_u.write(1.0)
>
> To read back in:
>
> u = Function(Q)
> hdf = HDF5File("example.h5", "r")
> hdf_u = HDF5FunctionHandle("/my_**function", u)
> # read back at time t=0.0
> t=0.0
> hdf_u.read(t)
> # or just read back the next in sequence
> hdf_u.read()
>
>
I'm curious about the HDF5FunctionHandle. I guess you would need to send
the hdf5file object on initiation?
I don't know if this is an improvement, but here's a modification I would
consider:
u = Function(Q)
hdf = HDF5File("example.h5", 'w')
hdf.function_handle(u, "my_function", 'w') # 'w' could be omitted
hdf.write("my_function", 0.0)
...
hdf.write("my_function", 1.0)
This could also support appending/restarting
hdf.function_handle(u, "my_function", 'a')
hdf.write("my_function", 2.0)
And to read back:
hdf = HDF5File("example.h5", 'r')
u = Function(Q)
hdf.function_handle(u, "my_function", 'r') # This really wouldn't be
necessary?
hdf.read(u, "my_function", 0.0)
hdf.read(u, "my_function", 1.0)
hdf.read(u, "my_function") # I'm not sure if this should be allowed for
function handle?
I'm imagining that function_handle writes the necessary structural
metadata. If append mode is desired, this would require some clever
handling of this, as this structural metadata might change. (Yes, I'm
thinking about hashing again...)
How should the data be stored for function handles? A suggestion:
-> my_function
'-> _metadata
'-> <hash>
'-> x_cell_dofs
'-> cell_dofs
'-> cells
'-> Function0
'-> vector
'-> x_cell_dofs -> /my_function/_metadata/<hash>/x_cell_dofs
'-> cell_dofs -> /my_function/_metadata/<hash>/cell_dofs
'-> cells -> /my_function/_metadata/<hash>/cells
'-> Function1
'-> vector
'-> x_cell_dofs -> /my_function/_metadata/<hash>/x_cell_dofs
'-> cell_dofs -> /my_function/_metadata/<hash>/cell_dofs
'-> cells -> /my_function/_metadata/<hash>/cells
> Proposal
> --------
> Allow more diverse manipulation of HDF5 files from the user interface.
> e.g. read/write attributes, create links, delete datasets, get listings of
> group contents.
> Also allow explicit close() on a file.
>
> Implementation
> --------------
>
> hdf = HDF5File("example.h5", "w")
> hdf.write(mesh, "/ExampleMesh")
> hdf.set_attribute("/**ExampleMesh", "name", "mesh of unusual
> structure")
>
> # return a list of all attributes on this dataset (if any)
> # this could also work e.g. for the HDF5FunctionHandle above...
> print hdf.get_attributes("/**ExampleMesh")
>
> # get value of a specific attribute
> print hdf.attribute("/ExampleMesh", "name")
>
> # Could make this available, if useful
> hdf.link("/ExampleMesh", "/NewMesh")
>
> # could be a bit like 'ls -l'
> print hdf.list("/ExampleMesh")
>
> hdf.delete("/ExampleMesh")
>
> # Convenience - similar to "del hdf"
> hdf.close()
>
>
> ______________________________**_________________
> fenics mailing list
> [email protected]
> http://fenicsproject.org/**mailman/listinfo/fenics<http://fenicsproject.org/mailman/listinfo/fenics>
>
I really like the idea of exposing links and attributes, as this would
allow for all sorts of user customization.
-Øyvind
_______________________________________________
fenics mailing list
[email protected]
http://fenicsproject.org/mailman/listinfo/fenics