FEATool  v1.8Finite Element Analysis Toolbox
grid_cell_type.m File Reference

## Description

GRID_CELL_TYPE Determine grid cell type.

[ CELL_TYPE, N_SDIM, N_VC ] = GRID_CELL_TYPE( VARARGIN ) Determines the cell type from cell vertex connectivity array C, or alternatively the number of space dimensions N_SDIM, and the number of vertices per cell N_VC. Returns the CELL_TYPE, N_SDIM, and N_VC. Also assigns the cell_type integer code variables (LINE, TRI, QUAD, TET, and HEX) in the workspace of the caller function.

# Code listing

assignin( 'caller', 'LINE', 12 );
assignin( 'caller', 'TRI',  23 );
assignin( 'caller', 'TET',  34 );
assignin( 'caller', 'HEX',  38 );

if( nargin>=1 && nargin<=2 && all(cellfun(@isnumeric,varargin)) )

if( nargin==1 && numel(varargin{1})>1 )

c = varargin{1};
n_vc = size(c,1);
if( n_vc==4 )
if( size(c,2)==1 )
end

[~,tmp] = unique( sort( [ c(1:3,:) c([1 2 4],:) c([2 3 4],:) c([3 1 4],:) ], 1 )', 'rows' );
else
n_sdim = (n_vc==2) + 2*(n_vc==3) + 3*(n_vc==8);
end

varargin = { n_sdim n_vc };

end

cell_type = cell2mat( varargin ) * [10.^[(numel(varargin)-1):-1:0]]';

n_sdim = floor(cell_type/10);
n_vc   = rem(cell_type,10);

end