-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathaFemImplementation.m
More file actions
204 lines (159 loc) · 5.71 KB
/
aFemImplementation.m
File metadata and controls
204 lines (159 loc) · 5.71 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
function [] = aFemImplementation()
close all;
global NumericalDerivative;
NumericalDerivative = false;
%hElem = 0.0075;
hElem = 0.015;
hElem = 0.015;
hElem = 0.15;
tStart = tic;
FEM(hElem, 10, -1, true, true);
toc(tStart)
figure(900)
ll = caxis();
colorbar off;
drawnow
pause(4)
print('BVP-Strain', '-dpng')
print('BVP-Strain', '-dpdf')
figure(22)
colorbar
caxis(ll);
axis off
print('BVP-Strain-L', '-dpng')
print('BVP-Strain-L', '-dpdf')
figure(902)
ll = caxis();
colorbar off;
drawnow
pause(4)
print('BVP-Stress', '-dpng')
print('BVP-Stress', '-dpdf')
figure(23)
colorbar
caxis(ll);
axis off
print('BVP-Stress-L', '-dpng')
print('BVP-Stress-L', '-dpdf')
for consistent = [true,false]
for nSteps = [20, 200]
% figure(100)
% hold off
% plot(-RefDisp, -RefForce, 'k', 'linewidth', 2)
% hold on
%
figure(100); hold off; clf
figure(101); hold off; clf
figure(102); hold off; clf
figure(201); hold off; clf
figure(202); hold off; clf
for method = [ (1:8)+20, -1]
disp([method, consistent])
tStart = tic;
[DispI, ForceI, Residuals1, ResidualsEnd] = FEM(hElem, nSteps, method, consistent);
toc(tStart)
SPEC = '*-.';
if (method == 28 )
SPEC = '*r-.';
elseif ( method == -1)
SPEC = 'k-.';
end
figure(100)
plot(-DispI, -ForceI, SPEC)
set(gca, 'FontSize', 15)
xlabel('Vertical shortening, $(H-h)/H$', 'interpreter', 'latex')
ylabel('Vertical pressure (kPa)', 'interpreter', 'latex')
xlim([0, 0.2])
drawnow
hold on;
SPEC = '*-.';
if (method == 28 )
SPEC = '*r-.';
elseif ( method == -1)
SPEC = 'ks-.';
end
figure(101)
semilogy(0:(length(Residuals1)-1), Residuals1, SPEC)
set(gca, 'FontSize', 15)
xlabel('Iteration', 'interpreter', 'latex')
ylabel('Norm of the residual, $\|\mathbf{R}\|$', 'interpreter', 'latex')
drawnow
hold on;
if (nSteps == 20)
xlim([0,40])
ylim([1E-15,10])
else
xlim([0,25])
ylim([1E-15,10])
end
figure(102)
loglog(Residuals1(1:end-1), Residuals1(2:end), SPEC)
set(gca, 'FontSize', 15)
xlabel('$\|\mathbf{R}_k\|$', 'interpreter', 'latex')
ylabel('$\|\mathbf{R}_{k+1}\|$', 'interpreter', 'latex')
hold on
drawnow
xlim([1E-15,10])
ylim([1E-15,10])
figure(201)
semilogy(0:(length(ResidualsEnd)-1), ResidualsEnd, SPEC)
set(gca, 'FontSize', 15)
xlabel('Iteration', 'interpreter', 'latex')
ylabel('Norm of the residual, $\|\mathbf{R}\|$', 'interpreter', 'latex')
drawnow
hold on;
if (nSteps == 20)
xlim([0,40])
ylim([1E-15,10])
else
xlim([0,25])
ylim([1E-15,10])
end
figure(202)
loglog(ResidualsEnd(1:end-1), ResidualsEnd(2:end), SPEC)
set(gca, 'FontSize', 15)
xlabel('$\|\mathbf{R}_k\|$', 'interpreter', 'latex')
ylabel('$\|\mathbf{R}_{k+1}\|$', 'interpreter', 'latex')
hold on
drawnow
xlim([1E-15,10])
ylim([1E-15,10])
if ( consistent == true)
figure(100)
print(['BVP-', num2str(nSteps), '-', num2str(consistent)], '-dpdf')
print(['BVP-', num2str(nSteps), '-', num2str(consistent)], '-dpng')
end
figure(101)
print(['BVP-A-', num2str(nSteps), '-', num2str(consistent)], '-dpdf')
print(['BVP-A-', num2str(nSteps), '-', num2str(consistent)], '-dpng')
figure(102)
print(['BVP-B-', num2str(nSteps), '-', num2str(consistent)], '-dpdf')
print(['BVP-B-', num2str(nSteps), '-', num2str(consistent)], '-dpng')
figure(201)
print(['BVP-C-', num2str(nSteps), '-', num2str(consistent)], '-dpdf')
print(['BVP-C-', num2str(nSteps), '-', num2str(consistent)], '-dpng')
figure(202)
print(['BVP-D-', num2str(nSteps), '-', num2str(consistent)], '-dpdf')
print(['BVP-D-', num2str(nSteps), '-', num2str(consistent)], '-dpng')
end
figure(102)
PrintSlope(1E-3, 1E-2, 1, 10)
PrintSlope(1E-2, 1E-9, 2, 10)
print(['BVP-B-', num2str(nSteps), '-', num2str(consistent)], '-dpdf')
print(['BVP-B-', num2str(nSteps), '-', num2str(consistent)], '-dpng')
figure(202)
PrintSlope(1E-3, 1E-2, 1, 10)
PrintSlope(1E-2, 1E-9, 2, 10)
print(['BVP-D-', num2str(nSteps), '-', num2str(consistent)], '-dpdf')
print(['BVP-D-', num2str(nSteps), '-', num2str(consistent)], '-dpng')
figure(100)
axis off
xlim([1E9,1E10])
ll = legend('RK-1', 'RK-2', 'RK-3', 'RK-4', ...
'RK-5', 'RK-6', 'RK-7', 'RK-8', 'RM');
set(ll, 'interpreter', 'latex');
print('ExampleBVP-legend', '-dpng')
print('ExampleBVP-legend', '-dpdf')
end
end
%legend('Reference','RK1', 'RK2', 'RK3', 'RK4', 'RK5', 'RK6', 'RK7', 'RK8', 'Implicit', 'location', 'best')