OptFEM2D Toolbox for Matlab  V1.2b1
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 %
9 % OptFEM2DP1 [V1.2b1] - Copyright (C) 2013 CJS (LAGA)
10 %
11 % This file is part of OptFEM2DP1.
12 % OptFEM2DP1 is free software: you can redistribute it and/or modify
13 % it under the terms of the GNU General Public License as published by
14 % the Free Software Foundation, either version 3 of the License, or
15 % (at your option) any later version.
16 %
17 % OptFEM2DP1 is distributed in the hope that it will be useful,
18 % but WITHOUT ANY WARRANTY; without even the implied warranty of
19 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 % GNU General Public License for more details.
21 %
22 % You should have received a copy of the GNU General Public License
23 % along with this program. If not, see <http://www.gnu.org/licenses/>.
24  p = inputParser;
25 
26  if isOctave()
27  p=p.addParamValue('LN', [20:20:100] , @isnumeric );
28  p=p.parse(varargin{:});
29  else % Matlab
30  p.addParamValue('LN', [20:20:100], @isnumeric );
31  p.parse(varargin{:});
32  end
33  k=1;
34  for N=p.Results.LN
35  Th=SquareMesh(N);
36  fprintf('---------------------------------------------------------\n')
37  fprintf('BENCH (Stiffness Matrix Assembling) %d\n',k)
38  fprintf(' Vertices number : %d - Triangles number : %d\n',Th.nq,Th.nme)
39  fprintf(' Matrix size : %d\n',Th.nq)
40  Lnq(k)=Th.nq;
41  tic();
42  M=StiffAssemblingP1base(Th.nq,Th.nme,Th.q,Th.me,Th.areas);
43  T(k,1)=toc();
44  Ldof(k)=length(M);
45  fprintf(' CPU times base (ref) : %3.4f (s)\n',T(k,1))
46  tic();
47  M=StiffAssemblingP1OptV0(Th.nq,Th.nme,Th.q,Th.me,Th.areas);
48  T(k,2)=toc();
49  fprintf(' CPU times OptV0 : %3.4f (s) - Speed Up X%3.3f\n',T(k,2),T(k,1)/T(k,2))
50  tic();
51  M=StiffAssemblingP1OptV1(Th.nq,Th.nme,Th.q,Th.me,Th.areas);
52  T(k,3)=toc();
53  fprintf(' CPU times OptV1 : %3.4f (s) - Speed Up X%3.3f\n',T(k,3),T(k,1)/T(k,3))
54  tic();
55  M=StiffAssemblingP1OptV2(Th.nq,Th.nme,Th.q,Th.me,Th.areas);
56  T(k,4)=toc();
57  fprintf(' CPU times OptV2 : %3.4f (s) - Speed Up X%3.3f\n',T(k,4),T(k,1)/T(k,4))
58  k=k+1;
59  end
60 
61  bench.T=T;
62  bench.Lnq=Lnq;
63  bench.Ldof=Ldof;
64  bench.LN=p.Results.LN;
65