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;
79 int new_v, id_node, flag_hit;
85 "The type of element is conflict with its index: data error\n");
87 j < mesh->elem_node_index[id_elem + 1]; j++) {
91 if (id_node < mesh->nn_internal) {
92 for (k = 0; k < 3; k++) {
99 for (m = 0; m < adj_link[id_node].
vertex_num; m++) {
109 fprintf(stderr,
"There is no enough memory for p1 in adj_link\n");
129 int new_v, id_node, flag_hit;
135 "The type of element is conflict with its index: data error\n");
137 j < mesh->elem_node_index[id_elem + 1]; j++) {
139 if ((id_node >=
mesh->
n_node) || (id_node < 0))
141 if (id_node < mesh->nn_internal) {
142 for (k = 0; k < 3; k++) {
149 for (m = 0; m < adj_link[id_node].
vertex_num; m++) {
159 fprintf(stderr,
"There is no enough memory for p1 in adj_link\n");
179 int new_v, id_node, flag_hit;
185 "The type of element is conflict with its index: data error\n");
187 j < mesh->elem_node_index[id_elem + 1]; j++) {
189 if ((id_node >=
mesh->
n_node) || (id_node < 0))
191 if (id_node < mesh->nn_internal) {
192 for (k = 0; k < 3; k++) {
199 for (m = 0; m < adj_link[id_node].
vertex_num; m++) {
224 for (i = 0; i < num; i++) {
226 for (j = 0; j < adj_link[i].
vertex_num; j++) {
243 int new_v8[3 * 8], new_v4[3 * 4], new_v6[3 * 6];
244 int nvtxs = 0, nedges = 0, global_num_node = 0;
246 int readew = -1, readvw = -1, dummy, edge;
247 int *vtxdist, *xadj, *adjncy, *vwgts, *adjwgts;
248 int wgtflag, numflag, ncon, nparts, edgecut,
options[4];
249 float *tpwgts, *ubvec, itr;
251 int *tmp_index, tmp_nvtxs, tmp_sum, tmp_pe, tmp_lid;
252 FILE *fp_test, *fp_wgts;
272 "Start transform original mesh data into graph structure of "
283 result->
t_node = global_num_node;
285 graph->vtxdist = (
int *)calloc((pesize + 1),
sizeof(int));
288 graph->vtxdist[0] = 0;
289 graph->vtxdist[1] = nvtxs;
291 for (i = 1; i < pesize; i++) {
294 tmp_sum += tmp_nvtxs;
295 graph->vtxdist[i + 1] = tmp_sum;
297 for (i = 1; i < pesize; i++)
323 if (flag_count == 1) {
332 for (i = 0; i <
mesh->
nn_internal; i++) nedges += adj_link[i].vertex_num;
333 graph->xadj = (
int *)calloc(nvtxs + 1,
sizeof(
int));
334 graph->adjncy = (
int *)calloc(nedges,
sizeof(
int));
335 if ((graph->xadj ==
NULL) || (graph->adjncy ==
NULL))
340 graph->xadj[i + 1] = m + adj_link[i].
vertex_num;
342 for (j = 0; j < adj_link[i].
vertex_num; j++) {
344 graph->adjncy[m + j] = graph->vtxdist[mynode] + p1->
vertex_num;
348 graph->adjncy[m + j] = graph->vtxdist[tmp_pe] + tmp_lid;
375 graph->gnvtxs = global_num_node;
411 result->
part = (
int *)calloc(nvtxs,
sizeof(
int));
429 ParMETIS_V3_PartKway(graph->vtxdist, graph->xadj, graph->adjncy,
NULL,
435 else if ((stat_para[6] != 0) && (stat_para[7] == 0)) {
439 if (fp_wgts ==
NULL) {
440 fprintf(stderr,
"control file wrong: vwgt_filename\n");
443 for (i = 0; i <
mesh->
nn_internal; i++) fscanf(fp_wgts,
"%d", &vwgts[i]);
445 ParMETIS_V3_PartKway(graph->vtxdist, graph->xadj, graph->adjncy, vwgts,
452 }
else if ((stat_para[6] == 0) && (stat_para[7] != 0)) {
456 if (fp_wgts ==
NULL) {
457 fprintf(stderr,
"control file wrong: adjwgt_filename\n");
461 fscanf(fp_wgts,
"%d", &adjwgts[i]);
463 ParMETIS_V3_PartKway(graph->vtxdist, graph->xadj, graph->adjncy,
NULL,
464 adjwgts, &(ctl_para->
wgtflag), &numflag,
470 }
else if ((stat_para[6] != 0) && (stat_para[7] != 0)) {
474 if (fp_wgts ==
NULL) {
475 fprintf(stderr,
"control file wrong: vwgt_filename\n");
478 for (i = 0; i <
mesh->
nn_internal; i++) fscanf(fp_wgts,
"%d", &vwgts[i]);
483 if (fp_wgts ==
NULL) {
484 fprintf(stderr,
"control file wrong: adjwgt_filename\n");
488 fscanf(fp_wgts,
"%d", &adjwgts[i]);
490 ParMETIS_V3_PartKway(graph->vtxdist, graph->xadj, graph->adjncy, vwgts,
491 adjwgts, &(ctl_para->
wgtflag), &numflag,
503 ParMETIS_V3_AdaptiveRepart(
504 graph->vtxdist, graph->xadj, graph->adjncy,
NULL,
NULL,
NULL,
510 else if ((stat_para[6] != 0) && (stat_para[7] == 0)) {
514 if (fp_wgts ==
NULL) {
515 fprintf(stderr,
"control file wrong: vwgt_filename\n");
518 for (i = 0; i <
mesh->
nn_internal; i++) fscanf(fp_wgts,
"%d", &vwgts[i]);
520 ParMETIS_V3_AdaptiveRepart(
521 graph->vtxdist, graph->xadj, graph->adjncy, vwgts,
NULL,
NULL,
527 }
else if ((stat_para[6] == 0) && (stat_para[7] != 0)) {
531 if (fp_wgts ==
NULL) {
532 fprintf(stderr,
"control file wrong: adjwgt_filename\n");
536 fscanf(fp_wgts,
"%d", &adjwgts[i]);
538 ParMETIS_V3_AdaptiveRepart(
539 graph->vtxdist, graph->xadj, graph->adjncy,
NULL,
NULL, adjwgts,
545 }
else if ((stat_para[6] != 0) && (stat_para[7] != 0)) {
549 if (fp_wgts ==
NULL) {
550 fprintf(stderr,
"control file wrong: vwgt_filename\n");
553 for (i = 0; i <
mesh->
nn_internal; i++) fscanf(fp_wgts,
"%d", &vwgts[i]);
558 if (fp_wgts ==
NULL) {
559 fprintf(stderr,
"control file wrong: adjwgt_filename\n");
563 fscanf(fp_wgts,
"%d", &adjwgts[i]);
565 ParMETIS_V3_AdaptiveRepart(
566 graph->vtxdist, graph->xadj, graph->adjncy, vwgts,
NULL, adjwgts,
int HECMW_Comm_rank(HECMW_Comm comm, int *rank)
int HECMW_Comm_size(HECMW_Comm comm, int *size)
int HECMW_Allreduce(void *sendbuf, void *recvbuf, int count, HECMW_Datatype datatype, HECMW_Op op, HECMW_Comm comm)
int HECMW_Send(void *buffer, int count, HECMW_Datatype datatype, int dest, int tag, HECMW_Comm comm)
int HECMW_Recv(void *buffer, int count, HECMW_Datatype datatype, int source, int tag, HECMW_Comm comm, HECMW_Status *status)
struct hecmwST_local_mesh * mesh
void HECMW_dlb_print_exit(char *var)
void HECMW_dlb_memory_exit(char *var)
void mesh2graph(struct hecmwST_local_mesh *mesh, GraphType *graph, Control_para *ctl_para, int stat_para[NUM_CONTROL_PARAS], Result_part *result, HECMW_Comm repart_comm)
void find_new_v8(int new_v8[24])
void add6_adj_link(Adj_find *adj_link, int id_elem, struct hecmwST_local_mesh *mesh, int new_v6[18])
void find_new_v4(int new_v4[12])
void find_new_v6(int new_v6[18])
void adj_link_free(Adj_find *adj_link, int num)
void add8_adj_link(Adj_find *adj_link, int id_elem, struct hecmwST_local_mesh *mesh, int new_v8[24])
void add4_adj_link(Adj_find *adj_link, int id_elem, struct hecmwST_local_mesh *mesh, int new_v4[12])
#define NUM_CONTROL_PARAS
struct option_rec options[]
specify command line option name and executing function name.
struct _adj_find_struct * next_vertex
char adjwgt_filename[128]
char adaptive_repartition[4]
long long * elem_node_index