[conn,connnum,count]=neighborelem(elem,nn) create node neighbor list from a mesh author: Qianqian Fang, <q.fang at neu.edu> date: 2007/11/21 input: elem: element table of a mesh nn : total node number of the mesh output: conn: output, a cell structure of length nn, conn{n} contains a list of all neighboring elem ID for node n connnum: vector of length nn, denotes the neighbor number of each node count: total neighbor numbers -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net)
0001 function [conn,connnum,count]=neighborelem(elem,nn); 0002 % 0003 % [conn,connnum,count]=neighborelem(elem,nn) 0004 % 0005 % create node neighbor list from a mesh 0006 % 0007 % author: Qianqian Fang, <q.fang at neu.edu> 0008 % date: 2007/11/21 0009 % 0010 % input: 0011 % elem: element table of a mesh 0012 % nn : total node number of the mesh 0013 % 0014 % output: 0015 % conn: output, a cell structure of length nn, conn{n} 0016 % contains a list of all neighboring elem ID for node n 0017 % connnum: vector of length nn, denotes the neighbor number of each node 0018 % count: total neighbor numbers 0019 % 0020 % -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net) 0021 % 0022 0023 conn=cell(nn,1); 0024 dim=size(elem); 0025 for i=1:dim(1) 0026 for j=1:dim(2) 0027 conn{elem(i,j)}=[conn{elem(i,j)},i]; 0028 end 0029 end 0030 count=0; 0031 connnum=zeros(1,nn); 0032 for i=1:nn 0033 conn{i}=sort(conn{i}); 0034 connnum(i)=length(conn{i}); 0035 count=count+connnum(i); 0036 end