80 lines
1.9 KiB
Mathematica
80 lines
1.9 KiB
Mathematica
|
% Benchmark for recursively partitioning meshes, based on various
|
||
|
% bisection approaches
|
||
|
%
|
||
|
% D.P & O.S for Numerical Computing in USI
|
||
|
|
||
|
|
||
|
|
||
|
% add necessary paths
|
||
|
addpaths_GP;
|
||
|
nlevels_a = 3;
|
||
|
nlevels_b = 4;
|
||
|
|
||
|
fprintf(' *********************************************\n')
|
||
|
fprintf(' *** Recursive graph bisection benchmark ***\n');
|
||
|
fprintf(' *********************************************\n')
|
||
|
|
||
|
% load cases
|
||
|
cases = {
|
||
|
'airfoil1.mat';
|
||
|
'3elt.mat';
|
||
|
'barth4.mat';
|
||
|
'mesh3e1.mat';
|
||
|
'crack.mat';
|
||
|
};
|
||
|
|
||
|
nc = length(cases);
|
||
|
maxlen = 0;
|
||
|
for c = 1:nc
|
||
|
if length(cases{c}) > maxlen
|
||
|
maxlen = length(cases{c});
|
||
|
end
|
||
|
end
|
||
|
|
||
|
for c = 1:nc
|
||
|
fprintf('.');
|
||
|
sparse_matrices(c) = load(cases{c});
|
||
|
end
|
||
|
|
||
|
|
||
|
fprintf('\n\n Report Cases Nodes Edges\n');
|
||
|
fprintf(repmat('-', 1, 40));
|
||
|
fprintf('\n');
|
||
|
for c = 1:nc
|
||
|
spacers = repmat('.', 1, maxlen+3-length(cases{c}));
|
||
|
[params] = Initialize_case(sparse_matrices(c));
|
||
|
fprintf('%s %s %10d %10d\n', cases{c}, spacers,params.numberOfVertices,params.numberOfEdges);
|
||
|
end
|
||
|
|
||
|
%% Create results table
|
||
|
fprintf('\n%7s %16s %20s %16s %16s\n','Bisection','Spectral','Metis 5.0.2','Coordinate','Inertial');
|
||
|
fprintf('%10s %10d %6d %10d %6d %10d %6d %10d %6d\n','Partitions',8,16,8,16,8,16,8,16);
|
||
|
fprintf(repmat('-', 1, 100));
|
||
|
fprintf('\n');
|
||
|
|
||
|
|
||
|
for c = 1:nc
|
||
|
spacers = repmat('.', 1, maxlen+3-length(cases{c}));
|
||
|
fprintf('%s %s', cases{c}, spacers);
|
||
|
sparse_matrix = load(cases{c});
|
||
|
|
||
|
|
||
|
% Recursively bisect the loaded graphs in 8 and 16 subgraphs.
|
||
|
% Steps
|
||
|
% 1. Initialize the problem
|
||
|
[params] = Initialize_case(sparse_matrices(c));
|
||
|
W = params.Adj;
|
||
|
coords = params.coords;
|
||
|
% 2. Recursive routines
|
||
|
% i. Spectral
|
||
|
% ii. Metis
|
||
|
% iii. Coordinate
|
||
|
% iv. Inertial
|
||
|
% 3. Calculate number of cut edges
|
||
|
% 4. Visualize the partitioning result
|
||
|
|
||
|
|
||
|
fprintf('%6d %6d %10d %6d %10d %6d %10d %6d\n',0,0,...
|
||
|
0,0,0,0,0,0);
|
||
|
|
||
|
end
|