OptFEM3DP1 Toolbox  V1.0
Matlab/Octave Optimized P1-Lagrange Finite Element Method in 3D
 All Files Functions Variables Pages
benchMassVF3DP1.m
Go to the documentation of this file.
1 function bench=benchMassVF3DP1(varargin)
2 % function benchMassVFP1()
3 % Benchmark function for MassVFAssembling `P_1` functions in 3D
4 %
5 % See also:
7 % Copyright:
8 % See \ref license
9  p = inputParser;
10 
11  if isOctave()
12  p=p.addParamValue('LN', [20:10:60] , @isnumeric );
13  p=p.addParamValue('Num', 0 , @isnumeric );
14  p=p.parse(varargin{:});
15  else % Matlab
16  p.addParamValue('LN', [20:10:60], @isnumeric );
17  p.addParamValue('Num', 0 , @isnumeric );
18  p.parse(varargin{:});
19  end
20  Num=p.Results.Num;
21 
22  switch Num
23  case 0
24  s=sprintf('Global alternate numbering / local alternate numbering');
25  case 1
26  s=sprintf('Global block numbering / local alternate numbering');
27  case 2
28  s=sprintf('Global alternate numbering / local block numbering');
29  case 3
30  s=sprintf('Global block numbering / local block numbering');
31  otherwise
32  error('invalid Num value')
33  end
34 
35  k=1;
36  for N=p.Results.LN
37  Th=CubeMesh(N);
38  fprintf('---------------------------------------------------------\n')
39  fprintf('BENCH (MassVF Matrix Assembling) %d\n',k)
40  fprintf(' Numbering Choice : %s\n',s);
41  fprintf(' Vertices number : %d - Tetrahedra number : %d\n',Th.nq,Th.nme)
42  Lnq(k)=Th.nq;
43  tic();
44  Mb=MassVFAssembling3DP1base(Th.nq,Th.nme,Th.me,Th.volumes,Num);
45  T(k,1)=toc();
46  fprintf(' Matrix size : %d\n',length(Mb))
47  fprintf(' CPU times base (ref) : %3.4f (s)\n',T(k,1))
48  Ldof(k)=length(Mb);
49  tic();
50  M=MassVFAssembling3DP1OptV0(Th.nq,Th.nme,Th.me,Th.volumes,Num);
51  T(k,2)=toc();
52  fprintf(' CPU times OptV0 : %3.4f (s) - Error = %e - Speed Up X%3.3f\n',T(k,2),norm(Mb-M,Inf),T(k,1)/T(k,2))
53  tic();
54  M=MassVFAssembling3DP1OptV1(Th.nq,Th.nme,Th.me,Th.volumes,Num);
55  T(k,3)=toc();
56  fprintf(' CPU times OptV1 : %3.4f (s) - Error = %e - Speed Up X%3.3f\n',T(k,3),norm(Mb-M,Inf),T(k,1)/T(k,3))
57  tic();
58  M=MassVFAssembling3DP1OptV2(Th.nq,Th.nme,Th.me,Th.volumes,Num);
59  T(k,4)=toc();
60  fprintf(' CPU times OptV2 : %3.4f (s) - Error = %e - Speed Up X%3.3f\n',T(k,4),norm(Mb-M,Inf),T(k,1)/T(k,4))
61  k=k+1;
62  end
63  bench.T=T;
64  bench.Lnq=Lnq;
65  bench.Ldof=Ldof;
66  bench.LN=p.Results.LN;
67