ucftools/matlab/colmap_from_flags.m

58 lines
1.5 KiB
Matlab

function [col] = colmap_from_flags(irank,ihybrid,idem,iscal)
% [col] = colmap_from_flags(irank,ihybrid,idem,iscal)
% Create a containers.Map object with particle column order.
% Input
% irank rank written?
% ihybrid hybrid written?
% idem DEM written?
% iscal scalar written? (number of scalars)
% Output
% col column map which can be indexed by e.g. col('x')
col = containers.Map('KeyType','char','ValueType','double');
ioffset = 0;
if irank
col('rank') = ioffset+1;
ioffset = ioffset+1;
end
if ihybrid
col('id') = ioffset+1;
col('x') = ioffset+2;
col('y') = ioffset+3;
col('z') = ioffset+4;
col('r') = ioffset+5;
col('rho')= ioffset+6;
col('ax') = ioffset+7;
col('ay') = ioffset+8;
col('az') = ioffset+9;
col('u') = ioffset+10;
col('v') = ioffset+11;
col('w') = ioffset+12;
col('ox') = ioffset+13;
col('oy') = ioffset+14;
col('oz') = ioffset+15;
col('fx') = ioffset+16;
col('fy') = ioffset+17;
col('fz') = ioffset+18;
col('tx') = ioffset+19;
col('ty') = ioffset+20;
col('tz') = ioffset+21;
ioffset = ioffset+21;
end
if idem
col('fxc') = ioffset+1;
col('fyc') = ioffset+2;
col('fzc') = ioffset+3;
col('txc') = ioffset+4;
col('tyc') = ioffset+5;
col('tzc') = ioffset+6;
ioffset = ioffset+6;
end
if iscal
for ii=1:iscal
col(['s',sprintf('%d',ii)]) = ioffset+1;
col(['q',sprintf('%d',ii)]) = ioffset+2;
ioffset = ioffset+2;
end
end
end