implemented tar-mode
This commit is contained in:
parent
98435d9272
commit
b7913bc624
|
|
@ -1,15 +1,17 @@
|
||||||
function [data,ib,jb,kb,nxl,nyl,nzl,ighost] = read_field_chunk_ucf(file,ifield,varargin)
|
function [data,ib,jb,kb,nxl,nyl,nzl,ighost] = read_field_chunk_ucf(file,field,varargin)
|
||||||
% [data,ib,jb,kb,nxl,nyl,nzl,ighost] = read_field_chunk_ucf(file,ifield,varargin)
|
% [data,ib,jb,kb,nxl,nyl,nzl,ighost] = read_field_chunk_ucf(file,field,varargin)
|
||||||
% Reads single field from one processor chunk.
|
% Reads single field from one processor chunk.
|
||||||
% Input
|
% Input
|
||||||
% file file to be read
|
% file file name (if tar-mode: ustar handle)
|
||||||
% ifield field to be read
|
% field field to be read
|
||||||
% 'uvwp': 1:u, 2:v, 3:w, 4:p
|
% {'u','v','w','p','s1','s2',...}
|
||||||
% 'scal': 1:s1, 2:s2, ...
|
% or integer with dataset index (not in tar-mode)
|
||||||
% Optional input (key/value pair)
|
% ? step index of timestep to be read (default: 1)
|
||||||
% ghost keep ghost cells? (default: yes)
|
% ? ghost keep ghost cells? (default: yes)
|
||||||
% 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)
|
||||||
|
% ? rank rank of processor, ignored if not in tarmode (default: 0)
|
||||||
% Output
|
% Output
|
||||||
% data partial field with dim(nxl+2*ighost,nyl+2*ighost,nzl+2*ighost)
|
% data partial field with dim(nxl+2*ighost,nyl+2*ighost,nzl+2*ighost)
|
||||||
% 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
|
||||||
|
|
@ -18,17 +20,42 @@ function [data,ib,jb,kb,nxl,nyl,nzl,ighost] = read_field_chunk_ucf(file,ifield,v
|
||||||
|
|
||||||
% 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;
|
||||||
|
|
||||||
|
% Parse field
|
||||||
|
if ischar(field)
|
||||||
|
switch field(1)
|
||||||
|
case 'u'; ifield=1; fbase='uvwp';
|
||||||
|
case 'v'; ifield=2; fbase='uvwp';
|
||||||
|
case 'w'; ifield=3; fbase='uvwp';
|
||||||
|
case 'p'; ifield=4; fbase='uvwp';
|
||||||
|
case 's'; ifield=str2double(field(2:end)); fbase='scal';
|
||||||
|
end
|
||||||
|
elseif isnumeric(field)
|
||||||
|
if par.Results.tarmode
|
||||||
|
error('field cannot be numeric, if tar-mode is used.');
|
||||||
|
end
|
||||||
|
ifield=field; fbase='';
|
||||||
|
else
|
||||||
|
error('field must either be numeric or string.');
|
||||||
|
end
|
||||||
|
|
||||||
% 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('%s.%05d',fbase,par.Results.rank);
|
||||||
|
obj.opentar(file.pointer(subfile));
|
||||||
|
else
|
||||||
|
obj.open(file);
|
||||||
|
end
|
||||||
|
|
||||||
% Read raw data
|
% Read raw data
|
||||||
if ~obj.validateType('field')
|
if ~obj.validateType('field')
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,15 @@
|
||||||
function [q] = read_field_complete_ucf(file,ifield,varargin)
|
function [q] = read_field_complete_ucf(file,field,varargin)
|
||||||
% [data] = read_field_complete_ucf(file,ifield,varargin)
|
% [data] = read_field_complete_ucf(file,field,varargin)
|
||||||
% Reads a specific field from all processor chunks.
|
% Reads a specific field from all processor chunks.
|
||||||
% Input
|
% Input
|
||||||
% file file to be read
|
% file file to be read
|
||||||
% ifield field to be read
|
% field field to be read
|
||||||
% 'uvwp': 1:u, 2:v, 3:w, 4:p
|
% {'u','v','w','p','s1','s2',...}
|
||||||
% 'scal': 1:s1, 2:s2, ...
|
% or integer with dataset index (not in tar-mode)
|
||||||
% Optional input (key/value pair)
|
% ? step index of step 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
|
||||||
% data partial field with dim(nxl+2*ighost,nyl+2*ighost,nzl+2*ighost)
|
% data partial field with dim(nxl+2*ighost,nyl+2*ighost,nzl+2*ighost)
|
||||||
|
|
||||||
|
|
@ -18,16 +18,39 @@ function [q] = read_field_complete_ucf(file,ifield,varargin)
|
||||||
addOptional(par,'timestep',1,@isnumeric);
|
addOptional(par,'timestep',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.timestep;
|
||||||
|
|
||||||
% Parse filename
|
% Parse field
|
||||||
[fdir,fbase,fext] = fileparts(file);
|
if ischar(field)
|
||||||
fname = sprintf('%s/%s.%05d',fdir,fbase,0);
|
switch field(1)
|
||||||
|
case 'u'; ifield=1; fbase='uvwp';
|
||||||
|
case 'v'; ifield=2; fbase='uvwp';
|
||||||
|
case 'w'; ifield=3; fbase='uvwp';
|
||||||
|
case 'p'; ifield=4; fbase='uvwp';
|
||||||
|
case 's'; ifield=str2double(field(2:end)); fbase='scal';
|
||||||
|
end
|
||||||
|
elseif isnumeric(field)
|
||||||
|
if par.Results.tarmode
|
||||||
|
error('field cannot be numeric, if tar-mode is used.');
|
||||||
|
end
|
||||||
|
ifield=field; fbase='';
|
||||||
|
else
|
||||||
|
error('field must either be numeric or string.');
|
||||||
|
end
|
||||||
|
|
||||||
% 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('%s.%05d',fbase,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
|
||||||
|
|
@ -59,11 +82,22 @@ function [q] = read_field_complete_ucf(file,ifield,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('%s.%05d',fbase,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
|
||||||
|
|
@ -91,6 +125,10 @@ function [q] = read_field_complete_ucf(file,ifield,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('%s.%05d',fbase,ifile);
|
||||||
|
else
|
||||||
|
fname = sprintf('%s/%s.%05d',fdir,fbase,ifile);
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,9 @@ function [xu,yu,zu,xv,yv,zv,xw,yw,zw,xp,yp,zp] = read_grid_ucf(file,varargin)
|
||||||
% Reads staggered grid from ucf file.
|
% Reads staggered grid from ucf file.
|
||||||
% Input
|
% Input
|
||||||
% file file to be read
|
% file file to be read
|
||||||
% Optional input (key/value pair)
|
% ? 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
|
||||||
% xu,yu,zu velocity grid u
|
% xu,yu,zu velocity grid u
|
||||||
% xv,yv,zv velocity grid v
|
% xv,yv,zv velocity grid v
|
||||||
|
|
@ -16,6 +16,7 @@ function [xu,yu,zu,xv,yv,zv,xw,yw,zw,xp,yp,zp] = read_grid_ucf(file,varargin)
|
||||||
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
|
||||||
|
|
@ -24,7 +25,12 @@ function [xu,yu,zu,xv,yv,zv,xw,yw,zw,xp,yp,zp] = read_grid_ucf(file,varargin)
|
||||||
|
|
||||||
% Open UCF file and read
|
% Open UCF file and read
|
||||||
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('grid.bin');
|
||||||
|
obj.opentar(ptr);
|
||||||
|
else
|
||||||
|
obj.open(file);
|
||||||
|
end
|
||||||
|
|
||||||
% Read raw data
|
% Read raw data
|
||||||
x = cell(1,nset);
|
x = cell(1,nset);
|
||||||
|
|
|
||||||
|
|
@ -8,12 +8,13 @@ function [u,ibu,jbu,kbu,nxul,nyul,nzul,...
|
||||||
% p,ibp,jbp,kbp,nxpl,nypl,nzpl,ighost] = read_uvwp_chunk_ucf(file,varargin)
|
% p,ibp,jbp,kbp,nxpl,nypl,nzpl,ighost] = read_uvwp_chunk_ucf(file,varargin)
|
||||||
% Reads u,v,w,p from one processor chunk.
|
% Reads u,v,w,p 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
|
||||||
% u,v,w,p partial fields with dim(nxl,nyl,nzl)+2*ighost
|
% u,v,w,p partial fields with dim(nxl,nyl,nzl)+2*ighost
|
||||||
% ibu,jbu,kbu,... global index of first grid point of the partial field w/o ghost cells
|
% ibu,jbu,kbu,... global index of first grid point of the partial field w/o ghost cells
|
||||||
|
|
@ -22,12 +23,14 @@ function [u,ibu,jbu,kbu,nxul,nyul,nzul,...
|
||||||
|
|
||||||
% 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;
|
||||||
|
|
||||||
% Define sets to be read
|
% Define sets to be read
|
||||||
|
|
@ -36,9 +39,11 @@ function [u,ibu,jbu,kbu,nxul,nyul,nzul,...
|
||||||
|
|
||||||
% 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
|
||||||
if ~obj.validateType('field')
|
subfile = sprintf('uvwp.%05d',par.Results.rank);
|
||||||
error('read error: no field data.');
|
obj.opentar(file.pointer(subfile));
|
||||||
|
else
|
||||||
|
obj.open(file);
|
||||||
end
|
end
|
||||||
|
|
||||||
% Read raw data
|
% Read raw data
|
||||||
|
|
|
||||||
|
|
@ -2,19 +2,20 @@ function [u,v,w,p] = read_uvwp_complete_ucf(file,varargin)
|
||||||
% [u,v,w,p] = read_uvwp_complete_ucf(file,varargin)
|
% [u,v,w,p] = read_uvwp_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: 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
|
||||||
% u,v,w,p complete fields with dim(nx,ny,nz)
|
% u,v,w,p complete fields with dim(nx,ny,nz)
|
||||||
|
|
||||||
% 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.timestep;
|
||||||
|
|
||||||
|
|
@ -22,13 +23,17 @@ function [u,v,w,p] = read_uvwp_complete_ucf(file,varargin)
|
||||||
sets = {'u','v','w','p'};
|
sets = {'u','v','w','p'};
|
||||||
nset = numel(sets);
|
nset = numel(sets);
|
||||||
|
|
||||||
% 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('uvwp.%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
|
||||||
|
|
@ -93,11 +98,22 @@ function [u,v,w,p] = read_uvwp_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('uvwp.%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
|
||||||
|
|
@ -152,6 +168,10 @@ function [u,v,w,p] = read_uvwp_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('uvwp.%05d',ifile);
|
||||||
|
else
|
||||||
|
fname = sprintf('%s/%s.%05d',fdir,fbase,ifile);
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue