OptFEM2DP1 Toolbox  V1.2b3
Matlab/Octave Optimized P1-Lagrange Finite Element Method in 2D
 All Files Functions Pages
benchMassWP1.m
Go to the documentation of this file.
1 function bench=benchMassWP1(varargin)
2 % function benchMassWP1()
3 % Benchmark function for MassWAssemblingP1 functions.
4 %
5 % See also:
7 % #SquareMesh
8 % Copyright:
9 % See \ref license
10 
11  p = inputParser;
12 
13  if isOctave()
14  p=p.addParamValue('LN', [20:20:100] , @isnumeric );
15  p=p.parse(varargin{:});
16  else % Matlab
17  p.addParamValue('LN', [20:20:100], @isnumeric );
18  p.parse(varargin{:});
19  end
20  w=@(x,y) cos(x+y);
21  k=1;
22  for N=p.Results.LN
23  Th=SquareMesh(N);
24  fprintf('---------------------------------------------------------\n')
25  fprintf('BENCH (MassW Matrix Assembling) %d\n',k)
26  fprintf(' Vertices number : %d - Triangles number : %d\n',Th.nq,Th.nme)
27  fprintf(' Matrix size : %d\n',Th.nq)
28  Lnq(k)=Th.nq;
29  Tw=w(Th.q(1,:),Th.q(2,:));
30  tic();
31  M=MassWAssemblingP1base(Th.nq,Th.nme,Th.me,Th.areas,Tw);
32  T(k,1)=toc();
33  Ldof(k)=length(M);
34  fprintf(' CPU times base (ref) : %3.4f (s)\n',T(k,1))
35  tic();
36  M=MassWAssemblingP1OptV0(Th.nq,Th.nme,Th.me,Th.areas,Tw);
37  T(k,2)=toc();
38  fprintf(' CPU times OptV0 : %3.4f (s) - Speed Up X%3.3f\n',T(k,2),T(k,1)/T(k,2))
39  tic();
40  M=MassWAssemblingP1OptV1(Th.nq,Th.nme,Th.me,Th.areas,Tw);
41  T(k,3)=toc();
42  fprintf(' CPU times OptV1 : %3.4f (s) - Speed Up X%3.3f\n',T(k,3),T(k,1)/T(k,3))
43  tic();
44  M=MassWAssemblingP1OptV2(Th.nq,Th.nme,Th.me,Th.areas,Tw);
45  T(k,4)=toc();
46  fprintf(' CPU times OptV2 : %3.4f (s) - Speed Up X%3.3f\n',T(k,4),T(k,1)/T(k,4))
47  k=k+1;
48  end
49 
50  bench.T=T;
51  bench.Lnq=Lnq;
52  bench.Ldof=Ldof;
53  bench.LN=p.Results.LN;