Multimesh_output
Multiple meshes can be written into a single hdf5 file. A set of xdmf files is written (1 xdmf for each mesh). HDF5 file also now contains a group that gives a mapping from timestep to the actual time (datatype: double unit: seconds)
-
Feature description was added to the changelog -
Tests covering your feature were added? -
Any new feature or behavior change was documented?
For updated version of this documention (with coming Merge requests See Wiki)
A copy of the changed part of the wiki documentation to reflect status of this merge request is here:
import h5py
def demo():
with h5py.File('square_5x5_tris_32.h5') as myfile:
# inspect what is inside the root of the file:
# Each HDF will contain a group 'meshes' (with 1 or more meshes) and a group 'times'
# with time series
myfile.keys()
# Output: <KeysViewHDF5 ['meshes', 'times']>
# Select the group 'meshes' and look what is inside and select a mesh
meshes = myfile['meshes']
meshes.keys()
# < KeysViewHDF5['square_5x5_tris_32', 'square_5x5_tris_32_left_boundary', 'square_5x5_tris_32_right_boundary'] >
# Select a mesh and check which attributes it contains
mesh = meshes['square_5x5_tris_32']
# Each mesh will contain 'geometry' and 'topology'. Optionally other attributes
# < KeysViewHDF5['HydraulicFlow', 'MaterialIDs', 'geometry', 'pressure', 'topology', 'v']>
# Select an attribute
# choose any key , here in example 'pressure', it is only a reference (no copy of data into memory)
pressure = mesh['pressure']
# get dimensions
pressure.shape
# example: (8, 25)
# first dimension is time, here with length 8 - pressure is a variable attribute
# e.g. for MateralIDs we would get as number of time steps 1 - it is a constant attribute
MaterialIDs = mesh['MaterialIDs']
MaterialIDs.shape
# (1, 25)
# load data into memory (only selected data is loaded into memory)
# example: load all timesteps and choose all data points 10:20
p = pressure [:,10:20]
# p can now be processed e.g. with numpy
# import numpy
# y = numpy.array(p)
# In the example of pressure attribute we have 8 time steps for the variable attributes like pressure
times = f['times']
# list all time values
times[:]
# array([0. , 0.3, 0.6, 0.9, 1.2, 1.5, 1.8, 2. ])
# To relate the values of pressure of timestep 2 (beginning with 0) to an actual time value we define:
time_step = 2
pressure_t2 = pressure[time_step,:]
t2 = times[time_step]
t2
# 0.6
File structures
Structure of HDF5 file
Output of all time steps is written into a single hdf5 - file. All data is written into group "meshes" and its mesh name.
Example #1:
h5dump -H square_5x5_tris_32.h5
square_5x5_tris_32.h5
HDF5 "square_5x5_tris_32.h5" {
GROUP "/" {
GROUP "meshes" {
GROUP "square_5x5_tris_32" {
DATASET "HydraulicFlow" {
DATATYPE H5T_IEEE_F64LE
DATASPACE SIMPLE { ( 1, 25 ) / ( H5S_UNLIMITED, 25 ) }
}
DATASET "MaterialIDs" {
DATATYPE H5T_STD_I32LE
DATASPACE SIMPLE { ( 1, 25 ) / ( H5S_UNLIMITED, 25 ) }
}
DATASET "geometry" {
DATATYPE H5T_IEEE_F64LE
DATASPACE SIMPLE { ( 1, 25, 3 ) / ( H5S_UNLIMITED, 25, 3 ) }
}
DATASET "pressure" {
DATATYPE H5T_IEEE_F64LE
DATASPACE SIMPLE { ( 8, 25 ) / ( H5S_UNLIMITED, 25 ) }
}
DATASET "topology" {
DATATYPE H5T_STD_I32LE
DATASPACE SIMPLE { ( 1, 128 ) / ( H5S_UNLIMITED, 128 ) }
}
DATASET "v" {
DATATYPE H5T_IEEE_F64LE
DATASPACE SIMPLE { ( 8, 25, 2 ) / ( H5S_UNLIMITED, 25, 2 ) }
}
}
GROUP "square_5x5_tris_32_left_boundary" {
DATASET "bulk_element_ids" {
DATATYPE H5T_STD_U64LE
DATASPACE SIMPLE { ( 1, 4 ) / ( H5S_UNLIMITED, 4 ) }
}
DATASET "bulk_node_ids" {
DATATYPE H5T_STD_U64LE
DATASPACE SIMPLE { ( 1, 5 ) / ( H5S_UNLIMITED, 5 ) }
}
DATASET "geometry" {
DATATYPE H5T_IEEE_F64LE
DATASPACE SIMPLE { ( 1, 5, 3 ) / ( H5S_UNLIMITED, 5, 3 ) }
}
DATASET "pressure" {
DATATYPE H5T_IEEE_F64LE
DATASPACE SIMPLE { ( 8, 5 ) / ( H5S_UNLIMITED, 5 ) }
}
DATASET "topology" {
DATATYPE H5T_STD_I32LE
DATASPACE SIMPLE { ( 1, 16 ) / ( H5S_UNLIMITED, 16 ) }
}
}
GROUP "square_5x5_tris_32_right_boundary" {
DATASET "bulk_element_ids" {
DATATYPE H5T_STD_U64LE
DATASPACE SIMPLE { ( 1, 4 ) / ( H5S_UNLIMITED, 4 ) }
}
DATASET "bulk_node_ids" {
DATATYPE H5T_STD_U64LE
DATASPACE SIMPLE { ( 1, 5 ) / ( H5S_UNLIMITED, 5 ) }
}
DATASET "geometry" {
DATATYPE H5T_IEEE_F64LE
DATASPACE SIMPLE { ( 1, 5, 3 ) / ( H5S_UNLIMITED, 5, 3 ) }
}
DATASET "pressure" {
DATATYPE H5T_IEEE_F64LE
DATASPACE SIMPLE { ( 8, 5 ) / ( H5S_UNLIMITED, 5 ) }
}
DATASET "topology" {
DATATYPE H5T_STD_I32LE
DATASPACE SIMPLE { ( 1, 16 ) / ( H5S_UNLIMITED, 16 ) }
}
}
}
DATASET "times" {
DATATYPE H5T_IEEE_F64LE
DATASPACE SIMPLE { ( 8 ) / ( 8 ) }
}
}
}