117 lines
3.6 KiB
Matlab
117 lines
3.6 KiB
Matlab
function [u,ibu,jbu,kbu,nxul,nyul,nzul,...
|
|
v,ibv,jbv,kbv,nxvl,nyvl,nzvl,...
|
|
w,ibw,jbw,kbw,nxwl,nywl,nzwl,...
|
|
p,ibp,jbp,kbp,nxpl,nypl,nzpl,ighost] = read_uvwp_chunk_ucf(file,varargin)
|
|
% [u,ibu,jbu,kbu,nxul,nyul,nzul,...
|
|
% v,ibv,jbv,kbv,nxvl,nyvl,nzvl,...
|
|
% w,ibw,jbw,kbw,nxwl,nywl,nzwl,...
|
|
% p,ibp,jbp,kbp,nxpl,nypl,nzpl,ighost] = read_uvwp_chunk_ucf(file,varargin)
|
|
% Reads u,v,w,p from one processor chunk.
|
|
% Input
|
|
% file file name (if tar-mode: ustar handle)
|
|
% ? step index of timestep to be read (default: 1)
|
|
% ? ghost keep ghost cells? (default: 1)
|
|
% ? verbosity verbose output? (default: 0)
|
|
% ? debug debug output? (default: 0)
|
|
% ? tarmode read from tar-file? (default: 0)
|
|
% ? rank rank of processor, ignored if not in tarmode (default: 0)
|
|
% Output
|
|
% 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
|
|
% nxul,nyul,nzul,... local field size w/o ghost cells
|
|
% ighost ghost cell flag
|
|
|
|
% Parse optional input arguments
|
|
par = inputParser;
|
|
addParamValue(par,'step',1,@isnumeric);
|
|
addParamValue(par,'ghost',1,@isnumeric);
|
|
addParamValue(par,'verbosity',0,@isnumeric);
|
|
addParamValue(par,'debug',0,@isnumeric);
|
|
addParamValue(par,'tarmode',0,@isnumeric); % deprecated
|
|
addParamValue(par,'rank',0,@isnumeric);
|
|
parse(par,varargin{:});
|
|
istep = par.Results.step;
|
|
keepghost = par.Results.ghost;
|
|
|
|
% Define sets to be read
|
|
sets = {'u','v','w','p'};
|
|
nset = numel(sets);
|
|
|
|
% Open file
|
|
obj = ucf('verbosity',par.Results.verbosity,'debug',par.Results.debug);
|
|
switch class(file)
|
|
case 'char'
|
|
obj.open(file);
|
|
case {'ustar','ucfmulti'}
|
|
subfile = sprintf('uvwp.%05d',par.Results.rank);
|
|
obj.opentar(file.pointer(subfile));
|
|
otherwise
|
|
error('Input file type not supported: %s',class(file));
|
|
end
|
|
|
|
% Read raw data
|
|
ib = cell(1,nset);
|
|
jb = cell(1,nset);
|
|
kb = cell(1,nset);
|
|
nxl = cell(1,nset);
|
|
nyl = cell(1,nset);
|
|
nzl = cell(1,nset);
|
|
q = cell(1,nset);
|
|
for iset=1:nset
|
|
[data,params] = obj.readSet(istep,iset);
|
|
params = cast(params,'double');
|
|
ighost = params(1);
|
|
ib{iset} = params(2);
|
|
jb{iset} = params(3);
|
|
kb{iset} = params(4);
|
|
nxl{iset} = params(5);
|
|
nyl{iset} = params(6);
|
|
nzl{iset} = params(7);
|
|
q{iset} = reshape(data,nxl{iset}+2*ighost,nyl{iset}+2*ighost,nzl{iset}+2*ighost);
|
|
if ighost && ~keepghost
|
|
q{iset} = q{iset}(2:end-1,2:end-1,2:end-1);
|
|
ighost = 0;
|
|
end
|
|
end
|
|
|
|
% Close UCF file
|
|
obj.close();
|
|
|
|
% Reassign content from loop
|
|
iset = find(strcmp(sets,'u'));
|
|
u = q{iset};
|
|
ibu = ib{iset};
|
|
jbu = jb{iset};
|
|
kbu = kb{iset};
|
|
nxul = nxl{iset};
|
|
nyul = nyl{iset};
|
|
nzul = nzl{iset};
|
|
|
|
iset = find(strcmp(sets,'v'));
|
|
v = q{iset};
|
|
ibv = ib{iset};
|
|
jbv = jb{iset};
|
|
kbv = kb{iset};
|
|
nxvl = nxl{iset};
|
|
nyvl = nyl{iset};
|
|
nzvl = nzl{iset};
|
|
|
|
iset = find(strcmp(sets,'w'));
|
|
w = q{iset};
|
|
ibw = ib{iset};
|
|
jbw = jb{iset};
|
|
kbw = kb{iset};
|
|
nxwl = nxl{iset};
|
|
nywl = nyl{iset};
|
|
nzwl = nzl{iset};
|
|
|
|
iset = find(strcmp(sets,'p'));
|
|
p = q{iset};
|
|
ibp = ib{iset};
|
|
jbp = jb{iset};
|
|
kbp = kb{iset};
|
|
nxpl = nxl{iset};
|
|
nypl = nyl{iset};
|
|
nzpl = nzl{iset};
|
|
end
|