1 | %
|
---|
2 | % create a node connectivity table for the elements in the model.
|
---|
3 | %
|
---|
4 | % [nodecon]=edgeadjacency(elem,nnodes,mxepg)
|
---|
5 | %
|
---|
6 | % where the required input is:
|
---|
7 | % elem (numeric, element connectivity array (elems x nodes))
|
---|
8 | %
|
---|
9 | % and the required output is:
|
---|
10 | % nodecon (numeric, node connectivity array (nnodes x mxepg+1))
|
---|
11 | %
|
---|
12 | % the optional input is:
|
---|
13 | % nnodes (numeric, number of nodes)
|
---|
14 | % mxepg (numeric, max elements per node)
|
---|
15 | %
|
---|
16 | function [nodecon]=kmlnodeconnectivity(elem,nnodes,mxepg)
|
---|
17 |
|
---|
18 | if ~nargin
|
---|
19 | help kmlnodeconnectivity
|
---|
20 | return
|
---|
21 | end
|
---|
22 |
|
---|
23 | if ~exist('nnodes','var') || isempty(nnodes)
|
---|
24 | nnodes=max(max(elem));
|
---|
25 | end
|
---|
26 | if ~exist('mxepg','var') || isempty(mxepg)
|
---|
27 | mxepg=25;
|
---|
28 | end
|
---|
29 |
|
---|
30 | %% create the node connectivity array
|
---|
31 |
|
---|
32 | nodecon=zeros(nnodes,mxepg+1);
|
---|
33 |
|
---|
34 | % loop over the elements
|
---|
35 |
|
---|
36 | for i=1:size(elem,1)
|
---|
37 |
|
---|
38 | % loop over the nodes for each element
|
---|
39 |
|
---|
40 | for j=1:size(elem,2)
|
---|
41 | if elem(i,j)
|
---|
42 | nodecon(elem(i,j),nodecon(elem(i,j),end)+1)=i;
|
---|
43 | nodecon(elem(i,j),end)=nodecon(elem(i,j),end)+1;
|
---|
44 | end
|
---|
45 | end
|
---|
46 | end
|
---|
47 |
|
---|
48 | %% sort the node connectivity array
|
---|
49 |
|
---|
50 | % loop over the nodes
|
---|
51 |
|
---|
52 | for i=1:size(nodecon,1)
|
---|
53 | if (nodecon(i,end) > 1)
|
---|
54 | nodecon(i,1:nodecon(i,end))=sort(nodecon(i,1:nodecon(i,end)));
|
---|
55 | end
|
---|
56 | end
|
---|
57 |
|
---|
58 | end
|
---|