1 | %
|
---|
2 | % create an edge adjacency table for the elements in the model.
|
---|
3 | %
|
---|
4 | % [edgeadj,edgeuns,elemuns]=edgeadjacency(elem,nodecon)
|
---|
5 | %
|
---|
6 | % where the required input is:
|
---|
7 | % elem (numeric, element connectivity array (elems x nodes))
|
---|
8 | % nodecon (numeric, node connectivity array (nodes x elems+1))
|
---|
9 | %
|
---|
10 | % and the required output is:
|
---|
11 | % edgeadj (numeric, edge adjacency array (elems x edges))
|
---|
12 | %
|
---|
13 | % the optional output is:
|
---|
14 | % edgeuns (numeric, unshared edge list (edgeuns x 2))
|
---|
15 | % elemuns (numeric, unshared edge element list (edgeuns x 1))
|
---|
16 | %
|
---|
17 | function [edgeadj,edgeuns,elemuns]=edgeadjacency(elem,nodecon)
|
---|
18 |
|
---|
19 | if ~nargin
|
---|
20 | help edgeadjacency
|
---|
21 | return
|
---|
22 | end
|
---|
23 |
|
---|
24 | %% create the edge adjacency array
|
---|
25 |
|
---|
26 | edgeadj=zeros(size(elem));
|
---|
27 |
|
---|
28 | % loop over the elements
|
---|
29 |
|
---|
30 | for i=1:size(elem,1)
|
---|
31 |
|
---|
32 | % loop over the edges for each element (trias only for now)
|
---|
33 |
|
---|
34 | for j=1:size(elem,2)
|
---|
35 | inode1=elem(i,j);
|
---|
36 | inode2=elem(i,mod(j,size(elem,2))+1);
|
---|
37 |
|
---|
38 | % loop over the elements containing the first node of the edge to see
|
---|
39 | % if they contain the second node of the edge
|
---|
40 |
|
---|
41 | for k=1:nodecon(inode1,end)
|
---|
42 | if (nodecon(inode1,k) ~= i) && ...
|
---|
43 | ~isempty(find(elem(nodecon(inode1,k),:)==inode2,1))
|
---|
44 | edgeadj(i,j)=nodecon(inode1,k);
|
---|
45 | break;
|
---|
46 | end
|
---|
47 | end
|
---|
48 | end
|
---|
49 | end
|
---|
50 |
|
---|
51 | %% create the unshared edge list
|
---|
52 |
|
---|
53 | if (nargout >= 2)
|
---|
54 | [icol,irow]=find(edgeadj'==0);
|
---|
55 | edgeuns=zeros(length(irow),2);
|
---|
56 | if (nargout >= 3)
|
---|
57 | elemuns=zeros(length(irow),1);
|
---|
58 | end
|
---|
59 |
|
---|
60 | % loop over the edges
|
---|
61 |
|
---|
62 | for i=1:length(irow)
|
---|
63 | edgeuns(i,1)=elem(irow(i),icol(i));
|
---|
64 | edgeuns(i,2)=elem(irow(i),mod(icol(i),size(elem,2))+1);
|
---|
65 | if (nargout >= 3)
|
---|
66 | elemuns(i)=irow(i);
|
---|
67 | end
|
---|
68 | end
|
---|
69 | end
|
---|
70 |
|
---|
71 | end
|
---|