forked from fangq/iso2mesh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
neighborelem.m
36 lines (35 loc) · 870 Bytes
/
neighborelem.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
function [conn,connnum,count]=neighborelem(elem,nn);
%
% [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)
%
conn=cell(nn,1);
dim=size(elem);
for i=1:dim(1)
for j=1:dim(2)
conn{elem(i,j)}=[conn{elem(i,j)},i];
end
end
count=0;
connnum=zeros(1,nn);
for i=1:nn
conn{i}=sort(conn{i});
connnum(i)=length(conn{i});
count=count+connnum(i);
end