added tarmode support

This commit is contained in:
Michael Stumpf 2018-11-27 15:51:09 +01:00
parent ad416da7cf
commit 3b2b577211
5 changed files with 116 additions and 68 deletions

View File

@ -3,19 +3,27 @@ function [params] = read_parameters_ucf(file,varargin)
% Reads the entire parameters_XXXX.asc as written by UCF file format % Reads the entire parameters_XXXX.asc as written by UCF file format
% into a struct. % into a struct.
% Input % Input
% file file name % file file name (if tar-mode: ustar handle)
% Optional input % ? verbosity verbose screen output? (default: 0)
% verbosity verbose screen output? (default: no) % ? tarmode read from tar-file? (default: 0)
% Output % Output
% params struct with content of parameters_XXXX.asc % params struct with content of parameters_XXXX.asc
% Parse optional input arguments % Parse optional input arguments
par = inputParser; par = inputParser;
addOptional(par,'verbosity',0,@isnumeric); addOptional(par,'verbosity',0,@isnumeric);
addOptional(par,'tarmode',0,@isnumeric);
parse(par,varargin{:}); parse(par,varargin{:});
% Open file
obj = ini('verbosity',par.Results.verbosity); obj = ini('verbosity',par.Results.verbosity);
obj.open(file); if par.Results.tarmode
ptr = file.pointer('parameters.asc');
obj.opentar(ptr);
else
obj.open(file);
end
% Get parsed content
params = obj.getContent(); params = obj.getContent();
% Close file
obj.close(); obj.close();
end end

View File

@ -2,16 +2,16 @@ function [pp,col,stime] = read_particles_ucf(file,varargin)
% [pp,col] = read_particles_ucf(file,varargin) % [pp,col] = read_particles_ucf(file,varargin)
% Reads particle data from UCF file % Reads particle data from UCF file
% Input % Input
% file file to be read % file file name (if tar-mode: ustar handle)
% Optional input (key/value pair) % ? step timestep to be read (default: 0 [all])
% timestep timestep to be read (default: all) % ? format MATLAB format (default: 'array')
% format MATLAB format (default: 'array')
% 'array' plain array with dim(ncol.np,nt) % 'array' plain array with dim(ncol.np,nt)
% 'struct' structure array with short fieldnames % 'struct' structure array with short fieldnames
% 'paraview' structure array with H5Part fieldnames % 'paraview' structure array with H5Part fieldnames
% 'cell' cell array with dim(1,nt) and plain arrays with dim(ncol,np) inside % 'cell' cell array with dim(1,nt) and plain arrays with dim(ncol,np) inside
% verbosity verbose output? (default: no) % ? verbosity verbose output? (default: no)
% debug debug output? (default: no) % ? debug debug output? (default: no)
% ? tarmode read from tar-file? (default: 0)
% Output % Output
% pp particle data in specified format % pp particle data in specified format
% col container map 'char'->'double' which maps quantity names to column index % col container map 'char'->'double' which maps quantity names to column index
@ -19,17 +19,23 @@ function [pp,col,stime] = read_particles_ucf(file,varargin)
% Parse optional input arguments % Parse optional input arguments
par = inputParser; par = inputParser;
addOptional(par,'timestep',0,@isnumeric); addOptional(par,'step',0,@isnumeric);
addOptional(par,'format','array',@ischar); addOptional(par,'format','array',@ischar);
addOptional(par,'verbosity',0,@isnumeric); addOptional(par,'verbosity',0,@isnumeric);
addOptional(par,'debug',0,@isnumeric); addOptional(par,'debug',0,@isnumeric);
addOptional(par,'tarmode',0,@isnumeric);
parse(par,varargin{:}); parse(par,varargin{:});
istep = par.Results.timestep; istep = par.Results.step;
mlformat = par.Results.format; mlformat = par.Results.format;
% Open file % Open file
obj = ucf('verbosity',par.Results.verbosity,'debug',par.Results.debug); obj = ucf('verbosity',par.Results.verbosity,'debug',par.Results.debug);
obj.open(file); if par.Results.tarmode
ptr = file.pointer('particles.bin');
obj.opentar(ptr);
else
obj.open(file);
end
if ~obj.validateType('particle') if ~obj.validateType('particle')
error('read error: no particle data.'); error('read error: no particle data.');
end end

