| 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
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 matrices, we compare cputimes 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 %
44 % OptFEM2DP1 [V1.2b1] - Copyright (C) 2013 CJS (LAGA)
45 %
46 % This file is part of OptFEM2DP1.
47 % OptFEM2DP1 is free software: you can redistribute it and/or modify
48 % it under the terms of the GNU General Public License as published by
49 % the Free Software Foundation, either version 3 of the License, or
50 % (at your option) any later version.
51 %
52 % OptFEM2DP1 is distributed in the hope that it will be useful,
53 % but WITHOUT ANY WARRANTY; without even the implied warranty of
54 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
55 % GNU General Public License for more details.
56 %
57 % You should have received a copy of the GNU General Public License
58 % along with this program. If not, see <http://www.gnu.org/licenses/>.
59 close all
60
61 InitOptFEM2D();
62
63 p = inputParser;
64
65 if isOctave()
66 p=p.addParamValue('save', false, @islogical );
67 p=p.addParamValue('directory', 'latex' , @ischar );
68 p=p.addParamValue('name', 'bench' , @ischar );
69 p=p.addParamValue('LN', [20:20:100] , @isnumeric );
70 p=p.parse(varargin{:});
71 else % Matlab
72 p.addParamValue('save', false, @islogical );
73 p.addParamValue('directory', 'latex' , @ischar );
74 p.addParamValue('name', 'bench' , @ischar );
75 p.addParamValue('LN', [20:20:100], @isnumeric );
76 p.parse(varargin{:});
77 end
78 LN=p.Results.LN;
79 if p.Results.save
80 [succes,message,messageid] = mkdir(p.Results.directory);
81 if (~succes)
82 error(message)
83 end
84 end
85 BenchMassP1=benchMassP1('LN',LN);
86 if p.Results.save
87 % Build LaTeX tabular
88 BenchToLatexTabular(BenchMassP1,[p.Results.directory,filesep,p.Results.name,'_MassP1.tex']);
89 end
90
91 BenchMassWP1=benchMassWP1('LN',LN);
92 if p.Results.save
93 % Build LaTeX tabular
94 BenchToLatexTabular(BenchMassWP1,[p.Results.directory,filesep,p.Results.name,'_MassWP1.tex']);
95 end
96
97 BenchStiffP1=benchStiffP1('LN',LN);
98 if p.Results.save
99 % Build LaTeX tabular
100 BenchToLatexTabular(BenchStiffP1,[p.Results.directory,filesep,p.Results.name,'_StiffP1.tex']);
101 end
102
103 BenchStiffElasP1=benchStiffElasP1('LN',LN);
104 if p.Results.save
105 % Build LaTeX tabular
106 BenchToLatexTabular(BenchStiffElasP1,[p.Results.directory,filesep,p.Results.name,'_StiffElasP1.tex']);
107 end
108 end
109
110 function BenchToLatexTabular(bench,LaTeXFilename)
111 T=bench.T;
112 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)];
113 Header={'$n_{dof}$', 'base', 'OptV0', 'OptV1', 'OptV2'};
114 DataFormat={'$%d$','\\begin{tabular}{c} %.3f (s)\\\\ \\texttt{x %.2f} \\end{tabular}', ...
115 '\\begin{tabular}{c} %.3f (s)\\\\ \\texttt{x %.2f} \\end{tabular}', ...
116 '\\begin{tabular}{c} %.3f (s)\\\\ \\texttt{x %.2f} \\end{tabular}', ...
117 '\\begin{tabular}{c} %.3f (s)\\\\ \\texttt{x %.2f} \\end{tabular}'};
118 ColumnFormat= '|r||*{4}{c|}';
119 RowFormat='\hline';
120 RowHeaderFormat='\hline \hline';
121 PrintDataInLatexTabular(Data,Header,DataFormat,ColumnFormat,RowFormat,RowHeaderFormat,LaTeXFilename)
122
123 end