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

root/gliderproc/trunk/MATLAB/opnml/mat4/belint4.m

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

Initial import of Stark code.

Line 
1 %BELINT4 - compute shape function information for a FEM domain
2 %   BELINT4(E,X,Y) computes shape function information
3 %   to be used in element finding (FINDELE).  BELINT4
4 %   returns nothing;  all results are stored in global
5 %   variables and accessed as needed.
6 % Globals: A - elemental x-edge differences
7 %
8 % Call as:  >> belint4e,x,y);
9 %         
10 % Written by : Brian O. Blanton (October 95)
11 %
12 function belint4e,x,y)
13 clear global A B T A0
14 global A B T A0
15
16 % DEFINE ERROR STRINGS
17 err1=['matrix of elements must be 3 or 4 columns wide'];
18 err2=['more than 1 column in x-coordinate vector.'];
19 err3=['more than 1 column in y-coordinate vector.'];
20 err5=str2mat('length of x or y does not equal the',...
21       'max node number found in element list.');
22 err6=['lengths of x & y must be equal'];
23
24 % CHECK SIZE OF ELEMENT MATRIX
25 % NELEMS = NUMBER OF ELEMENTS, S = # OF COLS
26 %
27 [ne,s]=size(e); 
28 if s<3 | s>4
29    error(err1);
30 elseif(s==4)
31    e=e(:,2:4);
32 end
33 % CHECK SIZE OF X-COORDINATE VECTOR
34 % NX = NUMBER OF X-COORDINATE VALUES, S = # OF COLS
35 %
36 [nx,s]=size(x);           
37 if nx~=1&s~=1
38    error(err2);
39 end
40  
41 % CHECK SIZE OF Y-COORDINATE VECTOR
42 % NY = NUMBER OF Y-COORDINATE VALUES, S = # OF COLS
43 %
44 [ny,s]=size(y);           
45 if ny~=1&s~=1
46    error(err3);
47 end
48
49 % CHECK LENGTHS OF X & Y
50 %
51 if nx~=ny
52   error(err6);
53 end
54
55 % MAKE SURE NUMBER OF NODES EQUALS THE MAX
56 % NODE NUMBER FOUND IN ELEMENT MATRIX
57 % MAXNN = MAXIMUM NODE NUMBER IN ELEMENT MATRIX
58 %
59 maxnn=max(max(e));
60 if maxnn~=length(x) | maxnn~=length(y)
61    disp(' ');
62    disp('??? Error using ==>> belint');
63    disp(err5);
64    error;
65 end
66
67 % COMPUTE GLOBAL DY
68 %
69 dy=[y(e(:,2))-y(e(:,3)) y(e(:,3))-y(e(:,1)) y(e(:,1))-y(e(:,2))];
70
71 % COMPUTE ELEMENTAL AREAS
72 %
73 AR=(x(e(:,1)).*dy(:,1)+x(e(:,2)).*dy(:,2)+x(e(:,3)).*dy(:,3))/2.;
74
75 % COMPUTE ARRAYS FOR ELEMENT FINDING (BELEL)
76 %
77 n1 = e(:,1);
78 n2 = e(:,2);
79 n3 = e(:,3);
80 A(:,1)=x(n3)-x(n2);
81 A(:,2)=x(n1)-x(n3);
82 A(:,3)=x(n2)-x(n1);
83 B(:,1)=y(n2)-y(n3);
84 B(:,2)=y(n3)-y(n1);
85 B(:,3)=y(n1)-y(n2);
86 A0(:,1)=.5*(x(n2).*y(n3)-x(n3).*y(n2));
87 A0(:,2)=.5*(x(n3).*y(n1)-x(n1).*y(n3));
88 T(:,1)=A0(:,1)*2;
89 T(:,2)=A0(:,2)*2;
90 T(:,3)=2*AR-T(:,1)-T(:,2);
91
92
93 %
94 %        Brian O. Blanton
95 %        Curriculum in Marine Sciences
96 %        Ocean Processes Numerical Modeling Laboratory
97 %        15-1A Venable Hall
98 %        CB# 3300
99 %        Uni. of North Carolina
100 %        Chapel Hill, NC
101 %                 27599-3300
102 %
103 %        919-962-4466
104 %        blanton@marine.unc.edu
105 %
106 %        October 1995
107 %
Note: See TracBrowser for help on using the browser.