function [xu,yu,zu,xv,yv,zv,xw,yw,zw,xp,yp,zp] = 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; addParameter(par,'verbosity',0,@isnumeric); addParameter(par,'debug',0,@isnumeric); addParameter(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 = params(1); ny = params(2); nz = params(3); x{iset} = data(1:nx); y{iset} = data(nx+1:nx+ny); z{iset} = data(nx+ny+1:nx+ny+nz); end % Close UCF file obj.close(); % Reassign content from loop iset = find(strcmp(sets,'u')); xu = x{iset}; yu = y{iset}; zu = z{iset}; iset = find(strcmp(sets,'v')); xv = x{iset}; yv = y{iset}; zv = z{iset}; iset = find(strcmp(sets,'w')); xw = x{iset}; yw = y{iset}; zw = z{iset}; iset = find(strcmp(sets,'p')); xp = x{iset}; yp = y{iset}; zp = z{iset}; end