OptFEM3DP1 Toolbox: runBenchs.m Source File

| OptFEM3DP1 Toolbox 20130614_170440 Matlab/Octave Optimized P1-Lagrange Finite Element Method in 3D

- Main Page
- Related Pages
- Files

- File List
- File Members

All Files Functions Variables Pages
runBenchs.m
Go to the documentation of this file.
1 function runBenchs(varargin)
2 % function runBenchs(varargin)
3 % Run 3D benchs for Mass (#benchMass3DP1), Stiff (#benchStiff3DP1),
4 % MassVF (#benchMassVF3DP1)and StiffElas (#benchStiffElas3DP1) 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 #CubeMesh function.
13 %
14 % Example:
15 % @verbatim
16 % runBenchs('save',true,'name','benchMatlabR2012b','LN',5:3:20)@endverbatim
17 %
18 % Results under Matlab R2012b:
19 % Here are the results on our reference machine.
20 % - functions <b>MassAssembling3DP1</b>
21 % ``\mbox{\input{\INPUTLATEXDIR/benchMatlabR2012b_Mass3DP1.tex}} ``
22 % - functions <b>StiffAssembling3DP1</b>
23 % ``\mbox{\input{\INPUTLATEXDIR/benchMatlabR2012b_Stiff3DP1.tex}} ``
24 % - functions <b>StiffElasAssembling3DP1</b>
25 % ``\mbox{\input{\INPUTLATEXDIR/benchMatlabR2012b_StiffElas3DP1.tex}} ``
26 % - functions <b>MassVFAssembling3DP1</b>
27 % ``\mbox{\input{\INPUTLATEXDIR/benchMatlabR2012b_MassVF3DP1.tex}} ``
28 %
29 % % Results under Octave 3.6.3:
30 % Here are the results on our reference machine.
31 % - functions <b>MassAssembling3DP1</b>
32 % ``\mbox{\input{\INPUTLATEXDIR/benchOctave3.6.3_Mass3DP1.tex}} ``
33 % - functions <b>StiffAssembling3DP1</b>
34 % ``\mbox{\input{\INPUTLATEXDIR/benchOctave3.6.3_Stiff3DP1.tex}} ``
35 % - functions <b>StiffElasAssembling3DP1</b>
36 % ``\mbox{\input{\INPUTLATEXDIR/benchOctave3.6.3_StiffElas3DP1.tex}} ``
37 % - functions <b>MassVFAssembling3DP1</b>
38 % ``\mbox{\input{\INPUTLATEXDIR/benchOctave3.6.3_MassVF3DP1.tex}} ``
39 %
40 %
41 % See also:
42 % #benchMass3DP1, #benchStiff3DP1, #benchStiffElas3DP1, #benchMassVF3DP1, #InitOptFEM3D
43 % Copyright:
44 % See \ref license
45 close all
46
47 InitOptFEM3D();
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', [5:2:11] , @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', [5:2:11], @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 BenchMass3DP1=benchMass3DP1('LN',LN);
72 if p.Results.save
73 % Build LaTeX tabular
74 BenchToLatexTabular(BenchMass3DP1,[p.Results.directory,filesep,p.Results.name,'_Mass3DP1.tex']);
75 end
76
77 BenchStiff3DP1=benchStiff3DP1('LN',LN);
78 if p.Results.save
79 % Build LaTeX tabular
80 BenchToLatexTabular(BenchStiff3DP1,[p.Results.directory,filesep,p.Results.name,'_Stiff3DP1.tex']);
81 end
82
83 BenchMassVF3DP1=benchMassVF3DP1('LN',LN);
84 if p.Results.save
85 % Build LaTeX tabular
86 BenchToLatexTabular(BenchMassVF3DP1,[p.Results.directory,filesep,p.Results.name,'_MassVF3DP1.tex']);
87 end
88
89 BenchStiffElas3DP1=benchStiffElas3DP1('LN',LN);
90 if p.Results.save
91 % Build LaTeX tabular
92 BenchToLatexTabular(BenchStiffElas3DP1,[p.Results.directory,filesep,p.Results.name,'_StiffElas3DP1.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