function load_results(resultDir, serialOrParallel, plotboth)
% Function to load the results
% Set plotboth to true and specify both the directories that have serial
% and parallel mode results. resultsDir{1} should have serial mode
% results and resultsDir{2} should have parallel mode results
% serialOrParallel can be set to any number when loading both parallel and
% serial moce results
eL_rF = [0.01 0; ...
1e-6 0; ...
7e-7 0; ...
0.01 1; ...
1.7e-6 1; ...
1e-6 1; ...
7e-7 1; ...
5e-7 1; ...
1e-6 2; ...
3e-7 1; ...
7e-7 2; ...
5.5e-7 2; ...
5e-7 2; ...
1e-6 3; ...
1e-7 0; ...
3e-7 2; ...
7e-8 0; ...
0.1 4; ...
1e-7 1; ...
1.5e-7 2; ...
1e-7 2; ...
];
if ~plotboth
[ndof, assembleTimeSecs, totExecTimeSecs, maxYDisp] = plotResults(resultDir, eL_rF, serialOrParallel);
% Assembly time and total execution time versus DOF
figure
plot(ndof, assembleTimeSecs, '-.rs', 'LineWidth',2, 'markersize', 10);
hold on
plot(ndof, totExecTimeSecs, '--g*', 'LineWidth',2, 'markersize', 10);
title('Assembly and Total Execution Time VS # DOF');
legend('Assembly', 'Total Execution')
xlabel('DOF')
ylabel('Assembly and Total Execution time (secs)')
hold off
% log log plot - Total execution time
figure
loglog(ndof, assembleTimeSecs, '-.r+', 'LineWidth',2, 'markersize', 10);
hold on
loglog(ndof, totExecTimeSecs, '--gd', 'LineWidth',2, 'markersize', 10);
title('LOGLOG Plot - Assembly and Total Execution Time VS # DOF');
legend('Assembly', 'Total Execution')
xlabel('DOF')
ylabel('Assembly and Total Execution time (secs)')
hold off
figure
plot(ndof, maxYDisp);
title('Max Y Displacement VS # DOF');
else
[ndof, SassembleTimeSecs, StotExecTimeSecs, SmaxYDisp] = plotResults(resultDir{1}, eL_rF, 0);
[ndof, PassembleTimeSecs, PtotExecTimeSecs, PmaxYDisp] = plotResults(resultDir{2}, eL_rF, 1);
% Assembly time versus DOF
figure
plot(ndof, SassembleTimeSecs, '-.rs', 'LineWidth',2, 'markersize', 10);
hold on
plot(ndof, PassembleTimeSecs, '--g*', 'LineWidth',2,'markersize', 10);
title('Assembly Time VS # DOF');
legend('Serial', 'Parallel')
xlabel('DOF')
ylabel('Assembly time (secs)')
hold off
% Total execution time versus DOF
figure
plot(ndof, StotExecTimeSecs, '-.rs', 'LineWidth',2, 'markersize', 10);
hold on
plot(ndof, PtotExecTimeSecs, '--g*', 'LineWidth',2, 'markersize', 10);
title('Total Execution Time VS # DOF');
legend('Serial', 'Parallel')
xlabel('DOF')
ylabel('Total execution time (secs)')
hold off
% Serial Mode - Assembly time and total execution time versus DOF
figure
plot(ndof, SassembleTimeSecs, '-.rs', 'LineWidth',2, 'markersize', 10);
hold on
plot(ndof, StotExecTimeSecs, '--g*', 'LineWidth',2, 'markersize', 10);
title('Serial Mode - Assembly and Total Execution Time VS # DOF');
legend('Assembly', 'Total Execution')
xlabel('DOF')
ylabel('Assembly and Total Execution time (secs)')
hold off
% Parallel Mode - Assembly time and total execution time versus DOF
figure
plot(ndof, PassembleTimeSecs, '-.rs', 'LineWidth',2, 'markersize', 10);
hold on
plot(ndof, PtotExecTimeSecs, '--g*', 'LineWidth',2, 'markersize', 10);
title('Parallel Mode - Assembly and Total Execution Time VS # DOF');
legend('Assembly', 'Total Execution')
xlabel('DOF')
ylabel('Assembly and Total Execution time (secs)')
hold off
% log log plot - Total execution time
figure
loglog(ndof, StotExecTimeSecs, '-.r+', 'LineWidth',2, 'markersize', 10);
hold on
loglog(ndof, PtotExecTimeSecs, '--gd', 'LineWidth',2, 'markersize', 10);
title('LOGLOG plot - Total Execution Time VS # DOF');
legend('Serial', 'Parallel')
xlabel('DOF')
ylabel('Total execution time (secs)')
hold off
figure
plot(ndof, SmaxYDisp);
title('Max Y Displacement VS # DOF');
end
end
%%
function [ndof, assembleTimeSecs, totExecTimeSecs, maxYDisp] = plotResults(resultDir, eL_rF, serialOrParallel)
curDir = pwd;
cd(resultDir);
% Look for all the .mat files
matFiles = dir('*.mat');
fileNo = [];
for idx = 1:length(matFiles)
% Assuming the name format is either '..._pmode_<#>.mat' or
% '...smode_<#>.mat'
dotmatLoc = strfind(matFiles(idx).name, '.mat');
if serialOrParallel == 0
% serial mode
psmodeLoc = strfind(matFiles(idx).name, 'smode_');
else
% parallel mode
psmodeLoc = strfind(matFiles(idx).name, 'pmode_');
end
fileNo(idx) = str2num(matFiles(idx).name(psmodeLoc+6:dotmatLoc-1));
end
[s ix] = sort(fileNo);
nele = [];
ndof = [];
stiffnessAssembleTimeSecs = [];
loadAssembleTimeSecs = [];
bcTimeSecs = [];
assembleTimeSecs = [];
KsparsePer = [];
KszBytes = [];
totExecTimeSecs = [];
maxYDisp = [];
for idx=1:length(matFiles)
load(matFiles(ix(idx)).name);
nele(idx) = perfStats.NumberOfElems;
ndof(idx) = perfStats.DegreesOfFreedom;
stiffnessAssembleTimeSecs(idx) = perfStats.StiffnessMatrixAssemblyTimeInSec;
loadAssembleTimeSecs(idx) = perfStats.LoadMatrixAssemblyTimeInSec;
bcTimeSecs(idx) = perfStats.BoundaryConditionsTimeInSec;
assembleTimeSecs(idx) = perfStats.AssemblyTimeInSec;
KsparsePer(idx) = perfStats.K_SparsePercent;
KszBytes(idx) = perfStats.Ksize_bytes;
totExecTimeSecs(idx) = perfStats.TotalExecutionTimeInSec;
maxYDisp(idx) = perfStats.MaxYDisp;
end
data = {'Element Length' ...
'Refine Factor' ...
'Number of Elements' ...
'Number of DOF' ...
'Stiffness Matrix Assembly Time (Secs)' ...
'Load Matrix Assembly Time (Secs)' ...
'Boundary Conditions Time (Secs)' ...
'Assembly Time (Secs)' ...
'Total Execution Time (Secs)' ...
'Max. Y Displacement (microns)'};
for idx = 1:length(nele)
data{idx+1,1} = eL_rF(idx,1);
data{idx+1,2} = eL_rF(idx,2);
data{idx+1,3} = nele(idx);
data{idx+1,4} = ndof(idx);
data{idx+1,5} = stiffnessAssembleTimeSecs(idx);
data{idx+1,6} = loadAssembleTimeSecs(idx);
data{idx+1,7} = bcTimeSecs(idx);
data{idx+1,8} = assembleTimeSecs(idx);
data{idx+1,9} = totExecTimeSecs(idx);
data{idx+1,10} = maxYDisp(idx);
end
xlsfilename = 'results.xls';
if serialOrParallel == 0
xlsfilename = 'serial_mode_results.xls';
else
xlsfilename = 'parallel_mode_results.xls';
end
xlswrite(xlsfilename, data);
cd(curDir);
end