1 |
% BELINT - compute shape function information for a FEM domain |
---|
2 |
% |
---|
3 |
% BELINT(FEM_GRID_STRUCT) computes shape function |
---|
4 |
% information to be used in element finding (FINDELE). |
---|
5 |
% BELINT must return a new structure containing the input |
---|
6 |
% structure and adding the new components. The returned |
---|
7 |
% structure now includes:... |
---|
8 |
% |
---|
9 |
% INPUT : fem_grid_struct - (from LOADGRID, see FEM_GRID_STRUCT) |
---|
10 |
% |
---|
11 |
% OUTPUT : new_struct (REQ) - new structure with areas |
---|
12 |
% |
---|
13 |
% CALL : >>new_struct=belint(fem_grid_struct); |
---|
14 |
% |
---|
15 |
% Written by : Brian O. Blanton |
---|
16 |
% Summer 1997 |
---|
17 |
% |
---|
18 |
|
---|
19 |
function ret_struct=el_areas(fem_grid_struct) |
---|
20 |
|
---|
21 |
% VERIFY INCOMING STRUCTURE |
---|
22 |
% |
---|
23 |
if ~is_valid_struct(fem_grid_struct) |
---|
24 |
error(' Argument to EL_AREAS must be a valid fem_grid_struct.') |
---|
25 |
end |
---|
26 |
|
---|
27 |
% NEED ONE OUT ARG |
---|
28 |
% |
---|
29 |
if nargout~=1 |
---|
30 |
error(' BELINT must have 1 output argument.') |
---|
31 |
end |
---|
32 |
|
---|
33 |
% BREAK DOWN INCOMING STRUCTURE |
---|
34 |
% |
---|
35 |
e=fem_grid_struct.e; |
---|
36 |
x=fem_grid_struct.x; |
---|
37 |
y=fem_grid_struct.y; |
---|
38 |
|
---|
39 |
|
---|
40 |
% COMPUTE GLOBAL DY |
---|
41 |
% |
---|
42 |
dy=[y(e(:,2))-y(e(:,3)) y(e(:,3))-y(e(:,1)) y(e(:,1))-y(e(:,2))]; |
---|
43 |
|
---|
44 |
% COMPUTE ELEMENTAL AREAS |
---|
45 |
% |
---|
46 |
AR=(x(e(:,1)).*dy(:,1)+x(e(:,2)).*dy(:,2)+x(e(:,3)).*dy(:,3))/2.; |
---|
47 |
|
---|
48 |
% COMPUTE ARRAYS FOR ELEMENT FINDING |
---|
49 |
% |
---|
50 |
n1 = e(:,1); |
---|
51 |
n2 = e(:,2); |
---|
52 |
n3 = e(:,3); |
---|
53 |
A(:,1)=x(n3)-x(n2); |
---|
54 |
A(:,2)=x(n1)-x(n3); |
---|
55 |
A(:,3)=x(n2)-x(n1); |
---|
56 |
B(:,1)=y(n2)-y(n3); |
---|
57 |
B(:,2)=y(n3)-y(n1); |
---|
58 |
B(:,3)=y(n1)-y(n2); |
---|
59 |
A0(:,1)=.5*(x(n2).*y(n3)-x(n3).*y(n2)); |
---|
60 |
A0(:,2)=.5*(x(n3).*y(n1)-x(n1).*y(n3)); |
---|
61 |
T(:,1)=A0(:,1)*2; |
---|
62 |
T(:,2)=A0(:,2)*2; |
---|
63 |
T(:,3)=2*AR-T(:,1)-T(:,2); |
---|
64 |
|
---|
65 |
%Create return structure and attach element areas to ret_struct |
---|
66 |
% |
---|
67 |
ret_struct=fem_grid_struct; |
---|
68 |
ret_struct.A=A; |
---|
69 |
ret_struct.B=B; |
---|
70 |
ret_struct.A0=A0; |
---|
71 |
ret_struct.T=T; |
---|
72 |
|
---|
73 |
% |
---|
74 |
% Brian O. Blanton |
---|
75 |
% Curriculum in Marine Sciences |
---|
76 |
% Ocean Processes Numerical Modeling Laboratory |
---|
77 |
% 15-1A Venable Hall |
---|
78 |
% CB# 3300 |
---|
79 |
% Uni. of North Carolina |
---|
80 |
% Chapel Hill, NC |
---|
81 |
% 27599-3300 |
---|
82 |
% |
---|
83 |
% 919-962-4466 |
---|
84 |
% blanton@marine.unc.edu |
---|
85 |
% |
---|
86 |
% October 1995 |
---|
87 |
% |
---|