27 int options[10], pnumflag=0, wgtflag=0;
28 int nnbrs, nbrind[200], nbrwgt[200], maxpwgt;
29 int esize, esizes[] = {-1, 3, 4, 8, 4};
31 esize = esizes[*etype];
36 xadj =
idxmalloc(*nn+1,
"METIS_MESHPARTNODAL: xadj");
37 adjncy =
idxmalloc(20*(*nn),
"METIS_MESHPARTNODAL: adjncy");
41 adjncy = realloc(adjncy, xadj[*nn]*
sizeof(
idxtype));
44 METIS_PartGraphKway(nn, xadj, adjncy, NULL, NULL, &wgtflag, &pnumflag, nparts, options, edgecut, npart);
48 pwgts =
idxsmalloc(*nparts, 0,
"METIS_MESHPARTNODAL: pwgts");
49 for (i=0; i<*ne; i++) {
50 me = npart[elmnts[i*esize]];
51 for (j=1; j<esize; j++) {
52 if (npart[elmnts[i*esize+j]] != me)
61 maxpwgt = 1.03*(*ne)/(*nparts);
62 for (i=0; i<*ne; i++) {
65 for (j=0; j<esize; j++) {
66 me = npart[elmnts[i*esize+j]];
67 for (k=0; k<nnbrs; k++) {
68 if (nbrind[k] == me) {
79 j =
iamax(nnbrs, nbrwgt);
80 if (pwgts[nbrind[j]] < maxpwgt) {
85 for (j=0; j<nnbrs; j++) {
86 if (pwgts[nbrind[j]] < maxpwgt) {
92 epart[i] = nbrind[
iamax(nnbrs, nbrwgt)];
114 idxtype *xadj, *adjncy, *pwgts, *nptr, *nind;
115 int options[10], pnumflag=0, wgtflag=0;
116 int nnbrs, nbrind[200], nbrwgt[200], maxpwgt;
117 int esize, esizes[] = {-1, 3, 4, 8, 4};
119 esize = esizes[*etype];
124 xadj =
idxmalloc(*ne+1,
"METIS_MESHPARTNODAL: xadj");
125 adjncy =
idxmalloc(esize*(*ne),
"METIS_MESHPARTNODAL: adjncy");
130 METIS_PartGraphKway(ne, xadj, adjncy, NULL, NULL, &wgtflag, &pnumflag, nparts, options, edgecut, epart);
133 nptr =
idxsmalloc(*nn+1, 0,
"METIS_MESHPARTDUAL: nptr");
134 for (j=esize*(*ne), i=0; i<j; i++)
138 nind =
idxmalloc(nptr[*nn],
"METIS_MESHPARTDUAL: nind");
139 for (k=i=0; i<(*ne); i++) {
140 for (j=0; j<esize; j++, k++)
141 nind[nptr[elmnts[k]]++] = i;
143 for (i=(*nn); i>0; i--)
150 pwgts =
idxsmalloc(*nparts, 0,
"METIS_MESHPARTDUAL: pwgts");
151 for (i=0; i<*nn; i++) {
152 me = epart[nind[nptr[i]]];
153 for (j=nptr[i]+1; j<nptr[i+1]; j++) {
154 if (epart[nind[j]] != me)
157 if (j == nptr[i+1]) {
163 maxpwgt = 1.03*(*nn)/(*nparts);
164 for (i=0; i<*nn; i++) {
165 if (npart[i] == -1) {
167 for (j=nptr[i]; j<nptr[i+1]; j++) {
169 for (k=0; k<nnbrs; k++) {
170 if (nbrind[k] == me) {
181 j =
iamax(nnbrs, nbrwgt);
182 if (pwgts[nbrind[j]] < maxpwgt) {
183 npart[i] = nbrind[j];
187 npart[i] = nbrind[0];
188 for (j=0; j<nnbrs; j++) {
189 if (pwgts[nbrind[j]] < maxpwgt) {
190 npart[i] = nbrind[j];
202 GKfree(&xadj, &adjncy, &pwgts, &nptr, &nind,
LTERM);
void METIS_MeshToNodal(int *ne, int *nn, idxtype *elmnts, int *etype, int *numflag, idxtype *dxadj, idxtype *dadjncy)
void METIS_PartMeshDual(int *ne, int *nn, idxtype *elmnts, int *etype, int *numflag, int *nparts, int *edgecut, idxtype *epart, idxtype *npart)
#define ChangeMesh2FNumbering2
void METIS_PartGraphKway(int *nvtxs, idxtype *xadj, idxtype *adjncy, idxtype *vwgt, idxtype *adjwgt, int *wgtflag, int *numflag, int *nparts, int *options, int *edgecut, idxtype *part)
void GKfree(void **ptr1,...)
void METIS_MeshToDual(int *ne, int *nn, idxtype *elmnts, int *etype, int *numflag, idxtype *dxadj, idxtype *dadjncy)
void METIS_PartMeshNodal(int *ne, int *nn, idxtype *elmnts, int *etype, int *numflag, int *nparts, int *edgecut, idxtype *epart, idxtype *npart)
#define ChangeMesh2CNumbering