NCCOOS Trac Projects: Top | Web | Platforms | Processing | Viz | Sprints | Sandbox | (Wind)

root/gliderproc/trunk/MATLAB/opnml/FEM/reduce.m

Revision 495 (checked in by cbc, 11 years ago)

Initial import of Stark code.

Line 
1 function [new_struct,perm]=reduce(fem_grid_struct)
2 % REDUCE compute a bandwidth-reduced FEM domain connectivity list
3 %
4 %        REDUCE reduces the bandwidth of a FEM element list
5 %        using the symmetric reverse Cuthill-McKee bandwidth reduction
6 %        algorithm.  It employs the MATLAB routine SYMRCM to perform
7 %        the reordering and then permutes the remaining input arguments
8 %        according to the new node numbering.
9 %
10 %  INPUT: fem_grid_struct  - Finite element structure
11 %
12 % OUTPUT: new_struct - new structure with reduced bandwidth
13 %         perm       -  permutation list (OPT)
14 %
15 %   CALL: REDUCE requires the following calling formats:
16 %
17 %       [new_struct,perm]=reduce(fem_grid_struct)
18 %
19 % Calls: opnml, sparfun toolbox,
20 %
21 % Written by : Brian O. Blanton
22 %              October 1995
23 % Modified by: Jay Veeramony
24 %               April 2000
25
26 % VERIFY INCOMING STRUCTURE
27 %
28 if ~is_valid_struct(fem_grid_struct)
29    error('    Argument to INTERP_SCALAR must be a valid fem_grid_struct.')
30 end
31
32 if ~is_valid_struct2(fem_grid_struct)
33    disp('Adding components')
34    fem_grid_struct=el_areas(fem_grid_struct);
35 end
36
37 % BREAK DOWN INCOMING STRUCTURE
38 %
39 e=fem_grid_struct.e;
40 x=fem_grid_struct.x;
41 y=fem_grid_struct.y;
42 z=fem_grid_struct.z;
43
44 % Report original bandwidth to screen
45 disp(['Initial 1/2 Bandwidth = ',int2str((bwidth(e)-1)/2)])
46 disp('Forming adjacency matrix ...');
47
48 % Form (i,j) connection list from .ele element list
49 %
50 i=[e(:,1);e(:,2);e(:,3)];
51 j=[e(:,2);e(:,3);e(:,1)];
52
53 % Form the sparse adjacency matrix.
54 %
55 n = max(max(i),max(j));
56 A = sparse(i,j,1,n,n);
57 disp('Cuthill-McKee ...');
58 perm=symrcm(A);
59 perm=perm(:);
60
61 % The reduced bandwidth adjacency matrix in
62 % sparse form for boundary segment determination
63 %
64 ARBW=A(perm,perm);
65
66 disp('Permute inputs ...');
67 % Reverse the permutation "direction"
68 %
69 orignodelist=1:n;
70 l = zeros(n,1);
71 v=perm;
72 l(v)=orignodelist;
73
74 %Permute the element list
75 re=NaN*ones(size(e));
76 re(:,1) = l(e(:,1));
77 re(:,2) = l(e(:,2));
78 re(:,3) = l(e(:,3));
79
80 % Report reduced bandwidth to screen
81 disp(['Reduced 1/2 Bandwidth = ',int2str((bwidth(re)-1)/2)])
82
83 % Permute remaining input arguments
84 new_struct.name=fem_grid_struct.name;
85 new_struct.e=re;
86 new_struct.x=x(perm);
87 new_struct.y=y(perm);
88 new_struct.z=z(perm);
89 new_struct.bnd=detbndy(re);
90 new_struct=el_areas(new_struct);
Note: See TracBrowser for help on using the browser.