87 lines
2.4 KiB
Matlab
87 lines
2.4 KiB
Matlab
function [xu,yu,zu,xv,yv,zv,xw,yw,zw,xp,yp,zp,...
|
|
nxu,nyu,nzu,nxv,nyv,nzv,nxw,nyw,nzw,nxp,nyp,nzp] = read_grid_ucf(file,varargin)
|
|
% [xu,yu,zu,xv,yv,zv,xw,yw,zw,xp,yp,zp] = read_grid_ucf(file,varargin)
|
|
% Reads staggered grid from ucf file.
|
|
% Input
|
|
% file file to be read
|
|
% ? verbosity verbose output? (default: 0)
|
|
% ? debug debug output? (default: 0)
|
|
% ? tarmode read from tar-file? (default: 0)
|
|
% Output
|
|
% xu,yu,zu velocity grid u
|
|
% xv,yv,zv velocity grid v
|
|
% xw,yw,zw velocity grid w
|
|
% xp,yp,zp pressure grid / scalar grid
|
|
|
|
% Parse optional input arguments
|
|
par = inputParser;
|
|
addParamValue(par,'verbosity',0,@isnumeric);
|
|
addParamValue(par,'debug',0,@isnumeric);
|
|
addParamValue(par,'tarmode',0,@isnumeric);
|
|
parse(par,varargin{:});
|
|
|
|
% Define sets to be read
|
|
sets = {'u','v','w','p'};
|
|
nset = numel(sets);
|
|
|
|
% Open UCF file and read
|
|
obj = ucf('verbosity',par.Results.verbosity,'debug',par.Results.debug);
|
|
if par.Results.tarmode
|
|
ptr = file.pointer('grid.bin');
|
|
obj.opentar(ptr);
|
|
else
|
|
obj.open(file);
|
|
end
|
|
|
|
% Read raw data
|
|
x = cell(1,nset);
|
|
y = cell(1,nset);
|
|
z = cell(1,nset);
|
|
for iset=1:nset
|
|
[data,params] = obj.readSet(1,iset);
|
|
params = cast(params,'double');
|
|
nx{iset} = params(1);
|
|
ny{iset} = params(2);
|
|
nz{iset} = params(3);
|
|
x{iset} = data(1:nx{iset});
|
|
y{iset} = data(nx{iset}+1:nx{iset}+ny{iset});
|
|
z{iset} = data(nx{iset}+ny{iset}+1:nx{iset}+ny{iset}+nz{iset});
|
|
end
|
|
|
|
% Close UCF file
|
|
obj.close();
|
|
|
|
% Reassign content from loop
|
|
iset = find(strcmp(sets,'u'));
|
|
xu = x{iset};
|
|
yu = y{iset};
|
|
zu = z{iset};
|
|
nxu = nx{iset};
|
|
nyu = ny{iset};
|
|
nzu = nz{iset};
|
|
|
|
iset = find(strcmp(sets,'v'));
|
|
xv = x{iset};
|
|
yv = y{iset};
|
|
zv = z{iset};
|
|
nxv = nx{iset};
|
|
nyv = ny{iset};
|
|
nzv = nz{iset};
|
|
|
|
iset = find(strcmp(sets,'w'));
|
|
xw = x{iset};
|
|
yw = y{iset};
|
|
zw = z{iset};
|
|
nxw = nx{iset};
|
|
nyw = ny{iset};
|
|
nzw = nz{iset};
|
|
|
|
iset = find(strcmp(sets,'p'));
|
|
xp = x{iset};
|
|
yp = y{iset};
|
|
zp = z{iset};
|
|
nxp = nx{iset};
|
|
nyp = ny{iset};
|
|
nzp = nz{iset};
|
|
end
|