-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathmain_cantileverBeamConvergenceStudy.m
More file actions
341 lines (288 loc) · 9.86 KB
/
Copy pathmain_cantileverBeamConvergenceStudy.m
File metadata and controls
341 lines (288 loc) · 9.86 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
%% 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/');
% On the analysis to be performed
addpath('../../equationSystemSolvers/');
% 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/');
%% CAD model (NURBS)
% Polynomial degree
p = 1;
% Knot vector
Xi = [0 0 1 1];
% Beam's length
L = 10;
% 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 = 4e6;
% Poisson ration
parameters.Nu = 0;
% 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', 'Timoshenko'
analysis.type = 'Bernoulli';
% Define 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 = 'moment';
% 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 outpur graph
% 1 : The basis functions themselves
% n : Up to the (n-1)-th derivative
%
graph.plotBasisFunctionsAndDerivs = 0;
%% Initial refinement
% Order elevation
a = 1;
if strcmp(analysis.type, 'Bernoulli')
tp = a;
elseif strcmp(analysis.type, 'Timoshenko')
tp = a-1;
end
[Xi, CP, p] = degreeElevateBSplineCurve ...
(p, Xi, CP, tp, 'outputEnabled');
% Knot insertion
n = 0;
[Xi, CP] = knotRefineUniformlyBSplineCurve ...
(n, p, Xi, CP, 'outputEnabled');
%% Perform a refinement study
% Number of h-refinement steps
numRef = 50;
% Initialize arrays
errorDisplacements = zeros(numRef, 1);
errorRotations = zeros(numRef, 1);
minElSize = zeros(numRef, 1);
fprintf('---------------------------------------- \n');
fprintf('| Loop over all the h-refinement steps | \n');
fprintf('---------------------------------------- \n \n');
for i = 1:numRef
%% Print message on the current h-refinement
fprintf('\t Refinement step %d/%d \n', i, numRef);
fprintf('\t ----------------------- \n \n');
%% Perform an h-refinement
[XiRef, CPRef] = knotRefineUniformlyBSplineCurve(10*i, p, Xi, CP, '');
fprintf('\t \t No. Elements = %d \n', length(XiRef));
if strcmp(analysis.type,'Bernoulli')
fprintf('\t \t No. DOFs = %d \n', 2*length(CPRef(:, 1)));
elseif strcmp(analysis.type,'Timoshenko')
fprintf('\t \t No. DOFs = %d \n', 3*length(CPRef(:, 1)));
end
fprintf('\n \n');
%% Fill up computational patch
BSplinePatch.p = p;
BSplinePatch.Xi = XiRef;
BSplinePatch.CP = CPRef;
BSplinePatch.isNURBS = isNURBS;
%% Compute the load vector
% On the application of a pressure load on the beam
NBC.noCnd = 1;
xib = [0 1];
NBC.xiLoadExtension = {xib};
NBC.etaLoadExtension = {'undefined'};
pLoad = - 1e3;
NBC.loadAmplitude = {pLoad};
loadDir = 2;
NBC.loadDirection = {loadDir};
NBC.isFollower(1, 1) = false;
NBC.isTimeDependent(1, 1) = false;
for iNBC = 1:NBC.noCnd
F = [];
if strcmp(analysis.type,'Bernoulli')
NBC.computeLoadVct = {'computeLoadVctLinePressureVectorForIGABernoulliBeam2D'};
elseif strcmp(analysis.type,'Timoshenko')
NBC.computeLoadVct = {'computeLoadVctLinePressureVectorForIGATimoshenkoBeam2D'};
end
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
%% Find the constrained DOFs
% Initialize the array of the constrained DOFs
homDOFs = [];
if strcmp(analysis.type, 'Bernoulli')
% Clamp the left edge of the beam
xib = [XiRef(1) XiRef(p + 1)];
dir = 1;
homDOFs = findDofsForBernoulliBeams2D ...
(homDOFs, xib, dir, CPRef);
xib = [XiRef(1) XiRef(p + 2)];
dir = 2;
homDOFs = findDofsForBernoulliBeams2D ...
(homDOFs, xib, dir, CPRef);
% Clamp the right edge of the beam
% xib = [Xi(end - 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 = [XiRef(1) XiRef(p + 1)];
dir = 1;
homDOFs = findDofsForTimoshenkoBeams2D ...
(homDOFs, xib, dir, CPRef);
xib = [XiRef(1) XiRef(p + 1)];
dir = 2;
homDOFs = findDofsForTimoshenkoBeams2D ...
(homDOFs, xib, dir, CPRef);
xib = [XiRef(1) XiRef(p + 1)];
dir = 3;
homDOFs = findDofsForTimoshenkoBeams2D ...
(homDOFs, xib, dir, CPRef);
% 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
%% Solve the linear equation system
[dHat, ~, minElSize(i, 1)] = solve_IGABeamLinear2D ...
(analysis, p, XiRef, CPRef, homDOFs, NBC, parameters, isNURBS, ...
solve_LinearSystem, int, '');
%% Compute the relative error
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')
errorDisplacements(i, 1) = ...
computeErrIGABernoulliBeam2D ...
(p, XiRef, CPRef, isNURBS, dHat, ...
@computeExactDispl4BernoulliCantileverBeamInUniformPressure,...
problemSettings, intError, '');
elseif strcmp(analysis.type,'Timoshenko')
[errorDisplacements(i, 1), errorRotations(i, 1)] = ...
computeErrIGATimoshenkoBeam2D ...
(p, XiRef, CPRef, isNURBS, dHat, ...
@computeExactDispl4TimoshenkoCantileverBeamInUniformPressure, ...
problemSettings, intError, '');
end
end
%% Plot the convergence graphs
[minElSize, pid] = sort(minElSize) ;
errorDisplacements = errorDisplacements(pid);
figure(graph.index)
loglog(minElSize, errorDisplacements);
title('Refinement study over the L2-norm of the displacement');
grid on;
graph.index = graph.index + 1;
if strcmp(analysis.type, 'Timoshenko')
errorRotations = errorRotations(pid);
figure(graph.index)
loglog(minElSize, errorRotations);
title('Refinement study over the L2-norm of the rotation');
end
grid on;
graph.index = graph.index + 1;
%% End of script