Octave compatibility: ReadHDF5*.m
This commit is contained in:
parent
f6663eeccb
commit
6f3aa5fd11
@ -18,6 +18,12 @@ function hdf_fielddata = ReadHDF5FieldData(file)
|
||||
%
|
||||
% See also ReadHDF5Mesh ReadHDF5Dump
|
||||
|
||||
isOctave = exist('OCTAVE_VERSION','builtin') ~= 0;
|
||||
if isOctave
|
||||
hdf_fielddata = ReadHDF5FieldData_octave(file);
|
||||
return
|
||||
end
|
||||
|
||||
info = hdf5info(file);
|
||||
|
||||
for n=1:numel(info.GroupHierarchy.Groups)
|
||||
@ -32,4 +38,14 @@ end
|
||||
hdf_fielddata.names = names;
|
||||
for n=1:numel(names)
|
||||
hdf_fielddata.values{n} = double(hdf5read(file,names{n}));
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
function hdf_fielddata = ReadHDF5FieldData_octave(file)
|
||||
hdf = load( '-hdf5', file );
|
||||
hdf_fielddata.names = fieldnames(hdf.FieldData);
|
||||
for n=1:numel(hdf_fielddata.names)
|
||||
hdf_fielddata.time(n) = str2double(hdf_fielddata.names{n}(2:end));
|
||||
hdf_fielddata.values{n} = hdf.FieldData.(hdf_fielddata.names{n});
|
||||
end
|
||||
|
@ -14,6 +14,12 @@ function hdf_mesh = ReadHDF5Mesh(file)
|
||||
%
|
||||
% See also ReadHDF5FieldData
|
||||
|
||||
isOctave = exist('OCTAVE_VERSION','builtin') ~= 0;
|
||||
if isOctave
|
||||
hdf_mesh = ReadHDF5Mesh_octave(file);
|
||||
return
|
||||
end
|
||||
|
||||
info = hdf5info(file);
|
||||
|
||||
for n=1:numel(info.GroupHierarchy.Groups)
|
||||
@ -38,3 +44,16 @@ if (strcmp(names{1},'/Mesh/alpha'))
|
||||
end
|
||||
|
||||
hdf_mesh.type=0;
|
||||
|
||||
|
||||
function hdf_mesh = ReadHDF5Mesh_octave(file)
|
||||
hdf = load( '-hdf5', file );
|
||||
hdf_mesh.names = fieldnames(hdf.Mesh);
|
||||
hdf_mesh.type = 0; % cartesian mesh
|
||||
for n=1:numel(hdf_mesh.names)
|
||||
hdf_mesh.lines{n} = hdf.Mesh.(hdf_mesh.names{n});
|
||||
hdf_mesh.names{n} = ['/Mesh/' hdf_mesh.names{n}];
|
||||
if strcmp(hdf_mesh.names{n},'/Mesh/alpha')
|
||||
hdf_mesh.type = 1; % cylindrical mesh
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user