9 disp(
'-----------------------------------------')
10 disp(' Test 1: Matrices errors and CPU times ')
11 disp('-----------------------------------------')
18 Test1.error(1)=norm(Mbase-MOptV0,Inf);
19 Test1.name{1}=
'MassAssembling3DP1OptV0';
20 fprintf(
' Error P1base vs OptV0 : %e\n',Test1.error(1))
24 Test1.error(2)=norm(Mbase-MOptV1,Inf);
25 Test1.name{2}=
'MassAssembling3DP1OptV1';
26 fprintf(
' Error P1base vs OptV1 : %e\n',Test1.error(2))
30 Test1.error(3)=norm(Mbase-MOptV2,Inf);
31 Test1.name{3}=
'MassAssembling3DP1OptV2';
32 fprintf(
' Error P1base vs OptV2 : %e\n',Test1.error(3))
34 fprintf(
' CPU times base (ref) : %3.4f (s)\n',
T(1))
35 fprintf(
' CPU times OptV0 : %3.4f (s) - Speed Up X%3.3f\n',
T(2),
T(1)/
T(2))
36 fprintf(
' CPU times OptV1 : %3.4f (s) - Speed Up X%3.3f\n',
T(3),
T(1)/
T(3))
37 fprintf(
' CPU times OptV2 : %3.4f (s) - Speed Up X%3.3f\n',
T(4),
T(1)/
T(4))
41 disp(
'-----------------------------------------------------------')
42 disp(' Test 2: Validations by integration on [0,1]x[0,1]x[0,1] ')
43 disp('-----------------------------------------------------------')
47 U=Test(kk).u(Th.q(1,:),Th.q(2,:),Th.q(3,:));
48 V=Test(kk).v(Th.q(1,:),Th.q(2,:),Th.q(3,:));
49 Test(kk).error=abs(Test(kk).Mass-U*
M*V');
50 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,abs(Test(kk).Mass-U*
M*V'));
55 disp('--------------------------------')
56 disp(' Test 3: Validations by order ')
57 disp('--------------------------------')
62 fprintf(' functions %d : u(x,y,z)=%s, v(x,y,z)=%s,\n',n, ...
63 Test(n).cu,Test(n).cv);
64 fprintf(' Integral of u(x,y,z)v(x,y,z) over unit cube : %.16f\n',ExSol);
68 fprintf('(%d/%d) Matrix size : %d\n',k,
N,Th.nq);
73 U=u(Th.q(1,:),Th.q(2,:),Th.q(3,:));
74 V=v(Th.q(1,:),Th.q(2,:),Th.q(3,:));
75 Error(k)=abs(ExSol-U*
M*V');
77 fprintf(' Error : %e\n',Error(k));
80 loglog(h,Error,'+-r',h,h*1.1*Error(1)/h(1),'-sm',h,1.1*Error(1)*(h/h(1)).^2,'-db')
81 legend('Error','O(h)','O(h^2)')
83 title('Test 3 : Mass Matrix')
88 function checkTest1(Test)
89 I=find(Test.error>1e-14);
91 disp('------------------------')
92 disp(' Test 1 (results): OK')
93 disp('------------------------')
95 disp('----------------------------')
96 disp(' Test 1 (results): FAILED')
97 disp('----------------------------')
101 function checkTest2(Test)
105 if (ismember(Test(k).degree,[0 1]))
106 if (Test(k).error>1e-14)
112 disp('------------------------')
113 disp(' Test 2 (results): OK')
114 disp('------------------------')
116 disp('----------------------------')
117 disp(' Test 2 (results): FAILED')
118 disp('----------------------------')
122 function checkTest3(h,error)
124 P=polyfit(log(h),log(error),1);
126 disp('------------------------')
127 disp(' Test 3 (results): OK')
128 fprintf(' -> found numerical order %f. Must be 2\n',P(1))
129 disp('------------------------')
131 disp('----------------------------')
132 disp(' Test 3 (results): FAILED')
133 fprintf(' -> found numerical order %f. Must be 2\n',P(1))
134 disp('----------------------------')