-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathmain_cantileverBeam.m
More file actions
381 lines (319 loc) · 11.9 KB
/
Copy pathmain_cantileverBeam.m
File metadata and controls
381 lines (319 loc) · 11.9 KB
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
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
%% Licensing
%
% License: BSD License
% cane Multiphysics default license: cane/license.txt
%
% Main authors: Andreas Apostolatos
%
%% Script documentation
%
% Task : The benchmark is a cantilever beam subject to uniform pressure
% load in 2D analysis. For both the Bernoulli and the Timoshenko
% settings there exist an analytical solution in terms of the
% displacements (and cross sectional rotations for the Timoshenko
% problem), namely:
%
% Bernoulli :
% w(x) = p*x^2*(6*L^2 - 4L*x + x^2)/24/E/I
%
% Timoshenko :
% w(x) = (p*L*x-p*x^2/2)/G/Aq - (-p*x^4/24+p*L*x^3/6-p*L^2*x^2/4)/E/I
% beta(x) = - p*x^3/6/E/I
% Aq = alpha*A
%
% Date : 13.11.2013
%
%% Preamble
clear;
clc;
%% Includes
% Add general math functions
addpath('../../generalMath/');
% Add all functions related to the Computer-Aided Geometric Design (GACD) kernel
addpath('../../CAGDKernel/CAGDKernel_basisFunctions',...
'../../CAGDKernel/CAGDKernel_geometryResolutionRefinement/',...
'../../CAGDKernel/CAGDKernel_baseVectors/',...
'../../CAGDKernel/CAGDKernel_graphics/',...
'../../CAGDKernel/CAGDKernel_BSplineCurve/');
% Add all functions related to the isogeometric beam analysis
addpath('../../isogeometricBeamAnalysis/stiffnessMatrices/',...
'../../isogeometricBeamAnalysis/graphics/',...
'../../isogeometricBeamAnalysis/loads/',...
'../../isogeometricBeamAnalysis/postprocessing/',...
'../../isogeometricBeamAnalysis/solvers/',...
'../../isogeometricBeamAnalysis/math/',...
'../../isogeometricBeamAnalysis/auxiliary/',...
'../../isogeometricBeamAnalysis/errorComputation/');
% Add all functions related to the equation system solvers
addpath('../../equationSystemSolvers/');
%% CAD model (NURBS)
% Polynomial degree
p = 1;
% Knot vector
Xi = [0 0 1 1];
% Beam's length
L = 4;
% Control Point coordinates and weights
% x-coordinates
CP(:,1) = [0 1]*L;
% y-coordinates
CP(:,2) = [0 0]*L;
% z-coordinates
CP(:,3) = [0 0];
% weights
CP(:,4) = [1 1];
% Find whether the geometrical basis is a NURBS or a B-Spline
isNURBS = false;
for i = length(CP(:, 1))
if CP(i, 4) ~= 1
isNURBS = true;
break;
end
end
%% Material constants
% Young's modulus (connected to epsilon_11 = E)
parameters.EYoung = 1e7;
% Poisson ratio
parameters.Nu = .3;
% shear modulus (connected to epsilon_12 = E/(1+nu))
parameters.GShear = parameters.EYoung/(2*(1 + parameters.Nu));
% shear correction factor
parameters.alpha = 5/6;
% Width of the beam
parameters.b = .1;
% height of the beam
parameters.h = .1;
% cross sectional area
parameters.A = parameters.b*parameters.h;
% Moment of inertia (I_z = I for a simple 2D case)
parameters.I = parameters.b*(parameters.h^3)/12;
% shear cross sectional area
parameters.Aq = parameters.alpha*parameters.A;
%% GUI
% Analysis type (Bernoulli or Timoshenko Beam Theory)
analysis.type = 'Bernoulli';
if ~strcmp(analysis.type, 'Bernoulli') && ...
~strcmp(analysis.type, 'Timoshenko')
error('Choose valid analysis type')
end
% Choose linear equation solver
solve_LinearSystem = @solve_LinearSystemMatlabBackslashSolver;
% Integration
% .type = 'default' : Default choice of Gauss points
% .type = 'user' : Manual choice of Gauss points
int.type = 'default';
intError.type = 'user';
% Number of Gauss points
int.noGP = 6;
int.noGPLoad = 6;
intError.noGP = 12;
% Postprocessing features
% resultant : 'displacement', 'crossSectionalRotation', 'force', 'moment',
% 'shearForce'
graph.resultant = 'shearForce';
% Component (only for graph.resultant = 'displacement'): 'x', 'y', '2norm'
graph.component = 'y';
% Plot initial and/or deformed geometry
% type 0 : None
% type 1 : Undeformed beam
% type 2 : Deformed beam
% type 3 : Undeformed && deformed beam
graph.postProcVisType = 'deformedAndUndeformedShape';
% initialization of the plot index
graph.index = 1;
% Plot NURBS basis functions and its derivatives after the refinement:
% graph.plotBasisFunctionsAndDerivs :
%
% 0 : No output graph
% 1 : The basis functions themselves
% n : Up to the (n-1)-th derivative
%
graph.plotBasisFunctionsAndDerivs = 1;
%% Refinement
% Order elevation
tp = 2;
[Xi, CP, p] = degreeElevateBSplineCurve ...
(p, Xi, CP, tp, 'outputEnabled');
% Knot insertion
n = 10;
[Xi, CP] = knotRefineUniformlyBSplineCurve ...
(n, p, Xi, CP, 'outputEnabled');
% Rxi = [.25 .5 .5];
% [Xi, CP] = knotRefineBSplineCurve ...
% (p,Xi,CP,Rxi,'outputEnabled');
%% Plot the shape functions and their derivatives
numEval = 149;
graph.index = plot_IGABasisFunctionsAndDerivativesForCurve ...
(p, Xi, CP, numEval, isNURBS, graph, 'outputEnabled');
%% Apply boundary conditions
% Dirichlet boundary conditions
homDOFs = [];
if strcmp(analysis.type, 'Bernoulli')
% Clamp the left edge of the beam
xib = [Xi(1) Xi(p + 1)];
dir = 1;
homDOFs = findDofsForBernoulliBeams2D ...
(homDOFs, xib, dir, CP);
xib = [Xi(1) Xi(p + 2)];
dir = 2;
homDOFs = findDofsForBernoulliBeams2D ...
(homDOFs, xib, dir, CP);
% Clamp the right edge of the beam
% xib = [Xi(length(Xi) - p) Xi(end)];
% dir = 1;
% homDOFs = findDofsForBernoulliBeams2D(homDOFs, xib, dir, CP);
% xib = [Xi(length(Xi)-p-1) Xi(length(Xi))];
% dir = 2;
% homDOFs = findDofsForBernoulliBeams2D(homDOFs, xib, dir, CP);
elseif strcmp(analysis.type,'Timoshenko')
% Clamp the left edge of the beam (3 DoFs two translations and 1 rotation)
xib = [Xi(1) Xi(p + 1)];
dir = 1;
homDOFs = findDofsForTimoshenkoBeams2D ...
(homDOFs, xib, dir, CP);
xib = [Xi(1) Xi(p + 1)];
dir = 2;
homDOFs = findDofsForTimoshenkoBeams2D ...
(homDOFs, xib, dir, CP);
xib = [Xi(1) Xi(p + 1)];
dir = 3;
homDOFs = findDofsForTimoshenkoBeams2D ...
(homDOFs, xib, dir, CP);
% Clamp the right edge of the beam (3 DoFs two translations and 1 rotation)
% xib = [Xi(end - p) Xi(end)];
% dir = 1;
% homDOFs = findDofsForTimoshenkoBeams2D(homDOFs, xib, dir, CP);
% xib = [Xi(end - p) Xi(end)];
% dir = 2;
% homDOFs = findDofsForTimoshenkoBeams2D(homDOFs, xib, dir, CP);
% xib = [Xi(end - p) Xi(end)];
% dir = 3;
% homDOFs = findDofsForTimoshenkoBeams2D(homDOFs, xib, dir, CP);
end
% Neumann boundary conditions
% On the application of a pressure load on the beam
NBC.noCnd = 1;
xib = [0 1]; % Distributed load
% xib = 1; % Point load
NBC.xiLoadExtension = {xib};
NBC.etaLoadExtension = {'undefined'};
pLoad = - 1e2; % Distributed load
% pLoad = + 1e2; % Point load
NBC.loadAmplitude = {pLoad};
if strcmp(analysis.type, 'Bernoulli') % Distributed load
NBC.computeLoadVct = ...
{'computeLoadVctLinePressureVectorForIGABernoulliBeam2D'};
elseif strcmp(analysis.type, 'Timoshenko')
NBC.computeLoadVct = {'computeLoadVctLinePressureVectorForIGATimoshenkoBeam2D'};
end
% if strcmp(analysis.type, 'Bernoulli') % Point load
% NBC.computeLoadVct = ...
% {'computeLoadPointVectorForIGABernoulliBeam2D'};
% elseif strcmp(analysis.type, 'Timoshenko')
% NBC.computeLoadVct = {'computeLoadPointVectorForIGATimoshenkoBeam2D'};
% end
loadDir = 2;
NBC.loadDirection = {loadDir};
NBC.isFollower(1, 1) = false;
NBC.isTimeDependent(1, 1) = false;
% On the application of a point load on the beam
% xib = 1;
% dir = 2;
% F = computeLoadPointVectorForIGATimoshenkoBeam2D ...
% (F, BSplinePatch, xib, etab, pLoad, dir, isFollower, int, 'outputEnabled');
%% Fill up computational patch
BSplinePatch.p = p;
BSplinePatch.Xi = Xi;
BSplinePatch.CP = CP;
BSplinePatch.isNURBS = isNURBS;
%% Compute the load vector only for the visualization of the reference configuration
for iNBC = 1:NBC.noCnd
F = [];
funcHandle = str2func(NBC.computeLoadVct{iNBC});
F = funcHandle ...
(F, BSplinePatch, NBC.xiLoadExtension{iNBC}, ...
NBC.etaLoadExtension{iNBC}, NBC.loadAmplitude{iNBC}, ...
NBC.loadDirection{iNBC}, NBC.isFollower(iNBC,1), 0, int, '');
end
%% Plot reference configuration
graph.index = plot_referenceConfigurationIGABeams ...
(p, Xi, CP, isNURBS, homDOFs, F, analysis, graph, 'outputEnabled');
%% Solve the problem
[dHat, F, minElEdgeSize] = solve_IGABeamLinear2D ...
(analysis, p, Xi, CP, homDOFs, NBC, parameters, isNURBS, ...
solve_LinearSystem, int, 'outputEnabled');
%% Postprocessing
graph.index = plot_currentConfigurationIGABeamsLinear ...
(analysis, p, Xi, CP, isNURBS, dHat, homDOFs, parameters, graph, ...
'outputEnabled');
%% Benchmarking the solution
problemSettings.Length = L;
problemSettings.pressure = pLoad;
problemSettings.EYoung = parameters.EYoung;
problemSettings.I = parameters.I;
problemSettings.GShear = parameters.GShear;
problemSettings.Aq = parameters.Aq;
if strcmp(analysis.type,'Bernoulli')
[relErrL2,minElSize] = computeErrIGABernoulliBeam2D(p,Xi,CP,isNURBS,dHat,...
@computeExactDispl4BernoulliCantileverBeamInUniformPressure,...
problemSettings,intError,'outputEnabled');
relativeErrorL2NormDispBernoulli = relErrL2
elseif strcmp(analysis.type,'Timoshenko')
[relDisplErrL2,relRotErrL2] = computeErrIGATimoshenkoBeam2D...
(p,Xi,CP,isNURBS,dHat,...
@computeExactDispl4TimoshenkoCantileverBeamInUniformPressure,...
problemSettings,intError,'outputEnabled');
relativeErrorL2NormDispTimoshenko = relDisplErrL2
relativeErrorL2NormRotTimoshenko = relRotErrL2
end
if strcmp(analysis.type,'Bernoulli')
% Compute the reference deflection value on the tip
x = L;
wReference = abs(pLoad)*x^2*(6*L^2 - 4*L*x + x^2)/24/parameters.EYoung/parameters.I;
% Compute the numerical deflection value on the tip
wIGA = abs(dHat(length(dHat)));
% Compute the relative error in the absolute value for the tip
% deflection
relativeErrorTipDeflectionBernoulli = abs(wIGA-wReference)/abs(wReference)
elseif strcmp(analysis.type,'Timoshenko')
% Compute the reference deflection values on the tip
x = L;
wReference = (abs(pLoad)*L*x-abs(pLoad)*x^2/2)/parameters.GShear/parameters.Aq -...
(-abs(pLoad)*x^4/24+abs(pLoad)*L*x^3/6-abs(pLoad)*L^2*x^2/4)/parameters.EYoung/parameters.I;
betaReference = -abs(pLoad)*x^3/6/parameters.EYoung/parameters.I;
% Compute the numerical values on the tip
wIGA = abs(dHat(length(dHat)-1));
betaIGA = dHat(length(dHat));
% Compute the relative error in the absolute value for the tip
% resultants
relativeErrorTipDeflectionTimoshenko = abs(wIGA-wReference)/abs(wReference)
relativeErrorTipCrossSectionalRotationTimoshenko = 100*abs(betaIGA-betaReference)/abs(betaReference)
end
if strcmp(analysis.type,'Timoshenko')
% w(x) = (q*L*x-q*x^2/2)/G/Aq - (-q*x^4/24+q*L*x^3/6-q*L^2*x^2/4)/E/I
% beta(x) = - q*x^3/6/E/I
% Aq = alpha*A
syms w(x) beta(x) Lsym qsym Gsym Aqsym Esym Isym
w(x) = (qsym*Lsym*x-qsym*x^2/2)/Gsym/(Aqsym) - (-qsym*x^4/24+qsym*Lsym*x^3/6-qsym*Lsym^2*x^2/4)/Esym/Isym;
beta(x) = - qsym*x^3/6/Esym/Isym;
Q(x) = Aqsym*Gsym*(-beta(x) + diff(w, x));
w(x) = subs(w,{Lsym, qsym, Gsym, Esym, Isym, Aqsym}, ...
{L, abs(pLoad), problemSettings.GShear, problemSettings.EYoung, problemSettings.I, problemSettings.Aq});
beta(x) = subs(beta,{Lsym, qsym, Gsym, Esym, Isym, Aqsym}, ...
{L, abs(pLoad), problemSettings.GShear, problemSettings.EYoung, problemSettings.I, problemSettings.Aq});
Q(x) = subs(Q,{Lsym, qsym, Gsym, Esym, Isym, Aqsym}, ...
{L, abs(pLoad), problemSettings.GShear, problemSettings.EYoung, problemSettings.I, problemSettings.Aq});
figure(graph.index)
tiledlayout(3,1)
nexttile
fplot(w(x), [0 L]);
title("Analytical solution for the vertical deflection field")
nexttile
fplot(beta(x), [0 L]);
title("Analytical solution for the rotation field")
nexttile
fplot(Q(x), [0 L]);
title("Analytical solution for the shear force field")
graph.index = graph.index + 1;
end
%% End of script