5 disp(
'***********************************************')
6 disp('* Stiff Elas 3D Assembling P1 validations *')
7 disp('***********************************************')
10 s=sprintf('Global alternate numbering / local alternate numbering');
12 s=sprintf('Global block numbering / local alternate numbering');
14 s=sprintf('Global alternate numbering / local block numbering');
16 s=sprintf('Global block numbering / local block numbering');
18 error('invalid Num value')
20 fprintf(' Numbering Choice : %s\n',s);
27 disp('-----------------------------------------')
28 disp(' Test 1: Matrices errors and CPU times ')
29 disp('-----------------------------------------')
36 Test1.error(1)=norm(Mbase-MOptV0,Inf);
37 Test1.name{1}=
'StiffElasAssembling3DP1OptV0';
38 fprintf(
' Error P1base vs OptV0 : %e\n',Test1.error(1))
42 Test1.error(2)=norm(Mbase-MOptV1,Inf);
43 Test1.name{2}=
'StiffElasAssembling3DP1OptV1';
44 fprintf(
' Error P1base vs OptV1 : %e\n',Test1.error(2))
48 Test1.error(3)=norm(Mbase-MOptV2,Inf);
49 Test1.name{3}=
'StiffElasAssembling3DP1OptV2';
50 fprintf(
' Error P1base vs OptV2 : %e\n',Test1.error(3))
52 fprintf(
' CPU times base (ref) : %3.4f (s)\n',
T(1))
53 fprintf(
' CPU times OptV0 : %3.4f (s) - Speed Up X%3.3f\n',
T(2),
T(1)/
T(2))
54 fprintf(
' CPU times OptV1 : %3.4f (s) - Speed Up X%3.3f\n',
T(3),
T(1)/
T(3))
55 fprintf(
' CPU times OptV2 : %3.4f (s) - Speed Up X%3.3f\n',
T(4),
T(1)/
T(4))
57 disp('-----------------------------------------------------------')
58 disp(' Test 2: Validations by integration on [0,1]x[0,1]x[0,1] ')
59 disp('-----------------------------------------------------------')
64 disp('-----------------------------------------------------')
65 disp(' Test 2: Validations by integration on [0,1]x[0,1] ')
66 disp('-----------------------------------------------------')
75 U=[u{1}(qf(1,:),qf(2,:),qf(3,:));u{2}(qf(1,:),qf(2,:),qf(3,:));u{3}(qf(1,:),qf(2,:),qf(3,:))];
77 V=[v{1}(qf(1,:),qf(2,:),qf(3,:));v{2}(qf(1,:),qf(2,:),qf(3,:));v{3}(qf(1,:),qf(2,:),qf(3,:))];
80 U=[u{1}(qf(1,:),qf(2,:),qf(3,:)) u{2}(qf(1,:),qf(2,:),qf(3,:)) u{3}(qf(1,:),qf(2,:),qf(3,:))]
';
81 V=[v{1}(qf(1,:),qf(2,:),qf(3,:)) v{2}(qf(1,:),qf(2,:),qf(3,:)) v{3}(qf(1,:),qf(2,:),qf(3,:))]';
83 Test(kk).error=abs(Test(kk).Stiff-U
'*KK*V);
84 fprintf(' functions %d : u(x,y,z)=(%s,%s,%s), v(x,y,z)=(%s,%s,%s),\n -> Stiff error=%e\n
', ...
85 kk,Test(kk).cu{1},Test(kk).cu{2},Test(kk).cu{3},Test(kk).cv{1},Test(kk).cv{2},Test(kk).cv{3},Test(kk).error);
90 disp('--------------------------------
')
91 disp(' Test 3: Validations by order
')
92 disp('--------------------------------
')
96 lambda=Test(n).lambda;
99 fprintf(' functions %d : u(x,y,z)=(%s,%s,%s), v(x,y,z)=(%s,%s,%s),\n
',n, ...
100 Test(n).cu{1},Test(n).cu{2},Test(n).cu{3}, ...
101 Test(n).cv{1},Test(n).cv{2},Test(n).cv{3});
102 fprintf(' Lame coefficients : lambda = %f, mu =%f\n
',lambda,mu);
103 fprintf(' Integral of epsilon(u)^t C epsilon(v) over unit cube : %.16f\n
',ExSol);
108 fprintf('(%d/%d) Matrix size : %d\n
',k,N,Th.nq);
109 h(k)=GetMaxLengthEdges(Th.q,Th.me);
111 M=StiffElasAssembling3DP1OptV2(Th.nq,Th.nme,Th.q,Th.me,Th.volumes,lambda,mu,Num);
115 U=[u{1}(qf(1,:),qf(2,:),qf(3,:));u{2}(qf(1,:),qf(2,:),qf(3,:));u{3}(qf(1,:),qf(2,:),qf(3,:))];
117 V=[v{1}(qf(1,:),qf(2,:),qf(3,:));v{2}(qf(1,:),qf(2,:),qf(3,:));v{3}(qf(1,:),qf(2,:),qf(3,:))];
120 U=[u{1}(qf(1,:),qf(2,:),qf(3,:)) u{2}(qf(1,:),qf(2,:),qf(3,:)) u{3}(qf(1,:),qf(2,:),qf(3,:))]';
121 V=[v{1}(qf(1,:),qf(2,:),qf(3,:)) v{2}(qf(1,:),qf(2,:),qf(3,:)) v{3}(qf(1,:),qf(2,:),qf(3,:))]
';
123 Error(k)=abs(ExSol-U'*
M*V);
124 fprintf(
' StiffElasAssemblingP1OptV2 CPU times : %3.3f(s)\n',TT(
k));
128 loglog(h,Error,
'+-r',h,h*1.1*Error(1)/h(1),
'-sm',h,1.1*Error(1)*(h/h(1)).^2,
'-db')
129 legend('Error','O(h)','O(h^2)')
131 title(sprintf('Test 3 : Stiff Elas. Matrix (Num=%d)',Num))
136 %title(sprintf('Matrix sparsity for %s numbering',s))
139 function checkTest1(Test)
140 I=find(Test.error>1e-14);
142 disp('------------------------')
143 disp(' Test 1 (results): OK')
144 disp('------------------------')
146 disp('----------------------------')
147 disp(' Test 1 (results): FAILED')
148 disp('----------------------------')
152 function checkTest2(Test)
156 if (ismember(Test(
k).degree,[0 1]))
157 if (Test(
k).error>1e-12)
163 disp('------------------------')
164 disp(' Test 2 (results): OK')
165 disp('------------------------')
167 disp('----------------------------')
168 disp(' Test 2 (results): FAILED')
169 disp('----------------------------')
173 function checkTest3(h,error)
175 P=polyfit(log(h),log(error),1);
177 disp('------------------------')
178 disp(' Test 3 (results): OK')
179 fprintf(' -> found numerical order %f. Must be 2\n',P(1))
180 disp('------------------------')
182 disp('----------------------------')
183 disp(' Test 3 (results): FAILED')
184 fprintf(' -> found numerical order %f. Must be 2\n',P(1))
185 disp('----------------------------')