57 lines
1.9 KiB
Matlab
57 lines
1.9 KiB
Matlab
function [q,x,y,z] = read_field_complete_ucf(hucf,field,varargin)
|
|
% [q,x,y,z] = read_field_complete_ucf(hucf,field,varargin)
|
|
% Reads a specific field from all processor chunks.(UCF tar version)
|
|
% Input
|
|
% hucf handle of UCF object (ustar,ucfmulti)
|
|
% field field to be read
|
|
% {'u','v','w','p','s1','s2',...}
|
|
% ? step index of step to be read (default: 1)
|
|
% ? verbosity verbose output? (default: 0)
|
|
% ? debug debug output? (default: 0)
|
|
% Output
|
|
% q complete field
|
|
% x,y,z corresponding grid
|
|
|
|
% Parse optional input arguments
|
|
par = inputParser;
|
|
addParamValue(par,'step',1,@isnumeric);
|
|
addParamValue(par,'verbosity',0,@isnumeric);
|
|
addParamValue(par,'debug',0,@isnumeric);
|
|
parse(par,varargin{:});
|
|
istep = par.Results.step;
|
|
|
|
% Parse field
|
|
switch field(1)
|
|
case 'u'; cmesh = 'u';
|
|
case 'v'; cmesh = 'v';
|
|
case 'w'; cmesh = 'w';
|
|
case 'p'; cmesh = 'p';
|
|
case 's'; cmesh = 'p';
|
|
otherwise; error('Invalid field: %s',field);
|
|
end
|
|
|
|
% Read parameters
|
|
params = read_parameters_ucf(hucf);
|
|
|
|
% Construct an array with final mesh size
|
|
nx = params.mesh.(sprintf('nx%s',cmesh));
|
|
ny = params.mesh.(sprintf('ny%s',cmesh));
|
|
nz = params.mesh.(sprintf('nz%s',cmesh));
|
|
q = zeros(nx,ny,nz);
|
|
|
|
% Read grid
|
|
[x.u,y.u,z.u,x.v,y.v,z.v,x.w,y.w,z.w,x.p,y.p,z.p] = read_grid_ucf(hucf);
|
|
x = x.(cmesh);
|
|
y = y.(cmesh);
|
|
z = z.(cmesh);
|
|
|
|
% Get number of processors
|
|
nprocs = params.parallel.nprocs;
|
|
|
|
% Now read chunk by chunk
|
|
for iproc=0:nprocs-1
|
|
[data,ib,jb,kb,nxl,nyl,nzl] = read_field_chunk_ucf(hucf,field,'rank',iproc,'ghost',0,'step',istep);
|
|
q(ib:ib+nxl-1,jb:jb+nyl-1,kb:kb+nzl-1) = data;
|
|
end
|
|
end
|