| 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
runBenchs.m
Go to the documentation of this file.
1 function runBenchs(varargin)
2 % function runBenchs(varargin)
3 % Run benchs for Mass (#benchMassP1), MassW (#benchMassWP1)
4 % Stiff (#benchStiffP1) and StiffElas (#benchStiffElasP1) matrices.
5 % For each assembly matrix, we compare computation times of corresponding functions
6 % for version 'base', 'OptV0', 'OptV1' and 'OptV2'.
7 %
8 % Optional parameters:
9 % - 'save' : true for saving each bench in latex files. (default false)
10 % - 'directory' : name of the directory for saving `\LaTeX{}` files.
11 % - 'name' : base name of `\LaTeX{}` files.
12 % - 'LN' : List of N parameters for #SquareMesh function.
13 %
14 % Example:
15 % @verbatim
16 % runBenchs('save',true,'name','benchMatlabR2012b','LN',20:20:160)@endverbatim
17 %
18 % Results under Matlab R2012b:
19 % Here are the results on our reference machine.
20 % - functions <b>MassAssemblingP1</b>
21 % ``\mbox{\input{\INPUTLATEXDIR/benchMatlabR2012b_MassP1.tex}} ``
22 % - functions <b>MassWAssemblingP1</b>
23 % ``\mbox{\input{\INPUTLATEXDIR/benchMatlabR2012b_MassWP1.tex}} ``
24 % - functions <b>StiffAssemblingP1</b>
25 % ``\mbox{\input{\INPUTLATEXDIR/benchMatlabR2012b_StiffP1.tex}} ``
26 % - functions <b>StiffElasAssembling</b>
27 % ``\mbox{\input{\INPUTLATEXDIR/benchMatlabR2012b_StiffElasP1.tex}} ``
28 %
29 % % Results under Octave 3.6.3:
30 % Here are the results on our reference machine.
31 % - functions <b>MassAssemblingP1</b>
32 % ``\mbox{\input{\INPUTLATEXDIR/benchOctave3.6.3_MassP1.tex}} ``
33 % - functions <b>MassWAssemblingP1</b>
34 % ``\mbox{\input{\INPUTLATEXDIR/benchOctave3.6.3_MassWP1.tex}} ``
35 % - functions <b>StiffAssemblingP1</b>
36 % ``\mbox{\input{\INPUTLATEXDIR/benchOctave3.6.3_StiffP1.tex}} ``
37 % - functions <b>StiffElasAssembling</b>
38 % ``\mbox{\input{\INPUTLATEXDIR/benchOctave3.6.3_StiffElasP1.tex}} ``
39 %
40 %
41 % See also:
42 % #benchMassP1, #benchMassWP1, #benchStiffP1, #benchStiffElasP1, #InitOptFEM2D
43 % Copyright:
44 % See \ref license
45 close all
46
47 InitOptFEM2D();
48
49 p = inputParser;
50
51 if isOctave()
52 p=p.addParamValue('save', false, @islogical );
53 p=p.addParamValue('directory', 'latex' , @ischar );
54 p=p.addParamValue('name', 'bench' , @ischar );
55 p=p.addParamValue('LN', [20:20:100] , @isnumeric );
56 p=p.parse(varargin{:});
57 else % Matlab
58 p.addParamValue('save', false, @islogical );
59 p.addParamValue('directory', 'latex' , @ischar );
60 p.addParamValue('name', 'bench' , @ischar );
61 p.addParamValue('LN', [20:20:100], @isnumeric );
62 p.parse(varargin{:});
63 end
64 LN=p.Results.LN;
65 if p.Results.save
66 [succes,message,messageid] = mkdir(p.Results.directory);
67 if (~succes)
68 error(message)
69 end
70 end
71 BenchMassP1=benchMassP1('LN',LN);
72 if p.Results.save
73 % Build LaTeX tabular
74 BenchToLatexTabular(BenchMassP1,[p.Results.directory,filesep,p.Results.name,'_MassP1.tex']);
75 end
76
77 BenchMassWP1=benchMassWP1('LN',LN);
78 if p.Results.save
79 % Build LaTeX tabular
80 BenchToLatexTabular(BenchMassWP1,[p.Results.directory,filesep,p.Results.name,'_MassWP1.tex']);
81 end
82
83 BenchStiffP1=benchStiffP1('LN',LN);
84 if p.Results.save
85 % Build LaTeX tabular
86 BenchToLatexTabular(BenchStiffP1,[p.Results.directory,filesep,p.Results.name,'_StiffP1.tex']);
87 end
88
89 BenchStiffElasP1=benchStiffElasP1('LN',LN);
90 if p.Results.save
91 % Build LaTeX tabular
92 BenchToLatexTabular(BenchStiffElasP1,[p.Results.directory,filesep,p.Results.name,'_StiffElasP1.tex']);
93 end
94 end
95
96 function BenchToLatexTabular(bench,LaTeXFilename)
97 T=bench.T;
98 Data=[bench.Ldof',T(:,1),T(:,1)./T(:,1),T(:,2),T(:,1)./T(:,2),T(:,3),T(:,1)./T(:,3),T(:,4),T(:,1)./T(:,4)];
99 Header={'$n_{dof}$', 'base', 'OptV0', 'OptV1', 'OptV2'};
100 DataFormat={'$%d$','\\begin{tabular}{c} %.3f (s)\\\\ \\texttt{x %.2f} \\end{tabular}', ...
101 '\\begin{tabular}{c} %.3f (s)\\\\ \\texttt{x %.2f} \\end{tabular}', ...
102 '\\begin{tabular}{c} %.3f (s)\\\\ \\texttt{x %.2f} \\end{tabular}', ...
103 '\\begin{tabular}{c} %.3f (s)\\\\ \\texttt{x %.2f} \\end{tabular}'};
104 ColumnFormat= '|r||*{4}{c|}';
105 RowFormat='\hline';
106 RowHeaderFormat='\hline \hline';
107 PrintDataInLatexTabular(Data,Header,DataFormat,ColumnFormat,RowFormat,RowHeaderFormat,LaTeXFilename)
108
109 end