update to new interface
This commit is contained in:
parent
78c0243b8c
commit
0e1b24d0e9
|
|
@ -17,24 +17,25 @@ function [s] = read_scal_complete_ucf(file,varargin)
|
||||||
addOptional(par,'debug',0,@isnumeric);
|
addOptional(par,'debug',0,@isnumeric);
|
||||||
parse(par,varargin{:});
|
parse(par,varargin{:});
|
||||||
istep = par.Results.timestep;
|
istep = par.Results.timestep;
|
||||||
|
|
||||||
% Parse filename
|
% Parse filename
|
||||||
[fdir,fbase,fext] = fileparts(file);
|
[fdir,fbase,fext] = fileparts(file);
|
||||||
fname = sprintf('%s/%s.%05d',fdir,fbase,0);
|
fname = sprintf('%s/%s.%05d',fdir,fbase,0);
|
||||||
|
|
||||||
% Open first file
|
% Open first file
|
||||||
obj = ucf(fname,'read','verbosity',par.Results.verbosity,'debug',par.Results.debug);
|
obj = ucf('verbosity',par.Results.verbosity,'debug',par.Results.debug);
|
||||||
|
obj.open(fname);
|
||||||
if ~obj.validateType('field')
|
if ~obj.validateType('field')
|
||||||
error('read error: no field data.');
|
error('read error: no field data.');
|
||||||
end
|
end
|
||||||
nscal = obj.getNumDatasets(istep);
|
nscal = obj.getNumDatasets(istep);
|
||||||
|
|
||||||
% Read raw data
|
% Read raw data
|
||||||
q = cell(1,nscal);
|
q = cell(1,nscal);
|
||||||
for iset=1:nscal
|
for iset=1:nscal
|
||||||
[data,params] = obj.readSet(istep,iset);
|
[data,params] = obj.readSet(istep,iset);
|
||||||
params = cast(params,'double');
|
params = cast(params,'double');
|
||||||
ighost = params(1);
|
ighost = params(1);
|
||||||
ib = params(2);
|
ib = params(2);
|
||||||
jb = params(3);
|
jb = params(3);
|
||||||
kb = params(4);
|
kb = params(4);
|
||||||
|
|
@ -49,7 +50,7 @@ function [s] = read_scal_complete_ucf(file,varargin)
|
||||||
q{iset} = q{iset}(2:end-1,2:end-1,2:end-1);
|
q{iset} = q{iset}(2:end-1,2:end-1,2:end-1);
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
% Reassign content from loop and create global arrays
|
% Reassign content from loop and create global arrays
|
||||||
s = zeros(nx,ny,nz,nscal,class(q{1}));
|
s = zeros(nx,ny,nz,nscal,class(q{1}));
|
||||||
for iscal=1:nscal
|
for iscal=1:nscal
|
||||||
|
|
@ -64,11 +65,12 @@ function [s] = read_scal_complete_ucf(file,varargin)
|
||||||
fname = sprintf('%s/%s.%05d',fdir,fbase,ifile);
|
fname = sprintf('%s/%s.%05d',fdir,fbase,ifile);
|
||||||
while exist(fname,'file')
|
while exist(fname,'file')
|
||||||
% Open file
|
% Open file
|
||||||
obj = ucf(fname,'read','verbosity',par.Results.verbosity,'debug',par.Results.debug);
|
obj = ucf('verbosity',par.Results.verbosity,'debug',par.Results.debug);
|
||||||
|
obj.open(fname)
|
||||||
if ~obj.validateType('field')
|
if ~obj.validateType('field')
|
||||||
error('read error: no field data.');
|
error('read error: no field data.');
|
||||||
end
|
end
|
||||||
|
|
||||||
% Read raw data
|
% Read raw data
|
||||||
q = cell(1,nscal);
|
q = cell(1,nscal);
|
||||||
for iset=1:nscal
|
for iset=1:nscal
|
||||||
|
|
@ -86,15 +88,15 @@ function [s] = read_scal_complete_ucf(file,varargin)
|
||||||
q{iset} = q{iset}(2:end-1,2:end-1,2:end-1);
|
q{iset} = q{iset}(2:end-1,2:end-1,2:end-1);
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
% Reassign content from loop and create global arrays
|
% Reassign content from loop and create global arrays
|
||||||
for iscal=1:nscal
|
for iscal=1:nscal
|
||||||
s(ib:ib+nxl-1,jb:jb+nyl-1,kb:kb+nzl-1,iscal) = q{iset};
|
s(ib:ib+nxl-1,jb:jb+nyl-1,kb:kb+nzl-1,iscal) = q{iset};
|
||||||
end
|
end
|
||||||
|
|
||||||
% Close file
|
% Close file
|
||||||
obj.close();
|
obj.close();
|
||||||
|
|
||||||
% Move on to next file
|
% Move on to next file
|
||||||
ifile = ifile+1;
|
ifile = ifile+1;
|
||||||
fname = sprintf('%s/%s.%05d',fdir,fbase,ifile);
|
fname = sprintf('%s/%s.%05d',fdir,fbase,ifile);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
function [tbeg,tend,nstat,sm,ss,su,sv] = read_statistics_channel_scal_ucf(file,varargin)
|
function [tbeg,tend,nstat,sm,ss,su,sv] = read_statistics_channel_scal_ucf(file,varargin)
|
||||||
|
|
||||||
% Parse optional input arguments
|
% Parse optional input arguments
|
||||||
par = inputParser;
|
par = inputParser;
|
||||||
addOptional(par,'verbosity',0,@isnumeric);
|
addOptional(par,'verbosity',0,@isnumeric);
|
||||||
|
|
@ -9,14 +9,15 @@ function [tbeg,tend,nstat,sm,ss,su,sv] = read_statistics_channel_scal_ucf(file,v
|
||||||
% Define sets to be read
|
% Define sets to be read
|
||||||
sets = {'um','uu','vv','ww','uv','uub','uvb'};
|
sets = {'um','uu','vv','ww','uv','uub','uvb'};
|
||||||
nset = numel(sets);
|
nset = numel(sets);
|
||||||
|
|
||||||
% Open UCF file and read
|
% Open UCF file and read
|
||||||
obj = ucf(file,'read','verbosity',par.Results.verbosity,'debug',par.Results.debug);
|
obj = ucf('verbosity',par.Results.verbosity,'debug',par.Results.debug);
|
||||||
|
obj.open(file);
|
||||||
tend = obj.getSimulationTime(1);
|
tend = obj.getSimulationTime(1);
|
||||||
|
|
||||||
% Read parameters of first set
|
% Read parameters of first set
|
||||||
params = obj.readParameters(1,1);
|
params = obj.readParameters(1,1);
|
||||||
|
|
||||||
% Parse parameters
|
% Parse parameters
|
||||||
tbeg = typecast(params(1),'double');
|
tbeg = typecast(params(1),'double');
|
||||||
nstat = cast(params(2),'double');
|
nstat = cast(params(2),'double');
|
||||||
|
|
@ -34,7 +35,7 @@ function [tbeg,tend,nstat,sm,ss,su,sv] = read_statistics_channel_scal_ucf(file,v
|
||||||
su(:,iscal) = obj.readSet(1,(iscal-1)*4+3)/nstat;
|
su(:,iscal) = obj.readSet(1,(iscal-1)*4+3)/nstat;
|
||||||
sv(:,iscal) = obj.readSet(1,(iscal-1)*4+4)/nstat;
|
sv(:,iscal) = obj.readSet(1,(iscal-1)*4+4)/nstat;
|
||||||
end
|
end
|
||||||
|
|
||||||
% Close file
|
% Close file
|
||||||
obj.close();
|
obj.close();
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
function [tbeg,tend,nstat,um,uu,vv,ww,uv,uub,uvb,varargout] = read_statistics_channel_ucf(file,varargin)
|
function [tbeg,tend,nstat,um,uu,vv,ww,uv,uub,uvb,varargout] = read_statistics_channel_ucf(file,varargin)
|
||||||
|
|
||||||
% Parse optional input arguments
|
% Parse optional input arguments
|
||||||
par = inputParser;
|
par = inputParser;
|
||||||
addOptional(par,'verbosity',0,@isnumeric);
|
addOptional(par,'verbosity',0,@isnumeric);
|
||||||
|
|
@ -9,20 +9,21 @@ function [tbeg,tend,nstat,um,uu,vv,ww,uv,uub,uvb,varargout] = read_statistics_ch
|
||||||
% Define sets to be read
|
% Define sets to be read
|
||||||
sets = {'um','uu','vv','ww','uv','uub','uvb'};
|
sets = {'um','uu','vv','ww','uv','uub','uvb'};
|
||||||
nset = numel(sets);
|
nset = numel(sets);
|
||||||
|
|
||||||
% Open UCF file and read
|
% Open UCF file and read
|
||||||
obj = ucf(file,'read','verbosity',par.Results.verbosity,'debug',par.Results.debug);
|
obj = ucf('verbosity',par.Results.verbosity,'debug',par.Results.debug);
|
||||||
|
obj.open(file);
|
||||||
tend = obj.getSimulationTime(1);
|
tend = obj.getSimulationTime(1);
|
||||||
|
|
||||||
% Read first dataset
|
% Read first dataset
|
||||||
[um,params] = obj.readSet(1,1);
|
[um,params] = obj.readSet(1,1);
|
||||||
|
|
||||||
% Parse parameters
|
% Parse parameters
|
||||||
tbeg = typecast(params(1),'double');
|
tbeg = typecast(params(1),'double');
|
||||||
nstat = cast(params(2),'double');
|
nstat = cast(params(2),'double');
|
||||||
nset1 = cast(params(4),'double'); % channel stats
|
nset1 = cast(params(4),'double'); % channel stats
|
||||||
nset2 = cast(params(5),'double'); % force eulerian
|
nset2 = cast(params(5),'double'); % force eulerian
|
||||||
|
|
||||||
if nset1~=7
|
if nset1~=7
|
||||||
error('Invalid file.');
|
error('Invalid file.');
|
||||||
end
|
end
|
||||||
|
|
@ -33,7 +34,7 @@ function [tbeg,tend,nstat,um,uu,vv,ww,uv,uub,uvb,varargout] = read_statistics_ch
|
||||||
uv = obj.readSet(1,5)/nstat;
|
uv = obj.readSet(1,5)/nstat;
|
||||||
uub = obj.readSet(1,6)/nstat;
|
uub = obj.readSet(1,6)/nstat;
|
||||||
uvb = obj.readSet(1,7)/nstat;
|
uvb = obj.readSet(1,7)/nstat;
|
||||||
|
|
||||||
% If eulerian force data, read that too
|
% If eulerian force data, read that too
|
||||||
if nset2==3
|
if nset2==3
|
||||||
if par.Results.verbosity
|
if par.Results.verbosity
|
||||||
|
|
@ -46,7 +47,7 @@ function [tbeg,tend,nstat,um,uu,vv,ww,uv,uub,uvb,varargout] = read_statistics_ch
|
||||||
varargout{2} = fyp;
|
varargout{2} = fyp;
|
||||||
varargout{3} = fzp;
|
varargout{3} = fzp;
|
||||||
end
|
end
|
||||||
|
|
||||||
% Close file
|
% Close file
|
||||||
obj.close();
|
obj.close();
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -29,17 +29,18 @@ function [u,ibu,jbu,kbu,nxul,nyul,nzul,...
|
||||||
parse(par,varargin{:});
|
parse(par,varargin{:});
|
||||||
istep = par.Results.timestep;
|
istep = par.Results.timestep;
|
||||||
keepghost = par.Results.ghost;
|
keepghost = par.Results.ghost;
|
||||||
|
|
||||||
% Define sets to be read
|
% Define sets to be read
|
||||||
sets = {'u','v','w','p'};
|
sets = {'u','v','w','p'};
|
||||||
nset = numel(sets);
|
nset = numel(sets);
|
||||||
|
|
||||||
% Open file
|
% Open file
|
||||||
obj = ucf(file,'read','verbosity',par.Results.verbosity,'debug',par.Results.debug);
|
obj = ucf('verbosity',par.Results.verbosity,'debug',par.Results.debug);
|
||||||
|
obj.open(file);
|
||||||
if ~obj.validateType('field')
|
if ~obj.validateType('field')
|
||||||
error('read error: no field data.');
|
error('read error: no field data.');
|
||||||
end
|
end
|
||||||
|
|
||||||
% Read raw data
|
% Read raw data
|
||||||
ib = cell(1,nset);
|
ib = cell(1,nset);
|
||||||
jb = cell(1,nset);
|
jb = cell(1,nset);
|
||||||
|
|
@ -64,7 +65,7 @@ function [u,ibu,jbu,kbu,nxul,nyul,nzul,...
|
||||||
ighost = 0;
|
ighost = 0;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
% Close UCF file
|
% Close UCF file
|
||||||
obj.close();
|
obj.close();
|
||||||
|
|
||||||
|
|
@ -77,7 +78,7 @@ function [u,ibu,jbu,kbu,nxul,nyul,nzul,...
|
||||||
nxul = nxl{iset};
|
nxul = nxl{iset};
|
||||||
nyul = nyl{iset};
|
nyul = nyl{iset};
|
||||||
nzul = nzl{iset};
|
nzul = nzl{iset};
|
||||||
|
|
||||||
iset = find(strcmp(sets,'v'));
|
iset = find(strcmp(sets,'v'));
|
||||||
v = q{iset};
|
v = q{iset};
|
||||||
ibv = ib{iset};
|
ibv = ib{iset};
|
||||||
|
|
@ -86,7 +87,7 @@ function [u,ibu,jbu,kbu,nxul,nyul,nzul,...
|
||||||
nxvl = nxl{iset};
|
nxvl = nxl{iset};
|
||||||
nyvl = nyl{iset};
|
nyvl = nyl{iset};
|
||||||
nzvl = nzl{iset};
|
nzvl = nzl{iset};
|
||||||
|
|
||||||
iset = find(strcmp(sets,'w'));
|
iset = find(strcmp(sets,'w'));
|
||||||
w = q{iset};
|
w = q{iset};
|
||||||
ibw = ib{iset};
|
ibw = ib{iset};
|
||||||
|
|
@ -95,7 +96,7 @@ function [u,ibu,jbu,kbu,nxul,nyul,nzul,...
|
||||||
nxwl = nxl{iset};
|
nxwl = nxl{iset};
|
||||||
nywl = nyl{iset};
|
nywl = nyl{iset};
|
||||||
nzwl = nzl{iset};
|
nzwl = nzl{iset};
|
||||||
|
|
||||||
iset = find(strcmp(sets,'p'));
|
iset = find(strcmp(sets,'p'));
|
||||||
p = q{iset};
|
p = q{iset};
|
||||||
ibp = ib{iset};
|
ibp = ib{iset};
|
||||||
|
|
|
||||||
|
|
@ -21,17 +21,18 @@ function [u,v,w,p] = read_uvwp_complete_ucf(file,varargin)
|
||||||
% Define sets to be read
|
% Define sets to be read
|
||||||
sets = {'u','v','w','p'};
|
sets = {'u','v','w','p'};
|
||||||
nset = numel(sets);
|
nset = numel(sets);
|
||||||
|
|
||||||
% Parse filename
|
% Parse filename
|
||||||
[fdir,fbase,fext] = fileparts(file);
|
[fdir,fbase,fext] = fileparts(file);
|
||||||
fname = sprintf('%s/%s.%05d',fdir,fbase,0);
|
fname = sprintf('%s/%s.%05d',fdir,fbase,0);
|
||||||
|
|
||||||
% Open first file
|
% Open first file
|
||||||
obj = ucf(fname,'read','verbosity',par.Results.verbosity,'debug',par.Results.debug);
|
obj = ucf('verbosity',par.Results.verbosity,'debug',par.Results.debug);
|
||||||
|
obj.open(fname);
|
||||||
if ~obj.validateType('field')
|
if ~obj.validateType('field')
|
||||||
error('read error: no field data.');
|
error('read error: no field data.');
|
||||||
end
|
end
|
||||||
|
|
||||||
% Read raw data
|
% Read raw data
|
||||||
q = cell(1,nset);
|
q = cell(1,nset);
|
||||||
ib = cell(1,nset);
|
ib = cell(1,nset);
|
||||||
|
|
@ -61,26 +62,26 @@ function [u,v,w,p] = read_uvwp_complete_ucf(file,varargin)
|
||||||
q{iset} = q{iset}(2:end-1,2:end-1,2:end-1);
|
q{iset} = q{iset}(2:end-1,2:end-1,2:end-1);
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
% Reassign content from loop and create global arrays
|
% Reassign content from loop and create global arrays
|
||||||
iset = find(strcmp(sets,'u'));
|
iset = find(strcmp(sets,'u'));
|
||||||
u = zeros(nx{iset},ny{iset},nz{iset},class(q{iset}));
|
u = zeros(nx{iset},ny{iset},nz{iset},class(q{iset}));
|
||||||
u(ib{iset}:ib{iset}+nxl{iset}-1,...
|
u(ib{iset}:ib{iset}+nxl{iset}-1,...
|
||||||
jb{iset}:jb{iset}+nyl{iset}-1,...
|
jb{iset}:jb{iset}+nyl{iset}-1,...
|
||||||
kb{iset}:kb{iset}+nzl{iset}-1) = q{iset};
|
kb{iset}:kb{iset}+nzl{iset}-1) = q{iset};
|
||||||
|
|
||||||
iset = find(strcmp(sets,'v'));
|
iset = find(strcmp(sets,'v'));
|
||||||
v = zeros(nx{iset},ny{iset},nz{iset},class(q{iset}));
|
v = zeros(nx{iset},ny{iset},nz{iset},class(q{iset}));
|
||||||
v(ib{iset}:ib{iset}+nxl{iset}-1,...
|
v(ib{iset}:ib{iset}+nxl{iset}-1,...
|
||||||
jb{iset}:jb{iset}+nyl{iset}-1,...
|
jb{iset}:jb{iset}+nyl{iset}-1,...
|
||||||
kb{iset}:kb{iset}+nzl{iset}-1) = q{iset};
|
kb{iset}:kb{iset}+nzl{iset}-1) = q{iset};
|
||||||
|
|
||||||
iset = find(strcmp(sets,'w'));
|
iset = find(strcmp(sets,'w'));
|
||||||
w = zeros(nx{iset},ny{iset},nz{iset},class(q{iset}));
|
w = zeros(nx{iset},ny{iset},nz{iset},class(q{iset}));
|
||||||
w(ib{iset}:ib{iset}+nxl{iset}-1,...
|
w(ib{iset}:ib{iset}+nxl{iset}-1,...
|
||||||
jb{iset}:jb{iset}+nyl{iset}-1,...
|
jb{iset}:jb{iset}+nyl{iset}-1,...
|
||||||
kb{iset}:kb{iset}+nzl{iset}-1) = q{iset};
|
kb{iset}:kb{iset}+nzl{iset}-1) = q{iset};
|
||||||
|
|
||||||
iset = find(strcmp(sets,'p'));
|
iset = find(strcmp(sets,'p'));
|
||||||
p = zeros(nx{iset},ny{iset},nz{iset},class(q{iset}));
|
p = zeros(nx{iset},ny{iset},nz{iset},class(q{iset}));
|
||||||
p(ib{iset}:ib{iset}+nxl{iset}-1,...
|
p(ib{iset}:ib{iset}+nxl{iset}-1,...
|
||||||
|
|
@ -95,11 +96,12 @@ function [u,v,w,p] = read_uvwp_complete_ucf(file,varargin)
|
||||||
fname = sprintf('%s/%s.%05d',fdir,fbase,ifile);
|
fname = sprintf('%s/%s.%05d',fdir,fbase,ifile);
|
||||||
while exist(fname,'file')
|
while exist(fname,'file')
|
||||||
% Open file
|
% Open file
|
||||||
obj = ucf(fname,'read','verbosity',par.Results.verbosity,'debug',par.Results.debug);
|
obj = ucf('verbosity',par.Results.verbosity,'debug',par.Results.debug);
|
||||||
|
obj.open(fname);
|
||||||
if ~obj.validateType('field')
|
if ~obj.validateType('field')
|
||||||
error('read error: no field data.');
|
error('read error: no field data.');
|
||||||
end
|
end
|
||||||
|
|
||||||
% Read raw data
|
% Read raw data
|
||||||
q = cell(1,nset);
|
q = cell(1,nset);
|
||||||
ib = cell(1,nset);
|
ib = cell(1,nset);
|
||||||
|
|
@ -123,31 +125,31 @@ function [u,v,w,p] = read_uvwp_complete_ucf(file,varargin)
|
||||||
q{iset} = q{iset}(2:end-1,2:end-1,2:end-1);
|
q{iset} = q{iset}(2:end-1,2:end-1,2:end-1);
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
% Reassign content from loop and create global arrays
|
% Reassign content from loop and create global arrays
|
||||||
iset = find(strcmp(sets,'u'));
|
iset = find(strcmp(sets,'u'));
|
||||||
u(ib{iset}:ib{iset}+nxl{iset}-1,...
|
u(ib{iset}:ib{iset}+nxl{iset}-1,...
|
||||||
jb{iset}:jb{iset}+nyl{iset}-1,...
|
jb{iset}:jb{iset}+nyl{iset}-1,...
|
||||||
kb{iset}:kb{iset}+nzl{iset}-1) = q{iset};
|
kb{iset}:kb{iset}+nzl{iset}-1) = q{iset};
|
||||||
|
|
||||||
iset = find(strcmp(sets,'v'));
|
iset = find(strcmp(sets,'v'));
|
||||||
v(ib{iset}:ib{iset}+nxl{iset}-1,...
|
v(ib{iset}:ib{iset}+nxl{iset}-1,...
|
||||||
jb{iset}:jb{iset}+nyl{iset}-1,...
|
jb{iset}:jb{iset}+nyl{iset}-1,...
|
||||||
kb{iset}:kb{iset}+nzl{iset}-1) = q{iset};
|
kb{iset}:kb{iset}+nzl{iset}-1) = q{iset};
|
||||||
|
|
||||||
iset = find(strcmp(sets,'w'));
|
iset = find(strcmp(sets,'w'));
|
||||||
w(ib{iset}:ib{iset}+nxl{iset}-1,...
|
w(ib{iset}:ib{iset}+nxl{iset}-1,...
|
||||||
jb{iset}:jb{iset}+nyl{iset}-1,...
|
jb{iset}:jb{iset}+nyl{iset}-1,...
|
||||||
kb{iset}:kb{iset}+nzl{iset}-1) = q{iset};
|
kb{iset}:kb{iset}+nzl{iset}-1) = q{iset};
|
||||||
|
|
||||||
iset = find(strcmp(sets,'p'));
|
iset = find(strcmp(sets,'p'));
|
||||||
p(ib{iset}:ib{iset}+nxl{iset}-1,...
|
p(ib{iset}:ib{iset}+nxl{iset}-1,...
|
||||||
jb{iset}:jb{iset}+nyl{iset}-1,...
|
jb{iset}:jb{iset}+nyl{iset}-1,...
|
||||||
kb{iset}:kb{iset}+nzl{iset}-1) = q{iset};
|
kb{iset}:kb{iset}+nzl{iset}-1) = q{iset};
|
||||||
|
|
||||||
% Close file
|
% Close file
|
||||||
obj.close();
|
obj.close();
|
||||||
|
|
||||||
% Move on to next file
|
% Move on to next file
|
||||||
ifile = ifile+1;
|
ifile = ifile+1;
|
||||||
fname = sprintf('%s/%s.%05d',fdir,fbase,ifile);
|
fname = sprintf('%s/%s.%05d',fdir,fbase,ifile);
|
||||||
|
|
|
||||||
|
|
@ -10,19 +10,19 @@ function [] = write_particles_ucf(file,pp,col,time,varargin)
|
||||||
% endian endianess of the file as used by fopen (default: 'n')
|
% endian endianess of the file as used by fopen (default: 'n')
|
||||||
% verbosity verbose output? (default: no)
|
% verbosity verbose output? (default: no)
|
||||||
% debug debug output? (default: no)
|
% debug debug output? (default: no)
|
||||||
|
|
||||||
% Parse variable input
|
% Parse variable input
|
||||||
par = inputParser;
|
par = inputParser;
|
||||||
addOptional(par,'endian','n',@ischar);
|
addOptional(par,'endian','n',@ischar);
|
||||||
addOptional(par,'verbosity',0,@isnumeric);
|
addOptional(par,'verbosity',0,@isnumeric);
|
||||||
addOptional(par,'debug',0,@isnumeric);
|
addOptional(par,'debug',0,@isnumeric);
|
||||||
parse(par,varargin{:});
|
parse(par,varargin{:});
|
||||||
|
|
||||||
ncol = size(pp,1);
|
ncol = size(pp,1);
|
||||||
np = size(pp,2);
|
np = size(pp,2);
|
||||||
[ncolref,ncol_rank,ncol_hybrid,ncol_dem,ncol_scal] = ncol_from_colmap(col);
|
[ncolref,ncol_rank,ncol_hybrid,ncol_dem,ncol_scal] = ncol_from_colmap(col);
|
||||||
nt = size(pp,3);
|
nt = size(pp,3);
|
||||||
|
|
||||||
% Check for consistency
|
% Check for consistency
|
||||||
if ncol~=col.Count || ncol~=ncolref
|
if ncol~=col.Count || ncol~=ncolref
|
||||||
error('Particle data does not match column map.');
|
error('Particle data does not match column map.');
|
||||||
|
|
@ -30,11 +30,10 @@ function [] = write_particles_ucf(file,pp,col,time,varargin)
|
||||||
if nt~=numel(time)
|
if nt~=numel(time)
|
||||||
error('Number of time steps must match the number of time values given. %d,%d',nt,numel(time));
|
error('Number of time steps must match the number of time values given. %d,%d',nt,numel(time));
|
||||||
end
|
end
|
||||||
|
|
||||||
% Create file
|
% Create file
|
||||||
obj = ucf(file,'create','verbosity',par.Results.verbosity,'debug',par.Results.debug);
|
obj = ucf('verbosity',par.Results.verbosity,'debug',par.Results.debug);
|
||||||
obj.setFileHeader('particle','endian',par.Results.endian);
|
obj.create(file,'type','particle','endian',par.Results.endian);
|
||||||
|
|
||||||
% Add particle data step by step
|
% Add particle data step by step
|
||||||
for it=1:nt
|
for it=1:nt
|
||||||
obj.appendStep(time(it));
|
obj.appendStep(time(it));
|
||||||
|
|
@ -42,7 +41,7 @@ function [] = write_particles_ucf(file,pp,col,time,varargin)
|
||||||
data = pp(:,:,it);
|
data = pp(:,:,it);
|
||||||
obj.appendSet(data,params);
|
obj.appendSet(data,params);
|
||||||
end
|
end
|
||||||
|
|
||||||
% Close file
|
% Close file
|
||||||
obj.close();
|
obj.close();
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ function [] = write_scal_chunk_ucf(file,s,ib,jb,kb,nx,ny,nz,time,ighost,varargin
|
||||||
% endian endianess of the file as used by fopen (default: 'n')
|
% endian endianess of the file as used by fopen (default: 'n')
|
||||||
% verbosity verbose output? (default: no)
|
% verbosity verbose output? (default: no)
|
||||||
% debug debug output? (default: no)
|
% debug debug output? (default: no)
|
||||||
|
|
||||||
% Parse variable input
|
% Parse variable input
|
||||||
par = inputParser;
|
par = inputParser;
|
||||||
addOptional(par,'rank',[0,0,0,0],@(x)isnumeric(x)&&numel(x)==4);
|
addOptional(par,'rank',[0,0,0,0],@(x)isnumeric(x)&&numel(x)==4);
|
||||||
|
|
@ -21,15 +21,15 @@ function [] = write_scal_chunk_ucf(file,s,ib,jb,kb,nx,ny,nz,time,ighost,varargin
|
||||||
addOptional(par,'verbosity',0,@isnumeric);
|
addOptional(par,'verbosity',0,@isnumeric);
|
||||||
addOptional(par,'debug',0,@isnumeric);
|
addOptional(par,'debug',0,@isnumeric);
|
||||||
parse(par,varargin{:});
|
parse(par,varargin{:});
|
||||||
|
|
||||||
% Determine number of scalar fields
|
% Determine number of scalar fields
|
||||||
nscal = size(s,4);
|
nscal = size(s,4);
|
||||||
|
|
||||||
% Create file and write to it
|
% Create file and write to it
|
||||||
obj = ucf(file,'create','verbosity',par.Results.verbosity,'debug',par.Results.debug);
|
obj = ucf('verbosity',par.Results.verbosity,'debug',par.Results.debug);
|
||||||
obj.setFileHeader('field','rank',par.Results.rank,'endian',par.Results.endian);
|
obj.create(file,'type','field','rank',par.Results.rank,'endian',par.Results.endian);
|
||||||
obj.appendStep(time);
|
obj.appendStep(time);
|
||||||
|
|
||||||
% Write scalar field by field
|
% Write scalar field by field
|
||||||
for iscal=1:nscal
|
for iscal=1:nscal
|
||||||
nxl = size(s,1)-2*ighost;
|
nxl = size(s,1)-2*ighost;
|
||||||
|
|
@ -38,7 +38,7 @@ function [] = write_scal_chunk_ucf(file,s,ib,jb,kb,nx,ny,nz,time,ighost,varargin
|
||||||
params = int64([ighost,ib,jb,kb,nxl,nyl,nzl,nx,ny,nz]);
|
params = int64([ighost,ib,jb,kb,nxl,nyl,nzl,nx,ny,nz]);
|
||||||
obj.appendSet(s(:,:,:,iscal),params);
|
obj.appendSet(s(:,:,:,iscal),params);
|
||||||
end
|
end
|
||||||
|
|
||||||
% Close file
|
% Close file
|
||||||
obj.close();
|
obj.close();
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -18,11 +18,11 @@ function [] = write_scal_complete_ucf(file,s,ibegp,iendp,jbegp,jendp,kbegp,kendp
|
||||||
addOptional(par,'verbosity',0,@isnumeric);
|
addOptional(par,'verbosity',0,@isnumeric);
|
||||||
addOptional(par,'debug',0,@isnumeric);
|
addOptional(par,'debug',0,@isnumeric);
|
||||||
parse(par,varargin{:});
|
parse(par,varargin{:});
|
||||||
|
|
||||||
% Parse filename
|
% Parse filename
|
||||||
[fdir,fbase,fext] = fileparts(file);
|
[fdir,fbase,fext] = fileparts(file);
|
||||||
fbasepath = fullfile(fdir,fbase);
|
fbasepath = fullfile(fdir,fbase);
|
||||||
|
|
||||||
nxprocs = numel(ibegp);
|
nxprocs = numel(ibegp);
|
||||||
nyprocs = numel(jbegp);
|
nyprocs = numel(jbegp);
|
||||||
nzprocs = numel(kbegp);
|
nzprocs = numel(kbegp);
|
||||||
|
|
@ -31,13 +31,13 @@ function [] = write_scal_complete_ucf(file,s,ibegp,iendp,jbegp,jendp,kbegp,kendp
|
||||||
ny = size(s,2);
|
ny = size(s,2);
|
||||||
nz = size(s,3);
|
nz = size(s,3);
|
||||||
nscal = size(s,4);
|
nscal = size(s,4);
|
||||||
|
|
||||||
for ixproc=0:nxprocs-1
|
for ixproc=0:nxprocs-1
|
||||||
for iyproc=0:nyprocs-1
|
for iyproc=0:nyprocs-1
|
||||||
for izproc=0:nzprocs-1
|
for izproc=0:nzprocs-1
|
||||||
[iproc] = locfun_proc_id(ixproc,iyproc,izproc,nxprocs,nyprocs,nzprocs);
|
[iproc] = locfun_proc_id(ixproc,iyproc,izproc,nxprocs,nyprocs,nzprocs);
|
||||||
fname = sprintf('%s.%05d',fbasepath,iproc);
|
fname = sprintf('%s.%05d',fbasepath,iproc);
|
||||||
|
|
||||||
% Extract local indices
|
% Extract local indices
|
||||||
ib = ibegp(ixproc+1);
|
ib = ibegp(ixproc+1);
|
||||||
ie = iendp(ixproc+1);
|
ie = iendp(ixproc+1);
|
||||||
|
|
@ -45,12 +45,12 @@ function [] = write_scal_complete_ucf(file,s,ibegp,iendp,jbegp,jendp,kbegp,kendp
|
||||||
je = jendp(iyproc+1);
|
je = jendp(iyproc+1);
|
||||||
kb = kbegp(izproc+1);
|
kb = kbegp(izproc+1);
|
||||||
ke = kendp(izproc+1);
|
ke = kendp(izproc+1);
|
||||||
|
|
||||||
% Create a new chunk file
|
% Create a new chunk file
|
||||||
obj = ucf(fname,'create','verbosity',par.Results.verbosity,'debug',par.Results.debug);
|
obj = ucf('verbosity',par.Results.verbosity,'debug',par.Results.debug);
|
||||||
obj.setFileHeader('field','rank',[iproc,ixproc,iyproc,izproc],'endian',par.Results.endian);
|
obj.create(fname,'type','field','rank',[iproc,ixproc,iyproc,izproc],'endian',par.Results.endian);
|
||||||
obj.appendStep(time);
|
obj.appendStep(time);
|
||||||
|
|
||||||
% Write data field by field
|
% Write data field by field
|
||||||
for iscal=1:nscal
|
for iscal=1:nscal
|
||||||
ighost = 0;
|
ighost = 0;
|
||||||
|
|
@ -61,7 +61,7 @@ function [] = write_scal_complete_ucf(file,s,ibegp,iendp,jbegp,jendp,kbegp,kendp
|
||||||
data = s(ib:ie,jb:je,kb:ke,iscal);
|
data = s(ib:ie,jb:je,kb:ke,iscal);
|
||||||
obj.appendSet(data,params);
|
obj.appendSet(data,params);
|
||||||
end
|
end
|
||||||
|
|
||||||
% Close chunk file
|
% Close chunk file
|
||||||
obj.close();
|
obj.close();
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ function [] = write_uvwp_chunk_ucf(file,...
|
||||||
% endian endianess of the file as used by fopen (default: 'n')
|
% endian endianess of the file as used by fopen (default: 'n')
|
||||||
% verbosity verbose output? (default: no)
|
% verbosity verbose output? (default: no)
|
||||||
% debug debug output? (default: no)
|
% debug debug output? (default: no)
|
||||||
|
|
||||||
% Parse variable input
|
% Parse variable input
|
||||||
par = inputParser;
|
par = inputParser;
|
||||||
addOptional(par,'rank',[0,0,0,0],@(x)isnumeric(x)&&numel(x)==4);
|
addOptional(par,'rank',[0,0,0,0],@(x)isnumeric(x)&&numel(x)==4);
|
||||||
|
|
@ -31,40 +31,40 @@ function [] = write_uvwp_chunk_ucf(file,...
|
||||||
addOptional(par,'verbosity',0,@isnumeric);
|
addOptional(par,'verbosity',0,@isnumeric);
|
||||||
addOptional(par,'debug',0,@isnumeric);
|
addOptional(par,'debug',0,@isnumeric);
|
||||||
parse(par,varargin{:});
|
parse(par,varargin{:});
|
||||||
|
|
||||||
% Create file and write to it
|
% Create file and write to it
|
||||||
obj = ucf(file,'create','verbosity',par.Results.verbosity,'debug',par.Results.debug);
|
obj = ucf('verbosity',par.Results.verbosity,'debug',par.Results.debug);
|
||||||
obj.setFileHeader('field','rank',par.Results.rank,'endian',par.Results.endian);
|
obj.create(file,'type','field','rank',par.Results.rank,'endian',par.Results.endian);
|
||||||
obj.appendStep(time);
|
obj.appendStep(time);
|
||||||
|
|
||||||
% Write u
|
% Write u
|
||||||
nxul = size(u,1)-2*ighost;
|
nxul = size(u,1)-2*ighost;
|
||||||
nyul = size(u,2)-2*ighost;
|
nyul = size(u,2)-2*ighost;
|
||||||
nzul = size(u,3)-2*ighost;
|
nzul = size(u,3)-2*ighost;
|
||||||
params = int64([ighost,ibu,jbu,kbu,nxul,nyul,nzul,nxu,nyu,nzu]);
|
params = int64([ighost,ibu,jbu,kbu,nxul,nyul,nzul,nxu,nyu,nzu]);
|
||||||
obj.appendSet(u,params);
|
obj.appendSet(u,params);
|
||||||
|
|
||||||
% Write v
|
% Write v
|
||||||
nxvl = size(v,1)-2*ighost;
|
nxvl = size(v,1)-2*ighost;
|
||||||
nyvl = size(v,2)-2*ighost;
|
nyvl = size(v,2)-2*ighost;
|
||||||
nzvl = size(v,3)-2*ighost;
|
nzvl = size(v,3)-2*ighost;
|
||||||
params = int64([ighost,ibv,jbv,kbv,nxvl,nyvl,nzvl,nxv,nyv,nzv]);
|
params = int64([ighost,ibv,jbv,kbv,nxvl,nyvl,nzvl,nxv,nyv,nzv]);
|
||||||
obj.appendSet(v,params);
|
obj.appendSet(v,params);
|
||||||
|
|
||||||
% Write w
|
% Write w
|
||||||
nxwl = size(w,1)-2*ighost;
|
nxwl = size(w,1)-2*ighost;
|
||||||
nywl = size(w,2)-2*ighost;
|
nywl = size(w,2)-2*ighost;
|
||||||
nzwl = size(w,3)-2*ighost;
|
nzwl = size(w,3)-2*ighost;
|
||||||
params = int64([ighost,ibw,jbw,kbw,nxwl,nywl,nzwl,nxw,nyw,nzw]);
|
params = int64([ighost,ibw,jbw,kbw,nxwl,nywl,nzwl,nxw,nyw,nzw]);
|
||||||
obj.appendSet(w,params);
|
obj.appendSet(w,params);
|
||||||
|
|
||||||
% Write p
|
% Write p
|
||||||
nxpl = size(p,1)-2*ighost;
|
nxpl = size(p,1)-2*ighost;
|
||||||
nypl = size(p,2)-2*ighost;
|
nypl = size(p,2)-2*ighost;
|
||||||
nzpl = size(p,3)-2*ighost;
|
nzpl = size(p,3)-2*ighost;
|
||||||
params = int64([ighost,ibp,jbp,kbp,nxpl,nypl,nzpl,nxp,nyp,nzp]);
|
params = int64([ighost,ibp,jbp,kbp,nxpl,nypl,nzpl,nxp,nyp,nzp]);
|
||||||
obj.appendSet(p,params);
|
obj.appendSet(p,params);
|
||||||
|
|
||||||
% Close file
|
% Close file
|
||||||
obj.close();
|
obj.close();
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ function [] = write_uvwp_complete_ucf(file,...
|
||||||
for izproc=0:nzprocs-1
|
for izproc=0:nzprocs-1
|
||||||
[iproc] = locfun_proc_id(ixproc,iyproc,izproc,nxprocs,nyprocs,nzprocs);
|
[iproc] = locfun_proc_id(ixproc,iyproc,izproc,nxprocs,nyprocs,nzprocs);
|
||||||
fname = sprintf('%s.%05d',fbasepath,iproc);
|
fname = sprintf('%s.%05d',fbasepath,iproc);
|
||||||
|
|
||||||
% Extract local indices
|
% Extract local indices
|
||||||
ibu = ibegu(ixproc+1); ibv = ibegv(ixproc+1); ibw = ibegw(ixproc+1); ibp = ibegp(ixproc+1);
|
ibu = ibegu(ixproc+1); ibv = ibegv(ixproc+1); ibw = ibegw(ixproc+1); ibp = ibegp(ixproc+1);
|
||||||
ieu = iendu(ixproc+1); iev = iendv(ixproc+1); iew = iendw(ixproc+1); iep = iendp(ixproc+1);
|
ieu = iendu(ixproc+1); iev = iendv(ixproc+1); iew = iendw(ixproc+1); iep = iendp(ixproc+1);
|
||||||
|
|
@ -54,13 +54,13 @@ function [] = write_uvwp_complete_ucf(file,...
|
||||||
jeu = jendu(iyproc+1); jev = jendv(iyproc+1); jew = jendw(iyproc+1); jep = jendp(iyproc+1);
|
jeu = jendu(iyproc+1); jev = jendv(iyproc+1); jew = jendw(iyproc+1); jep = jendp(iyproc+1);
|
||||||
kbu = kbegu(izproc+1); kbv = kbegv(izproc+1); kbw = kbegw(izproc+1); kbp = kbegp(izproc+1);
|
kbu = kbegu(izproc+1); kbv = kbegv(izproc+1); kbw = kbegw(izproc+1); kbp = kbegp(izproc+1);
|
||||||
keu = kendu(izproc+1); kev = kendv(izproc+1); kew = kendw(izproc+1); kep = kendp(izproc+1);
|
keu = kendu(izproc+1); kev = kendv(izproc+1); kew = kendw(izproc+1); kep = kendp(izproc+1);
|
||||||
|
|
||||||
% Create a new chunk file
|
% Create a new chunk file
|
||||||
obj = ucf(fname,'create','verbosity',par.Results.verbosity,'debug',par.Results.debug);
|
obj = ucf('verbosity',par.Results.verbosity,'debug',par.Results.debug);
|
||||||
obj.setFileHeader('field','rank',[iproc,ixproc,iyproc,izproc],'endian',par.Results.endian);
|
obj.create(fname,'type','field','rank',[iproc,ixproc,iyproc,izproc],'endian',par.Results.endian);
|
||||||
obj.appendStep(time);
|
obj.appendStep(time);
|
||||||
ighost = 0;
|
ighost = 0;
|
||||||
|
|
||||||
% Write u
|
% Write u
|
||||||
nxul = size(u,1)-2*ighost;
|
nxul = size(u,1)-2*ighost;
|
||||||
nyul = size(u,2)-2*ighost;
|
nyul = size(u,2)-2*ighost;
|
||||||
|
|
@ -68,7 +68,7 @@ function [] = write_uvwp_complete_ucf(file,...
|
||||||
params = int64([ighost,ibu,jbu,kbu,nxul,nyul,nzul,nxu,nyu,nzu]);
|
params = int64([ighost,ibu,jbu,kbu,nxul,nyul,nzul,nxu,nyu,nzu]);
|
||||||
data = u(ibu:ieu,jbu:jeu,kbu:keu);
|
data = u(ibu:ieu,jbu:jeu,kbu:keu);
|
||||||
obj.appendSet(data,params);
|
obj.appendSet(data,params);
|
||||||
|
|
||||||
% Write v
|
% Write v
|
||||||
nxvl = size(v,1)-2*ighost;
|
nxvl = size(v,1)-2*ighost;
|
||||||
nyvl = size(v,2)-2*ighost;
|
nyvl = size(v,2)-2*ighost;
|
||||||
|
|
@ -76,7 +76,7 @@ function [] = write_uvwp_complete_ucf(file,...
|
||||||
params = int64([ighost,ibv,jbv,kbv,nxvl,nyvl,nzvl,nxv,nyv,nzv]);
|
params = int64([ighost,ibv,jbv,kbv,nxvl,nyvl,nzvl,nxv,nyv,nzv]);
|
||||||
data = v(ibv:iev,jbv:jev,kbv:kev);
|
data = v(ibv:iev,jbv:jev,kbv:kev);
|
||||||
obj.appendSet(data,params);
|
obj.appendSet(data,params);
|
||||||
|
|
||||||
% Write w
|
% Write w
|
||||||
nxwl = size(w,1)-2*ighost;
|
nxwl = size(w,1)-2*ighost;
|
||||||
nywl = size(w,2)-2*ighost;
|
nywl = size(w,2)-2*ighost;
|
||||||
|
|
@ -84,7 +84,7 @@ function [] = write_uvwp_complete_ucf(file,...
|
||||||
params = int64([ighost,ibw,jbw,kbw,nxwl,nywl,nzwl,nxw,nyw,nzw]);
|
params = int64([ighost,ibw,jbw,kbw,nxwl,nywl,nzwl,nxw,nyw,nzw]);
|
||||||
data = w(ibw:iew,jbw:jew,kbw:kew);
|
data = w(ibw:iew,jbw:jew,kbw:kew);
|
||||||
obj.appendSet(data,params);
|
obj.appendSet(data,params);
|
||||||
|
|
||||||
% Write p
|
% Write p
|
||||||
nxpl = size(p,1)-2*ighost;
|
nxpl = size(p,1)-2*ighost;
|
||||||
nypl = size(p,2)-2*ighost;
|
nypl = size(p,2)-2*ighost;
|
||||||
|
|
@ -103,4 +103,4 @@ end
|
||||||
function [ind] = locfun_proc_id(ii,jj,kk,nx,ny,nz)
|
function [ind] = locfun_proc_id(ii,jj,kk,nx,ny,nz)
|
||||||
% local version of 'sub2ind_zero_row'
|
% local version of 'sub2ind_zero_row'
|
||||||
ind=ii*ny*nz+jj*nz+kk;
|
ind=ii*ny*nz+jj*nz+kk;
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -72,8 +72,8 @@ function [] = write_uvwp_newmesh_ucf(file,...
|
||||||
keu = kendu(izproc+1); kev = kendv(izproc+1); kew = kendw(izproc+1); kep = kendp(izproc+1);
|
keu = kendu(izproc+1); kev = kendv(izproc+1); kew = kendw(izproc+1); kep = kendp(izproc+1);
|
||||||
|
|
||||||
% Create output file
|
% Create output file
|
||||||
obj = ucf(fname,'create','verbosity',par.Results.verbosity,'debug',par.Results.debug);
|
obj = ucf('verbosity',par.Results.verbosity,'debug',par.Results.debug);
|
||||||
obj.setFileHeader('field','rank',[iproc,ixproc,iyproc,izproc],'endian',par.Results.endian);
|
obj.create(fname,'type','field','rank',[iproc,ixproc,iyproc,izproc],'endian',par.Results.endian);
|
||||||
obj.appendStep(time);
|
obj.appendStep(time);
|
||||||
|
|
||||||
% Interpolate to refined chunk and write
|
% Interpolate to refined chunk and write
|
||||||
|
|
@ -99,8 +99,6 @@ function [] = write_uvwp_newmesh_ucf(file,...
|
||||||
obj.appendField(tmp,0,ibp,jbp,kbp,nxp,nyp,nzp);
|
obj.appendField(tmp,0,ibp,jbp,kbp,nxp,nyp,nzp);
|
||||||
|
|
||||||
obj.close();
|
obj.close();
|
||||||
clear obj
|
|
||||||
fclose all;
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue