| OptFEM2DP1 Toolbox V1.2b2 Matlab/Octave Optimized P1-Lagrange Finite Element Method in 2D

- Main Page
- Related Pages
- Files

- File List
- File Members

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 % Copyright:
15 % See \ref license
16
17 p = inputParser;
18
19 if isOctave()
20 p=p.addParamValue('LN', [20:20:100] , @isnumeric );
21 p=p.addParamValue('Num', 0 , @isnumeric );
22 p=p.parse(varargin{:});
23 else % Matlab
24 p.addParamValue('LN', [20:20:100], @isnumeric );
25 p.addParamValue('Num', 0, @isnumeric );
26 p.parse(varargin{:});
27 end
28 Num=p.Results.Num;
29
30 switch Num
31 case 0
32 s=sprintf('Global alternate numbering / local alternate numbering');
33 case 1
34 s=sprintf('Global block numbering / local alternate numbering');
35 case 2
36 s=sprintf('Global alternate numbering / local block numbering');
37 case 3
38 s=sprintf('Global block numbering / local block numbering');
39 otherwise
40 error('invalid Num value')
41 end
42
43 k=1;
44 for N=p.Results.LN
45 Th=SquareMesh(N);
46 fprintf('---------------------------------------------------------\n')
47 fprintf('BENCH (Stiff Elas. Matrix Assembling) %d\n',k)
48 fprintf(' Numbering Choice : %s\n',s);
49 fprintf(' Vertices number : %d - Triangles number : %d\n',Th.nq,Th.nme)
50 Lnq(k)=Th.nq;
51 tic();
52 Mb=StiffElasAssemblingP1base(Th.nq,Th.nme,Th.q,Th.me,Th.areas,1,1,Num);
53 T(k,1)=toc();
54 fprintf(' Matrix size : %d\n',length(Mb))
55 fprintf(' CPU times base (ref) : %3.4f (s)\n',T(k,1))
56 Ldof(k)=length(Mb);
57 tic();
58 M=StiffElasAssemblingP1OptV0(Th.nq,Th.nme,Th.q,Th.me,Th.areas,1,1,Num);
59 T(k,2)=toc();
60 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))
61 tic();
62 M=StiffElasAssemblingP1OptV1(Th.nq,Th.nme,Th.q,Th.me,Th.areas,1,1,Num);
63 T(k,3)=toc();
64 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))
65 tic();
66 M=StiffElasAssemblingP1OptV2(Th.nq,Th.nme,Th.q,Th.me,Th.areas,1,1,Num);
67 T(k,4)=toc();
68 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))
69 k=k+1;
70 end
71
72 bench.T=T;
73 bench.Lnq=Lnq;
74 bench.Ldof=Ldof;
75 bench.LN=p.Results.LN;