-
Notifications
You must be signed in to change notification settings - Fork 199
/
Copy pathAxisymmetricTriangularElement.R
302 lines (263 loc) · 10.1 KB
/
AxisymmetricTriangularElement.R
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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
#' Area of an axisymmetric triangular element
#'
#' This function computes the area of an axisymmetric triangular element
#' from the coordinates of its nodes.
#'
#' @param vec_nodalcoordinates A vector of nodal coordinates
#' in the form c(x1,y1,x2,y2,x3,y3).
#'
#' @return Area of an axisymmetric triangular triangular element.
#' @export
AxisymmetricT_Area =function(vec_nodalcoordinates)
{
r1 = vec_nodalcoordinates[1];
r2 = vec_nodalcoordinates[3];
r3 = vec_nodalcoordinates[5];
z1 = vec_nodalcoordinates[2];
z2 = vec_nodalcoordinates[4];
z3 = vec_nodalcoordinates[6]
Area=abs(r3*(z1-z2)+r2*(z3-z1)+r1*(z2-z3))
return(Area/2)
}
#' Centroid of an axisymmetric triangular element
#'
#' @param vec_nodalcoordinates A vector of nodal coordinates
#' in the form c(x1,y1,x2,y2,x3,y3).
#'
#' @return A vector (rbar and zbar) describing the centroid
#' of an axisymmetric triangular element.
#' @export
AxisymmetricT_Centroid =function(vec_nodalcoordinates)
{
r1 = vec_nodalcoordinates[1];
r2 = vec_nodalcoordinates[3];
r3 = vec_nodalcoordinates[5];
z1 = vec_nodalcoordinates[2];
z2 = vec_nodalcoordinates[4];
z3 = vec_nodalcoordinates[6]
rbar = (1/3)*(r1+r2+r3);
zbar = (1/3)*(z1+z2+z3);
return(c(rbar,zbar))
}
#' Element stiffness matrix (axisymmetric triangular element)
#'
#' @param DOF Degree of freedom (6 for an axisymmetric triangular element).
#' @param YoungMod Young's modulus.
#' @param Nu Poisson's ratio.
#' @param vec_nodalcoordinates Vector of nodal coordinates
#' in the form c(x1,y1,x2,y2,x3,y3).
#'
#' @return Stiffness matrix of an axisymmetric triangular element.
#' @export
AxisymmetricT_Element_Matrix=function(DOF=6,YoungMod,Nu,vec_nodalcoordinates)
{
r1=vec_nodalcoordinates[1];r2=vec_nodalcoordinates[3];
r3=vec_nodalcoordinates[5];z1=vec_nodalcoordinates[2];
z2=vec_nodalcoordinates[4];z3=vec_nodalcoordinates[6];
Area=abs(r3*(z1-z2)+r2*(z3-z1)+r1*(z2-z3))*0.5;
rbar=(1/3)*(r1+r2+r3);zbar=(1/3)*(z1+z2+z3);
a1=r2*z3-z2*r3;
a2=r3*z1-z3*r1;
a3=r1*z2-z1*r2;
B1=z2-z3;B2=z3-z1;B3=z1-z2;
G1=r3-r2;G2=r1-r3;G3=r2-r1;
row1=c(B1,0,B2,0,B3,0);
row2=c(0,G1,0,G2,0,G3);
row3=c(((a1/rbar)+B1+(G1*zbar/rbar)),0,((a2/rbar)+B2+(G2*zbar/rbar)),0,((a3/rbar)+B3+(G3*zbar/rbar)),0);
row4=c(G1,B1,G2,B2,G3,B3);
constitutiveprop=c(1-Nu,Nu,Nu,0,Nu,1-Nu,Nu,0,Nu,Nu,1-Nu,0,0,0,0,(1-2*Nu)/2)
BMatrix=(1/(2*Area))*matrix(c(row1,row2,row3,row4),nrow=4,byrow=T);
DMatrix=YoungMod/((1+Nu)*(1-2*Nu))*matrix(constitutiveprop,nrow=4,byrow=T);
eMatrix=(2*pi*rbar*Area)*t(BMatrix)%*%DMatrix%*%BMatrix
return(eMatrix)
}
#' Expanded stiffness matrix (axisymmetric triangular element)
#'
#' This function generates the expanded matrix for each element in a
#' connected system of an axisymmetric triangular element elements.
#'
#' @param TDOF Total degree of freedom of a discretized structure.
#' @param eMatrix The 6 by 6 stiffness matrix of a
#' specific axisymmetric triangular element.
#' @param i Index of the first node.
#' @param j Index of the second node.
#' @param k Index of the third node.
#'
#' @return The expanded matrix of an axisymmetric triangular element.
#' @export
AxisymmetricT_ExpandedElement_Matrix = function(TDOF,eMatrix,i,j,k)
{
r1=2*i-1; r2=2*i
r3=2*j-1; r4=2*j
r5=2*k-1; r6=2*k
bigMatrix=matrix(vector(l=TDOF*TDOF),nrow=TDOF,byrow=T);
bigMatrix[c(r1,r2,r3,r4,r5,r6),c(r1,r2,r3,r4,r5,r6)]=eMatrix;
return (bigMatrix)
}
#' Equivalent surface load for an element with distributed load
#'
#' @param DOF Degree of freedom of the element (6 by default)
#' @param pr Magnitude of a uniform radial load
#' @param pz Magnitude of a uniform axial load
#' @param case Use 1 (if load is on side i-j,
#' 2 if on side j-k, &
#' 3 if on side i-k)
#' @param vec_nodalcoordinates Vector of nodal coordinates
#' in the form c(x1,y1,x2,y2,x3,y3).
#'
#' @return A vector of equivalent nodal loads for an axisymmetric
#' triangular element with surface load.
#' @export
AxisymmetricT_SF= function(DOF=6,pr,pz,case,vec_nodalcoordinates)
{
r1=vec_nodalcoordinates[1];
r2=vec_nodalcoordinates[3];
r3=vec_nodalcoordinates[5];
z1=vec_nodalcoordinates[2];
z2=vec_nodalcoordinates[4];
z3=vec_nodalcoordinates[6];
if(case==1){
equivalentsfload=pi*r2*abs((z3-z2))*matrix(c(0,0,pr,pz,pr,pz),nrow=DOF,byrow=T)
}
if(case==2){
equivalentsfload=pi*r1*abs((z3-z1))*matrix(c(pr,pz,0,0,pr,pz),nrow=DOF,byrow=T)
}
if(case==3){
equivalentsfload=pi*r1*abs((z2-z1))*matrix(c(pr,pz,pr,pz,0,0),nrow=DOF,byrow=T)
}
return (equivalentsfload)
}
#' Equivalent body load for an element with body force
#'
#' @param DOF Degree of freedom of the element (6 by default)
#' @param Rb Radial body force.
#' @param Zb Axial body force
#' @param vec_nodalcoordinates Vector of nodal coordinates
#' in the form c(x1,y1,x2,y2,x3,y3).
#'
#' @return A vector of equivalent nodal loads for an axisymmetric
#' triangular element with body load.
#' @export
AxisymmetricT_BF= function(DOF=6,Rb,Zb,vec_nodalcoordinates)
{
r1=vec_nodalcoordinates[1];
r2=vec_nodalcoordinates[3];
r3=vec_nodalcoordinates[5];
z1=vec_nodalcoordinates[2];
z2=vec_nodalcoordinates[4];
z3=vec_nodalcoordinates[6];
rbar=(1/3)*(r1+r2+r3);
Area=abs(r3*(z1-z2)+r2*(z3-z1)+r1*(z2-z3))*0.5;
equivalentbodyload=(2/3)*pi*rbar*Area*matrix(c(Rb,Zb,Rb,Zb,Rb,Zb),nrow=DOF,byrow=T)
return (equivalentbodyload)
}
#' Expanded vector of equivalent nodal loads (surface/body)
#'
#' @param TDOF Total degree of freedom.
#' @param LoadColumnMatrix The unexpanded vector of equivalent loads,
#' from either AxisymmetricT_BF() or AxisymmetricT_SF().
#' @param i Index of the first node.
#' @param j Index of the second node.
#' @param k Index of the third node.
#'
#' @return Expanded vector (a column matrix) of equivalent loads.
#' @export
AxisymmetricT_ExpandedSFBF = function(TDOF,LoadColumnMatrix,i,j,k)
{
r1=2*i-1; r2=2*i
r3=2*j-1; r4=2*j
r5=2*k-1; r6=2*k
bigColumnMatrix=matrix(vector(l=TDOF),nrow=TDOF,byrow=T);
bigColumnMatrix[c(r1,r2,r3,r4,r5,r6)]=LoadColumnMatrix;
return (bigColumnMatrix)
}
#' Global nodal forces
#'
#' This function generates the nodal global forces for linear triangular element.
#'
#' @param bigKmatrix Global stiffness matrix.
#' @param vec_globalnodaldisp Vector of all global nodal displacements.
#'
#' @return Global nodal forces.
#' @export
AxisymmetricT_GlobalForces= function(bigKmatrix,vec_globalnodaldisp)
{
columndof=matrix(vec_globalnodaldisp,byrow = T)
globalforces = bigKmatrix %*% vec_globalnodaldisp
return(globalforces)
}
AxisymmetricT_ReducedStiffnessMatrix = function(bigKmatrix,knownloadnodes)
{
reducedk = bigKmatrix[c(knownloadnodes),(knownloadnodes)]
return(reducedk)
}
AxisymmetricT_ReducedLoadVector = function(loadvector)
{
reducedf = matrix(loadvector,ncol = 1)
return(reducedf)
}
#' Local element forces (axisymmetric triangular element)
#'
#' @param ematrix Element matrix
#' @param vec_globalnodaldisp Vector of all global nodal displacements.
#' @param i Index of the first node.
#' @param j Index of the second node.
#' @param k Index of the third node.
#'
#' @return Local nodal forces (axisymmetric triangular element).
#' @export
AxisymmetricT_LocalForces = function(ematrix,vec_globalnodaldisp,i,j,k)
{
r1=2*i-1; r2=2*i
r3=2*j-1; r4=2*j
r5=2*k-1; r6=2*k
localforces = ematrix%*%vec_globalnodaldisp[c(r1,r1,r3,r4,r5,r6)]
return(round(localforces))
}
#' Centroidal stress
#'
#' @param YoungMod Young's modulus.
#' @param Nu Poisson's ratio.
#' @param vec_nodalcoord Vector of nodal coordinates
#' in the form c(x1,y1,x2,y2,x3,y3).
#' @param vec_globalnodaldisp Vector of all global nodal displacements.
#' @param i Index of the first node.
#' @param j Index of the second node.
#' @param k Index of the third node.
#'
#' @return Centroidal stresses in an axisymmetric triangular element.
#' @export
AxisymmetricT_Stresses = function(YoungMod,Nu,vec_nodalcoord,vec_globalnodaldisp,i,j,k)
{
r1=vec_nodalcoord[1];
r2=vec_nodalcoord[3];
r3=vec_nodalcoord[5];
z1=vec_nodalcoord[2];
z2=vec_nodalcoord[4];
z3=vec_nodalcoord[6]
Area=abs(r3*(z1-z2)+r2*(z3-z1)+r1*(z2-z3))*0.5;
rbar=(1/3)*(r1+r2+r3);
zbar=(1/3)*(z1+z2+z3);
a1=r2*z3-z2*r3;
a2=r3*z1-z3*r1;
a3=r1*z2-z1*r2;
B1=z2-z3;B2=z3-z1;B3=z1-z2;
G1=r3-r2;G2=r1-r3;G3=r2-r1;
row1=c(B1,0,B2,0,B3,0);
row2=c(0,G1,0,G2,0,G3);
row3=c(((a1/rbar)+B1+(G1*zbar/rbar)),0,((a2/rbar)+B2+(G2*zbar/rbar)),0,((a3/rbar)+B3+(G3*zbar/rbar)),0);
row4=c(G1,B1,G2,B2,G3,B3);
constitutiveprop=c(1-Nu,Nu,Nu,0,Nu,1-Nu,Nu,0,Nu,Nu,1-Nu,0,0,0,0,(1-2*Nu)/2)
BMatrix=(1/(2*Area))*matrix(c(row1,row2,row3,row4),nrow=4,byrow=T);
DPlaneStress=YoungMod/((1+Nu)*(1-2*Nu))*matrix(constitutiveprop,nrow=4,byrow=T);
r1=2*i-1; r2=2*i
r3=2*j-1; r4=2*j
r5=2*k-1; r6=2*k
localstresses=DPlaneStress%*%BMatrix%*%vec_globalnodaldisp[c(r1,r2,r3,r4,r5,r6)]
return(localstresses)
}
AxisymmetricT_NodalDisplacement =
function(reducedmatrix,vec_reducedforce)
{
return(solve(reducedmatrix,vec_reducedforce))
}