OptFEM2D Toolbox for Matlab  V1.2b1
Matlab/Octave Optimized P1-Lagrange Finite Element Method in 2D
 All Files Functions Pages
benchStiffElasP1.m
Go to the documentation of this file.
1 function bench=benchStiffElasP1(varargin)
2 % function benchStiffElasP1()
3 % Benchmark function for StiffElasAssemblingP1 functions.
4 %
5 % Parameters:
6 % Num
7 % - 0 global alternate numbering with local alternate numbering (classical method),
8 % - 1 global block numbering with local alternate numbering,
9 % - 2 global alternate numbering with local block numbering,
10 % - 3 global block numbering with local block numbering.
11 %
12 % See also:
13 % #StiffElasAssemblingP1base, #StiffElasAssemblingP1OptV0, #StiffElasAssemblingP1OptV1, #StiffElasAssemblingP1OptV2
14 %
15 % OptFEM2DP1 [V1.2b1] - Copyright (C) 2013 CJS (LAGA)
16 %
17 % This file is part of OptFEM2DP1.
18 % OptFEM2DP1 is free software: you can redistribute it and/or modify
19 % it under the terms of the GNU General Public License as published by
20 % the Free Software Foundation, either version 3 of the License, or
21 % (at your option) any later version.
22 %
23 % OptFEM2DP1 is distributed in the hope that it will be useful,
24 % but WITHOUT ANY WARRANTY; without even the implied warranty of
25 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 % GNU General Public License for more details.
27 %
28 % You should have received a copy of the GNU General Public License
29 % along with this program. If not, see <http://www.gnu.org/licenses/>.
30 
31  p = inputParser;
32 
33  if isOctave()
34  p=p.addParamValue('LN', [20:20:100] , @isnumeric );
35  p=p.addParamValue('Num', 0 , @isnumeric );
36  p=p.parse(varargin{:});
37  else % Matlab
38  p.addParamValue('LN', [20:20:100], @isnumeric );
39  p.addParamValue('Num', 0, @isnumeric );
40  p.parse(varargin{:});
41  end
42  Num=p.Results.Num;
43 
44  switch Num
45  case 0
46  s=sprintf('Global alternate numbering / local alternate numbering');
47  case 1
48  s=sprintf('Global block numbering / local alternate numbering');
49  case 2
50  s=sprintf('Global alternate numbering / local block numbering');
51  case 3
52  s=sprintf('Global block numbering / local block numbering');
53  otherwise
54  error('invalid Num value')
55  end
56  fprintf(' Numbering Choice : %s\n',s);
57 
58  k=1;
59  for N=p.Results.LN
60  Th=SquareMesh(N);
61  fprintf('---------------------------------------------------------\n')
62  fprintf('BENCH (Stiff Elas. Matrix Assembling) %d\n',k)
63  fprintf(' Numbering Choice : %s\n',s);
64  fprintf(' Vertices number : %d - Triangles number : %d\n',Th.nq,Th.nme)
65  Lnq(k)=Th.nq;
66  tic();
67  Mb=StiffElasAssemblingP1base(Th.nq,Th.nme,Th.q,Th.me,Th.areas,1,1,Num);
68  T(k,1)=toc();
69  fprintf(' Matrix size : %d\n',length(Mb))
70  fprintf(' CPU times base (ref) : %3.4f (s)\n',T(k,1))
71  Ldof(k)=length(Mb);
72  tic();
73  M=StiffElasAssemblingP1OptV0(Th.nq,Th.nme,Th.q,Th.me,Th.areas,1,1,Num);
74  T(k,2)=toc();
75  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))
76  tic();
77  M=StiffElasAssemblingP1OptV1(Th.nq,Th.nme,Th.q,Th.me,Th.areas,1,1,Num);
78  T(k,3)=toc();
79  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))
80  tic();
81  M=StiffElasAssemblingP1OptV2(Th.nq,Th.nme,Th.q,Th.me,Th.areas,1,1,Num);
82  T(k,4)=toc();
83  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))
84  k=k+1;
85  end
86 
87  bench.T=T;
88  bench.Lnq=Lnq;
89  bench.Ldof=Ldof;
90  bench.LN=p.Results.LN;