5 addpath([pwd,filesep,
'..',filesep,
'base'])
6 addpath([pwd,filesep,'..',filesep,'sage'])
7 addpath([pwd,filesep,'..',filesep,'Opt'])
8 addpath([pwd,filesep,'..',filesep,'ElemMat'])
14 disp('-----------------------------------------')
15 disp(' Test 1: Matrices errors and CPU times ')
16 disp('-----------------------------------------')
23 Test1.error(1)=norm(Mbase-MOptV0,Inf);
24 Test1.name{1}=
'MassAssembling3DP1OptV0';
25 fprintf(
' Error P1base vs OptV0 : %e\n',Test1.error(1))
29 Test1.error(2)=norm(Mbase-MOptV1,Inf);
30 Test1.name{2}=
'MassAssembling3DP1OptV1';
31 fprintf(
' Error P1base vs OptV1 : %e\n',Test1.error(2))
35 Test1.error(3)=norm(Mbase-MOptV2,Inf);
36 Test1.name{3}=
'MassAssembling3DP1OptV2';
37 fprintf(
' Error P1base vs OptV2 : %e\n',Test1.error(3))
39 fprintf(
' CPU times base (ref) : %3.4f (s)\n',
T(1))
40 fprintf(
' CPU times OptV0 : %3.4f (s) - Speed Up X%3.3f\n',
T(2),
T(1)/
T(2))
41 fprintf(
' CPU times OptV1 : %3.4f (s) - Speed Up X%3.3f\n',
T(3),
T(1)/
T(3))
42 fprintf(
' CPU times OptV2 : %3.4f (s) - Speed Up X%3.3f\n',
T(4),
T(1)/
T(4))
46 disp(
'-----------------------------------------------------------')
47 disp(' Test 2: Validations by integration on [0,1]x[0,1]x[0,1] ')
48 disp('-----------------------------------------------------------')
52 U=Test(kk).u(Th.q(1,:),Th.q(2,:),Th.q(3,:));
53 V=Test(kk).v(Th.q(1,:),Th.q(2,:),Th.q(3,:));
54 Test(kk).error=abs(Test(kk).Mass-U*
M*V');
55 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'));
60 disp('--------------------------------')
61 disp(' Test 3: Validations by order ')
62 disp('--------------------------------')
70 fprintf('(%d/%d) Matrix size : %d\n',k,
N,Th.nq);
71 h(k)=GetMaxLengthEdges(Th.q,Th.me);
75 U=u(Th.q(1,:),Th.q(2,:),Th.q(3,:));
76 V=v(Th.q(1,:),Th.q(2,:),Th.q(3,:));
77 Error(k)=abs(ExSol-U*
M*V');
79 fprintf(' Error : %e\n',Error(k));
82 loglog(h,Error,'+-r',h,h*1.1*Error(1)/h(1),'-sm',h,1.1*Error(1)*(h/h(1)).^2,'-db')
83 legend('Error','O(h)','O(h^2)')
85 title('Test 3 : Mass Matrix')
90 function checkTest1(Test)
91 I=find(Test.error>1e-14);
93 disp('------------------------')
94 disp(' Test 1 (results): OK')
95 disp('------------------------')
97 disp('----------------------------')
98 disp(' Test 1 (results): FAILED')
99 disp('----------------------------')
103 function checkTest2(Test)
107 if (Test(k).degree<=1)
108 if (Test(k).error>1e-14)
114 disp('------------------------')
115 disp(' Test 2 (results): OK')
116 disp('------------------------')
118 disp('----------------------------')
119 disp(' Test 2 (results): FAILED')
120 disp('----------------------------')
124 function checkTest3(h,error)
126 P=polyfit(log(h),log(error),1);
128 disp('------------------------')
129 disp(' Test 3 (results): OK')
130 fprintf(' -> found numerical order %f. Must be 2\n',P(1))
131 disp('------------------------')
133 disp('----------------------------')
134 disp(' Test 3 (results): FAILED')
135 fprintf(' -> found numerical order %f. Must be 2\n',P(1))
136 disp('----------------------------')