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()
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