On 03/10/2013 09:50, Garth N. Wells wrote:
On 3 October 2013 09:40, Maximilian Albert
<[email protected]> wrote:
2013/10/3 Garth N. Wells <[email protected]>:
What's required is the right abstraction for handling Functions and
files. I think the hashing approach is more a hack. What about
something along the lines of:
Function u(V);
Function w(V);
HDF5Function hdf5_function_file("my_filename.h5", "w");
hdf5_function_file.register(u, "u_name");
hdf5_function_file.register(w, "w_name");
hdf5_function_file.parameters["common_mesh"] = true;
hdf5_function_file.parameters["write_mesh_once"] = true;
// Write all registered functions
hdf5_function_file.write();
// Write all registered functions again
hdf5_function_file.write();
// Write u only
hdf5_function_file.write("u_name");
I thought of this (below, in python) but not sure about
the naming "HDF5FunctionHandle" etc. Any suggestions / criticisms...
mesh = Mesh("mesh.xml")
u = Function(V)
p = Function(Q)
# Open a file for writing - HDF files are like 'filesystems'
# which can contain multiple datasets
hdf = HDF5File("main_file.h5","w")
# Create 'filehandles' which can be used for Functions,
MeshFunctions, Meshes etc.
# each of which may have specific appropriate parameters and
properties
hdf_u = HDF5FunctionHandle(hdf, "/main/velocity")
hdf_p = HDF5FunctionHandle(hdf, "/main/pressure")
hdf_mesh = HDF5MeshHandle(hdf, "/mesh")
hdf_mesh.write(mesh)
# or even (especially for Garth)
hdf_mesh << mesh
# HDF5 functions do not store the mesh, only the cells and dofmap
hdf_u.parameters['fixed_dofmap'] = true;
# Set any text, float or integer attribute on an object
hdf_u.set_attribute("name", "photon flux")
# write data - if not specified, a default attribute 'time' with
value '0.0' will be added
hdf_u.write(u)
# HDF5FunctionHandle can accept multiple writes (interpreted as time
series)
# set an attribute on a particular timestep
hdf_u.write(u, name = 'second timestep')
# do stuff to u
timestamp = 1.0
hdf_u.write(u, timestamp)
_______________________________________________
fenics mailing list
[email protected]
http://fenicsproject.org/mailman/listinfo/fenics