-
Notifications
You must be signed in to change notification settings - Fork 3
/
Ex1092.m
218 lines (171 loc) · 8.33 KB
/
Ex1092.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
%----------------------------------------------------------------------------
% Example 10.9.2
% A clamped square plate is subjected to a uniform load of 2 psi.
% Find the deflection of the plate using 4 four-node
% isoparametric elements of the shear deformable displacement
% formulation. The size of the plate is 10 in. by 10 in. and its
% thickness is 0.1 in. It is made of steel.
% (see Fig. 10.9.1 for the finite element mesh)
%
% Variable descriptions
% k = element matrix
% kb = element matrix for bending stiffness
% ks = element matrix for shear stiffness
% f = element vector
% kk = system matrix
% ff = system vector
% disp = system nodal displacement vector
% gcoord = coordinate values of each node
% nodes = nodal connectivity of each element
% index = a vector containing system dofs associated with each element
% pointb = matrix containing sampling points for bending term
% weightb = matrix containing weighting coefficients for bending term
% points = matrix containing sampling points for shear term
% weights = matrix containing weighting coefficients for shear term
% bcdof = a vector containing dofs associated with boundary conditions
% bcval = a vector containing boundary condition values associated with
% the dofs in 'bcdof'
% kinmtpb = matrix for kinematic equation for bending
% matmtpb = matrix for material property for bending
% kinmtps = matrix for kinematic equation for shear
% matmtps = matrix for material property for shear
%
%----------------------------------------------------------------------------
%------------------------------------
% input data for control parameters
%------------------------------------
clear
nel=4; % number of elements
nnel=4; % number of nodes per element
ndof=3; % number of dofs per node
nnode=9; % total number of nodes in system
sdof=nnode*ndof; % total system dofs
edof=nnel*ndof; % degrees of freedom per element
emodule=30e6; % elastic modulus
poisson=0.3; % Poisson's ratio
t=0.1; % plate thickness
nglxb=2; nglyb=2; % 2x2 Gauss-Legendre quadrature for bending
nglb=nglxb*nglyb; % number of sampling points per element for bending
nglxs=1; nglys=1; % 1x1 Gauss-Legendre quadrature for shear
ngls=nglxs*nglys; % number of sampling points per element for shear
%---------------------------------------------
% input data for nodal coordinate values
% gcoord(i,j) where i->node no. and j->x or y
%---------------------------------------------
gcoord=[0.0 0.0; 2.5 0.0; 5.0 0.0;
0.0 2.5; 2.5 2.5; 5.0 2.5;
0.0 5.0; 2.5 5.0; 5.0 5.0];
%---------------------------------------------------------
% input data for nodal connectivity for each element
% nodes(i,j) where i-> element no. and j-> connected nodes
%---------------------------------------------------------
nodes=[1 2 5 4; 2 3 6 5; 4 5 8 7; 5 6 9 8];
%-------------------------------------
% input data for boundary conditions
%-------------------------------------
bcdof=[1 2 3 4 5 6 7 8 9 10 11 12 16 19 20 21 23 25 26]; % constrained dofs
bcval=zeros(1,19); % whose described values are 0
%----------------------------------------------
% initialization of matrices and vectors
%----------------------------------------------
ff=zeros(sdof,1); % system force vector
kk=zeros(sdof,sdof); % system matrix
disp=zeros(sdof,1); % system displacement vector
index=zeros(edof,1); % index vector
kinmtpb=zeros(3,edof); % kinematic matrix for bending
matmtpb=zeros(3,3); % constitutive matrix for bending
kinmtps=zeros(2,edof); % kinematic matrix for shear
matmtps=zeros(2,2); % constitutive matrix for shear
%----------------------------
% force vector
%----------------------------
ff(3)=3.125; ff(6)=6.25; ff(9)=3.125;
ff(12)=6.25; ff(15)=12.5; ff(18)=6.25;
ff(21)=3.125; ff(24)=6.25; ff(27)=3.125;
%-----------------------------------------------------------------
% computation of element matrices and vectors and their assembly
%-----------------------------------------------------------------
%
% for bending stiffness
%
[pointb,weightb]=feglqd2(nglxb,nglyb); % sampling points & weights
matmtpb=fematiso(1,emodule,poisson)*t^3/12; % bending material property
%
% for shear stiffness
%
[points,weights]=feglqd2(nglxs,nglys); % sampling points & weights
shearm=0.5*emodule/(1.0+poisson); % shear modulus
shcof=5/6; % shear correction factor
matmtps=shearm*shcof*t*[1 0; 0 1]; % shear material property
for iel=1:nel % loop for the total number of elements
for i=1:nnel
nd(i)=nodes(iel,i); % extract connected node for (iel)-th element
xcoord(i)=gcoord(nd(i),1); % extract x value of the node
ycoord(i)=gcoord(nd(i),2); % extract y value of the node
end
k=zeros(edof,edof); % initialization of element matrix to zero
kb=zeros(edof,edof); % initialization of bending matrix to zero
ks=zeros(edof,edof); % initialization of shear matrix to zero
%------------------------------------------------------
% numerical integration for bending term
%------------------------------------------------------
for intx=1:nglxb
x=pointb(intx,1); % sampling point in x-axis
wtx=weightb(intx,1); % weight in x-axis
for inty=1:nglyb
y=pointb(inty,2); % sampling point in y-axis
wty=weightb(inty,2) ; % weight in y-axis
[shape,dhdr,dhds]=feisoq4(x,y); % compute shape functions and
% derivatives at sampling point
jacob2=fejacob2(nnel,dhdr,dhds,xcoord,ycoord); % compute Jacobian
detjacob=det(jacob2); % determinant of Jacobian
invjacob=inv(jacob2); % inverse of Jacobian matrix
[dhdx,dhdy]=federiv2(nnel,dhdr,dhds,invjacob); % derivatives w.r.t.
% physical coordinate
kinmtpb=fekinepb(nnel,dhdx,dhdy); % bending kinematic matrix
%--------------------------------------------
% compute bending element matrix
%--------------------------------------------
kb=kb+kinmtpb'*matmtpb*kinmtpb*wtx*wty*detjacob;
end
end % end of numerical integration loop for bending term
%------------------------------------------------------
% numerical integration for bending term
%------------------------------------------------------
for intx=1:nglxs
x=points(intx,1); % sampling point in x-axis
wtx=weights(intx,1); % weight in x-axis
for inty=1:nglys
y=points(inty,2); % sampling point in y-axis
wty=weights(inty,2) ; % weight in y-axis
[shape,dhdr,dhds]=feisoq4(x,y); % compute shape functions and
% derivatives at sampling point
jacob2=fejacob2(nnel,dhdr,dhds,xcoord,ycoord); % compute Jacobian
detjacob=det(jacob2); % determinant of Jacobian
invjacob=inv(jacob2); % inverse of Jacobian matrix
[dhdx,dhdy]=federiv2(nnel,dhdr,dhds,invjacob); % derivatives w.r.t.
% physical coordinate
kinmtps=fekineps(nnel,dhdx,dhdy,shape); % shear kinematic matrix
%----------------------------------------
% compute shear element matrix
%----------------------------------------
ks=ks+kinmtps'*matmtps*kinmtps*wtx*wty*detjacob;
end
end % end of numerical integration loop for shear term
%--------------------------------
% compute element matrix
%--------------------------------
k=kb+ks;
index=feeldof(nd,nnel,ndof);% extract system dofs associated with element
kk=feasmbl1(kk,k,index); % assemble element matrices
end
%-----------------------------
% apply boundary conditions
%-----------------------------
[kk,ff]=feaplyc2(kk,ff,bcdof,bcval);
%----------------------------
% solve the matrix equation
%----------------------------
disp=kk\ff;
num=1:1:sdof;
displace=[num' disp] % print nodal displacements