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