matlab: update to ConvertHDF5_VTK

pull/1/head
Thorsten Liebig 2012-01-16 09:59:54 +01:00
parent ae49ee952f
commit 64c74919c7
1 changed files with 42 additions and 24 deletions

View File

@ -12,6 +12,7 @@ function ConvertHDF5_VTK(hdf_file, vtk_prefix, varargin)
% 'FD_Dump': activate dump for frequency-domain data (default is on) % 'FD_Dump': activate dump for frequency-domain data (default is on)
% 'NumPhase': number of phase to dump frequency domain data animation % 'NumPhase': number of phase to dump frequency domain data animation
% (default is 36 --> 10°) % (default is 36 --> 10°)
% 'FieldName': field name written to vtk, e.g. 'E-Field'
% %
% example: % example:
% % read time-domian data from hdf5, perform dft and dump as vtk % % read time-domian data from hdf5, perform dft and dump as vtk
@ -27,40 +28,57 @@ do_FD_dump = 1;
do_TD_dump = 0; do_TD_dump = 0;
phase_N = 36; phase_N = 36;
fieldname = 'unknown';
for n=1:2:numel(varargin) for n=1:2:numel(varargin)
if (strcmp(varargin{n},'TD_Dump')==1); if (strcmp(varargin{n},'TD_Dump')==1);
do_TD_dump = varargin{n+1}; do_TD_dump = varargin{n+1};
end end
if (strcmp(varargin{n},'FD_Dump')==1); if (strcmp(varargin{n},'FD_Dump')==1);
do_FD_dump = varargin{n+1}; do_FD_dump = varargin{n+1};
end end
if (strcmp(varargin{n},'NumPhase')==1); if (strcmp(varargin{n},'NumPhase')==1);
phase_N = varargin{n+1}; phase_N = varargin{n+1};
end end
if (strcmp(varargin{n},'FieldName')==1);
fieldname = varargin{n+1};
end
end end
[field mesh] = ReadHDF5Dump(hdf_file, varargin{:}); [field mesh] = ReadHDF5Dump(hdf_file, varargin{:});
if ((do_TD_dump==0) && (do_FD_dump==0))
warning('openEMS:ConvertHDF5_VTK','FD and TD dump disabled, nothing to be done...');
end
if (do_FD_dump) if (do_FD_dump)
ph = linspace(0,360,phase_N+1); if (~isfield(field,'FD'))
ph = ph(1:end-1); warning('openEMS:ConvertHDF5_VTK','no FD data found skipping frequency domian vtk dump...');
for n = 1:numel(field.FD.freq) else
for p = ph ph = linspace(0,360,phase_N+1);
filename = [vtk_prefix '_' num2str(field.FD.freq(n)) '_' num2str(p,'%03d') '.vtk' ]; ph = ph(1:end-1);
Dump2VTK(filename, real(field.FD.values{n}*exp(1j*p*pi/180)), mesh); for n = 1:numel(field.FD.freq)
for p = ph
filename = [vtk_prefix '_' num2str(field.FD.freq(n)) '_' num2str(p,'%03d') '.vtk' ];
Dump2VTK(filename, real(field.FD.values{n}*exp(1j*p*pi/180)), mesh, fieldname, varargin{:});
end
filename = [vtk_prefix '_' num2str(field.FD.freq(n)) '_abs.vtk' ];
Dump2VTK(filename, abs(field.FD.values{n}), mesh, fieldname, varargin{:});
filename = [vtk_prefix '_' num2str(field.FD.freq(n)) '_ang.vtk' ];
Dump2VTK(filename, angle(field.FD.values{n}), mesh, fieldname, varargin{:});
end end
filename = [vtk_prefix '_' num2str(field.FD.freq(n)) '_abs.vtk' ];
Dump2VTK(filename, abs(field.FD.values{n}), mesh);
filename = [vtk_prefix '_' num2str(field.FD.freq(n)) '_ang.vtk' ];
Dump2VTK(filename, angle(field.FD.values{n}), mesh);
end end
end end
if (do_TD_dump) if (do_TD_dump)
disp('dumping time domain data...') if (~isfield(field,'TD'))
acc = ['%0' int2str(ceil(log10(numel(field.TD.time)+1))) 'd']; warning('openEMS:ConvertHDF5_VTK','no TD data found skipping time domian vtk dump...');
for n = 1:numel(field.TD.time) else
filename = [vtk_prefix '_TD_' num2str(n,acc) '.vtk' ]; disp('dumping time domain data...')
Dump2VTK(filename, abs(field.TD.values{n}), mesh); acc = ['%0' int2str(ceil(log10(numel(field.TD.time)+1))) 'd'];
for n = 1:numel(field.TD.time)
filename = [vtk_prefix '_TD_' num2str(n,acc) '.vtk' ];
Dump2VTK(filename, abs(field.TD.values{n}), mesh, fieldname, varargin{:});
end
end end
end end