View File

@ -8,10 +8,9 @@ function [ibegu,iendu,jbegu,jendu,kbegu,kendu,...
% ibegp,iendp,jbegp,jendp,kbegp,kendp] = read_procgrid_ucf(file,varargin) % ibegp,iendp,jbegp,jendp,kbegp,kendp] = read_procgrid_ucf(file,varargin)
% Reads processor grids. % Reads processor grids.
% Input % Input
% file file to be read % file file name (if tar-mode: ustar handle)
% Optional input (key/value pair) % ? verbosity verbose output? (default: 0)
% verbosity verbose output? (default: no) % ? tarmode read from tar-file? (default: 0)
%
% Output % Output
% ibegu,iendu,jbegu,jendu,kbegu,kendu processor grid u % ibegu,iendu,jbegu,jendu,kbegu,kendu processor grid u
% ibegv,iendv,jbegv,jendv,kbegv,kendv processor grid v % ibegv,iendv,jbegv,jendv,kbegv,kendv processor grid v
@ -22,6 +21,7 @@ function [ibegu,iendu,jbegu,jendu,kbegu,kendu,...
par = inputParser; par = inputParser;
addOptional(par,'verbosity',0,@isnumeric); addOptional(par,'verbosity',0,@isnumeric);
addOptional(par,'debug',0,@isnumeric); addOptional(par,'debug',0,@isnumeric);
addOptional(par,'tarmode',0,@isnumeric);
parse(par,varargin{:}); parse(par,varargin{:});
% Define sets to be read % Define sets to be read
@ -30,7 +30,12 @@ function [ibegu,iendu,jbegu,jendu,kbegu,kendu,...
% Open file % Open file
obj = ucf('verbosity',par.Results.verbosity,'debug',par.Results.debug); obj = ucf('verbosity',par.Results.verbosity,'debug',par.Results.debug);
obj.open(file); if par.Results.tarmode
ptr = file.pointer('proc.bin');
obj.opentar(ptr);
else
obj.open(file);
end
% Read raw data % Read raw data
ibeg = cell(1,nset); ibeg = cell(1,nset);
@ -58,34 +63,34 @@ function [ibegu,iendu,jbegu,jendu,kbegu,kendu,...
% Reassign content from loop % Reassign content from loop
iset = find(strcmp(sets,'u')); iset = find(strcmp(sets,'u'));
ibegu = ibeg{iset}; ibegu = cast(ibeg{iset},'double');
iendu = iend{iset}; iendu = cast(iend{iset},'double');
jbegu = jbeg{iset}; jbegu = cast(jbeg{iset},'double');
jendu = jend{iset}; jendu = cast(jend{iset},'double');
kbegu = kbeg{iset}; kbegu = cast(kbeg{iset},'double');
kendu = kend{iset}; kendu = cast(kend{iset},'double');
iset = find(strcmp(sets,'v')); iset = find(strcmp(sets,'v'));
ibegv = ibeg{iset}; ibegv = cast(ibeg{iset},'double');
iendv = iend{iset}; iendv = cast(iend{iset},'double');
jbegv = jbeg{iset}; jbegv = cast(jbeg{iset},'double');
jendv = jend{iset}; jendv = cast(jend{iset},'double');
kbegv = kbeg{iset}; kbegv = cast(kbeg{iset},'double');
kendv = kend{iset}; kendv = cast(kend{iset},'double');
iset = find(strcmp(sets,'w')); iset = find(strcmp(sets,'w'));
ibegw = ibeg{iset}; ibegw = cast(ibeg{iset},'double');
iendw = iend{iset}; iendw = cast(iend{iset},'double');
jbegw = jbeg{iset}; jbegw = cast(jbeg{iset},'double');
jendw = jend{iset}; jendw = cast(jend{iset},'double');
kbegw = kbeg{iset}; kbegw = cast(kbeg{iset},'double');
kendw = kend{iset}; kendw = cast(kend{iset},'double');
iset = find(strcmp(sets,'p')); iset = find(strcmp(sets,'p'));
ibegp = ibeg{iset}; ibegp = cast(ibeg{iset},'double');
iendp = iend{iset}; iendp = cast(iend{iset},'double');
jbegp = jbeg{iset}; jbegp = cast(jbeg{iset},'double');
jendp = jend{iset}; jendp = cast(jend{iset},'double');
kbegp = kbeg{iset}; kbegp = cast(kbeg{iset},'double');
kendp = kend{iset}; kendp = cast(kend{iset},'double');
end end

View File

@ -2,12 +2,13 @@ function [s,ib,jb,kb,nxl,nyl,nzl,ighost] = read_scal_chunk_ucf(file,varargin)
% [s,ib,jb,kb,nxl,nyl,nzl,ighost] = read_scal_chunk_ucf(file,varargin) % [s,ib,jb,kb,nxl,nyl,nzl,ighost] = read_scal_chunk_ucf(file,varargin)
% Reads scalar fields from one processor chunk. % Reads scalar fields from one processor chunk.
% Input % Input
% file file to be read % file file name (if tar-mode: ustar handle)
% Optional input (key/value pair) % ? step index of timestep to be read (default: 1)
% timestep index of timestep to be read (default: 1) % ? ghost keep ghost cells? (default: 1)
% ghost keep ghost cells? (default: yes) % ? verbosity verbose output? (default: 0)
% verbosity verbose output? (default: no) % ? debug debug output? (default: 0)
% debug debug output? (default: no) % ? tarmode read from tar-file? (default: 0)
% ? rank rank of processor, ignored if not in tarmode (default: 0)
% Output % Output
% s partial fields with dim(nxl+2*ighost,nyl+2*ighost,nzl+2*ighost,nscal) % s partial fields with dim(nxl+2*ighost,nyl+2*ighost,nzl+2*ighost,nscal)
% ib,jb,kb,... global index of first grid point of the partial field w/o ghost cells % ib,jb,kb,... global index of first grid point of the partial field w/o ghost cells
@ -16,17 +17,25 @@ function [s,ib,jb,kb,nxl,nyl,nzl,ighost] = read_scal_chunk_ucf(file,varargin)
% Parse optional input arguments % Parse optional input arguments
par = inputParser; par = inputParser;
addOptional(par,'timestep',1,@isnumeric); addOptional(par,'step',1,@isnumeric);
addOptional(par,'ghost',1,@isnumeric); addOptional(par,'ghost',1,@isnumeric);
addOptional(par,'verbosity',0,@isnumeric); addOptional(par,'verbosity',0,@isnumeric);
addOptional(par,'debug',0,@isnumeric); addOptional(par,'debug',0,@isnumeric);
addOptional(par,'tarmode',0,@isnumeric);
addOptional(par,'rank',0,@isnumeric);
parse(par,varargin{:}); parse(par,varargin{:});
istep = par.Results.timestep; istep = par.Results.step;
keepghost = par.Results.ghost; keepghost = par.Results.ghost;
% Open file % Open file
obj = ucf('verbosity',par.Results.verbosity,'debug',par.Results.debug); obj = ucf('verbosity',par.Results.verbosity,'debug',par.Results.debug);
obj.open(file); if par.Results.tarmode
subfile = sprintf('scal.%05d',par.Results.rank);
obj.opentar(file.pointer(subfile));
else
obj.open(file);
end
if ~obj.validateType('field') if ~obj.validateType('field')
error('read error: no field data.'); error('read error: no field data.');
end end

View File

@ -2,29 +2,34 @@ function [s] = read_scal_complete_ucf(file,varargin)
% [s] = read_scal_complete_ucf(file,varargin) % [s] = read_scal_complete_ucf(file,varargin)
% Reads u,v,w,p from all processor chunks and combines them to a single field. % Reads u,v,w,p from all processor chunks and combines them to a single field.
% Input % Input
% file file to be read % file file name (if tar-mode: ustar handle)
% Optional input (key/value pair) % ? step index of timestep to be read (default: 1)
% timestep index of timestep to be read (default: 1) % ? verbosity verbose output? (default: 0)
% verbosity verbose output? (default: no) % ? debug debug output? (default: 0)
% debug debug output? (default: no) % ? tarmode read from tar-file? (default: 0)
% Output % Output
% s complete scalar fields with dim(nx,ny,nz,nscal) % s complete scalar fields with dim(nx,ny,nz,nscal)
% Parse optional input arguments % Parse optional input arguments
par = inputParser; par = inputParser;
addOptional(par,'timestep',1,@isnumeric); addOptional(par,'step',1,@isnumeric);
addOptional(par,'verbosity',0,@isnumeric); addOptional(par,'verbosity',0,@isnumeric);
addOptional(par,'debug',0,@isnumeric); addOptional(par,'debug',0,@isnumeric);
addOptional(par,'tarmode',0,@isnumeric);
parse(par,varargin{:}); parse(par,varargin{:});
istep = par.Results.timestep; istep = par.Results.step;
% Parse filename
[fdir,fbase,fext] = fileparts(file);
fname = sprintf('%s/%s.%05d',fdir,fbase,0);
% Open first file % Open first file
obj = ucf('verbosity',par.Results.verbosity,'debug',par.Results.debug); obj = ucf('verbosity',par.Results.verbosity,'debug',par.Results.debug);
obj.open(fname); if par.Results.tarmode
fname = sprintf('scal.%05d',0);
obj.opentar(file.pointer(fname));
else
[fdir,fbase,fext] = fileparts(file);
fname = sprintf('%s/%s.%05d',fdir,fbase,0);
obj.open(fname);
end
if ~obj.validateType('field') if ~obj.validateType('field')
error('read error: no field data.'); error('read error: no field data.');
end end
@ -62,11 +67,22 @@ function [s] = read_scal_complete_ucf(file,varargin)
% Now loop consecutively through files % Now loop consecutively through files
ifile = 1; ifile = 1;
fname = sprintf('%s/%s.%05d',fdir,fbase,ifile); if par.Results.tarmode
while exist(fname,'file') loopCondition = @(x) file.isSubfile(x);
fname = sprintf('scal.%05d',ifile);
else
loopCondition = @(x) exist(x,'file');
fname = sprintf('%s/%s.%05d',fdir,fbase,ifile);
end
while loopCondition(fname)
% Open file % Open file
obj = ucf('verbosity',par.Results.verbosity,'debug',par.Results.debug); obj = ucf('verbosity',par.Results.verbosity,'debug',par.Results.debug);
obj.open(fname) if par.Results.tarmode
obj.opentar(file.pointer(fname));
else
obj.open(fname);
end
if ~obj.validateType('field') if ~obj.validateType('field')
error('read error: no field data.'); error('read error: no field data.');
end end
@ -99,6 +115,10 @@ function [s] = read_scal_complete_ucf(file,varargin)
% Move on to next file % Move on to next file
ifile = ifile+1; ifile = ifile+1;
fname = sprintf('%s/%s.%05d',fdir,fbase,ifile); if par.Results.tarmode
fname = sprintf('scal.%05d',ifile);
else
fname = sprintf('%s/%s.%05d',fdir,fbase,ifile);
end
end end
end end