1 |
function ineg=el_areas4(e,x,y) |
---|
2 |
%EL_AREAS4 - compute triangular finite element areas |
---|
3 |
% EL_AREAS4(e,x,y) computes the areas for the elements |
---|
4 |
% defined by the element list (e) and the node coordinates |
---|
5 |
% (x,y). The areas are NOT returned to the workspace, but |
---|
6 |
% instead are stored globally in AR. An index of element |
---|
7 |
% numbers whose areas are negative (if any) are returned. |
---|
8 |
% Negative element areas indicate clockwise elemental |
---|
9 |
% node numbering, instead of the conventional counter- |
---|
10 |
% clockwise numbering. |
---|
11 |
% |
---|
12 |
% Call as: >> ineg=el_areas4(e,x,y); |
---|
13 |
% |
---|
14 |
% Written by : Brian O. Blanton (October 95) |
---|
15 |
% |
---|
16 |
|
---|
17 |
clear global AR |
---|
18 |
|
---|
19 |
% DEFINE ERROR STRINGS |
---|
20 |
err1=['matrix of elements must be 3 or 4 columns wide']; |
---|
21 |
err2=['more than 1 column in x-coordinate vector.']; |
---|
22 |
err3=['more than 1 column in y-coordinate vector.']; |
---|
23 |
err5=str2mat('length of x or y does not equal the',... |
---|
24 |
'max node number found in element list.'); |
---|
25 |
err6=['lengths of x & y must be equal']; |
---|
26 |
|
---|
27 |
% CHECK SIZE OF ELEMENT MATRIX |
---|
28 |
% NELEMS = NUMBER OF ELEMENTS, S = # OF COLS |
---|
29 |
% |
---|
30 |
[ne,s]=size(e); |
---|
31 |
if s<3 | s>4 |
---|
32 |
error(err1); |
---|
33 |
elseif(s==4) |
---|
34 |
e=e(:,2:4); |
---|
35 |
end |
---|
36 |
% CHECK SIZE OF X-COORDINATE VECTOR |
---|
37 |
% NX = NUMBER OF X-COORDINATE VALUES, S = # OF COLS |
---|
38 |
% |
---|
39 |
[nx,s]=size(x); |
---|
40 |
if nx~=1&s~=1 |
---|
41 |
error(err2); |
---|
42 |
end |
---|
43 |
|
---|
44 |
% CHECK SIZE OF Y-COORDINATE VECTOR |
---|
45 |
% NY = NUMBER OF Y-COORDINATE VALUES, S = # OF COLS |
---|
46 |
% |
---|
47 |
[ny,s]=size(y); |
---|
48 |
if ny~=1&s~=1 |
---|
49 |
error(err3); |
---|
50 |
end |
---|
51 |
|
---|
52 |
% CHECK LENGTHS OF X & Y |
---|
53 |
% |
---|
54 |
if nx~=ny |
---|
55 |
error(err6); |
---|
56 |
end |
---|
57 |
|
---|
58 |
% MAKE SURE NUMBER OF NODES EQUALS THE MAX |
---|
59 |
% NODE NUMBER FOUND IN ELEMENT MATRIX |
---|
60 |
% MAXNN = MAXIMUM NODE NUMBER IN ELEMENT MATRIX |
---|
61 |
% |
---|
62 |
maxnn=max(max(e)); |
---|
63 |
if maxnn~=length(x) | maxnn~=length(y) |
---|
64 |
error(err5); |
---|
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 |
% ANY NEGATIVE OR ZERO AREAS ? |
---|
76 |
% |
---|
77 |
ineg=find(AR<=0); |
---|
78 |
|
---|
79 |
global AR |
---|
80 |
|
---|
81 |
% |
---|
82 |
% Brian O. Blanton |
---|
83 |
% Curriculum in Marine Sciences |
---|
84 |
% Ocean Processes Numerical Modeling Laboratory |
---|
85 |
% 15-1A Venable Hall |
---|
86 |
% CB# 3300 |
---|
87 |
% Uni. of North Carolina |
---|
88 |
% Chapel Hill, NC |
---|
89 |
% 27599-3300 |
---|
90 |
% |
---|
91 |
% 919-962-4466 |
---|
92 |
% blanton@marine.unc.edu |
---|
93 |
% |
---|
94 |
% October 1995 |
---|
95 |
% |
---|