Home > vbmeg > external > iso2mesh > removeisolatednode.m

removeisolatednode

PURPOSE ^

SYNOPSIS ^

function [no,el]=removeisolatednode(node,elem)

DESCRIPTION ^

 [no,el]=removeisolatednode(node,elem)

 remove isolated nodes: nodes that are not included in any element

 author: Qianqian Fang, <q.fang at neu.edu>

 input:
     node: list of node coordinates
     elem: list of elements of the mesh, can be a regular array or a cell array for PLCs

 output:
     no: node coordinates after removing the isolated nodes
     el: element list of the resulting mesh

 -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [no,el]=removeisolatednode(node,elem)
0002 %
0003 % [no,el]=removeisolatednode(node,elem)
0004 %
0005 % remove isolated nodes: nodes that are not included in any element
0006 %
0007 % author: Qianqian Fang, <q.fang at neu.edu>
0008 %
0009 % input:
0010 %     node: list of node coordinates
0011 %     elem: list of elements of the mesh, can be a regular array or a cell array for PLCs
0012 %
0013 % output:
0014 %     no: node coordinates after removing the isolated nodes
0015 %     el: element list of the resulting mesh
0016 %
0017 % -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net)
0018 %
0019 
0020 oid=1:size(node,1);       % old node index
0021 if(~iscell(elem))
0022     idx=setdiff(oid,elem(:)); % indices to the isolated nodes
0023 else
0024     el=cell2mat(elem);
0025     idx=setdiff(oid,el(:)); % indices to the isolated nodes
0026 end
0027 idx=sort(idx);
0028 delta=zeros(size(oid));   
0029 delta(idx)=1;
0030 delta=-cumsum(delta);     % calculate the new node index after removing the isolated nodes
0031 oid=oid+delta;            % map to new index
0032 if(~iscell(elem))
0033     el=oid(elem);             % element list in the new index
0034 else
0035     el=cellfun(@(x) oid(x), elem,'UniformOutput',false);
0036 end
0037 no=node;                  
0038 no(idx,:)=[];             % remove the isolated nodes

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005