source: issm/trunk-jpl/src/m/partition/partitioner.m@ 13646

Last change on this file since 13646 was 13646, checked in by Mathieu Morlighem, 12 years ago

CHG: cosmetics, removed multiple blank lines

File size: 3.0 KB
Line 
1function md=partitioner(md,varargin)
2%PARTITIONER - partition mesh
3%
4% List of options to partitioner:
5%
6% package: 'chaco', 'metis' or 'scotch'
7% npart: number of partitions.
8% weighting: 'on' or 'off': default off
9% section: 1 by defaults(1=bisection, 2=quadrisection, 3=octasection)
10% recomputeadjacency: 'on' by default (set to 'off' to compute existing one)
11% Output: md.qmu.partition recover the partition vector
12%
13% Usage:
14% md=partitioner(md,'package','chaco','npart',100,'weighting','on');
15%
16
17%get options:
18options=pairoptions(varargin{:});
19
20%set defaults
21options=addfielddefault(options,'package','chaco');
22options=addfielddefault(options,'npart',10);
23options=addfielddefault(options,'weighting','on');
24options=addfielddefault(options,'section',1);
25options=addfielddefault(options,'recomputeadjacency','on');
26
27%get package:
28package=getfieldvalue(options,'package');
29npart=getfieldvalue(options,'npart');
30recomputeadjacency=getfieldvalue(options,'recomputeadjacency');
31
32if(md.mesh.dimension==3),
33 %partitioning essentially happens in 2D. So partition in 2D, then
34 %extrude the partition vector vertically.
35 md3d=md; %save for later
36 md.mesh.elements=md.mesh.elements2d;
37 md.mesh.x=md.mesh.x2d;
38 md.mesh.y=md.mesh.y2d;
39 md.mesh.numberofvertices=md.mesh.numberofvertices2d;
40 md.mesh.numberofelements=md.mesh.numberofelements2d;
41 md.qmu.vertex_weight=[];
42 md.mesh.vertexconnectivity=[];
43end
44
45%adjacency matrix if needed:
46if strcmpi(recomputeadjacency,'on'),
47 md=adjacency(md);
48else
49 disp('skipping adjacency matrix computation as requested in the options');
50end
51
52if strcmpi(package,'chaco'),
53
54 % default method (from chaco.m)
55 method=[1 1 0 0 1 1 50 0 .001 7654321]';
56 method(1)=3; % global method (3=inertial (geometric))
57 method(3)=0; % vertex weights (0=off, 1=on)
58
59 %specify bisection
60 method(6)=getfieldvalue(options,'section');% ndims (1=bisection, 2=quadrisection, 3=octasection)
61
62 %are we using weights?
63 if strcmpi(getfieldvalue(options,'weighting'),'on'),
64 weights=floor(md.qmu.vertex_weight/min(md.qmu.vertex_weight));
65 method(3)=1;
66 else
67 weights=[];
68 end
69
70 % partition into nparts
71 part=Chaco(md.qmu.adjacency,weights,[],md.mesh.x, md.mesh.y ,md.mesh.z,method,npart,[])'+1; %index partitions from 1 up. like metis.
72
73elseif strcmpi(package,'scotch'),
74
75 %are we using weights?
76 if strcmpi(getfieldvalue(options,'weighting'),'on'),
77 weights=floor(md.qmu.vertex_weight/min(md.qmu.vertex_weight));
78 end
79 maptab=Scotch(md.qmu.adjacency,[],weights,[],'cmplt',[npart]);
80
81 part=maptab(:,2);%index partitions from 1 up. like metis.
82
83elseif strcmpi(package,'linear'),
84
85 part=1:1:md.mesh.numberofvertices;
86
87elseif strcmpi(package,'metis'),
88
89 [element_partitioning,part]=MeshPartition(md.mesh,md.qmu.numberofpartitions);
90
91else
92
93 error(['partitioner error message: could not find ' package ' partitioner']);
94 help partitioner
95end
96
97%extrude if we are in 3D:
98if md.mesh.dimension==3,
99 md3d.qmu.vertex_weight=md.qmu.vertex_weight;
100 md3d.qmu.adjacency=md.qmu.adjacency;
101 md=md3d;
102 part=project3d(md,'vector',part','type','node');
103end
104
105md.qmu.partition=part;
Note: See TracBrowser for help on using the repository browser.