| OptFEM2DP1 Toolbox 1.2b4 Matlab/Octave Optimized P1-Lagrange Finite Element Method in 2D

- Main Page
- Related Pages
- Files

- File List
- File Members

bench/benchStiffElas2DP1.m
Go to the documentation of this file.

    00001 function bench=benchStiffElas2DP1(varargin)
    00002 % function benchStiffElas2DP1()
    00003 %   Benchmark function for StiffElasAssembling2DP1 functions.
    00004 %
    00005 % Parameters:
    00006 %   Num
    00007 %    - 0 global alternate numbering with local alternate numbering (classical method),
    00008 %    - 1 global block numbering with local alternate numbering,
    00009 %    - 2 global alternate numbering with local block numbering,
    00010 %    - 3 global block numbering with local block numbering.
    00011 %
    00012 % See also:
    00013 %   #StiffElasAssembling2DP1base, #StiffElasAssembling2DP1OptV0, #StiffElasAssembling2DP1OptV1, #StiffElasAssembling2DP1OptV2
    00014 % Copyright:
    00015 %   See \ref license
    00016
    00017   p = inputParser;
    00018
    00019   if isOctave()
    00020     p=p.addParamValue('LN', [20:20:100] , @isnumeric );
    00021     p=p.addParamValue('Num', 0 , @isnumeric );
    00022     p=p.parse(varargin{:});
    00023   else % Matlab
    00024     p.addParamValue('LN', [20:20:100], @isnumeric );
    00025     p.addParamValue('Num', 0, @isnumeric );
    00026     p.parse(varargin{:});
    00027   end
    00028   Num=p.Results.Num;
    00029
    00030   switch Num
    00031     case 0
    00032       s=sprintf('Global alternate numbering / local alternate numbering');
    00033     case 1
    00034       s=sprintf('Global block numbering / local alternate numbering');
    00035     case 2
    00036       s=sprintf('Global alternate numbering / local block numbering');
    00037     case 3
    00038       s=sprintf('Global block numbering / local block numbering');
    00039     otherwise
    00040       error('invalid Num value')
    00041   end
    00042
    00043   k=1;
    00044   for N=p.Results.LN
    00045     Th=SquareMesh(N);
    00046     fprintf('---------------------------------------------------------\n')
    00047     fprintf('BENCH (Stiff Elas. Matrix Assembling) %d\n',k)
    00048     fprintf(' Numbering Choice : %s\n',s);
    00049     fprintf(' Vertices number : %d - Triangles number : %d\n',Th.nq,Th.nme)
    00050     Lnq(k)=Th.nq;
    00051     tic();
    00052     Mb=StiffElasAssembling2DP1base(Th.nq,Th.nme,Th.q,Th.me,Th.areas,1,1,Num);
    00053     T(k,1)=toc();
    00054     fprintf(' Matrix size     : %d\n',length(Mb))
    00055     fprintf('    CPU times base (ref) : %3.4f (s)\n',T(k,1))
    00056     Ldof(k)=length(Mb);
    00057     tic();
    00058     M=StiffElasAssembling2DP1OptV0(Th.nq,Th.nme,Th.q,Th.me,Th.areas,1,1,Num);
    00059     T(k,2)=toc();
    00060     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))
    00061     tic();
    00062     M=StiffElasAssembling2DP1OptV1(Th.nq,Th.nme,Th.q,Th.me,Th.areas,1,1,Num);
    00063     T(k,3)=toc();
    00064     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))
    00065     tic();
    00066     M=StiffElasAssembling2DP1OptV2(Th.nq,Th.nme,Th.q,Th.me,Th.areas,1,1,Num);
    00067     T(k,4)=toc();
    00068     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))
    00069     k=k+1;
    00070   end
    00071
    00072   bench.T=T;
    00073   bench.Lnq=Lnq;
    00074   bench.Ldof=Ldof;
    00075   bench.LN=p.Results.LN;

All Files Functions