8 disp(
'-----------------------------------------')
9 disp(' Test 1: Matrices errors and CPU times ')
10 disp('-----------------------------------------')
17 Test1.error(1)=norm(Mbase-MOptV0,Inf);
18 Test1.name{1}=
'StiffAssembling3DP1OptV0';
19 fprintf(
' Error P1base vs OptV0 : %e\n',Test1.error(1))
23 Test1.error(2)=norm(Mbase-MOptV1,Inf);
24 Test1.name{2}=
'StiffAssembling3DP1OptV1';
25 fprintf(
' Error P1base vs OptV1 : %e\n',Test1.error(2))
29 Test1.error(3)=norm(Mbase-MOptV2,Inf);
30 Test1.name{3}=
'StiffAssembling3DP1OptV2';
31 fprintf(
' Error P1base vs OptV2 : %e\n',Test1.error(3))
33 fprintf(
' CPU times base (ref) : %3.4f (s)\n',
T(1))
34 fprintf(
' CPU times OptV0 : %3.4f (s) - Speed Up X%3.3f\n',
T(2),
T(1)/
T(2))
35 fprintf(
' CPU times OptV1 : %3.4f (s) - Speed Up X%3.3f\n',
T(3),
T(1)/
T(3))
36 fprintf(
' CPU times OptV2 : %3.4f (s) - Speed Up X%3.3f\n',
T(4),
T(1)/
T(4))
40 disp(
'-----------------------------------------------------------')
41 disp(' Test 2: Validations by integration on [0,1]x[0,1]x[0,1] ')
42 disp('-----------------------------------------------------------')
46 U=Test(kk).u(Th.q(1,:),Th.q(2,:),Th.q(3,:));
47 V=Test(kk).v(Th.q(1,:),Th.q(2,:),Th.q(3,:));
48 Test(kk).error=abs(Test(kk).Stiff-U*
M*V');
49 fprintf(' function %d : u(x,y,z)=%s, v(x,y,z)=%s,\n -> Mass error=%e\n',kk,Test(kk).cu,Test(kk).cv,Test(kk).error);
54 disp('--------------------------------')
55 disp(' Test 3: Validations by order ')
56 disp('--------------------------------')
61 fprintf(' functions %d : u(x,y,z)=%s, v(x,y,z)=%s,\n',n, ...
62 Test(n).cu,Test(n).cv);
63 fprintf(' Integral of dot(grad u(x,y,z),grad v(x,y,z)) over unit cube : %.16f\n',ExSol);
69 fprintf('(%d/%d) Matrix size : %d\n',
k,
N,Th.nq);
74 U=u(Th.q(1,:),Th.q(2,:),Th.q(3,:));
75 V=v(Th.q(1,:),Th.q(2,:),Th.q(3,:));
76 Error(k)=abs(ExSol-U*
M*V');
78 fprintf(' Error : %e\n',Error(k));
81 loglog(h,Error,'+-r',h,h*1.1*Error(1)/h(1),'-sm',h,1.1*Error(1)*(h/h(1)).^2,'-db')
82 legend('Error','O(h)','O(h^2)')
84 title('Test 3 : Stiff Matrix')
89 function checkTest1(Test)
90 I=find(Test.error>1e-14);
92 disp('------------------------')
93 disp(' Test 1 (results): OK')
94 disp('------------------------')
96 disp('----------------------------')
97 disp(' Test 1 (results): FAILED')
98 disp('----------------------------')
102 function checkTest2(Test)
106 if (ismember(Test(k).degree,[0 1]))
107 if (Test(k).error>1e-14)
113 disp('------------------------')
114 disp(' Test 2 (results): OK')
115 disp('------------------------')
117 disp('----------------------------')
118 disp(' Test 2 (results): FAILED')
119 disp('----------------------------')
123 function checkTest3(h,error)
125 P=polyfit(log(h),log(error),1);
127 disp('------------------------')
128 disp(' Test 3 (results): OK')
129 fprintf(' -> found numerical order %f. Must be 2\n',P(1))
130 disp('------------------------')
132 disp('----------------------------')
133 disp(' Test 3 (results): FAILED')
134 fprintf(' -> found numerical order %f. Must be 2\n',P(1))
135 disp('----------------------------')