13 new_v8[1 * 3 + 1] = 2;
14 new_v8[1 * 3 + 2] = 5;
16 new_v8[2 * 3 + 1] = 3;
17 new_v8[2 * 3 + 2] = 6;
19 new_v8[3 * 3 + 1] = 2;
20 new_v8[3 * 3 + 2] = 7;
22 new_v8[4 * 3 + 1] = 5;
23 new_v8[4 * 3 + 2] = 7;
25 new_v8[5 * 3 + 1] = 4;
26 new_v8[5 * 3 + 2] = 6;
28 new_v8[6 * 3 + 1] = 5;
29 new_v8[6 * 3 + 2] = 7;
31 new_v8[7 * 3 + 1] = 4;
32 new_v8[7 * 3 + 2] = 6;
41 new_v6[1 * 3 + 1] = 2;
42 new_v6[1 * 3 + 2] = 4;
44 new_v6[2 * 3 + 1] = 1;
45 new_v6[2 * 3 + 2] = 5;
47 new_v6[3 * 3 + 1] = 4;
48 new_v6[3 * 3 + 2] = 5;
50 new_v6[4 * 3 + 1] = 3;
51 new_v6[4 * 3 + 2] = 5;
53 new_v6[5 * 3 + 1] = 3;
54 new_v6[5 * 3 + 2] = 4;
63 new_v4[1 * 3 + 1] = 2;
64 new_v4[1 * 3 + 2] = 3;
66 new_v4[2 * 3 + 1] = 1;
67 new_v4[2 * 3 + 2] = 3;
69 new_v4[3 * 3 + 1] = 1;
70 new_v4[3 * 3 + 2] = 2;
78 int new_v, id_node, flag_hit;
84 "The type of element is conflict with its index: data error\n");
86 j < mesh->elem_node_index[id_elem + 1]; j++) {
90 if (id_node < mesh->nn_internal) {
91 for (k = 0; k < 3; k++) {
98 for (m = 0; m < adj_link[id_node].
vertex_num; m++) {
108 fprintf(stderr,
"There is no enough memory for p1 in adj_link\n");
127 int new_v, id_node, flag_hit;
133 "The type of element is conflict with its index: data error\n");
135 j < mesh->elem_node_index[id_elem + 1]; j++) {
137 if ((id_node >=
mesh->
n_node) || (id_node < 0))
139 if (id_node < mesh->nn_internal) {
140 for (k = 0; k < 3; k++) {
147 for (m = 0; m < adj_link[id_node].
vertex_num; m++) {
157 fprintf(stderr,
"There is no enough memory for p1 in adj_link\n");
176 int new_v, id_node, flag_hit;
182 "The type of element is conflict with its index: data error\n");
184 j < mesh->elem_node_index[id_elem + 1]; j++) {
186 if ((id_node >=
mesh->
n_node) || (id_node < 0))
188 if (id_node < mesh->nn_internal) {
189 for (k = 0; k < 3; k++) {
196 for (m = 0; m < adj_link[id_node].
vertex_num; m++) {
221 for (i = 0; i < num; i++) {
223 for (j = 0; j < adj_link[i].
vertex_num; j++) {
240 int new_v8[3 * 8], new_v4[3 * 4], new_v6[3 * 6];
241 int nvtxs = 0, nedges = 0, global_num_node = 0;
243 int readew = -1, readvw = -1, dummy, edge;
244 int *vtxdist, *xadj, *adjncy, *vwgts, *adjwgts;
245 int wgtflag, numflag, ncon, nparts, edgecut,
options[4];
246 float *tpwgts, *ubvec, itr;
248 int *tmp_index, tmp_nvtxs, tmp_sum, tmp_pe, tmp_lid;
249 FILE *fp_test, *fp_wgts;
269 "Start transform original mesh data into graph structure of "
280 result->
t_node = global_num_node;
282 graph->vtxdist = (
int *)calloc((pesize + 1),
sizeof(int));
285 graph->vtxdist[0] = 0;
286 graph->vtxdist[1] = nvtxs;
288 for (i = 1; i < pesize; i++) {
291 tmp_sum += tmp_nvtxs;
292 graph->vtxdist[i + 1] = tmp_sum;
294 for (i = 1; i < pesize; i++)
320 if (flag_count == 1) {
329 for (i = 0; i <
mesh->
nn_internal; i++) nedges += adj_link[i].vertex_num;
330 graph->xadj = (
int *)calloc(nvtxs + 1,
sizeof(
int));
331 graph->adjncy = (
int *)calloc(nedges,
sizeof(
int));
332 if ((graph->xadj ==
NULL) || (graph->adjncy ==
NULL))
337 graph->xadj[i + 1] = m + adj_link[i].
vertex_num;
339 for (j = 0; j < adj_link[i].
vertex_num; j++) {
341 graph->adjncy[m + j] = graph->vtxdist[mynode] + p1->
vertex_num;
345 graph->adjncy[m + j] = graph->vtxdist[tmp_pe] + tmp_lid;
372 graph->gnvtxs = global_num_node;
408 result->
part = (
int *)calloc(nvtxs,
sizeof(
int));
426 ParMETIS_V3_PartKway(graph->vtxdist, graph->xadj, graph->adjncy,
NULL,
432 else if ((stat_para[6] != 0) && (stat_para[7] == 0)) {
436 if (fp_wgts ==
NULL) {
437 fprintf(stderr,
"control file wrong: vwgt_filename\n");
440 for (i = 0; i <
mesh->
nn_internal; i++) fscanf(fp_wgts,
"%d", &vwgts[i]);
442 ParMETIS_V3_PartKway(graph->vtxdist, graph->xadj, graph->adjncy, vwgts,
449 }
else if ((stat_para[6] == 0) && (stat_para[7] != 0)) {
453 if (fp_wgts ==
NULL) {
454 fprintf(stderr,
"control file wrong: adjwgt_filename\n");
458 fscanf(fp_wgts,
"%d", &adjwgts[i]);
460 ParMETIS_V3_PartKway(graph->vtxdist, graph->xadj, graph->adjncy,
NULL,
461 adjwgts, &(ctl_para->
wgtflag), &numflag,
467 }
else if ((stat_para[6] != 0) && (stat_para[7] != 0)) {
471 if (fp_wgts ==
NULL) {
472 fprintf(stderr,
"control file wrong: vwgt_filename\n");
475 for (i = 0; i <
mesh->
nn_internal; i++) fscanf(fp_wgts,
"%d", &vwgts[i]);
480 if (fp_wgts ==
NULL) {
481 fprintf(stderr,
"control file wrong: adjwgt_filename\n");
485 fscanf(fp_wgts,
"%d", &adjwgts[i]);
487 ParMETIS_V3_PartKway(graph->vtxdist, graph->xadj, graph->adjncy, vwgts,
488 adjwgts, &(ctl_para->
wgtflag), &numflag,
500 ParMETIS_V3_AdaptiveRepart(
501 graph->vtxdist, graph->xadj, graph->adjncy,
NULL,
NULL,
NULL,
507 else if ((stat_para[6] != 0) && (stat_para[7] == 0)) {
511 if (fp_wgts ==
NULL) {
512 fprintf(stderr,
"control file wrong: vwgt_filename\n");
515 for (i = 0; i <
mesh->
nn_internal; i++) fscanf(fp_wgts,
"%d", &vwgts[i]);
517 ParMETIS_V3_AdaptiveRepart(
518 graph->vtxdist, graph->xadj, graph->adjncy, vwgts,
NULL,
NULL,
524 }
else if ((stat_para[6] == 0) && (stat_para[7] != 0)) {
528 if (fp_wgts ==
NULL) {
529 fprintf(stderr,
"control file wrong: adjwgt_filename\n");
533 fscanf(fp_wgts,
"%d", &adjwgts[i]);
535 ParMETIS_V3_AdaptiveRepart(
536 graph->vtxdist, graph->xadj, graph->adjncy,
NULL,
NULL, adjwgts,
542 }
else if ((stat_para[6] != 0) && (stat_para[7] != 0)) {
546 if (fp_wgts ==
NULL) {
547 fprintf(stderr,
"control file wrong: vwgt_filename\n");
550 for (i = 0; i <
mesh->
nn_internal; i++) fscanf(fp_wgts,
"%d", &vwgts[i]);
555 if (fp_wgts ==
NULL) {
556 fprintf(stderr,
"control file wrong: adjwgt_filename\n");
560 fscanf(fp_wgts,
"%d", &adjwgts[i]);
562 ParMETIS_V3_AdaptiveRepart(
563 graph->vtxdist, graph->xadj, graph->adjncy, vwgts,
NULL, adjwgts,