![]() |
OptFEM2DP1 Toolbox
V1.2
Matlab/Octave Optimized P1-Lagrange Finite Element Method in 2D
|
00001 function runBenchs(varargin) 00002 % function runBenchs(varargin) 00003 % Run benchs for Mass (#benchMass2DP1), MassW (#benchMassW2DP1) 00004 % Stiff (#benchStiff2DP1) and StiffElas (#benchStiffElas2DP1) matrices. 00005 % For each assembly matrix, we compare computation times of corresponding functions 00006 % for version 'base', 'OptV0', 'OptV1' and 'OptV2'. 00007 % 00008 % Optional parameters: 00009 % - 'save' : true for saving each bench in latex files. (default false) 00010 % - 'directory' : name of the directory for saving `\LaTeX{}` files. 00011 % - 'name' : base name of `\LaTeX{}` files. 00012 % - 'LN' : List of N parameters for #SquareMesh function. 00013 % 00014 % Example: 00015 % @verbatim 00016 % runBenchs('save',true,'name','benchMatlabR2012b','LN',20:20:160)@endverbatim 00017 % 00018 % Results under Matlab R2012b: 00019 % Here are the results on our reference machine. 00020 % - functions <b>MassAssembling2DP1</b> 00021 % ``\mbox{\input{\INPUTLATEXDIR/benchMatlabR2012b_MassP1.tex}} `` 00022 % - functions <b>MassWAssembling2DP1</b> 00023 % ``\mbox{\input{\INPUTLATEXDIR/benchMatlabR2012b_MassWP1.tex}} `` 00024 % - functions <b>StiffAssembling2DP1</b> 00025 % ``\mbox{\input{\INPUTLATEXDIR/benchMatlabR2012b_StiffP1.tex}} `` 00026 % - functions <b>StiffElasAssembling2DP1</b> 00027 % ``\mbox{\input{\INPUTLATEXDIR/benchMatlabR2012b_StiffElasP1.tex}} `` 00028 % 00029 % % Results under Octave 3.6.3: 00030 % Here are the results on our reference machine. 00031 % - functions <b>MassAssembling2DP1</b> 00032 % ``\mbox{\input{\INPUTLATEXDIR/benchOctave3.6.3_MassP1.tex}} `` 00033 % - functions <b>MassWAssembling2DP1</b> 00034 % ``\mbox{\input{\INPUTLATEXDIR/benchOctave3.6.3_MassWP1.tex}} `` 00035 % - functions <b>StiffAssembling2DP1</b> 00036 % ``\mbox{\input{\INPUTLATEXDIR/benchOctave3.6.3_StiffP1.tex}} `` 00037 % - functions <b>StiffElasAssembling2DP1</b> 00038 % ``\mbox{\input{\INPUTLATEXDIR/benchOctave3.6.3_StiffElasP1.tex}} `` 00039 % 00040 % 00041 % See also: 00042 % #benchMass2DP1, #benchMassW2DP1, #benchStiff2DP1, #benchStiffElas2DP1, #InitOptFEM2DP1 00043 % Copyright: 00044 % See \ref license 00045 close all 00046 00047 InitOptFEM2DP1(); 00048 00049 p = inputParser; 00050 00051 if isOctave() 00052 p=p.addParamValue('save', false, @islogical ); 00053 p=p.addParamValue('directory', 'latex' , @ischar ); 00054 p=p.addParamValue('name', 'bench' , @ischar ); 00055 p=p.addParamValue('LN', [20:20:100] , @isnumeric ); 00056 p=p.parse(varargin{:}); 00057 else % Matlab 00058 p.addParamValue('save', false, @islogical ); 00059 p.addParamValue('directory', 'latex' , @ischar ); 00060 p.addParamValue('name', 'bench' , @ischar ); 00061 p.addParamValue('LN', [20:20:100], @isnumeric ); 00062 p.parse(varargin{:}); 00063 end 00064 LN=p.Results.LN; 00065 if p.Results.save 00066 [succes,message,messageid] = mkdir(p.Results.directory); 00067 if (~succes) 00068 error(message) 00069 end 00070 end 00071 BenchMassP1=benchMass2DP1('LN',LN); 00072 if p.Results.save 00073 % Build LaTeX tabular 00074 BenchToLatexTabular(BenchMassP1,[p.Results.directory,filesep,p.Results.name,'_Mass2DP1.tex']); 00075 end 00076 00077 BenchMassWP1=benchMassW2DP1('LN',LN); 00078 if p.Results.save 00079 % Build LaTeX tabular 00080 BenchToLatexTabular(BenchMassWP1,[p.Results.directory,filesep,p.Results.name,'_MassW2DP1.tex']); 00081 end 00082 00083 BenchStiffP1=benchStiff2DP1('LN',LN); 00084 if p.Results.save 00085 % Build LaTeX tabular 00086 BenchToLatexTabular(BenchStiffP1,[p.Results.directory,filesep,p.Results.name,'_Stiff2DP1.tex']); 00087 end 00088 00089 BenchStiffElasP1=benchStiffElas2DP1('LN',LN); 00090 if p.Results.save 00091 % Build LaTeX tabular 00092 BenchToLatexTabular(BenchStiffElasP1,[p.Results.directory,filesep,p.Results.name,'_StiffElas2DP1.tex']); 00093 end 00094 end 00095 00096 function BenchToLatexTabular(bench,LaTeXFilename) 00097 T=bench.T; 00098 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)]; 00099 Header={'$n_{dof}$', 'base', 'OptV0', 'OptV1', 'OptV2'}; 00100 DataFormat={'$%d$','\\begin{tabular}{c} %.3f (s)\\\\ \\texttt{x %.2f} \\end{tabular}', ... 00101 '\\begin{tabular}{c} %.3f (s)\\\\ \\texttt{x %.2f} \\end{tabular}', ... 00102 '\\begin{tabular}{c} %.3f (s)\\\\ \\texttt{x %.2f} \\end{tabular}', ... 00103 '\\begin{tabular}{c} %.3f (s)\\\\ \\texttt{x %.2f} \\end{tabular}'}; 00104 ColumnFormat= '|r||*{4}{c|}'; 00105 RowFormat='\hline'; 00106 RowHeaderFormat='\hline \hline'; 00107 PrintDataInLatexTabular(Data,Header,DataFormat,ColumnFormat,RowFormat,RowHeaderFormat,LaTeXFilename) 00108 00109 end