From 84b7a7b56e3c788b28569306fe1e21cd497d9f95 Mon Sep 17 00:00:00 2001 From: Thorsten Liebig Date: Tue, 3 Dec 2013 11:29:15 +0100 Subject: [PATCH] hdf5 dump reader: remember original mesh indices Signed-off-by: Thorsten Liebig --- matlab/GetField_Interpolation.m | 4 ++++ matlab/GetField_Range.m | 9 +++++++++ matlab/GetField_SubSampling.m | 9 +++++++++ matlab/ReadHDF5Dump.m | 7 +++++++ 4 files changed, 29 insertions(+) diff --git a/matlab/GetField_Interpolation.m b/matlab/GetField_Interpolation.m index 61d143e..b88c58e 100644 --- a/matlab/GetField_Interpolation.m +++ b/matlab/GetField_Interpolation.m @@ -62,6 +62,10 @@ mesh_i.lines{1} = x_i; mesh_i.lines{2} = y_i; mesh_i.lines{3} = z_i; +% clear or create empty original indices list, since such do not make any +% sense with interpolated field values +mesh_i.original_indices = {}; + if (isfield(field,'TD')) field_i.TD = interpolate_fields(field.TD,x,y,z, x_i, y_i, z_i); field_i.TD.time = field.TD.time; diff --git a/matlab/GetField_Range.m b/matlab/GetField_Range.m index 979b535..8d489b9 100644 --- a/matlab/GetField_Range.m +++ b/matlab/GetField_Range.m @@ -47,6 +47,15 @@ for n=1:3 mesh_i.lines{n} = mesh.lines{n}(ind_range{n}); end +% store original indices +if (isfield(mesh_i,'original_indices')) + for n=1:3 + mesh_i.original_indices{n} = mesh_i.original_indices{n}(ind_range{n}); + end +else + mesh_i.original_indices = ind_range; +end + field_i = field; if (isfield(field,'FD')) diff --git a/matlab/GetField_SubSampling.m b/matlab/GetField_SubSampling.m index 6a4572a..9c792e0 100644 --- a/matlab/GetField_SubSampling.m +++ b/matlab/GetField_SubSampling.m @@ -33,6 +33,15 @@ mesh_i.lines{1} = x_i; mesh_i.lines{2} = y_i; mesh_i.lines{3} = z_i; +% store original indices +if (isfield(mesh_i,'original_indices')) + for n=1:3 + mesh_i.original_indices{n} = mesh_i.original_indices{n}(ss_idx{n}); + end +else + mesh_i.original_indices = ss_idx; +end + if (isfield(field,'TD')) field_i.TD = subsample_fields(field.TD,ss_idx); field_i.TD.time = field.TD.time; diff --git a/matlab/ReadHDF5Dump.m b/matlab/ReadHDF5Dump.m index eb13c67..3386971 100644 --- a/matlab/ReadHDF5Dump.m +++ b/matlab/ReadHDF5Dump.m @@ -74,6 +74,13 @@ for n=1:2:(nargin-1) field.FD.values{n}(:,end+1,:,:) = field.FD.values{n}(:,1,:,:); end end + if (isfield(mesh,'original_indices')) + if (~isempty(mesh.original_indices)) + mesh.original_indices{2} = [mesh.original_indices{2} 1]; + end + else + mesh.original_indices = {1:numel(mesh.lines{1}),[1:numel(mesh.lines{2}) 1],[1:numel(mesh.lines{3})]}; + end end end end \ No newline at end of file