[6346] | 1 | %
|
---|
| 2 | % create a node connectivity table for the elements in the model.
|
---|
| 3 | %
|
---|
[8298] | 4 | % [nodecon]=edgeadjacency(elem,nnodes,mxepg)
|
---|
[6346] | 5 | %
|
---|
| 6 | % where the required input is:
|
---|
| 7 | % elem (numeric, element connectivity array (elems x nodes))
|
---|
| 8 | %
|
---|
| 9 | % and the required output is:
|
---|
[8298] | 10 | % nodecon (numeric, node connectivity array (nnodes x mxepg+1))
|
---|
[6346] | 11 | %
|
---|
| 12 | % the optional input is:
|
---|
[8298] | 13 | % nnodes (numeric, number of nodes)
|
---|
| 14 | % mxepg (numeric, max elements per node)
|
---|
[6346] | 15 | %
|
---|
[12028] | 16 | function [nodecon]=kmlnodeconnectivity(elem,nnodes,mxepg)
|
---|
[6346] | 17 |
|
---|
| 18 | if ~nargin
|
---|
[12028] | 19 | help kmlnodeconnectivity
|
---|
[6346] | 20 | return
|
---|
| 21 | end
|
---|
| 22 |
|
---|
[8298] | 23 | if ~exist('nnodes','var') || isempty(nnodes)
|
---|
| 24 | nnodes=max(max(elem));
|
---|
[6346] | 25 | end
|
---|
| 26 | if ~exist('mxepg','var') || isempty(mxepg)
|
---|
| 27 | mxepg=25;
|
---|
| 28 | end
|
---|
| 29 |
|
---|
| 30 | %% create the node connectivity array
|
---|
| 31 |
|
---|
[8298] | 32 | nodecon=zeros(nnodes,mxepg+1);
|
---|
[6346] | 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
|
---|