| OptFEM2D Toolbox for Matlab V1.2b1 Matlab/Octave Optimized P1-Lagrange Finite Element Method in 2D

- Main Page
- Related Pages
- Files

- File List
- File Members

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:
6 % #MassWAssemblingP1base, #MassWAssemblingP1OptV0, #MassWAssemblingP1OptV1, #MassWAssemblingP1OptV2
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
25 p = inputParser;
26
27 if isOctave()
28 p=p.addParamValue('LN', [20:20:100] , @isnumeric );
29 p=p.parse(varargin{:});
30 else % Matlab
31 p.addParamValue('LN', [20:20:100], @isnumeric );
32 p.parse(varargin{:});
33 end
34 w=@(x,y) cos(x+y);
35 k=1;
36 for N=p.Results.LN
37 Th=SquareMesh(N);
38 fprintf('---------------------------------------------------------\n')
39 fprintf('BENCH (MassW Matrix Assembling) %d\n',k)
40 fprintf(' Vertices number : %d - Triangles number : %d\n',Th.nq,Th.nme)
41 fprintf(' Matrix size : %d\n',Th.nq)
42 Lnq(k)=Th.nq;
43 Tw=w(Th.q(1,:),Th.q(2,:));
44 tic();
45 M=MassWAssemblingP1base(Th.nq,Th.nme,Th.me,Th.areas,Tw);
46 T(k,1)=toc();
47 Ldof(k)=length(M);
48 fprintf(' CPU times base (ref) : %3.4f (s)\n',T(k,1))
49 tic();
50 M=MassWAssemblingP1OptV0(Th.nq,Th.nme,Th.me,Th.areas,Tw);
51 T(k,2)=toc();
52 fprintf(' CPU times OptV0 : %3.4f (s) - Speed Up X%3.3f\n',T(k,2),T(k,1)/T(k,2))
53 tic();
54 M=MassWAssemblingP1OptV1(Th.nq,Th.nme,Th.me,Th.areas,Tw);
55 T(k,3)=toc();
56 fprintf(' CPU times OptV1 : %3.4f (s) - Speed Up X%3.3f\n',T(k,3),T(k,1)/T(k,3))
57 tic();
58 M=MassWAssemblingP1OptV2(Th.nq,Th.nme,Th.me,Th.areas,Tw);
59 T(k,4)=toc();
60 fprintf(' CPU times OptV2 : %3.4f (s) - Speed Up X%3.3f\n',T(k,4),T(k,1)/T(k,4))
61 k=k+1;
62 end
63
64 bench.T=T;
65 bench.Lnq=Lnq;
66 bench.Ldof=Ldof;
67 bench.LN=p.Results.LN;