From eb4c271980ac8b8f6c8dffc4dc9d9a26af8b170e Mon Sep 17 00:00:00 2001 From: Thorsten Liebig Date: Mon, 28 Nov 2011 13:13:57 +0100 Subject: [PATCH] nf2ff: added direction support & reduced memory consumption --- matlab/AnalyzeNF2FF.m | 20 ++++++++++++---- matlab/CreateNF2FFBox.m | 53 +++++++++++++++++++++++++++++------------ 2 files changed, 53 insertions(+), 20 deletions(-) diff --git a/matlab/AnalyzeNF2FF.m b/matlab/AnalyzeNF2FF.m index 9d48b5b..207706c 100644 --- a/matlab/AnalyzeNF2FF.m +++ b/matlab/AnalyzeNF2FF.m @@ -1,5 +1,5 @@ -function [E_theta,E_phi,Prad,Dmax] = AnalyzeNFFF2( Sim_Path, nf2ff, f, theta, phi, r ) -% [E_theta,E_phi,Prad,Dmax] = AnalyzeNFFF2( Sim_Path, filenames_E, filenames_H, f, theta, phi, r ) +function [E_theta,E_phi,Prad,Dmax] = AnalyzeNF2FF( Sim_Path, nf2ff, f, theta, phi, r ) +% [E_theta,E_phi,Prad,Dmax] = AnalyzeNF2FF( Sim_Path, filenames_E, filenames_H, f, theta, phi, r ) % % calculates the farfield via a near field to far field transformation % @@ -23,6 +23,7 @@ function [E_theta,E_phi,Prad,Dmax] = AnalyzeNFFF2( Sim_Path, nf2ff, f, theta, ph % See also CreateNF2FFBox % % (C) 2010 Sebastian Held +% (C) 2011 Thorsten Liebig % check arguments error( nargchk(6,6,nargin) ); @@ -33,10 +34,19 @@ end filenames_E = nf2ff.filenames_E; filenames_H = nf2ff.filenames_H; +if (~isrow(nf2ff.directions)) + nf2ff.directions = nf2ff.directions'; +end + % read time domain field data and transform into frequency domain -for n=1:numel(filenames_E) +for n=find(nf2ff.directions==1) [Ef{n}, E_mesh{n}] = ReadHDF5Dump( [Sim_Path '/' filenames_E{n}], 'Frequency', f ); + %clear out time domain data + Ef{n} = rmfield(Ef{n},'TD'); + [Hf{n}, H_mesh{n}] = ReadHDF5Dump( [Sim_Path '/' filenames_H{n}], 'Frequency', f ); + %clear out time domain data + Hf{n} = rmfield(Hf{n},'TD'); % reshape mesh into row vector mesh{n}.x = reshape( E_mesh{n}.lines{1}, 1, [] ); @@ -73,7 +83,7 @@ for phi_deg_aufpunkt = phi N_phi = 0; L_theta = 0; L_phi = 0; - for a=1:6 + for a=find(nf2ff.directions==1) [N_theta_,N_phi_,L_theta_,L_phi_] = process_plane( k, n{a}, center, mesh{a}, Ef{a}.FD.values{1}, Hf{a}.FD.values{1}, theta_rad_aufpunkt, phi_rad_aufpunkt ); N_theta = N_theta + N_theta_; N_phi = N_phi + N_phi_; L_theta = L_theta + L_theta_; L_phi = L_phi + L_phi_; @@ -95,7 +105,7 @@ end % power Prad = 0; -for a=1:6 +for a=find(nf2ff.directions==1) [~,~,~,~,P] = process_plane( k, n{a}, center, mesh{a}, Ef{a}.FD.values{1}, Hf{a}.FD.values{1}, theta_rad_aufpunkt, phi_rad_aufpunkt ); Prad = Prad + P; end diff --git a/matlab/CreateNF2FFBox.m b/matlab/CreateNF2FFBox.m index 51c617b..192a408 100644 --- a/matlab/CreateNF2FFBox.m +++ b/matlab/CreateNF2FFBox.m @@ -1,5 +1,5 @@ -function [CSX nf2ff] = CreateNF2FFBox(CSX, name, start, stop) -% function [CSX nf2ff] = CreateNF2FFBox(CSX, name, start, stop) +function [CSX nf2ff] = CreateNF2FFBox(CSX, name, start, stop, directions) +% function [CSX nf2ff] = CreateNF2FFBox(CSX, name, start, stop, directions) % % create the dump boxes needed for the near field to far field transformation % @@ -13,20 +13,43 @@ function [CSX nf2ff] = CreateNF2FFBox(CSX, name, start, stop) % % See also AnalyzeNF2FF % -% (C) 2010 Thoorsten Liebig +% (C) 2010 Sebastian Held +% (C) 2010, 2011 Thorsten Liebig + +if (nargin<5) + directions = ones(6,1); +end nf2ff.filenames_E = {[name '_Et_xn'],[name '_Et_xp'],[name '_Et_yn'],[name '_Et_yp'],[name '_Et_zn'],[name '_Et_zp']}; nf2ff.filenames_H = {[name '_Ht_xn'],[name '_Ht_xp'],[name '_Ht_yn'],[name '_Ht_yp'],[name '_Ht_zn'],[name '_Ht_zp']}; +nf2ff.directions = directions; -CSX = AddBox( AddDump(CSX,nf2ff.filenames_E{1},'DumpType',0,'DumpMode',2,'FileType',1), nf2ff.filenames_E{1}, 0, start, [start(1) stop(2) stop(3)] ); -CSX = AddBox( AddDump(CSX,nf2ff.filenames_E{2},'DumpType',0,'DumpMode',2,'FileType',1), nf2ff.filenames_E{2}, 0, [stop(1) start(2) start(3)], stop ); -CSX = AddBox( AddDump(CSX,nf2ff.filenames_E{3},'DumpType',0,'DumpMode',2,'FileType',1), nf2ff.filenames_E{3}, 0, start, [stop(1) start(2) stop(3)] ); -CSX = AddBox( AddDump(CSX,nf2ff.filenames_E{4},'DumpType',0,'DumpMode',2,'FileType',1), nf2ff.filenames_E{4}, 0, [start(1) stop(2) start(3)], stop ); -CSX = AddBox( AddDump(CSX,nf2ff.filenames_E{5},'DumpType',0,'DumpMode',2,'FileType',1), nf2ff.filenames_E{5}, 0, start, [stop(1) stop(2) start(3)] ); -CSX = AddBox( AddDump(CSX,nf2ff.filenames_E{6},'DumpType',0,'DumpMode',2,'FileType',1), nf2ff.filenames_E{6}, 0, [start(1) start(2) stop(3)], stop ); -CSX = AddBox( AddDump(CSX,nf2ff.filenames_H{1},'DumpType',1,'DumpMode',2,'FileType',1), nf2ff.filenames_H{1}, 0, start, [start(1) stop(2) stop(3)] ); -CSX = AddBox( AddDump(CSX,nf2ff.filenames_H{2},'DumpType',1,'DumpMode',2,'FileType',1), nf2ff.filenames_H{2}, 0, [stop(1) start(2) start(3)], stop ); -CSX = AddBox( AddDump(CSX,nf2ff.filenames_H{3},'DumpType',1,'DumpMode',2,'FileType',1), nf2ff.filenames_H{3}, 0, start, [stop(1) start(2) stop(3)] ); -CSX = AddBox( AddDump(CSX,nf2ff.filenames_H{4},'DumpType',1,'DumpMode',2,'FileType',1), nf2ff.filenames_H{4}, 0, [start(1) stop(2) start(3)], stop ); -CSX = AddBox( AddDump(CSX,nf2ff.filenames_H{5},'DumpType',1,'DumpMode',2,'FileType',1), nf2ff.filenames_H{5}, 0, start, [stop(1) stop(2) start(3)] ); -CSX = AddBox( AddDump(CSX,nf2ff.filenames_H{6},'DumpType',1,'DumpMode',2,'FileType',1), nf2ff.filenames_H{6}, 0, [start(1) start(2) stop(3)], stop ); +if (directions(1)) + CSX = AddBox( AddDump(CSX,nf2ff.filenames_E{1},'DumpType',0,'DumpMode',2,'FileType',1), nf2ff.filenames_E{1}, 0, start, [start(1) stop(2) stop(3)] ); + CSX = AddBox( AddDump(CSX,nf2ff.filenames_H{1},'DumpType',1,'DumpMode',2,'FileType',1), nf2ff.filenames_H{1}, 0, start, [start(1) stop(2) stop(3)] ); +end + +if (directions(2)) + CSX = AddBox( AddDump(CSX,nf2ff.filenames_E{2},'DumpType',0,'DumpMode',2,'FileType',1), nf2ff.filenames_E{2}, 0, [stop(1) start(2) start(3)], stop ); + CSX = AddBox( AddDump(CSX,nf2ff.filenames_H{2},'DumpType',1,'DumpMode',2,'FileType',1), nf2ff.filenames_H{2}, 0, [stop(1) start(2) start(3)], stop ); +end + +if (directions(3)) + CSX = AddBox( AddDump(CSX,nf2ff.filenames_E{3},'DumpType',0,'DumpMode',2,'FileType',1), nf2ff.filenames_E{3}, 0, start, [stop(1) start(2) stop(3)] ); + CSX = AddBox( AddDump(CSX,nf2ff.filenames_H{3},'DumpType',1,'DumpMode',2,'FileType',1), nf2ff.filenames_H{3}, 0, start, [stop(1) start(2) stop(3)] ); +end + +if (directions(4)) + CSX = AddBox( AddDump(CSX,nf2ff.filenames_E{4},'DumpType',0,'DumpMode',2,'FileType',1), nf2ff.filenames_E{4}, 0, [start(1) stop(2) start(3)], stop ); + CSX = AddBox( AddDump(CSX,nf2ff.filenames_H{4},'DumpType',1,'DumpMode',2,'FileType',1), nf2ff.filenames_H{4}, 0, [start(1) stop(2) start(3)], stop ); +end + +if (directions(5)) + CSX = AddBox( AddDump(CSX,nf2ff.filenames_E{5},'DumpType',0,'DumpMode',2,'FileType',1), nf2ff.filenames_E{5}, 0, start, [stop(1) stop(2) start(3)] ); + CSX = AddBox( AddDump(CSX,nf2ff.filenames_H{5},'DumpType',1,'DumpMode',2,'FileType',1), nf2ff.filenames_H{5}, 0, start, [stop(1) stop(2) start(3)] ); +end + +if (directions(6)) + CSX = AddBox( AddDump(CSX,nf2ff.filenames_E{6},'DumpType',0,'DumpMode',2,'FileType',1), nf2ff.filenames_E{6}, 0, [start(1) start(2) stop(3)], stop ); + CSX = AddBox( AddDump(CSX,nf2ff.filenames_H{6},'DumpType',1,'DumpMode',2,'FileType',1), nf2ff.filenames_H{6}, 0, [start(1) start(2) stop(3)], stop ); +end