-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathEleType.m
231 lines (229 loc) · 9.52 KB
/
EleType.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
classdef EleType
properties
n_nodes % nodes_per_element
nodes_per_surface
N
dN
end
enumeration
Q4 (4,2,@EleType.N_Q4,@EleType.dN_Q4)
Q8 (8,3,@EleType.N_Q8,@EleType.dN_Q8)
Q9 (9,3,@EleType.N_Q9,@EleType.dN_Q9)
AHMAD4 (4,2,@EleType.N_Q4,@EleType.dN_Q4)
AHMAD8 (8,3,@EleType.N_Q8,@EleType.dN_Q8)
AHMAD9 (9,3,@EleType.N_Q9,@EleType.dN_Q9)
H8 (8,4,@EleType.N_H8,@EleType.dN_H8)
end
methods
function et = EleType(n_nodes,nodes_per_surface,N,dN)
% et = EleType(n_nodes,nodes_per_surface)
% Initializer, should contain all the properties, for
% enumeration
et.n_nodes = n_nodes;
et.nodes_per_surface = nodes_per_surface;
et.N = N;
et.dN = dN;
end
function [surfaces, s_coord, s_values] = surfaces(ele_type)
% [surfaces, s_directions, s_values] = surfaces(ele_type)
% Returns the nodes in each surface for the element type
% Each element has 4 surfaces, each one has an id (1 through 4)
% Each surface has either 1 or 3 nodes depending on the element.
% The surface can be defined by fixing one of the local
% coordinates, i.e. eta = 1 or ksi = -1.
% surfaces [4 x 3][Int]: each row has the nodes of the surface
% s_coord [4 x 1][Int]: each row has the local coordinate
% that remains fixed to represent that surface.
% s_values [4-6 x 1][Float]: the value of the coord that remains
% fixed, usually -1 or 1.
% BREAKS FOR H8
surfaces = [1 2 5;
2 3 6;
3 4 7;
1 4 8];
s_coord = [2 1 2 1]';
s_values = [-1 1 1 -1]';
surfaces = surfaces(:,1:ele_type.nodes_per_surface);
end
end
methods (Static)
%% Shell Elements
function types = Shell_Types()
% types = Shell_Types()
% types [1xn][EleType]: List with all the shell element types
types = [EleType.AHMAD4, EleType.AHMAD8, EleType.AHMAD9];
end
function bool = is_shell(ele_type)
% bool = is_shell(ele_type)
% Returns true if the ele_type argument is a shell.
shell_types = EleType.Shell_Types();
bool = false;
for i = 1:length(shell_types)
bool = bool || ele_type == shell_types(i);
end
end
%% 3D elements
%% H8 Methods
function N = N_H8(ksi,eta,zeta)
% N = N_H8(ksi,eta,zeta)
% N [1 x 8][Float]: Shape Functions for H8 element
% Follows anti-clockwise node-numbering convention:
% (ksi,eta,zeta) = [(-1,-1,-1), (1,-1,-1), (1,1,-1), (-1,1,-1)
% (-1,-1,1), (1,-1,1), (1,1,1), (-1,1,1)]
N = zeros(1,8);
count = 1;
for k = [-1 1]
for j = [-1 1]
for i = [-1 1]
N(count) = (1 + i*ksi)*(1 + j*eta)*(1 + k*zeta);
count = count + 1;
end
end
end
N = N(:,[1 2 4 3 5 6 8 7])/8;
end
function dN = dN_H8(ksi,eta,zeta)
% dN = dN_H8(ksi,eta,zeta)
% N [3 x 8][Float]: Shape Functions Derivatives for H8 element
% Follows anti-clockwise node-numbering convention:
% (ksi,eta,zeta) = [(-1,-1,-1), (1,-1,-1), (1,1,-1), (-1,1,-1)
% (-1,-1,1), (1,-1,1), (1,1,1), (-1,1,1)]
dN = [];
for k = [-1 1]
for j = [-1 1]
for i = [-1 1]
aux0 = [i*(1+j*eta)*(1+k*zeta) j*(1+i*ksi)*(1+k*zeta) k*(1+j*eta)*(1+i*ksi)]';
dN = [dN aux0];
end
end
end
dN = dN(:,[1 2 4 3 5 6 8 7])/8;
end
function Ndevsparse = dN_sparse(xi,eta,mu)
AUX = Element.dN_H8(xi,eta,mu);
Ndevsparse = [];
for i = 1:8
aux0 = AUX(:,i);
aux1 = [aux0 zeros(3,2)];
aux2 = [zeros(3,1) aux0 zeros(3,1)];
aux3 = [zeros(3,2) aux0];
aux0 = [aux1;aux2;aux3];
Ndevsparse = [Ndevsparse aux0];
end
end
%% 2D Elements
%% Q4 Methods
function N = N_Q4(ksi,eta,zeta)
% N = N_Q4(ksi,eta)
% N [1 x 4][Float]: Shape Functions for Q4 element
% Follows anti-clockwise node-numbering convention:
% (ksi,eta) = [(-1,-1), (1,-1), (1,1), (-1,1)]
N4 = 0.25*(1 - ksi)*(1 + eta);
N3 = 0.25*(1 + ksi)*(1 + eta);
N2 = 0.25*(1 + ksi)*(1 - eta);
N1 = 0.25*(1 - ksi)*(1 - eta);
N = [N1 N2 N3 N4];
end
function dN = dN_Q4(ksi,eta,zeta)
% dN = dN_Q4(ksi,eta)
% dN [2 x 4][Float]: Shape functions derivatives
% dN = [dN_dksi; dN_deta];
% Follows same numbering convention as N_Q4
dN = [ % dN_ksi
-0.25*(1 - eta), ...
0.25*(1 - eta), ...
0.25*(1 + eta), ...
-0.25*(1 + eta)
% dN_deta
-0.25*(1 - ksi), ...
-0.25*(1 + ksi), ...
0.25*(1 + ksi), ...
0.25*(1 - ksi) ];
end
%% Q8 methods
function N = N_Q8(ksi,eta,zeta)
% N = N_Q8(ksi,eta)
% N [1 x 8][Float]: Shape Functions for Q8 element
% Follows anti-clockwise node-numbering convention:
% (ksi,eta) = [(-1,-1), (1,-1), (1,1), (-1,1) ...
% (0,-1), (1,0), (0,1), (-1,0)]
N8 = 0.50*(1 - ksi )*(1 - eta^2);
N7 = 0.50*(1 - ksi^2)*(1 + eta );
N6 = 0.50*(1 + ksi )*(1 - eta^2);
N5 = 0.50*(1 - ksi^2)*(1 - eta );
N4 = 0.25*(1 - ksi )*(1 + eta ) - 0.5*(N7 + N8);
N3 = 0.25*(1 + ksi )*(1 + eta ) - 0.5*(N6 + N7);
N2 = 0.25*(1 + ksi )*(1 - eta ) - 0.5*(N5 + N6);
N1 = 0.25*(1 - ksi )*(1 - eta ) - 0.5*(N5 + N8);
N = [N1 N2 N3 N4 N5 N6 N7 N8];
end
function dN = dN_Q8(ksi,eta,zeta)
% dN = dN_Q8(ksi,eta)
% dN [2 x 8][Float]: Shape functions derivatives
% dN = [dN_dksi; dN_deta];
% Follows same numbering convention as N_Q8
dN = [ % dN_ksi
-0.25*(-1+eta)*(eta+2*ksi), ...
-0.25*(-1+eta)*(-eta+2*ksi), ...
0.25*(1+eta)*(eta+2*ksi), ...
0.25*(1+eta)*(-eta+2*ksi), ...
ksi*(-1+eta), ...
-0.5*(-1+eta)*(1+eta), ...
-ksi*(1+eta), ...
0.5*(-1+eta)*(1+eta);
% dN_deta
-0.25*(-1+ksi)*(ksi+2*eta), ...
-0.25*(1+ksi)*(ksi-2*eta), ...
0.25*(1+ksi)*(ksi+2*eta), ...
0.25*(-1+ksi)*(ksi-2*eta), ...
0.5*(-1+ksi)*(1+ksi), ...
-(1+ksi)*eta, ...
-0.5*(-1+ksi)*(1+ksi), ...
(-1+ksi)*eta ];
end
%% Q9 Methods
function N = N_Q9(ksi,eta,zeta)
% N = N_Q9(ksi,eta)
% N [1 x 9][Float]: Shape Functions for Q9 element
% Follows anti-clockwise node-numbering convention:
% (ksi,eta) = [(-1,-1), (1,-1), (1,1), (-1,1) ...
% (0,-1), (1,0), (0,1), (-1,0), (0,0)]
N9 = (1 - ksi^2)*(1 - eta^2);
N8 = 0.50*(1 - ksi )*(1 - eta^2) - 0.5*N9;
N7 = 0.50*(1 - ksi^2)*(1 + eta ) - 0.5*N9;
N6 = 0.50*(1 + ksi )*(1 - eta^2) - 0.5*N9;
N5 = 0.50*(1 - ksi^2)*(1 - eta ) - 0.5*N9;
N4 = 0.25*(1 - ksi )*(1 + eta ) - 0.5*(N7 + N8 + 0.5*N9);
N3 = 0.25*(1 + ksi )*(1 + eta ) - 0.5*(N6 + N7 + 0.5*N9);
N2 = 0.25*(1 + ksi )*(1 - eta ) - 0.5*(N5 + N6 + 0.5*N9);
N1 = 0.25*(1 - ksi )*(1 - eta ) - 0.5*(N5 + N8 + 0.5*N9);
N = [N1 N2 N3 N4 N5 N6 N7 N8 N9];
end
function dN = dN_Q9(ksi,eta,zeta)
% dN = dN_Q9(ksi,eta)
% dN [2 x 9][Float]: Shape functions derivatives
% dN = [dN_dksi; dN_deta];
% Follows same numbering convention as N_Q9
dN = [ % dN_ksi
0.25*eta*(-1+eta)*(2*ksi-1), ...
0.25*eta*(-1+eta)*(2*ksi+1), ...
0.25*eta*(1+eta)*(2*ksi+1), ...
0.25*eta*( 1+eta)*(2*ksi-1), ...
-ksi*eta*(-1+eta), ...
-1/2*(-1+eta)*(1+eta)*(2*ksi+1),...
-ksi*eta*(1+eta), ...
-1/2*(-1+eta)*(1+eta)*(2*ksi-1),...
2*ksi*(-1+eta)*(1+eta);
% dN_eta
0.25*ksi*(-1+2*eta)*(ksi-1), ...
0.25*ksi*(-1+2*eta)*(1+ksi), ...
0.25*ksi*(2*eta+1)*(1+ksi), ...
0.25*ksi*(2*eta+1)*(ksi-1), ...
-0.5*(ksi-1)*(1+ksi)*(-1+2*eta),...
-ksi*eta*(1+ksi), ...
-0.5*(ksi-1)*(1+ksi)*(2*eta+1), ...
-ksi*eta*(ksi-1), ...
2*(ksi-1)*(1+ksi)*eta ];
end
end
end