OptFEM3DP1 Toolbox  V1.0
Matlab/Octave Optimized P1-Lagrange Finite Element Method in 3D
 All Files Functions Variables Pages
benchStiff3DP1.m
Go to the documentation of this file.
1 function bench=benchStiff3DP1(varargin)
2 % function benchStiffP1()
3 % Benchmark function for StiffAssembling `P_1` functions.
4 %
5 % Usage
6 % bench=benchStiff3DP1('LN',[5:5:20]);
7 % bench=benchStiff3DP1('LN',[5:5:20],'version',{'OptV1','OptV2'});
8 % bench=benchStiff3DP1('LN',[5:5:20],'version',{'OptV1','OptV2'},'mesh','./mesh/cube');
9 % See also:
10 % #StiffAssemblingP1base, #StiffAssemblingP1OptV0, #StiffAssemblingP1OptV1, #StiffAssemblingP1OptV2
11 % Copyright:
12 % See \ref license
13  p = inputParser;
14 
15  if isOctave()
16  p=p.addParamValue('LN', [20:10:60] , @isnumeric );
17  p=p.addParamValue('version', {'base','OptV0','OptV1','OptV2'} , @iscell );
18  p=p.addParamValue('mesh','',@ischar);
19  p=p.parse(varargin{:});
20  else % Matlab
21  p.addParamValue('LN', [20:10:60], @isnumeric );
22  p.addParamValue('version', {'base','OptV0','OptV1','OptV2'}, @iscell );
23  p.addParamValue('mesh','',@ischar);
24  p.parse(varargin{:});
25  end
26  k=1;
27  version=p.Results.version;
28  nv=length(version);
29  if isempty(p.Results.mesh)
30  GenMesh=@(N) CubeMesh(N);
31  printMesh=@(N) sprintf('CubeMesh(%d)',N);
33  else
34  GenMesh=@(N) GetMeshOpt(sprintf('%s-%d.mesh',p.Results.mesh,N));
35  printMesh=@(N) sprintf('GetMeshOpt(''%s-%d.mesh'')',p.Results.mesh,N);
36  meshdesc=sprintf('GetMeshOpt(''%s-<N>.mesh'')',p.Results.mesh);
37  end
38  for N=p.Results.LN
39  Th=GenMesh(N);
40  fprintf('---------------------------------------------------------\n')
41  fprintf('BENCH (Stiffness Matrix Assembling) %d\n',k)
42  fprintf(' Mesh generation with : %s\n',printMesh(N));
43  fprintf(' Vertices number : %d - Tetrahedra number : %d\n',Th.nq,Th.nme)
44 
45  Lnq(k)=Th.nq;
46  eval(sprintf('Assembling=@(nq,nme,q,me,volumes) StiffAssembling3DP1%s(nq,nme,q,me,volumes);',version{1}));
47  tic();
48  Mb=Assembling(Th.nq,Th.nme,Th.q,Th.me,Th.volumes);
49  T(k,1)=toc();
50  fprintf(' Matrix size : %d\n',length(Mb))
51  Ldof(k)=length(Mb);
52  fprintf(' CPU times %5s (ref) : %3.4f (s)\n',version{1},T(k,1))
53  for v=2:nv
54  eval(sprintf('Assembling=@(nq,nme,q,me,volumes) StiffAssembling3DP1%s(nq,nme,q,me,volumes);',version{v}));
55  tic();
56  M=Assembling(Th.nq,Th.nme,Th.q,Th.me,Th.volumes);
57  T(k,v)=toc();
58  fprintf(' CPU times %5s : %3.4f (s) - Error = %e - Speed Up X%3.3f\n',version{v},T(k,v),norm(Mb-M,Inf),T(k,1)/T(k,v))
59  end
60  k=k+1;
61  end
62 
63  bench.T=T;
64  bench.Lnq=Lnq;
65  bench.Ldof=Ldof;
66  bench.LN=p.Results.LN;
67  bench.version=version;
68  bench.meshdesc=meshdesc;
69