function [tbeg,tend,nstat,um,uu,vv,ww,uv,uub,uvb,varargout] = read_statistics_channel_ucf(file,varargin) % [tbeg,tend,nstat,um,uu,vv,ww,uv,uub,uvb,varargout] = read_statistics_channel_ucf(file,varargin) % Reads statistics file for channel data in UCF format. % Input % file file name (if tar-mode: ustar handle) % ? verbosity verbose output? (default: no) % ? debug debug output? (default: no) % ? pure read an statistics_pure file? Only matters for tar archives (default: 0) % Output % tbeg time at beginning of sampling % tend time at end of sampling % nstat number of samples % um mean streamwise velocity % uu,vv,ww , , % uv % uub % uvb % ? fxp,fyp,fzp particle force in Eulerian frame % Parse optional input arguments par = inputParser; addParamValue(par,'verbosity',0,@isnumeric); addParamValue(par,'debug',0,@isnumeric); addParamValue(par,'pure',0,@isnumeric); parse(par,varargin{:}); ispure = par.Results.pure; % Define sets to be read sets = {'um','uu','vv','ww','uv','uub','uvb'}; nset = numel(sets); % Open UCF file and read obj = ucf('verbosity',par.Results.verbosity,'debug',par.Results.debug); switch class(file) case 'char' obj.open(file); case {'ustar','ucfmulti'} if ispure ptr = file.pointer('statistics_pure.bin'); else ptr = file.pointer('statistics.bin'); end obj.opentar(ptr); otherwise error('Input file type not supported: %s',class(file)); end tend = obj.getSimulationTime(); % Read first dataset [um,params] = obj.readSet(1,1); % Parse parameters tbeg = typecast(params(1),'double'); nstat = cast(params(2),'double'); nset1 = cast(params(4),'double'); % channel stats nset2 = cast(params(5),'double'); % force eulerian if nset1~=7 error('Invalid file.'); end um = um/nstat; uu = obj.readSet(1,2)/nstat; vv = obj.readSet(1,3)/nstat; ww = obj.readSet(1,4)/nstat; uv = obj.readSet(1,5)/nstat; uub = obj.readSet(1,6)/nstat; uvb = obj.readSet(1,7)/nstat; % If eulerian force data, read that too if nset2==3 if par.Results.verbosity fprintf('Eulerian force data found.\n'); end fxp = obj.readSet(1,8); fyp = obj.readSet(1,9); fzp = obj.readSet(1,10); varargout{1} = fxp/nstat; varargout{2} = fyp/nstat; varargout{3} = fzp/nstat; end % Close file obj.close(); end