6 #define INAGAKI_PARTITIONER
30 #ifdef HECMW_PART_WITH_METIS
52 #define NEIGHBOR_DOMAIN 2
64 #define QSORT_LOWER 50
66 #define MASK_BIT(map, bit) ((map) |= (bit))
68 #define EVAL_BIT(map, bit) ((map) & (bit))
70 #define INV_BIT(map, bit) ((map) ^= (bit))
72 #define CLEAR_BIT(map, bit) \
76 #define CLEAR_IEB(map) \
80 #define CLEAR_MM(map) \
84 #define DSWAP(a, aa) \
89 #define ISWAP(b, bb) \
96 #define RTC_ERROR (-1)
100 #define MAX_NODE_SIZE 20
117 static int *n_int_nlist =
NULL;
118 static int *n_bnd_nlist =
NULL;
119 static int *n_int_elist =
NULL;
120 static int *n_bnd_elist =
NULL;
121 static int **int_nlist =
NULL;
122 static int **bnd_nlist =
NULL;
123 static int **int_elist =
NULL;
124 static int **bnd_elist =
NULL;
125 static int **ngrp_idx =
NULL;
126 static int **ngrp_item =
NULL;
127 static int **egrp_idx =
NULL;
128 static int **egrp_item =
NULL;
131 static int spdup_clear_MMbnd(
char *node_flag,
char *elem_flag,
132 int current_domain) {
135 for (i = 0; i < n_bnd_nlist[2 * current_domain + 1]; i++) {
136 node = bnd_nlist[current_domain][i];
139 for (i = 0; i < n_bnd_elist[2 * current_domain + 1]; i++) {
140 elem = bnd_elist[current_domain][i];
146 static int spdup_clear_IEB(
char *node_flag,
char *elem_flag,
147 int current_domain) {
150 for (i = 0; i < n_int_nlist[current_domain]; i++) {
151 node = int_nlist[current_domain][i];
154 for (i = 0; i < n_bnd_nlist[2 * current_domain + 1]; i++) {
155 node = bnd_nlist[current_domain][i];
158 for (i = 0; i < n_int_elist[current_domain]; i++) {
159 elem = int_elist[current_domain][i];
162 for (i = 0; i < n_bnd_elist[2 * current_domain + 1]; i++) {
163 elem = bnd_elist[current_domain][i];
173 int node, n_domain, domain[20], flag;
177 if (n_int_nlist ==
NULL) {
182 if (n_bnd_nlist ==
NULL) {
187 if (n_int_elist ==
NULL) {
192 if (n_bnd_elist ==
NULL) {
197 if (int_nlist ==
NULL) {
202 if (bnd_nlist ==
NULL) {
207 if (int_elist ==
NULL) {
212 if (bnd_elist ==
NULL) {
218 for (i = 0; i < global_mesh->
n_node; i++) {
219 n_int_nlist[global_mesh->
node_ID[2 * i + 1]]++;
223 for (i = 0; i < global_mesh->
n_elem; i++) {
224 n_int_elist[global_mesh->
elem_ID[2 * i + 1]]++;
228 for (i = 0; i < global_mesh->
n_elem; i++) {
233 domain[0] = global_mesh->
node_ID[2 * node - 1];
234 for (j = js + 1; j < je; j++) {
236 for (flag = 0, k = 0; k < n_domain; k++) {
237 if (global_mesh->
node_ID[2 * node - 1] == domain[k]) {
243 domain[n_domain] = global_mesh->
node_ID[2 * node - 1];
249 for (j = 0; j < n_domain; j++) {
250 n_bnd_elist[domain[j]]++;
251 n_bnd_nlist[domain[j]] += je - js;
258 int_nlist[i] = (
int *)
HECMW_calloc(n_int_nlist[i],
sizeof(
int));
259 if (int_nlist[i] ==
NULL) {
263 bnd_nlist[i] = (
int *)
HECMW_calloc(n_bnd_nlist[i],
sizeof(
int));
264 if (bnd_nlist[i] ==
NULL) {
268 int_elist[i] = (
int *)
HECMW_calloc(n_int_elist[i],
sizeof(
int));
269 if (int_elist[i] ==
NULL) {
273 bnd_elist[i] = (
int *)
HECMW_calloc(n_bnd_elist[i],
sizeof(
int));
274 if (bnd_elist[i] ==
NULL) {
286 static int int_cmp(
const void *v1,
const void *v2) {
289 i1 = (
const int *)v1;
290 i2 = (
const int *)v2;
292 if (*i1 < *i2)
return -1;
293 if (*i1 > *i2)
return 1;
300 int ks, ke, node, elem, counter;
302 for (counter = 0, j = 0; j < n_bnd_elist[2 * domain + 1]; j++) {
303 elem = bnd_elist[domain][j];
306 for (k = ks; k < ke; k++) {
308 bnd_nlist[domain][counter] = node;
313 qsort(bnd_nlist[domain], counter,
sizeof(
int), int_cmp);
316 for (j = 1; j < counter; j++) {
317 if (bnd_nlist[domain][j - 1] != bnd_nlist[domain][j]) {
318 bnd_nlist[domain][i] = bnd_nlist[domain][j];
323 n_bnd_nlist[2 * domain + 1] = i;
332 int bnd_and_int, bnd_not_int;
333 int n_nlist, n_elist;
336 n_nlist = n_bnd_nlist[2 * domain + 1];
346 for (i = 0; i < n_nlist; i++) {
347 node = bnd_nlist[domain][i];
348 if (global_mesh->
node_ID[2 * node - 1] == domain) {
349 work[bnd_and_int] = node;
353 for (i = 0; i < n_nlist; i++) {
354 node = bnd_nlist[domain][i];
355 if (global_mesh->
node_ID[2 * node - 1] != domain) {
356 work[bnd_and_int + bnd_not_int] = node;
360 n_bnd_nlist[2 * domain] = bnd_and_int;
361 n_bnd_nlist[2 * domain + 1] = bnd_and_int + bnd_not_int;
366 bnd_nlist[domain] = (
int *)
HECMW_calloc(n_nlist,
sizeof(
int));
367 if (bnd_nlist[domain] ==
NULL) {
371 for (i = 0; i < n_nlist; i++) {
372 bnd_nlist[domain][i] = work[i];
377 n_elist = n_bnd_elist[2 * domain + 1];
387 for (i = 0; i < n_elist; i++) {
388 elem = bnd_elist[domain][i];
389 if (global_mesh->
elem_ID[2 * elem - 1] == domain) {
390 work[bnd_and_int] = elem;
394 for (i = 0; i < n_elist; i++) {
395 elem = bnd_elist[domain][i];
396 if (global_mesh->
elem_ID[2 * elem - 1] != domain) {
397 work[bnd_and_int + bnd_not_int] = elem;
401 n_bnd_elist[2 * domain] = bnd_and_int;
402 n_bnd_elist[2 * domain + 1] = bnd_and_int + bnd_not_int;
403 for (i = 0; i < n_elist; i++) {
404 bnd_elist[domain][i] = work[i];
418 int node, elem, n_domain, domain[20], flag;
425 n_bnd_nlist[2 * i] = 0;
426 n_bnd_nlist[2 * i + 1] = 0;
428 n_bnd_elist[2 * i] = 0;
429 n_bnd_elist[2 * i + 1] = 0;
433 for (i = 0; i < global_mesh->
n_node; i++) {
434 current_domain = global_mesh->
node_ID[2 * i + 1];
435 int_nlist[current_domain][n_int_nlist[current_domain]] = i + 1;
436 n_int_nlist[current_domain]++;
440 for (i = 0; i < global_mesh->
n_elem; i++) {
441 current_domain = global_mesh->
elem_ID[2 * i + 1];
442 int_elist[current_domain][n_int_elist[current_domain]] = i + 1;
443 n_int_elist[current_domain]++;
447 for (i = 0; i < global_mesh->
n_elem; i++) {
452 domain[0] = global_mesh->
node_ID[2 * node - 1];
453 for (j = js + 1; j < je; j++) {
455 for (flag = 0, k = 0; k < n_domain; k++) {
456 if (global_mesh->
node_ID[2 * node - 1] == domain[k]) {
462 domain[n_domain] = global_mesh->
node_ID[2 * node - 1];
468 for (j = 0; j < n_domain; j++) {
469 bnd_elist[domain[j]][n_bnd_elist[2 * domain[j] + 1]] = i + 1;
470 n_bnd_elist[2 * domain[j] + 1]++;
477 rtc = get_boundary_nodelist(global_mesh, i);
482 rtc = sort_and_resize_bndlist(global_mesh, i);
492 static int spdup_make_node_grouplist(
495 int i, j, k, node, n_bnd, n_out;
496 int *n_domain =
NULL;
503 if (n_domain ==
NULL) {
509 n_bnd = n_bnd_nlist[2 * i];
510 n_out = n_bnd_nlist[2 * i + 1] - n_bnd_nlist[2 * i];
511 if (n_out == 0)
continue;
512 for (j = 0; j < n_out; j++) {
513 node = bnd_nlist[i][n_bnd + j];
514 n_domain[node - 1]++;
519 if (domain ==
NULL) {
523 for (i = 0; i < global_mesh->
n_node; i++) {
526 if (domain[i] ==
NULL) {
530 domain[i][0] = global_mesh->
node_ID[2 * i + 1];
534 n_bnd = n_bnd_nlist[2 * i];
535 n_out = n_bnd_nlist[2 * i + 1] - n_bnd_nlist[2 * i];
536 if (n_out == 0)
continue;
537 for (j = 0; j < n_out; j++) {
538 node = bnd_nlist[i][n_bnd + j];
539 domain[node - 1][n_domain[node - 1]] = i;
540 n_domain[node - 1]++;
546 if (ngrp_idx ==
NULL) {
553 if (ngrp_idx[i] ==
NULL) {
558 for (i = 0; i < node_group_global->
n_grp; i++) {
560 ngrp_idx[j][i + 1] = ngrp_idx[j][i];
566 for (j = node_group_global->
grp_index[i];
567 j < node_group_global->
grp_index[i + 1]; j++) {
568 node = node_group_global->
grp_item[j];
569 for (k = 0; k < n_domain[node - 1]; k++) {
570 current_domain = domain[node - 1][k];
571 ngrp_idx[current_domain][i + 1]++;
578 if (ngrp_item ==
NULL) {
585 if (ngrp_item[i] ==
NULL) {
591 for (i = 0; i < node_group_global->
n_grp; i++) {
596 for (j = node_group_global->
grp_index[i];
597 j < node_group_global->
grp_index[i + 1]; j++) {
598 node = node_group_global->
grp_item[j];
599 for (k = 0; k < n_domain[node - 1]; k++) {
600 current_domain = domain[node - 1][k];
601 ngrp_item[current_domain][counter[current_domain]] = node;
602 counter[current_domain]++;
607 for (i = 0; i < global_mesh->
n_node; i++) {
618 static int spdup_make_element_grouplist(
621 int i, j, k, elem, n_bnd, n_out;
622 int *n_domain =
NULL;
629 if (n_domain ==
NULL) {
635 n_bnd = n_bnd_elist[2 * i];
636 n_out = n_bnd_elist[2 * i + 1] - n_bnd_elist[2 * i];
637 if (n_out == 0)
continue;
638 for (j = 0; j < n_out; j++) {
639 elem = bnd_elist[i][n_bnd + j];
640 n_domain[elem - 1]++;
645 if (domain ==
NULL) {
649 for (i = 0; i < global_mesh->
n_elem; i++) {
652 if (domain[i] ==
NULL) {
656 domain[i][0] = global_mesh->
elem_ID[2 * i + 1];
660 n_bnd = n_bnd_elist[2 * i];
661 n_out = n_bnd_elist[2 * i + 1] - n_bnd_elist[2 * i];
662 if (n_out == 0)
continue;
663 for (j = 0; j < n_out; j++) {
664 elem = bnd_elist[i][n_bnd + j];
665 domain[elem - 1][n_domain[elem - 1]] = i;
666 n_domain[elem - 1]++;
672 if (egrp_idx ==
NULL) {
679 if (egrp_idx[i] ==
NULL) {
684 for (i = 0; i < elem_group_global->
n_grp; i++) {
686 egrp_idx[j][i + 1] = egrp_idx[j][i];
692 for (j = elem_group_global->
grp_index[i];
693 j < elem_group_global->
grp_index[i + 1]; j++) {
694 elem = elem_group_global->
grp_item[j];
695 for (k = 0; k < n_domain[elem - 1]; k++) {
696 current_domain = domain[elem - 1][k];
697 egrp_idx[current_domain][i + 1]++;
704 if (egrp_item ==
NULL) {
711 if (egrp_item[i] ==
NULL) {
717 for (i = 0; i < elem_group_global->
n_grp; i++) {
722 for (j = elem_group_global->
grp_index[i];
723 j < elem_group_global->
grp_index[i + 1]; j++) {
724 elem = elem_group_global->
grp_item[j];
725 for (k = 0; k < n_domain[elem - 1]; k++) {
726 current_domain = domain[elem - 1][k];
727 egrp_item[current_domain][counter[current_domain]] = elem;
728 counter[current_domain]++;
733 for (i = 0; i < global_mesh->
n_elem; i++) {
747 rtc = spdup_init_list(global_mesh);
750 rtc = spdup_make_list(global_mesh);
753 rtc = spdup_make_node_grouplist(global_mesh);
756 rtc = spdup_make_element_grouplist(global_mesh);
802 static char *get_dist_file_name(
char *header,
int domain,
char *fname) {
805 sprintf(s_domain,
"%d", domain);
807 strcpy(fname, header);
809 strcat(fname, s_domain);
814 static void free_link_list(
struct link_unit *llist) {
817 for (p = llist; p; p = q) {
827 if (local_mesh ==
NULL) {
853 if (local_mesh ==
NULL) {
867 local_mesh->
n_dof = 0;
885 if (local_mesh ==
NULL) {
925 if (local_mesh ==
NULL) {
930 local_mesh->
zero = 0;
931 local_mesh->
PETOT = 0;
954 if (local_mesh ==
NULL) {
977 if (local_mesh ==
NULL) {
1003 if (local_mesh ==
NULL) {
1030 if (local_mesh ==
NULL) {
1034 if (local_mesh->
mpc ==
NULL) {
1053 if (local_mesh ==
NULL) {
1058 if (local_mesh->
amp ==
NULL) {
1079 if (local_mesh ==
NULL) {
1108 if (local_mesh ==
NULL) {
1136 if (local_mesh ==
NULL) {
1164 if (local_mesh ==
NULL) {
1171 "\'local_mesh->contact_pair\' is NULL");
1191 if (local_mesh ==
NULL)
return;
1193 init_struct_global(local_mesh);
1197 if (local_mesh ==
NULL)
return;
1202 if (local_mesh->
node) {
1221 init_struct_node(local_mesh);
1225 if (local_mesh ==
NULL)
return;
1258 init_struct_elem(local_mesh);
1262 if (local_mesh ==
NULL)
return;
1286 init_struct_comm(local_mesh);
1290 if (local_mesh ==
NULL)
return;
1292 init_struct_adapt(local_mesh);
1296 if (local_mesh ==
NULL)
return;
1299 init_struct_sect(local_mesh);
1303 if (local_mesh ==
NULL)
return;
1306 init_struct_mat(local_mesh);
1310 if (local_mesh ==
NULL)
return;
1311 if (local_mesh->
mpc ==
NULL)
return;
1319 init_struct_mpc(local_mesh);
1323 if (local_mesh ==
NULL)
return;
1324 if (local_mesh->
amp ==
NULL)
return;
1326 init_struct_amp(local_mesh);
1330 if (local_mesh ==
NULL)
return;
1340 init_struct_node_grp(local_mesh);
1344 if (local_mesh ==
NULL)
return;
1354 init_struct_elem_grp(local_mesh);
1358 if (local_mesh ==
NULL)
return;
1368 init_struct_surf_grp(local_mesh);
1372 if (local_mesh ==
NULL)
return;
1388 init_struct_contact_pair(local_mesh);
1392 if (local_mesh ==
NULL)
return;
1394 clean_struct_global(local_mesh);
1395 clean_struct_node(local_mesh);
1396 clean_struct_elem(local_mesh);
1397 clean_struct_comm(local_mesh);
1398 clean_struct_adapt(local_mesh);
1399 clean_struct_sect(local_mesh);
1400 clean_struct_mat(local_mesh);
1401 clean_struct_mpc(local_mesh);
1402 clean_struct_amp(local_mesh);
1403 clean_struct_node_grp(local_mesh);
1404 clean_struct_elem_grp(local_mesh);
1405 clean_struct_surf_grp(local_mesh);
1406 clean_struct_contact_pair(local_mesh);
1413 if (result_data ==
NULL) {
1435 if (result_data ==
NULL)
return;
1475 static int quick_sort(
int no,
int n,
double *arr,
int *brr,
int *istack) {
1488 for (j = l + 1; j <= ir; j++) {
1491 for (i = j - 1; i >= l; i--) {
1492 if (arr[i] <= a)
break;
1493 arr[i + 1] = arr[i];
1494 brr[i + 1] = brr[i];
1500 if (!jstack)
return 0;
1502 ir = istack[jstack];
1503 l = istack[jstack - 1];
1509 DSWAP(arr[k], arr[l + 1])
1510 ISWAP(brr[k], brr[l + 1])
1512 if (arr[l] > arr[ir]) {
1513 DSWAP(arr[l], arr[ir])
1514 ISWAP(brr[l], brr[ir])
1517 if (arr[l + 1] > arr[ir]) {
1518 DSWAP(arr[l + 1], arr[ir])
1519 ISWAP(brr[l + 1], brr[ir])
1522 if (arr[l] > arr[l + 1]) {
1523 DSWAP(arr[l], arr[l + 1])
1524 ISWAP(brr[l], brr[l + 1])
1542 DSWAP(arr[i], arr[j])
1543 ISWAP(brr[i], brr[j])
1546 arr[l + 1] = arr[j];
1548 brr[l + 1] = brr[j];
1553 if (jstack > nstack) {
1558 if (ir - i + 1 >= j - l) {
1559 istack[jstack] = ir;
1560 istack[jstack - 1] = i;
1563 istack[jstack] = j - 1;
1564 istack[jstack - 1] = l;
1574 static int rcb_partition(
int n,
const double *coord,
int *wnum,
1588 if (stack ==
NULL) {
1593 if (value ==
NULL) {
1598 for (i = 0; i <
cont_data->n_rcb_div; i++) {
1599 for (j = 0; j < pow(2, i); j++) {
1604 for (k = 0; k < n; k++) {
1605 if (wnum[2 * k + 1] == j) {
1607 value[counter] = coord[3 * k];
1614 for (k = 0; k < n; k++) {
1615 if (wnum[2 * k + 1] == j) {
1617 value[counter] = coord[3 * k + 1];
1624 for (k = 0; k < n; k++) {
1625 if (wnum[2 * k + 1] == j) {
1627 value[counter] = coord[3 * k + 2];
1639 rtc = quick_sort(n, counter, value,
id, stack);
1643 for (k = 0; k < counter *
F_1_2; k++) {
1644 wnum[2 *
id[k] + 1] = j + (int)pow(2, i);
1667 double coord_x, coord_y, coord_z;
1672 for (i = 0; i < global_mesh->
n_elem; i++) {
1676 for (coord_x = 0.0, coord_y = 0.0, coord_z = 0.0, j = js; j < je; j++) {
1679 coord_x += global_mesh->
node[3 * (node - 1)];
1680 coord_y += global_mesh->
node[3 * (node - 1) + 1];
1681 coord_z += global_mesh->
node[3 * (node - 1) + 2];
1684 coord[3 * i] = coord_x / (je - js);
1685 coord[3 * i + 1] = coord_y / (je - js);
1686 coord[3 * i + 2] = coord_z / (je - js);
1694 double *coord =
NULL;
1698 if (coord ==
NULL) {
1703 rtc = calc_gravity(global_mesh, coord);
1706 rtc = rcb_partition(global_mesh->
n_elem, coord, global_mesh->
elem_ID,
1722 static int create_node_graph_link_list(
1728 for (i = 0; i < edge_data->
n_edge; i++) {
1735 if (graph[node1 - 1]->last->next ==
NULL) {
1740 graph[node1 - 1]->
n += 1;
1748 if (graph[node2 - 1]->last->next ==
NULL) {
1753 graph[node2 - 1]->
n += 1;
1765 static int create_node_graph_compress(
1767 int *node_graph_index,
int *node_graph_item) {
1772 for (counter = 0, i = 0; i < global_mesh->
n_node; i++) {
1773 node_graph_index[i + 1] = node_graph_index[i] + graph[i]->
n;
1775 for (p = graph[i]->list, j = 0; j < graph[i]->
n; j++) {
1777 node_graph_item[counter++] = p->
id - 1;
1786 int *node_graph_index,
int *node_graph_item) {
1793 if (graph ==
NULL) {
1797 for (i = 0; i < global_mesh->
n_node; i++) {
1801 for (i = 0; i < global_mesh->
n_node; i++) {
1803 if (graph[i] ==
NULL) {
1810 for (i = 0; i < global_mesh->
n_node; i++) {
1812 if (graph[i]->list ==
NULL) {
1822 rtc = create_node_graph_link_list(global_mesh, edge_data, graph);
1825 rtc = create_node_graph_compress(global_mesh, graph, node_graph_index,
1829 for (i = 0; i < global_mesh->
n_node; i++) {
1830 free_link_list(graph[i]->list);
1839 for (i = 0; i < global_mesh->
n_node; i++) {
1841 free_link_list(graph[i]->list);
1870 for (i = 0; i < global_mesh->
n_node; i++) {
1874 for (i = 0; i < global_mesh->
n_node; i++) {
1883 for (i = 0; i < global_mesh->
n_node; i++) {
1896 for (i = 0; i < global_mesh->
n_elem; i++) {
1898 j < global_mesh->elem_node_index[i + 1]; j++) {
1921 for (i = 0; i < global_mesh->
n_node; i++) {
1932 for (counter = 0, i = 0; i < global_mesh->
n_node; i++) {
1940 for (i = 0; i < global_mesh->
n_node; i++) {
1950 for (i = 0; i < global_mesh->
n_node; i++) {
1967 static int create_elem_graph_link_list(
1970 char *elem_flag =
NULL;
1977 if (elem_flag ==
NULL) {
1982 for (counter = 0, i = 0; i < global_mesh->
n_elem; i++) {
1983 memset(elem_flag, 0,
sizeof(
char) * global_mesh->
n_elem);
1987 j < global_mesh->elem_node_index[i + 1]; j++) {
1991 k < node_data->node_elem_index[node]; k++) {
1999 if (graph[i]->last->next ==
NULL) {
2024 static int create_elem_graph_compress(
2026 int *elem_graph_index,
int *elem_graph_item) {
2031 for (counter = 0, i = 0; i < global_mesh->
n_elem; i++) {
2032 elem_graph_index[i + 1] = elem_graph_index[i] + graph[i]->
n;
2034 for (p = graph[i]->list, j = 0; j < graph[i]->
n; j++) {
2036 elem_graph_item[counter++] = p->
id - 1;
2045 int *elem_graph_index) {
2048 int *elem_graph_item =
NULL;
2055 if (node_data ==
NULL) {
2063 rtc = set_node_belong_elem(global_mesh, node_data);
2068 if (graph ==
NULL) {
2072 for (i = 0; i < global_mesh->
n_elem; i++) {
2076 for (i = 0; i < global_mesh->
n_elem; i++) {
2078 if (graph[i] ==
NULL) {
2085 for (i = 0; i < global_mesh->
n_elem; i++) {
2087 if (graph[i]->list ==
NULL) {
2097 n_graph = create_elem_graph_link_list(global_mesh, node_data, graph);
2098 if (n_graph < 0)
goto error;
2100 elem_graph_item = (
int *)
HECMW_malloc(
sizeof(
int) * n_graph);
2101 if (elem_graph_item ==
NULL) {
2106 rtc = create_elem_graph_compress(global_mesh, graph, elem_graph_index,
2113 for (i = 0; i < global_mesh->
n_elem; i++) {
2114 free_link_list(graph[i]->list);
2119 return elem_graph_item;
2128 for (i = 0; i < global_mesh->
n_elem; i++) {
2130 free_link_list(graph[i]->list);
2144 static int pmetis_interface(
const int n_vertex,
const int n_domain,
int *xadj,
2145 int *adjncy,
int *part) {
2147 #ifdef HECMW_PART_WITH_METIS
2151 int nparts = n_domain;
2153 #if defined(METIS_VER_MAJOR) && (METIS_VER_MAJOR == 5)
2156 real_t *tpwgts =
NULL;
2157 real_t *ubvec =
NULL;
2161 METIS_PartGraphRecursive(&n, &ncon, xadj, adjncy, vwgt, vsize, adjwgt,
2162 &nparts, tpwgts, ubvec,
options, &edgecut, part);
2167 int options[5] = {0, 0, 0, 0, 0};
2170 METIS_PartGraphRecursive(&n, xadj, adjncy, vwgt, adjwgt, &wgtflag, &numflag,
2171 &nparts,
options, &edgecut, part);
2179 static int kmetis_interface(
const int n_vertex,
const int n_domain,
int *xadj,
2180 int *adjncy,
int *part) {
2182 #ifdef HECMW_PART_WITH_METIS
2186 int nparts = n_domain;
2188 #if defined(METIS_VER_MAJOR) && (METIS_VER_MAJOR == 5)
2191 real_t *tpwgts =
NULL;
2192 real_t *ubvec =
NULL;
2196 METIS_PartGraphKway(&n, &ncon, xadj, adjncy, vwgt, vsize, adjwgt, &nparts,
2197 tpwgts, ubvec,
options, &edgecut, part);
2202 int options[5] = {0, 0, 0, 0, 0};
2205 METIS_PartGraphKway(&n, xadj, adjncy, vwgt, adjwgt, &wgtflag, &numflag,
2206 &nparts,
options, &edgecut, part);
2214 static int pmetis_interface_with_weight(
int n_vertex,
int ncon,
int n_domain,
2215 const int *xadj,
const int *adjncy,
2216 const int *vwgt,
int *part) {
2218 #ifdef HECMW_PART_WITH_METIS
2221 int nparts = n_domain;
2223 #if defined(METIS_VER_MAJOR) && (METIS_VER_MAJOR == 5)
2225 real_t *tpwgts =
NULL;
2226 real_t *ubvec =
NULL;
2230 METIS_PartGraphRecursive(&n, &ncon, (
int *)xadj, (
int *)adjncy, (
int *)vwgt,
2231 vsize, adjwgt, &nparts, tpwgts, ubvec,
options,
2237 int options[5] = {0, 0, 0, 0, 0};
2239 if (vwgt !=
NULL) wgtflag = 2;
2243 METIS_PartGraphRecursive(&n, (
int *)xadj, (
int *)adjncy, (
int *)vwgt,
2244 adjwgt, &wgtflag, &numflag, &nparts,
options,
2247 METIS_mCPartGraphRecursive(&n, &ncon, (
int *)xadj, (
int *)adjncy,
2248 (
int *)vwgt, adjwgt, &wgtflag, &numflag, &nparts,
2258 static int kmetis_interface_with_weight(
int n_vertex,
int ncon,
int n_domain,
2259 const int *xadj,
const int *adjncy,
2260 const int *vwgt,
int *part) {
2262 #ifdef HECMW_PART_WITH_METIS
2265 int nparts = n_domain;
2267 #if defined(METIS_VER_MAJOR) && (METIS_VER_MAJOR == 5)
2269 real_t *tpwgts =
NULL;
2270 real_t *ubvec =
NULL;
2274 METIS_PartGraphKway(&n, &ncon, (
int *)xadj, (
int *)adjncy, (
int *)vwgt, vsize,
2275 adjwgt, &nparts, tpwgts, ubvec,
options, &edgecut, part);
2280 float *ubvec =
NULL;
2281 int options[5] = {0, 0, 0, 0, 0};
2283 if (vwgt !=
NULL) wgtflag = 2;
2287 if (ubvec ==
NULL) {
2295 METIS_PartGraphKway(&n, (
int *)xadj, (
int *)adjncy, (
int *)vwgt, adjwgt,
2296 &wgtflag, &numflag, &nparts,
options, &edgecut, part);
2298 METIS_mCPartGraphKway(&n, &ncon, (
int *)xadj, (
int *)adjncy, (
int *)vwgt,
2299 adjwgt, &wgtflag, &numflag, &nparts, ubvec,
options,
2311 static int contact_agg_mark_node_group(
int *mark,
2313 int gid,
int agg_id,
int *agg_dup) {
2315 int istart, iend, i;
2321 for (i = istart; i < iend; i++) {
2324 if (0 <= mark[nid] && mark[nid] < agg_id) {
2326 if (*agg_dup == -1) {
2327 *agg_dup = mark[nid];
2328 }
else if (mark[nid] != *agg_dup) {
2330 "ERROR: node included in multiple node groups in different "
2332 " which is not supported by CONTACT=AGGREGATE\n");
2341 static int HECMW_get_num_surf_node(
int etype,
int sid) {
2356 if (1 <= sid && sid <= 3)
return 4;
2357 if (4 <= sid && sid <= 5)
return 3;
2359 if (1 <= sid && sid <= 3)
return 8;
2360 if (4 <= sid && sid <= 5)
return 6;
2364 "ERROR: parallel contact analysis of elem type %d not supported\n",
2371 static const int *HECMW_get_surf_node(
int etype,
int sid) {
2374 static const int elem_surf_tet1[4][3] = {
2375 {1, 2, 3}, {0, 3, 2}, {0, 1, 3}, {0, 2, 1}};
2376 static const int elem_surf_tet2[4][6] = {{1, 4, 2, 9, 3, 8},
2379 {0, 5, 2, 4, 1, 6}};
2380 static const int elem_surf_hex1[6][4] = {{3, 0, 4, 7}, {1, 2, 6, 5},
2381 {0, 1, 5, 4}, {2, 3, 7, 6},
2382 {3, 2, 1, 0}, {4, 5, 6, 7}};
2383 static const int elem_surf_hex2[6][8] = {
2384 {3, 11, 0, 16, 4, 15, 7, 19}, {1, 9, 2, 18, 6, 13, 5, 17},
2385 {0, 8, 1, 17, 5, 12, 4, 16}, {2, 10, 3, 19, 7, 14, 6, 18},
2386 {3, 10, 2, 9, 1, 8, 0, 11}, {4, 12, 5, 13, 6, 14, 7, 15}};
2387 static const int elem_surf_pri1[5][4] = {
2388 {1, 2, 5, 4}, {2, 0, 3, 5}, {0, 1, 4, 3}, {2, 1, 0, -1}, {3, 4, 5, -1}};
2389 static const int elem_surf_pri2[5][8] = {{1, 6, 2, 14, 5, 9, 4, 13},
2390 {2, 7, 0, 12, 3, 10, 5, 14},
2391 {0, 8, 1, 13, 4, 11, 3, 12},
2392 {2, 6, 1, 8, 0, 7, -1, -1},
2393 {3, 11, 4, 9, 5, 10, -1, -1}};
2394 static const int elem_surf_ptt1[3] = {0, 1, 2};
2395 static const int elem_surf_ptt2[6] = {0, 1, 2, 3, 4, 5};
2396 static const int elem_surf_ptq1[4] = {0, 1, 2, 3};
2397 static const int elem_surf_ptq2[8] = {0, 1, 2, 3, 4, 5, 6, 7};
2400 return elem_surf_tet1[sid - 1];
2402 return elem_surf_tet2[sid - 1];
2404 return elem_surf_hex1[sid - 1];
2406 return elem_surf_hex2[sid - 1];
2408 return elem_surf_pri1[sid - 1];
2410 return elem_surf_pri2[sid - 1];
2412 return elem_surf_ptt1;
2414 return elem_surf_ptt2;
2416 return elem_surf_ptq1;
2418 return elem_surf_ptq2;
2421 "ERROR: parallel contact analysis of element type %d not supported\n",
2426 static int HECMW_fistr_get_num_surf_node(
int etype,
int sid) {
2441 if (1 <= sid && sid <= 2)
return 3;
2442 if (3 <= sid && sid <= 5)
return 4;
2444 if (1 <= sid && sid <= 2)
return 6;
2445 if (3 <= sid && sid <= 5)
return 8;
2449 "ERROR: parallel contact analysis of elem type %d not supported\n",
2456 static const int *HECMW_fistr_get_surf_node(
int etype,
int sid) {
2459 static const int elem_surf_tet1[4][3] = {
2460 {0, 1, 2}, {0, 1, 3}, {1, 2, 3}, {2, 0, 3}};
2461 static const int elem_surf_tet2[4][6] = {{0, 6, 1, 4, 2, 5},
2464 {2, 5, 0, 9, 3, 7}};
2465 static const int elem_surf_hex1[6][4] = {{0, 1, 2, 3}, {4, 5, 6, 7},
2466 {0, 1, 5, 4}, {1, 2, 6, 5},
2467 {2, 3, 7, 6}, {3, 0, 4, 7}};
2468 static const int elem_surf_hex2[6][8] = {
2469 {0, 8, 1, 9, 2, 10, 3, 11}, {4, 12, 5, 13, 6, 14, 7, 15},
2470 {0, 8, 1, 17, 5, 12, 4, 16}, {1, 9, 2, 18, 6, 13, 5, 17},
2471 {2, 10, 3, 19, 7, 14, 6, 18}, {3, 11, 0, 16, 4, 15, 7, 19}};
2472 static const int elem_surf_pri1[5][4] = {
2473 {0, 1, 2, -1}, {3, 4, 5, -1}, {0, 1, 4, 3}, {1, 2, 5, 4}, {2, 0, 3, 5}};
2474 static const int elem_surf_pri2[5][8] = {{0, 8, 1, 6, 2, 7, -1, -1},
2475 {3, 11, 4, 9, 5, 10, -1, -1},
2476 {0, 8, 1, 13, 4, 11, 3, 12},
2477 {1, 6, 2, 14, 5, 9, 4, 13},
2478 {2, 7, 0, 12, 3, 10, 5, 14}};
2479 static const int elem_surf_ptt1[3] = {0, 1, 2};
2480 static const int elem_surf_ptt2[6] = {0, 1, 2, 3, 4, 5};
2481 static const int elem_surf_ptq1[4] = {0, 1, 2, 3};
2482 static const int elem_surf_ptq2[8] = {0, 1, 2, 3, 4, 5, 6, 7};
2485 return elem_surf_tet1[sid - 1];
2487 return elem_surf_tet2[sid - 1];
2489 return elem_surf_hex1[sid - 1];
2491 return elem_surf_hex2[sid - 1];
2493 return elem_surf_pri1[sid - 1];
2495 return elem_surf_pri2[sid - 1];
2497 return elem_surf_ptt1;
2499 return elem_surf_ptt2;
2501 return elem_surf_ptq1;
2503 return elem_surf_ptq2;
2506 "ERROR: parallel contact analysis of element type %d not supported\n",
2517 for (i = 0; i < global_mesh->
n_node; i++) {
2521 for (i = 0; i < cp->
n_pair; i++) {
2525 for (j = jstart; j < jend; j++) {
2526 int eid = sgrp->
grp_item[j * 2] - 1;
2527 int sid = sgrp->
grp_item[j * 2 + 1];
2530 int etype = global_mesh->
elem_type[eid];
2536 int num_snode = HECMW_fistr_get_num_surf_node(etype, sid);
2537 const int *snode = HECMW_fistr_get_surf_node(etype, sid);
2541 for (k = 0; k < num_snode; k++) {
2542 int nid = nop[snode[k]] - 1;
2551 static int contact_agg_mark_surf_group(
int *mark,
2553 int gid,
int agg_id,
int *agg_dup) {
2555 int istart, iend, i, j;
2562 for (i = istart; i < iend; i++) {
2563 int eid = sgrp->
grp_item[i * 2] - 1;
2564 int sid = sgrp->
grp_item[i * 2 + 1];
2566 int etype = global_mesh->
elem_type[eid];
2571 int num_snode = HECMW_fistr_get_num_surf_node(etype, sid);
2572 const int *snode = HECMW_fistr_get_surf_node(etype, sid);
2575 for (j = 0; j < num_snode; j++) {
2576 int nid = nop[snode[j]] - 1;
2578 if (0 <= mark[nid] && mark[nid] < agg_id) {
2580 if (*agg_dup == -1) {
2581 *agg_dup = mark[nid];
2582 }
else if (mark[nid] != *agg_dup) {
2584 "ERROR: node included in multiple surface groups in "
2585 "different contact pairs,\n"
2586 " which is not supported by CONTACT=AGGREGATE\n");
2596 static int metis_partition_nb_contact_agg(
2601 int *node_graph_index =
NULL;
2602 int *node_graph_item =
NULL;
2603 int *belong_domain =
NULL;
2608 int agg_id, agg_dup, gid;
2610 const int *node_graph_index2;
2611 const int *node_graph_item2;
2620 if (node_graph_index ==
NULL) {
2625 if (node_graph_item ==
NULL) {
2632 rtc = create_node_graph(global_mesh, edge_data, node_graph_index,
2649 for (i = 0; i < global_mesh->
n_node; i++) {
2654 for (i = 0; i < cp->
n_pair; i++) {
2660 contact_agg_mark_node_group(mark, global_mesh, gid, agg_id, &agg_dup);
2665 contact_agg_mark_surf_group(mark, global_mesh, gid, agg_id, &agg_dup);
2670 rtc = contact_agg_mark_surf_group(mark, global_mesh, gid, agg_id, &agg_dup);
2674 for (i = 0; i < global_mesh->
n_node; i++) {
2675 if (mark[i] == agg_id) {
2684 for (i = 0; i < global_mesh->
n_node; i++) {
2693 node_graph_index, node_graph_item);
2703 node_weight2 = (
int *)
HECMW_calloc(n_node2,
sizeof(
int));
2704 if (node_weight2 ==
NULL) {
2708 for (i = 0; i < global_mesh->
n_node; i++) {
2709 node_weight2[mark[i]] += 1;
2714 belong_domain = (
int *)
HECMW_calloc(n_node2,
sizeof(
int));
2715 if (belong_domain ==
NULL) {
2722 n_edgecut = pmetis_interface_with_weight(
2723 n_node2, ncon, global_mesh->
n_subdomain, node_graph_index2,
2724 node_graph_item2, node_weight2, belong_domain);
2725 if (n_edgecut < 0)
goto error;
2729 n_edgecut = kmetis_interface_with_weight(
2730 n_node2, ncon, global_mesh->
n_subdomain, node_graph_index2,
2731 node_graph_item2, node_weight2, belong_domain);
2732 if (n_edgecut < 0)
goto error;
2740 for (i = 0; i < global_mesh->
n_node; i++) {
2741 global_mesh->
node_ID[2 * i + 1] = belong_domain[mark[i]];
2763 static int metis_partition_nb_contact_dist(
2768 int *node_graph_index =
NULL;
2769 int *node_graph_item =
NULL;
2770 int *belong_domain =
NULL;
2774 int *node_weight =
NULL;
2782 if (node_graph_index ==
NULL) {
2787 if (node_graph_item ==
NULL) {
2794 rtc = create_node_graph(global_mesh, edge_data, node_graph_index,
2817 rtc = mark_contact_master_nodes(global_mesh, mark);
2821 if (node_weight ==
NULL) {
2826 for (i = 0; i < global_mesh->
n_node; i++) {
2828 node_weight[i * ncon] = 1;
2830 node_weight[i * ncon + 1] = mark[i];
2837 if (belong_domain ==
NULL) {
2844 n_edgecut = pmetis_interface_with_weight(
2846 node_graph_item, node_weight, belong_domain);
2847 if (n_edgecut < 0)
goto error;
2851 n_edgecut = kmetis_interface_with_weight(
2853 node_graph_item, node_weight, belong_domain);
2854 if (n_edgecut < 0)
goto error;
2862 for (i = 0; i < global_mesh->
n_node; i++) {
2863 global_mesh->
node_ID[2 * i + 1] = belong_domain[i];
2883 static int metis_partition_nb_default(
2888 int *node_graph_index =
NULL;
2889 int *node_graph_item =
NULL;
2890 int *belong_domain =
NULL;
2895 if (node_graph_index ==
NULL) {
2900 if (node_graph_item ==
NULL) {
2907 rtc = create_node_graph(global_mesh, edge_data, node_graph_index,
2914 if (belong_domain ==
NULL) {
2925 node_graph_index, node_graph_item, belong_domain);
2926 if (n_edgecut < 0)
goto error;
2932 node_graph_index, node_graph_item, belong_domain);
2933 if (n_edgecut < 0)
goto error;
2941 for (i = 0; i < global_mesh->
n_node; i++) {
2942 global_mesh->
node_ID[2 * i + 1] = belong_domain[i];
2965 return metis_partition_nb_contact_agg(global_mesh,
cont_data,
2970 return metis_partition_nb_contact_dist(global_mesh,
cont_data,
2977 return metis_partition_nb_default(global_mesh,
cont_data, edge_data);
2983 int *elem_graph_index,
int *elem_graph_item) {
2985 int *belong_domain =
NULL;
2989 if (belong_domain ==
NULL) {
2998 elem_graph_index, elem_graph_item, belong_domain);
2999 if (n_edgecut < 0)
goto error;
3005 elem_graph_index, elem_graph_item, belong_domain);
3006 if (n_edgecut < 0)
goto error;
3014 for (i = 0; i < global_mesh->
n_elem; i++) {
3015 global_mesh->
elem_ID[2 * i + 1] = belong_domain[i];
3030 static int set_node_belong_domain_nb(
3040 if (edge_data ==
NULL) {
3051 if (rtc != 0)
goto error;
3057 rtc = rcb_partition(global_mesh->
n_node, global_mesh->
node,
3061 for (n_edgecut = 0, i = 0; i < edge_data->
n_edge; i++) {
3074 n_edgecut = metis_partition_nb(global_mesh,
cont_data, edge_data);
3075 if (n_edgecut < 0)
goto error;
3110 for (i = 0; i < global_mesh->
n_node; i++) {
3114 for (i = 0; i < global_mesh->
n_elem; i++) {
3116 j < global_mesh->elem_node_index[i + 1]; j++) {
3118 if (global_mesh->
elem_ID[2 * i + 1] <
3119 global_mesh->
node_ID[2 * (node - 1) + 1]) {
3120 global_mesh->
node_ID[2 * (node - 1) + 1] =
3121 global_mesh->
elem_ID[2 * i + 1];
3134 if (counter ==
NULL) {
3139 for (j = 0; j < global_mesh->
n_node; j++) {
3140 domain = global_mesh->
node_ID[2 * j + 1];
3141 global_mesh->
node_ID[2 * j] = ++counter[domain];
3164 for (i = 0; i < global_mesh->
n_node; i++) {
3165 global_mesh->
node_ID[2 * i] = i + 1;
3166 global_mesh->
node_ID[2 * i + 1] = 0;
3174 rtc = set_node_belong_domain_nb(global_mesh,
cont_data);
3179 rtc = set_node_belong_domain_eb(global_mesh);
3188 rtc = set_local_node_id(global_mesh);
3200 int node, node_domain, min_domain;
3203 for (i = 0; i < global_mesh->
n_elem; i++) {
3206 j < global_mesh->elem_node_index[i + 1]; j++) {
3208 node_domain = global_mesh->
node_ID[2 * (node - 1) + 1];
3209 if (node_domain < min_domain) {
3210 min_domain = node_domain;
3213 global_mesh->
elem_ID[2 * i + 1] = min_domain;
3221 int *elem_graph_index,
int *elem_graph_item) {
3229 for (i = 0; i < global_mesh->
n_elem; i++) {
3230 for (j = elem_graph_index[i]; j < elem_graph_index[i + 1]; j++) {
3232 if (eid < 0)
goto error;
3237 if (elem_data->
n_edge < 0)
goto error;
3252 static int set_elem_belong_domain_eb(
3256 int *elem_graph_index =
NULL;
3257 int *elem_graph_item =
NULL;
3263 if (elem_graph_index ==
NULL) {
3269 if (elem_data ==
NULL) {
3279 elem_graph_item = create_elem_graph(global_mesh, elem_graph_index);
3280 if (elem_graph_item ==
NULL)
goto error;
3284 rtc = count_edge_for_eb(global_mesh, elem_data, elem_graph_index,
3290 rtc = rcb_partition_eb(global_mesh,
cont_data);
3293 for (n_edgecut = 0, i = 0; i < elem_data->
n_edge; i++) {
3306 n_edgecut = metis_partition_eb(global_mesh,
cont_data, elem_graph_index,
3308 if (n_edgecut < 0)
goto error;
3343 if (counter ==
NULL) {
3348 for (j = 0; j < global_mesh->
n_elem; j++) {
3349 domain = global_mesh->
elem_ID[2 * j + 1];
3350 global_mesh->
elem_ID[2 * j] = ++counter[domain];
3373 for (i = 0; i < global_mesh->
n_elem; i++) {
3374 global_mesh->
elem_ID[2 * i] = i + 1;
3375 global_mesh->
elem_ID[2 * i + 1] = 0;
3383 rtc = set_elem_belong_domain_nb(global_mesh);
3389 rtc = set_elem_belong_domain_eb(global_mesh,
cont_data);
3399 rtc = set_local_elem_id(global_mesh);
3419 rtc = wnumbering_node(global_mesh,
cont_data);
3422 rtc = wnumbering_elem(global_mesh,
cont_data);
3429 rtc = wnumbering_elem(global_mesh,
cont_data);
3432 rtc = wnumbering_node(global_mesh,
cont_data);
3460 char *node_flag,
int current_domain) {
3463 for (i = 0; i < n_int_nlist[current_domain]; i++) {
3464 node = int_nlist[current_domain][i];
3472 char *elem_flag,
int current_domain) {
3475 for (i = 0; i < global_mesh->
n_elem; i++) {
3476 (global_mesh->
elem_ID[2 * i + 1] == current_domain)
3485 static int mask_elem_by_domain_mod(
char *elem_flag,
int current_domain) {
3488 for (i = 0; i < n_int_elist[current_domain]; i++) {
3489 elem = int_elist[current_domain][i];
3500 char *node_flag,
int current_domain) {
3503 for (i = 0; i < global_mesh->
mpc->
n_mpc; i++) {
3504 int j0, je, slave, master, j, evalsum;
3514 for (j = j0 + 1; j < je; j++) {
3533 static int mask_overlap_elem(
char *elem_flag,
int domain) {
3536 for (i = 0; i < n_bnd_elist[2 * domain + 1]; i++) {
3537 elem = bnd_elist[domain][i];
3546 char *node_flag,
const char *elem_flag) {
3550 for (i = 0; i < global_mesh->
n_elem; i++) {
3553 j < global_mesh->elem_node_index[i + 1]; j++) {
3566 char *node_flag,
char *elem_flag,
3570 for (i = 0; i < n_bnd_nlist[2 * domain + 1]; i++) {
3571 node = bnd_nlist[domain][i];
3582 static int mask_boundary_elem_with_slave(
3584 char *elem_flag,
int *added) {
3590 for (i = 0; i < global_mesh->
n_elem; i++) {
3597 j < global_mesh->elem_node_index[i + 1]; j++) {
3618 static int mask_boundary_link_elem_with_slave(
3620 char *elem_flag,
int *added) {
3626 for (i = 0; i < global_mesh->
n_elem; i++) {
3633 j < global_mesh->elem_node_index[i + 1]; j++) {
3653 static int mask_additional_overlap_elem(
3659 for (i = 0; i < global_mesh->
n_elem; i++) {
3662 j < global_mesh->elem_node_index[i + 1]; j++) {
3677 char *elem_flag,
char *node_flag) {
3679 int elem, node, selem;
3680 int evalsum, evalsum2;
3681 int master_gid, slave_gid;
3691 for (i = 0; i < cp->
n_pair; i++) {
3692 switch (cp->
type[i]) {
3697 jstart = sgrp->
grp_index[master_gid - 1];
3699 for (j = jstart; j < jend; j++) {
3709 jstart = ngrp->
grp_index[slave_gid - 1];
3711 for (j = jstart; j < jend; j++) {
3721 jstart = sgrp->
grp_index[master_gid - 1];
3723 for (j = jstart; j < jend; j++) {
3733 jstart = ngrp->
grp_index[slave_gid - 1];
3735 for (j = jstart; j < jend; j++) {
3748 jstart = sgrp->
grp_index[master_gid - 1];
3750 for (j = jstart; j < jend; j++) {
3761 jstart = sgrp->
grp_index[slave_gid - 1];
3763 for (j = jstart; j < jend; j++) {
3768 k < global_mesh->elem_node_index[selem]; k++) {
3778 jstart = sgrp->
grp_index[master_gid - 1];
3780 for (j = jstart; j < jend; j++) {
3791 jstart = sgrp->
grp_index[slave_gid - 1];
3793 for (j = jstart; j < jend; j++) {
3797 k < global_mesh->elem_node_index[selem]; k++) {
3807 k < global_mesh->elem_node_index[selem]; k++) {
3824 char *node_flag,
char *elem_flag,
3825 int current_domain) {
3829 rtc = mask_node_by_domain(global_mesh, node_flag, current_domain);
3832 rtc = mask_elem_by_domain_mod(elem_flag, current_domain);
3835 rtc = mask_overlap_elem(elem_flag, current_domain);
3839 mask_boundary_node_mod(global_mesh, node_flag, elem_flag, current_domain);
3848 rtc = mask_slave_node(global_mesh, node_flag, current_domain);
3851 rtc = mask_boundary_elem_with_slave(global_mesh, node_flag, elem_flag,
3856 rtc = mask_boundary_node(global_mesh, node_flag, elem_flag);
3861 rtc = mask_boundary_link_elem_with_slave(global_mesh, node_flag, elem_flag,
3866 rtc = mask_boundary_node(global_mesh, node_flag, elem_flag);
3870 for (i = 0; i < global_mesh->
n_node; i++) {
3878 rtc = mask_additional_overlap_elem(global_mesh, node_flag, elem_flag);
3881 rtc = mask_boundary_node(global_mesh, node_flag, elem_flag);
3886 rtc = mask_contact_slave_surf(global_mesh, elem_flag, node_flag);
3900 char *node_flag,
const char *elem_flag) {
3904 for (i = 0; i < global_mesh->
n_elem; i++) {
3907 j < global_mesh->elem_node_index[i + 1]; j++) {
3914 j < global_mesh->elem_node_index[i + 1]; j++) {
3928 for (i = 0; i < global_mesh->
n_node; i++) {
3939 char *node_flag,
const char *elem_flag) {
3943 rtc = mask_overlap_node_mark(global_mesh, node_flag, elem_flag);
3946 rtc = mask_overlap_node_inner(global_mesh, node_flag);
3949 for (i = 0; i < global_mesh->
n_node; i++) {
3961 const char *node_flag,
char *elem_flag) {
3965 for (i = 0; i < global_mesh->
n_elem; i++) {
3968 j < global_mesh->elem_node_index[i + 1]; j++) {
3983 char *node_flag,
char *elem_flag,
3984 int current_domain) {
3988 for (i = 0; i < global_mesh->
n_node; i++) {
3993 for (i = 0; i < global_mesh->
n_elem; i++) {
3999 rtc = mask_node_by_domain(global_mesh, node_flag, current_domain);
4002 rtc = mask_elem_by_domain(global_mesh, elem_flag, current_domain);
4005 rtc = mask_overlap_node(global_mesh, node_flag, elem_flag);
4008 rtc = mask_boundary_elem(global_mesh, node_flag, elem_flag);
4020 const char *node_flag,
char *domain_flag) {
4023 for (i = 0; i < global_mesh->
n_node; i++) {
4033 static int mask_neighbor_domain_nb_mod(
4035 char *domain_flag,
int domain) {
4038 for (i = n_bnd_nlist[2 * domain]; i < n_bnd_nlist[2 * domain + 1]; i++) {
4039 node = bnd_nlist[domain][i];
4046 static int mask_neighbor_domain_nb_contact(
4048 const char *elem_flag,
char *domain_flag) {
4050 int elem, node, selem;
4052 int master_gid, slave_gid;
4062 for (i = 0; i < cp->
n_pair; i++) {
4065 switch (cp->
type[i]) {
4068 jstart = ngrp->
grp_index[slave_gid - 1];
4070 for (j = jstart; j < jend; j++) {
4080 jstart = sgrp->
grp_index[slave_gid - 1];
4082 for (j = jstart; j < jend; j++) {
4085 k < global_mesh->elem_node_index[selem]; k++) {
4101 jstart = sgrp->
grp_index[master_gid - 1];
4103 for (j = jstart; j < jend; j++) {
4116 const char *elem_flag,
char *domain_flag) {
4119 for (i = 0; i < global_mesh->
n_elem; i++) {
4129 const char *domain_flag) {
4133 for (counter = 0, i = 0; i < global_mesh->
n_subdomain; i++) {
4142 const char *domain_flag) {
4146 for (counter = 0, i = 0; i < global_mesh->
n_subdomain; i++) {
4157 char *node_flag,
char *elem_flag,
4158 int current_domain) {
4160 char *domain_flag =
NULL;
4168 "Starting creation of neighboring domain information...");
4174 if (domain_flag ==
NULL) {
4181 rtc = mask_mesh_status_nb(global_mesh, node_flag, elem_flag,
4185 if (is_spdup_available(global_mesh)) {
4186 rtc = mask_neighbor_domain_nb_mod(global_mesh, node_flag, domain_flag,
4189 rtc = mask_neighbor_domain_nb(global_mesh, node_flag, domain_flag);
4193 rtc = mask_neighbor_domain_nb_contact(global_mesh, node_flag, elem_flag,
4200 rtc = mask_mesh_status_eb(global_mesh, node_flag, elem_flag,
4204 rtc = mask_neighbor_domain_eb(global_mesh, elem_flag, domain_flag);
4214 local_mesh->
n_neighbor_pe = count_neighbor_domain(global_mesh, domain_flag);
4232 rtc = set_neighbor_domain(global_mesh, local_mesh, domain_flag);
4253 char *node_flag_current,
char *node_flag_neighbor) {
4256 for (i = 0; i < global_mesh->
n_node; i++) {
4268 char *node_flag_current,
char *node_flag_neighbor,
4269 int current_domain) {
4272 for (i = 0; i < n_bnd_nlist[2 * current_domain + 1]; i++) {
4273 node = bnd_nlist[current_domain][i];
4283 char *elem_flag_current,
char *elem_flag_neighbor) {
4286 for (i = 0; i < global_mesh->
n_elem; i++) {
4298 char *elem_flag_current,
char *elem_flag_neighbor,
4299 int current_domain) {
4302 for (i = 0; i < n_bnd_elist[2 * current_domain + 1]; i++) {
4303 elem = bnd_elist[current_domain][i];
4314 const char *node_flag,
int domain) {
4318 for (counter = 0, i = 0; i < n_int_nlist[domain]; i++) {
4319 node = int_nlist[domain][i];
4327 const char *elem_flag,
int domain) {
4331 for (counter = 0, i = 0; i < global_mesh->
n_elem; i++) {
4333 global_mesh->
elem_ID[2 * i + 1] == domain)
4340 static int count_masked_shared_node(
4345 for (counter = 0, i = 0; i < global_mesh->
n_node; i++) {
4352 static int count_masked_shared_elem(
4357 for (counter = 0, i = 0; i < global_mesh->
n_elem; i++) {
4365 static int count_masked_shared_elem_mod(
4371 for (counter = 0, i = 0; i < n_bnd_elist[2 * domain + 1]; i++) {
4372 elem = bnd_elist[domain][i];
4381 const char *node_flag,
int **comm_node,
4382 int neighbor_idx,
int domain) {
4386 for (counter = 0, i = 0; i < n_int_nlist[domain]; i++) {
4387 node = int_nlist[domain][i];
4389 comm_node[neighbor_idx][counter++] = node;
4397 const char *elem_flag,
int **comm_elem,
4398 int neighbor_idx,
int domain) {
4402 for (counter = 0, i = 0; i < global_mesh->
n_elem; i++) {
4404 global_mesh->
elem_ID[2 * i + 1] == domain) {
4405 comm_elem[neighbor_idx][counter++] = i + 1;
4413 const char *node_flag,
int **shared_node,
4418 for (counter = 0, i = 0; i < global_mesh->
n_node; i++) {
4420 shared_node[neighbor_idx][counter++] = i + 1;
4428 const char *elem_flag,
int **shared_elem,
4433 for (counter = 0, i = 0; i < global_mesh->
n_elem; i++) {
4435 shared_elem[neighbor_idx][counter++] = i + 1;
4443 static int create_shared_elem_pre_mod(
4445 int **shared_elem,
int neighbor_idx,
int neighbor_domain) {
4447 int i, idx1, idx2, elem1, elem2, n_bnd, n_out, maxe;
4449 n_bnd = n_bnd_elist[2 * neighbor_domain];
4451 n_bnd_elist[2 * neighbor_domain + 1] - n_bnd_elist[2 * neighbor_domain];
4452 maxe = global_mesh->
n_elem + 1;
4454 elem1 = (n_bnd == 0) ? maxe : bnd_elist[neighbor_domain][0];
4455 elem2 = (n_out == 0) ? maxe : bnd_elist[neighbor_domain][n_bnd];
4456 for (counter = 0, idx1 = 0, idx2 = 0, i = 0; i < n_bnd + n_out; i++) {
4457 if (elem1 < elem2) {
4459 shared_elem[neighbor_idx][counter++] = elem1;
4462 elem1 = (idx1 == n_bnd) ? maxe : bnd_elist[neighbor_domain][idx1];
4465 shared_elem[neighbor_idx][counter++] = elem2;
4468 elem2 = (idx2 == n_out) ? maxe : bnd_elist[neighbor_domain][idx2 + n_bnd];
4475 static int create_comm_item(
int n_neighbor_pe,
int **comm_item_pre,
4476 int *comm_index,
int *comm_item) {
4479 for (i = 0; i < n_neighbor_pe; i++) {
4481 je = comm_index[i + 1];
4483 for (j = 0; j < je - js; j++) {
4484 comm_item[js + j] = comm_item_pre[i][j];
4495 const char *node_flag,
int **import_node,
4496 int neighbor_idx,
int neighbor_domain) {
4497 int n_import_node, rtc;
4500 count_masked_comm_node(global_mesh, node_flag, neighbor_domain);
4504 local_mesh->
import_index[neighbor_idx] + n_import_node;
4506 import_node[neighbor_idx] = (
int *)
HECMW_malloc(
sizeof(
int) * n_import_node);
4507 if (import_node[neighbor_idx] ==
NULL) {
4512 rtc = create_comm_node_pre(global_mesh, node_flag, import_node, neighbor_idx,
4524 const char *node_flag,
int **export_node,
4525 int neighbor_idx,
int current_domain,
4526 int neighbor_domain) {
4527 int n_export_node, rtc;
4530 count_masked_comm_node(global_mesh, node_flag, current_domain);
4534 local_mesh->
export_index[neighbor_idx] + n_export_node;
4536 export_node[neighbor_idx] = (
int *)
HECMW_malloc(
sizeof(
int) * n_export_node);
4537 if (export_node[neighbor_idx] ==
NULL) {
4542 rtc = create_comm_node_pre(global_mesh, node_flag, export_node, neighbor_idx,
4554 const char *elem_flag,
int **shared_elem,
4555 int neighbor_idx,
int neighbor_domain) {
4556 int n_shared_elem, rtc;
4558 if (is_spdup_available(global_mesh)) {
4560 count_masked_shared_elem_mod(global_mesh, elem_flag, neighbor_domain);
4562 n_shared_elem = count_masked_shared_elem(global_mesh, elem_flag);
4568 local_mesh->
shared_index[neighbor_idx] + n_shared_elem;
4570 shared_elem[neighbor_idx] = (
int *)
HECMW_malloc(
sizeof(
int) * n_shared_elem);
4571 if (shared_elem[neighbor_idx] ==
NULL) {
4576 if (is_spdup_available(global_mesh)) {
4577 rtc = create_shared_elem_pre_mod(global_mesh, elem_flag, shared_elem,
4578 neighbor_idx, neighbor_domain);
4580 rtc = create_shared_elem_pre(global_mesh, elem_flag, shared_elem,
4594 char *node_flag,
char *elem_flag,
4595 char *node_flag_neighbor,
4596 char *elem_flag_neighbor,
int current_domain) {
4597 int **import_node =
NULL;
4598 int **export_node =
NULL;
4599 int **shared_elem =
NULL;
4600 int neighbor_domain;
4613 if (import_node ==
NULL) {
4618 import_node[i] =
NULL;
4622 if (export_node ==
NULL) {
4627 export_node[i] =
NULL;
4631 if (shared_elem ==
NULL) {
4636 shared_elem[i] =
NULL;
4662 rtc = mask_mesh_status_nb(global_mesh, node_flag_neighbor,
4663 elem_flag_neighbor, neighbor_domain);
4666 if (is_spdup_available(global_mesh)) {
4667 rtc = mask_comm_node_mod(global_mesh, node_flag, node_flag_neighbor,
4670 rtc = mask_comm_node(global_mesh, node_flag, node_flag_neighbor);
4675 if (is_spdup_available(global_mesh)) {
4676 rtc = mask_comm_elem_mod(global_mesh, elem_flag, elem_flag_neighbor,
4679 rtc = mask_comm_elem(global_mesh, elem_flag, elem_flag_neighbor);
4684 rtc = create_import_info_nb(global_mesh, local_mesh, node_flag, import_node,
4685 i, neighbor_domain);
4688 rtc = create_export_info_nb(global_mesh, local_mesh, node_flag, export_node,
4689 i, current_domain, neighbor_domain);
4692 rtc = create_shared_info_nb(global_mesh, local_mesh, elem_flag, shared_elem,
4693 i, neighbor_domain);
4696 if (is_spdup_available(global_mesh)) {
4698 rtc = spdup_clear_IEB(node_flag_neighbor, elem_flag_neighbor,
4702 rtc = spdup_clear_MMbnd(node_flag_neighbor, elem_flag_neighbor,
4706 rtc = spdup_clear_MMbnd(node_flag, elem_flag, current_domain);
4709 for (j = 0; j < global_mesh->
n_node; j++) {
4712 for (j = 0; j < global_mesh->
n_elem; j++) {
4716 memset(node_flag_neighbor, 0,
sizeof(
char) * global_mesh->
n_node);
4717 memset(elem_flag_neighbor, 0,
sizeof(
char) * global_mesh->
n_elem);
4728 rtc = create_comm_item(local_mesh->
n_neighbor_pe, import_node,
4745 rtc = create_comm_item(local_mesh->
n_neighbor_pe, export_node,
4762 rtc = create_comm_item(local_mesh->
n_neighbor_pe, shared_elem,
4818 const char *elem_flag,
int **import_elem,
4819 int neighbor_idx,
int neighbor_domain) {
4820 int n_import_elem, rtc;
4823 count_masked_comm_elem(global_mesh, elem_flag, neighbor_domain);
4827 local_mesh->
import_index[neighbor_idx] + n_import_elem;
4829 import_elem[neighbor_idx] = (
int *)
HECMW_malloc(
sizeof(
int) * n_import_elem);
4830 if (import_elem[neighbor_idx] ==
NULL) {
4835 rtc = create_comm_elem_pre(global_mesh, elem_flag, import_elem, neighbor_idx,
4847 const char *elem_flag,
int **export_elem,
4848 int neighbor_idx,
int current_domain,
4849 int neighbor_domain) {
4850 int n_export_elem, rtc;
4853 count_masked_comm_elem(global_mesh, elem_flag, current_domain);
4857 local_mesh->
export_index[neighbor_idx] + n_export_elem;
4859 export_elem[neighbor_idx] = (
int *)
HECMW_malloc(
sizeof(
int) * n_export_elem);
4860 if (export_elem[neighbor_idx] ==
NULL) {
4865 rtc = create_comm_elem_pre(global_mesh, elem_flag, export_elem, neighbor_idx,
4877 const char *node_flag,
int **shared_node,
4878 int neighbor_idx,
int neighbor_domain) {
4879 int n_shared_node, rtc;
4881 n_shared_node = count_masked_shared_node(global_mesh, node_flag);
4885 local_mesh->
shared_index[neighbor_idx] + n_shared_node;
4887 shared_node[neighbor_idx] = (
int *)
HECMW_malloc(
sizeof(
int) * n_shared_node);
4888 if (shared_node[neighbor_idx] ==
NULL) {
4894 create_shared_node_pre(global_mesh, node_flag, shared_node, neighbor_idx);
4907 char *node_flag,
char *elem_flag,
4908 char *node_flag_neighbor,
4909 char *elem_flag_neighbor,
int current_domain) {
4910 int **import_elem =
NULL;
4911 int **export_elem =
NULL;
4912 int **shared_node =
NULL;
4913 int neighbor_domain;
4927 if (import_elem ==
NULL) {
4932 import_elem[i] =
NULL;
4936 if (export_elem ==
NULL) {
4941 export_elem[i] =
NULL;
4945 if (shared_node ==
NULL) {
4950 shared_node[i] =
NULL;
4977 for (j = 0; j < global_mesh->
n_node; j++) {
4981 for (j = 0; j < global_mesh->
n_elem; j++) {
4986 memset(node_flag_neighbor, 0,
sizeof(
char) * global_mesh->
n_node);
4987 memset(elem_flag_neighbor, 0,
sizeof(
char) * global_mesh->
n_elem);
4990 rtc = mask_mesh_status_eb(global_mesh, node_flag_neighbor,
4991 elem_flag_neighbor, neighbor_domain);
4994 rtc = mask_comm_node(global_mesh, node_flag, node_flag_neighbor);
4997 rtc = mask_comm_elem(global_mesh, elem_flag, elem_flag_neighbor);
5001 rtc = create_import_info_eb(global_mesh, local_mesh, elem_flag, import_elem,
5002 i, neighbor_domain);
5006 rtc = create_export_info_eb(global_mesh, local_mesh, elem_flag, export_elem,
5007 i, current_domain, neighbor_domain);
5011 rtc = create_shared_info_eb(global_mesh, local_mesh, node_flag, shared_node,
5012 i, neighbor_domain);
5024 rtc = create_comm_item(local_mesh->
n_neighbor_pe, import_elem,
5042 rtc = create_comm_item(local_mesh->
n_neighbor_pe, export_elem,
5060 rtc = create_comm_item(local_mesh->
n_neighbor_pe, shared_node,
5115 char *node_flag,
char *elem_flag,
5116 char *node_flag_neighbor,
char *elem_flag_neighbor,
5117 int current_domain) {
5129 rtc = create_comm_info_nb(global_mesh, local_mesh, node_flag, elem_flag,
5130 node_flag_neighbor, elem_flag_neighbor,
5137 rtc = create_comm_info_eb(global_mesh, local_mesh, node_flag, elem_flag,
5138 node_flag_neighbor, elem_flag_neighbor,
5164 static int set_node_global2local_internal(
5167 const char *node_flag,
int domain) {
5177 for (counter = 0, i = 0; i < n_int_nlist[domain]; i++) {
5178 node = int_nlist[domain][i];
5179 node_global2local[node - 1] = ++counter;
5186 static int set_node_global2local_external(
5189 const char *node_flag) {
5200 for (counter = local_mesh->
nn_internal, i = 0; i < global_mesh->n_node; i++) {
5203 node_global2local[i] = ++counter;
5210 for (i = 0; i < global_mesh->
n_node; i++) {
5213 node_global2local[i] = ++counter;
5216 local_mesh->
n_node = counter;
5225 static int set_node_global2local_external_mod(
5228 const char *node_flag,
int domain) {
5238 for (counter = local_mesh->
nn_internal, i = n_bnd_nlist[2 * domain];
5239 i < n_bnd_nlist[2 * domain + 1]; i++) {
5240 node = bnd_nlist[domain][i];
5241 node_global2local[node - 1] = ++counter;
5243 local_mesh->
n_node = counter;
5251 static int set_node_global2local_all(
5254 const char *node_flag) {
5264 for (counter = 0, i = 0; i < global_mesh->
n_node; i++) {
5266 node_global2local[i] = ++counter;
5269 local_mesh->
n_node = counter;
5279 const char *node_flag) {
5288 for (counter = 0, i = 0; i < global_mesh->
n_node; i++) {
5296 static int const_node_internal_list(
5299 const char *node_flag) {
5321 for (counter = 0, i = 0; i < global_mesh->
n_node; i++) {
5337 int *node_global2local,
const char *node_flag,
5338 int current_domain) {
5349 rtc = set_node_global2local_internal(global_mesh, local_mesh,
5350 node_global2local, node_flag,
5354 if (is_spdup_available(global_mesh)) {
5355 rtc = set_node_global2local_external_mod(global_mesh, local_mesh,
5356 node_global2local, node_flag,
5359 rtc = set_node_global2local_external(global_mesh, local_mesh,
5360 node_global2local, node_flag);
5371 rtc = const_nn_internal(global_mesh, local_mesh, node_flag);
5374 rtc = set_node_global2local_all(global_mesh, local_mesh,
5375 node_global2local, node_flag);
5378 rtc = const_node_internal_list(global_mesh, local_mesh, node_global2local,
5399 int *node_global2local,
int domain) {
5407 if (is_spdup_available(global_mesh)) {
5408 for (i = 0; i < n_int_nlist[domain]; i++) {
5409 node = int_nlist[domain][i];
5410 node_global2local[node - 1] = 0;
5412 for (i = n_bnd_nlist[2 * domain]; i < n_bnd_nlist[2 * domain + 1]; i++) {
5413 node = bnd_nlist[domain][i];
5414 node_global2local[node - 1] = 0;
5417 for (i = 0; i < global_mesh->
n_node; i++) {
5418 node_global2local[i] = 0;
5429 const int *node_global2local,
5430 int *node_local2global) {
5440 for (counter = 0, i = 0; i < global_mesh->
n_node; i++) {
5441 if (node_global2local[i]) {
5442 node_local2global[node_global2local[i] - 1] = i + 1;
5452 static int set_node_local2global_mod(
5455 int *node_local2global,
int domain) {
5457 int i, idx1, idx2, node1, node2, n_int, n_bnd, n_out, maxn;
5465 n_int = n_int_nlist[domain];
5466 n_bnd = n_bnd_nlist[2 * domain];
5467 n_out = n_bnd_nlist[2 * domain + 1] - n_bnd_nlist[2 * domain];
5468 maxn = global_mesh->
n_node + 1;
5470 node1 = (n_int == 0) ? maxn : int_nlist[domain][0];
5471 node2 = (n_out == 0) ? maxn : bnd_nlist[domain][n_bnd];
5472 for (counter = 0, idx1 = 0, idx2 = 0, i = 0; i < n_int + n_out; i++) {
5473 if (node1 < node2) {
5474 node_local2global[node_global2local[node1 - 1] - 1] = node1;
5476 node1 = (idx1 == n_int) ? maxn : int_nlist[domain][idx1];
5478 node_local2global[node_global2local[node2 - 1] - 1] = node2;
5480 node2 = (idx2 == n_out) ? maxn : bnd_nlist[domain][idx2 + n_bnd];
5492 static int set_elem_global2local_internal(
5495 const char *elem_flag) {
5505 for (counter = 0, i = 0; i < global_mesh->
n_elem; i++) {
5507 elem_global2local[i] = ++counter;
5515 static int set_elem_global2local_external(
5518 const char *elem_flag) {
5528 for (counter = local_mesh->
ne_internal, i = 0; i < global_mesh->n_elem; i++) {
5530 elem_global2local[i] = ++counter;
5533 local_mesh->
n_elem = counter;
5541 static int set_elem_global2local_all(
5544 const char *elem_flag) {
5554 for (counter = 0, i = 0; i < global_mesh->
n_elem; i++) {
5556 elem_global2local[i] = ++counter;
5559 local_mesh->
n_elem = counter;
5568 static int set_elem_global2local_all_mod(
5571 const char *elem_flag,
int domain) {
5573 int i, idx1, idx2, elem1, elem2, n_int, n_bnd, n_out, maxe;
5581 n_int = n_int_elist[domain];
5582 n_bnd = n_bnd_elist[2 * domain];
5583 n_out = n_bnd_elist[2 * domain + 1] - n_bnd_elist[2 * domain];
5584 maxe = global_mesh->
n_elem + 1;
5586 elem1 = (n_int == 0) ? maxe : int_elist[domain][0];
5587 elem2 = (n_out == 0) ? maxe : bnd_elist[domain][n_bnd];
5588 for (counter = 0, idx1 = 0, idx2 = 0, i = 0; i < n_int + n_out; i++) {
5589 if (elem1 < elem2) {
5590 elem_global2local[elem1 - 1] = ++counter;
5592 elem1 = (idx1 == n_int) ? maxe : int_elist[domain][idx1];
5594 elem_global2local[elem2 - 1] = ++counter;
5596 elem2 = (idx2 == n_out) ? maxe : bnd_elist[domain][idx2 + n_bnd];
5600 local_mesh->
n_elem = counter;
5610 const char *elem_flag) {
5616 for (counter = 0, i = 0; i < global_mesh->
n_elem; i++) {
5625 static int const_elem_internal_list(
5628 const char *elem_flag,
int domain) {
5650 for (counter = 0, i = 0; i < n_int_elist[domain]; i++) {
5651 elem = int_elist[domain][i];
5665 int *elem_global2local,
const char *elem_flag,
5666 int current_domain) {
5677 local_mesh->
ne_internal = n_int_elist[current_domain];
5679 if (is_spdup_available(global_mesh)) {
5680 rtc = set_elem_global2local_all_mod(global_mesh, local_mesh,
5681 elem_global2local, elem_flag,
5684 rtc = set_elem_global2local_all(global_mesh, local_mesh,
5685 elem_global2local, elem_flag);
5690 rtc = const_elem_internal_list(global_mesh, local_mesh, elem_global2local,
5691 elem_flag, current_domain);
5699 rtc = set_elem_global2local_internal(global_mesh, local_mesh,
5700 elem_global2local, elem_flag);
5703 rtc = set_elem_global2local_external(global_mesh, local_mesh,
5704 elem_global2local, elem_flag);
5725 int *elem_global2local,
int domain) {
5733 if (is_spdup_available(global_mesh)) {
5734 for (i = 0; i < n_int_elist[domain]; i++) {
5735 elem = int_elist[domain][i];
5736 elem_global2local[elem - 1] = 0;
5738 for (i = n_bnd_elist[2 * domain]; i < n_bnd_elist[2 * domain + 1]; i++) {
5739 elem = bnd_elist[domain][i];
5740 elem_global2local[elem - 1] = 0;
5744 for (i = 0; i < global_mesh->
n_elem; i++) {
5745 elem_global2local[i] = 0;
5756 const int *elem_global2local,
5757 int *elem_local2global) {
5767 for (counter = 0, i = 0; i < global_mesh->
n_elem; i++) {
5768 if (elem_global2local[i]) {
5769 elem_local2global[elem_global2local[i] - 1] = i + 1;
5779 static int set_elem_local2global_mod(
5782 int *elem_local2global,
int domain) {
5784 int i, idx1, idx2, elem1, elem2, n_int, n_bnd, n_out, maxe;
5792 n_int = n_int_elist[domain];
5793 n_bnd = n_bnd_elist[2 * domain];
5794 n_out = n_bnd_elist[2 * domain + 1] - n_bnd_elist[2 * domain];
5795 maxe = global_mesh->
n_elem + 1;
5797 elem1 = (n_int == 0) ? maxe : int_elist[domain][0];
5798 elem2 = (n_out == 0) ? maxe : bnd_elist[domain][n_bnd];
5799 for (counter = 0, idx1 = 0, idx2 = 0, i = 0; i < n_int + n_out; i++) {
5800 if (elem1 < elem2) {
5801 elem_local2global[elem_global2local[elem1 - 1] - 1] = elem1;
5803 elem1 = (idx1 == n_int) ? maxe : int_elist[domain][idx1];
5805 elem_local2global[elem_global2local[elem2 - 1] - 1] = elem2;
5807 elem2 = (idx2 == n_out) ? maxe : bnd_elist[domain][idx2 + n_bnd];
5854 static int const_hecmw_flag_initcon(
5862 static int const_hecmw_flag_parttype(
5870 static int const_hecmw_flag_partdepth(
5878 static int const_hecmw_flag_version(
5886 static int const_hecmw_flag_partcontact(
5908 rtc = const_gridfile(global_mesh, local_mesh);
5911 rtc = const_hecmw_n_file(global_mesh, local_mesh);
5914 rtc = const_files(global_mesh, local_mesh);
5917 rtc = const_header(global_mesh, local_mesh);
5920 rtc = const_hecmw_flag_adapt(global_mesh, local_mesh);
5923 rtc = const_hecmw_flag_initcon(global_mesh, local_mesh);
5926 rtc = const_hecmw_flag_parttype(global_mesh, local_mesh);
5929 rtc = const_hecmw_flag_partdepth(global_mesh, local_mesh);
5932 rtc = const_hecmw_flag_version(global_mesh, local_mesh);
5935 rtc = const_hecmw_flag_partcontact(global_mesh, local_mesh);
5938 rtc = const_zero_temp(global_mesh, local_mesh);
5974 const char *node_flag) {
5988 for (counter = 0, i = 0; i < global_mesh->
n_dof_grp; i++) {
5990 j < global_mesh->node_dof_index[i + 1]; j++) {
6005 static int const_node_dof_index_mod(
6021 for (counter = 0, i = 0; i < global_mesh->
n_dof_grp; i++) {
6022 for (j = 0; j < n_int_nlist[domain]; j++) {
6023 node = int_nlist[domain][j];
6024 if (node <= global_mesh->node_dof_index[i])
continue;
6048 const int *node_local2global) {
6061 for (i = 0; i < local_mesh->
n_node; i++) {
6062 local_mesh->
node[3 * i] = global_mesh->
node[3 * (node_local2global[i] - 1)];
6063 local_mesh->
node[3 * i + 1] =
6064 global_mesh->
node[3 * (node_local2global[i] - 1) + 1];
6065 local_mesh->
node[3 * i + 2] =
6066 global_mesh->
node[3 * (node_local2global[i] - 1) + 2];
6077 const int *node_local2global) {
6090 for (i = 0; i < local_mesh->
n_node; i++) {
6092 global_mesh->
node_ID[2 * (node_local2global[i] - 1)];
6093 local_mesh->
node_ID[2 * i + 1] =
6094 global_mesh->
node_ID[2 * (node_local2global[i] - 1) + 1];
6105 const int *node_local2global) {
6118 for (i = 0; i < local_mesh->
n_node; i++) {
6129 static int const_node_init_val_index(
6146 for (i = 0; i < local_mesh->
n_node; i++) {
6147 old_idx = node_local2global[i] - 1;
6161 static int const_node_init_val_item(
6166 int i, j, gstart, gend, lstart, lend;
6185 for (counter = 0, i = 0; i < local_mesh->
n_node; i++) {
6193 for (j = 0; j < lend - lstart; j++) {
6209 const int *node_local2global,
const char *node_flag,
6210 int current_domain) {
6218 rtc = const_n_dof(global_mesh, local_mesh);
6221 rtc = const_n_dof_grp(global_mesh, local_mesh);
6226 rtc = const_node_dof_index_mod(global_mesh, local_mesh, node_flag,
6230 rtc = const_node_dof_index(global_mesh, local_mesh, node_flag);
6239 rtc = const_node_dof_item(global_mesh, local_mesh);
6242 rtc = const_node(global_mesh, local_mesh, node_local2global);
6245 rtc = const_node_id(global_mesh, local_mesh, node_local2global);
6248 rtc = const_global_node_id(global_mesh, local_mesh, node_local2global);
6252 rtc = const_node_init_val_index(global_mesh, local_mesh, node_local2global);
6255 rtc = const_node_init_val_item(global_mesh, local_mesh, node_local2global);
6281 const int *elem_local2global) {
6293 for (i = 0; i < local_mesh->
n_elem; i++) {
6305 const int *elem_global2local) {
6320 for (counter = 0, i = 0; i < global_mesh->
n_elem_type; i++) {
6322 j < global_mesh->elem_type_index[i + 1]; j++) {
6323 if (elem_global2local[j]) counter++;
6337 static int const_elem_type_index_mod(
6342 int i, j, idx1, idx2, elem_tmp, elem1, elem2, n_int, n_bnd, n_out, maxe;
6355 n_int = n_int_elist[domain];
6356 n_bnd = n_bnd_elist[2 * domain];
6357 n_out = n_bnd_elist[2 * domain + 1] - n_bnd_elist[2 * domain];
6358 maxe = global_mesh->
n_elem + 1;
6360 for (counter = 0, i = 0; i < global_mesh->
n_elem_type; i++) {
6361 elem1 = (n_int == 0) ? maxe : int_elist[domain][0];
6362 elem2 = (n_out == 0) ? maxe : bnd_elist[domain][n_bnd];
6363 for (idx1 = 0, idx2 = 0, j = 0; j < n_int + n_out; j++) {
6364 if (elem1 < elem2) {
6365 elem_tmp = elem1 - 1;
6367 elem1 = (idx1 == n_int) ? maxe : int_elist[domain][idx1];
6369 elem_tmp = elem2 - 1;
6371 elem2 = (idx2 == n_out) ? maxe : bnd_elist[domain][idx2 + n_bnd];
6374 elem_tmp < global_mesh->elem_type_index[i + 1]) {
6401 const int *elem_local2global) {
6415 for (i = 0; i < local_mesh->
n_elem; i++) {
6416 old_idx = elem_local2global[i] - 1;
6432 const int *node_global2local,
6433 const int *elem_local2global) {
6437 int i, j, gstart, gend, lstart, lend;
6451 for (counter = 0, i = 0; i < local_mesh->
n_elem; i++) {
6457 for (j = 0; j < lend - lstart; j++) {
6459 local_mesh->
elem_node_item[lstart + j] = node_global2local[node - 1];
6473 const int *elem_local2global) {
6486 for (i = 0; i < local_mesh->
n_elem; i++) {
6488 global_mesh->
elem_ID[2 * (elem_local2global[i] - 1)];
6489 local_mesh->
elem_ID[2 * i + 1] =
6490 global_mesh->
elem_ID[2 * (elem_local2global[i] - 1) + 1];
6501 const int *elem_local2global) {
6514 for (i = 0; i < local_mesh->
n_elem; i++) {
6527 const int *elem_local2global) {
6540 for (i = 0; i < local_mesh->
n_elem; i++) {
6542 global_mesh->
section_ID[elem_local2global[i] - 1];
6553 const int *elem_local2global) {
6567 for (i = 0; i < local_mesh->
n_elem; i++) {
6568 old_idx = elem_local2global[i] - 1;
6593 const int *elem_local2global) {
6596 int i, j, gstart, gend, lstart, lend;
6613 for (counter = 0, i = 0; i < local_mesh->
n_elem; i++) {
6621 for (j = 0; j < lend - lstart; j++) {
6638 const int *node_global2local,
6639 const int *elem_global2local,
6640 const int *elem_local2global,
int current_domain) {
6649 rtc = const_n_elem_type(global_mesh, local_mesh);
6652 rtc = const_elem_type(global_mesh, local_mesh, elem_local2global);
6655 if (is_spdup_available(global_mesh)) {
6656 rtc = const_elem_type_index_mod(global_mesh, local_mesh, elem_global2local,
6659 rtc = const_elem_type_index(global_mesh, local_mesh, elem_global2local);
6664 rtc = const_elem_type_item(global_mesh, local_mesh);
6667 rtc = const_elem_node_index(global_mesh, local_mesh, elem_local2global);
6670 rtc = const_elem_node_item(global_mesh, local_mesh, node_global2local,
6674 rtc = const_elem_id(global_mesh, local_mesh, elem_local2global);
6677 rtc = const_global_elem_id(global_mesh, local_mesh, elem_local2global);
6680 rtc = const_section_id(global_mesh, local_mesh, elem_local2global);
6683 rtc = const_elem_mat_id_index(global_mesh, local_mesh, elem_local2global);
6686 rtc = const_n_elem_mat_id(local_mesh);
6689 rtc = const_elem_mat_id_item(global_mesh, local_mesh, elem_local2global);
6709 int current_domain) {
6710 local_mesh->
zero = (current_domain == 0) ? 1 : 0;
6730 int current_domain) {
6731 local_mesh->
my_rank = current_domain;
6751 const int *global2local) {
6766 new_id = global2local[local_mesh->
import_item[i] - 1];
6774 const int *global2local) {
6789 new_id = global2local[local_mesh->
export_item[i] - 1];
6797 const int *global2local) {
6812 new_id = global2local[local_mesh->
shared_item[i] - 1];
6821 const int *node_global2local,
6822 const int *elem_global2local,
int current_domain) {
6830 rtc = const_hecmw_comm(global_mesh, local_mesh);
6833 rtc = const_zero(local_mesh, current_domain);
6836 rtc = const_petot(global_mesh, local_mesh);
6839 rtc = const_pesmptot(global_mesh, local_mesh);
6842 rtc = const_my_rank(local_mesh, current_domain);
6845 rtc = const_errnof(global_mesh, local_mesh);
6848 rtc = const_n_subdomain(global_mesh, local_mesh);
6853 rtc = const_import_item(local_mesh, node_global2local);
6856 rtc = const_export_item(local_mesh, node_global2local);
6859 rtc = const_shared_item(local_mesh, elem_global2local);
6865 rtc = const_import_item(local_mesh, elem_global2local);
6868 rtc = const_export_item(local_mesh, elem_global2local);
6871 rtc = const_shared_item(local_mesh, node_global2local);
6905 static int const_when_i_was_refined_node(
6913 static int const_when_i_was_refined_elem(
6949 static int const_adapt_children_index(
6957 static int const_adapt_children_item(
6972 rtc = const_n_adapt(global_mesh, local_mesh);
6975 rtc = const_coarse_grid_level(global_mesh, local_mesh);
6978 rtc = const_when_i_was_refined_node(global_mesh, local_mesh);
6981 rtc = const_when_i_was_refined_elem(global_mesh, local_mesh);
6984 rtc = const_adapt_parent_type(global_mesh, local_mesh);
6987 rtc = const_adapt_type(global_mesh, local_mesh);
6990 rtc = const_adapt_level(global_mesh, local_mesh);
6993 rtc = const_adapt_parent(global_mesh, local_mesh);
6996 rtc = const_adapt_children_index(global_mesh, local_mesh);
6999 rtc = const_adapt_children_item(global_mesh, local_mesh);
7085 rtc = const_n_sect(global_mesh, local_mesh);
7088 rtc = const_sect_type(global_mesh, local_mesh);
7091 rtc = const_sect_opt(global_mesh, local_mesh);
7094 rtc = const_sect_mat_id_index(global_mesh, local_mesh);
7097 rtc = const_sect_mat_id_item(global_mesh, local_mesh);
7100 rtc = const_sect_i_index(global_mesh, local_mesh);
7103 rtc = const_sect_i_item(global_mesh, local_mesh);
7106 rtc = const_sect_r_index(global_mesh, local_mesh);
7109 rtc = const_sect_r_item(global_mesh, local_mesh);
7202 rtc = const_n_mat(global_mesh, local_mesh);
7205 rtc = const_n_mat_item(global_mesh, local_mesh);
7208 rtc = const_n_mat_subitem(global_mesh, local_mesh);
7211 rtc = const_n_mat_table(global_mesh, local_mesh);
7214 rtc = const_mat_name(global_mesh, local_mesh);
7217 rtc = const_mat_item_index(global_mesh, local_mesh);
7220 rtc = const_mat_subitem_index(global_mesh, local_mesh);
7223 rtc = const_mat_table_index(global_mesh, local_mesh);
7226 rtc = const_mat_val(global_mesh, local_mesh);
7229 rtc = const_mat_temp(global_mesh, local_mesh);
7243 const int *node_global2local,
char *mpc_flag) {
7246 int node, diff, evalsum, counter;
7249 for (counter = 0, i = 0; i < mpc_global->
n_mpc; i++) {
7256 if (node_global2local[node - 1] > 0) evalsum++;
7259 if (evalsum == diff) {
7264 mpc_local->
n_mpc = counter;
7271 const char *mpc_flag) {
7283 for (counter = 0, i = 0; i < mpc_global->
n_mpc; i++) {
7301 const int *node_global2local,
const char *mpc_flag) {
7304 int mcounter, icounter;
7314 for (mcounter = 0, icounter = 0, i = 0; i < mpc_global->
n_mpc; i++) {
7319 node_global2local[mpc_global->
mpc_item[j] - 1];
7335 const char *mpc_flag) {
7338 int mcounter, icounter;
7348 for (mcounter = 0, icounter = 0, i = 0; i < mpc_global->
n_mpc; i++) {
7368 const char *mpc_flag) {
7372 int mcounter, icounter;
7382 for (mcounter = 0, icounter = 0, i = 0; i < mpc_global->
n_mpc; i++) {
7402 const char *mpc_flag) {
7409 size =
sizeof(double) * mpc_local->
n_mpc;
7416 for (icounter = 0, i = 0; i < mpc_global->
n_mpc; i++) {
7432 const int *node_global2local) {
7433 char *mpc_flag =
NULL;
7442 if (global_mesh->
mpc->
n_mpc == 0) {
7443 init_struct_mpc(local_mesh);
7448 if (mpc_flag ==
NULL) {
7453 rtc = const_n_mpc(global_mesh, local_mesh, node_global2local, mpc_flag);
7457 init_struct_mpc(local_mesh);
7462 rtc = const_mpc_index(global_mesh, local_mesh, mpc_flag);
7465 rtc = const_mpc_item(global_mesh, local_mesh, node_global2local, mpc_flag);
7468 rtc = const_mpc_dof(global_mesh, local_mesh, mpc_flag);
7471 rtc = const_mpc_val(global_mesh, local_mesh, mpc_flag);
7474 rtc = const_mpc_const(global_mesh, local_mesh, mpc_flag);
7504 static int const_amp_type_definition(
7556 if (global_mesh->
amp->
n_amp == 0) {
7557 init_struct_amp(local_mesh);
7561 rtc = const_n_amp(global_mesh, local_mesh);
7564 rtc = const_amp_name(global_mesh, local_mesh);
7567 rtc = const_amp_type_definition(global_mesh, local_mesh);
7570 rtc = const_amp_type_time(global_mesh, local_mesh);
7573 rtc = const_amp_type_value(global_mesh, local_mesh);
7576 rtc = const_amp_index(global_mesh, local_mesh);
7579 rtc = const_amp_val(global_mesh, local_mesh);
7582 rtc = const_amp_table(global_mesh, local_mesh);
7594 static int *const_node_grp_mask_eqn(
7597 int eqn_block_idx) {
7599 int *n_eqn_item =
NULL;
7601 int i, j, is, ie, js;
7603 is = node_group_global->
grp_index[eqn_block_idx];
7604 ie = node_group_global->
grp_index[eqn_block_idx + 1];
7606 n_eqn_item = (
int *)
HECMW_malloc(
sizeof(
int) * (ie - is));
7607 if (n_eqn_item ==
NULL) {
7612 for (js = 0, i = 0; i < ie - is; i++) {
7613 diff = node_group_global->
grp_item[is + i] - js;
7614 for (evalsum = 0, j = js; j < node_group_global->
grp_item[is + i]; j++) {
7615 if (node_global2local[j] > 0 &&
7622 n_eqn_item[i] = diff;
7627 js = node_group_global->
grp_item[is + i];
7652 const int *node_global2local,
7653 const int *n_eqn_item,
int eqn_block_idx) {
7667 for (counter = 0, i = 0; i < node_group_global->
n_grp; i++) {
7668 if (i != eqn_block_idx) {
7669 for (j = node_group_global->
grp_index[i];
7670 j < node_group_global->
grp_index[i + 1]; j++) {
7671 node = node_group_global->
grp_item[j];
7672 if (node_global2local[node - 1]) counter++;
7678 for (j = 0; j < diff; j++) {
7679 if (n_eqn_item[j] > 0) counter++;
7683 node_group_local->
grp_index[i + 1] = counter;
7693 static int const_node_grp_index_mod(
7696 const int *n_eqn_item,
int eqn_block_idx,
int domain) {
7710 for (counter = 0, i = 0; i < node_group_global->
n_grp; i++) {
7711 if (i != eqn_block_idx) {
7712 if (node_group_global->
grp_index[i + 1] -
7715 counter += n_int_nlist[domain];
7716 counter += n_bnd_nlist[2 * domain + 1] - n_bnd_nlist[2 * domain];
7718 counter += ngrp_idx[domain][i + 1] - ngrp_idx[domain][i];
7731 for (j = 0; j < diff; j++) {
7732 if (n_eqn_item[j] > 0) counter++;
7736 node_group_local->
grp_index[i + 1] = counter;
7747 const int *node_global2local,
7748 const int *n_eqn_item,
int eqn_block_idx) {
7754 int i, j, k, js, je, ks, ls;
7756 size =
sizeof(int) * node_group_local->
grp_index[node_group_local->
n_grp];
7763 for (counter = 0, i = 0; i < node_group_global->
n_grp; i++) {
7764 if (i != eqn_block_idx) {
7765 for (j = node_group_global->
grp_index[i];
7766 j < node_group_global->
grp_index[i + 1]; j++) {
7767 node = node_group_global->
grp_item[j];
7768 if (node_global2local[node - 1]) {
7769 node_group_local->
grp_item[counter++] = node_global2local[node - 1];
7775 je = node_group_global->
grp_index[i + 1];
7776 for (ks = 0, ls = 0, j = js; j < je; j++) {
7777 if (n_eqn_item[j - js]) {
7779 node_group_global->
grp_item[j] - ks);
7780 node_group_local->
grp_item[counter] = ls + n_eqn_item[j - js];
7782 for (k = ks; k < node_group_global->
grp_item[j]; k++) {
7784 node_global2local[k] <=
7785 node_group_local->
grp_item[counter]);
7787 ls = node_group_local->
grp_item[counter];
7790 ks = node_group_global->
grp_item[j];
7805 const int *node_global2local,
7806 const int *n_eqn_item,
int eqn_block_idx,
7813 int i, j, k, js, je, ks, ls;
7814 int idx1, idx2, node1, node2, n_int, n_bnd, n_out, maxn;
7816 size =
sizeof(int) * node_group_local->
grp_index[node_group_local->
n_grp];
7823 n_int = n_int_nlist[domain];
7824 n_bnd = n_bnd_nlist[2 * domain];
7825 n_out = n_bnd_nlist[2 * domain + 1] - n_bnd_nlist[2 * domain];
7826 maxn = global_mesh->
n_node + 1;
7828 for (counter = 0, i = 0; i < node_group_global->
n_grp; i++) {
7829 if (i != eqn_block_idx) {
7830 if (node_group_global->
grp_index[i + 1] -
7835 node1 = (n_int == 0) ? maxn : int_nlist[domain][0];
7836 node2 = (n_out == 0) ? maxn : bnd_nlist[domain][n_bnd];
7837 for (j = 0; j < n_int + n_out; j++) {
7838 if (node1 < node2) {
7839 node_group_local->
grp_item[counter++] =
7840 node_global2local[node1 - 1];
7842 node1 = (idx1 == n_int) ? maxn : int_nlist[domain][idx1];
7844 node_group_local->
grp_item[counter++] =
7845 node_global2local[node2 - 1];
7847 node2 = (idx2 == n_out) ? maxn : bnd_nlist[domain][idx2 + n_bnd];
7851 if (ngrp_idx[domain][i + 1] - ngrp_idx[domain][i] == 0)
continue;
7852 for (j = ngrp_idx[domain][i]; j < ngrp_idx[domain][i + 1]; j++) {
7853 node = ngrp_item[domain][j];
7854 node_group_local->
grp_item[counter++] = node_global2local[node - 1];
7859 je = node_group_global->
grp_index[i + 1];
7860 for (ks = 0, ls = 0, j = js; j < je; j++) {
7861 if (n_eqn_item[j - js]) {
7863 node_group_global->
grp_item[j] - ks);
7864 node_group_local->
grp_item[counter] = ls + n_eqn_item[j - js];
7866 for (k = ks; k < node_group_global->
grp_item[j]; k++) {
7868 node_global2local[k] <=
7869 node_group_local->
grp_item[counter]);
7871 ls = node_group_local->
grp_item[counter];
7874 ks = node_group_global->
grp_item[j];
7888 const int *node_global2local,
7889 int current_domain) {
7890 int *n_eqn_item =
NULL;
7901 init_struct_node_grp(local_mesh);
7905 eqn_block_idx = search_eqn_block_idx(global_mesh);
7907 if (eqn_block_idx >= 0) {
7908 n_eqn_item = const_node_grp_mask_eqn(global_mesh, local_mesh,
7909 node_global2local, eqn_block_idx);
7910 if (n_eqn_item ==
NULL)
goto error;
7913 rtc = const_node_n_grp(global_mesh, local_mesh);
7916 rtc = const_node_grp_name(global_mesh, local_mesh);
7919 if (is_spdup_available(global_mesh)) {
7920 rtc = const_node_grp_index_mod(global_mesh, local_mesh, node_global2local,
7921 n_eqn_item, eqn_block_idx, current_domain);
7923 rtc = const_node_grp_item_mod(global_mesh, local_mesh, node_global2local,
7924 n_eqn_item, eqn_block_idx, current_domain);
7928 rtc = const_node_grp_index(global_mesh, local_mesh, node_global2local,
7929 n_eqn_item, eqn_block_idx);
7931 rtc = const_node_grp_item(global_mesh, local_mesh, node_global2local,
7932 n_eqn_item, eqn_block_idx);
7965 const int *elem_global2local) {
7979 for (counter = 0, i = 0; i < elem_group_global->
n_grp; i++) {
7980 for (j = elem_group_global->
grp_index[i];
7981 j < elem_group_global->
grp_index[i + 1]; j++) {
7982 elem = elem_group_global->
grp_item[j];
7983 if (elem_global2local[elem - 1]) counter++;
7985 elem_group_local->
grp_index[i + 1] = counter;
7995 static int const_elem_grp_index_mod(
8003 int i, j, idx1, idx2, elem1, elem2;
8012 for (counter = 0, i = 0; i < elem_group_global->
n_grp; i++) {
8015 counter += n_int_elist[domain];
8016 counter += n_bnd_elist[2 * domain + 1] - n_bnd_elist[2 * domain];
8018 counter += egrp_idx[domain][i + 1] - egrp_idx[domain][i];
8020 elem_group_local->
grp_index[i + 1] = counter;
8031 const int *elem_global2local) {
8039 size =
sizeof(int) * elem_group_local->
grp_index[elem_group_local->
n_grp];
8046 for (counter = 0, i = 0; i < elem_group_global->
n_grp; i++) {
8047 for (j = elem_group_global->
grp_index[i];
8048 j < elem_group_global->
grp_index[i + 1]; j++) {
8049 elem = elem_group_global->
grp_item[j];
8050 if (elem_global2local[elem - 1]) {
8051 elem_group_local->
grp_item[counter++] = elem_global2local[elem - 1];
8066 const int *elem_global2local,
int domain) {
8072 int i, j, idx1, idx2, elem1, elem2, n_int, n_bnd, n_out, maxe;
8074 size =
sizeof(int) * elem_group_local->
grp_index[elem_group_local->
n_grp];
8081 n_int = n_int_elist[domain];
8082 n_bnd = n_bnd_elist[2 * domain];
8083 n_out = n_bnd_elist[2 * domain + 1] - n_bnd_elist[2 * domain];
8084 maxe = global_mesh->
n_elem + 1;
8086 for (counter = 0, i = 0; i < elem_group_global->
n_grp; i++) {
8089 elem1 = (n_int == 0) ? maxe : int_elist[domain][0];
8090 elem2 = (n_out == 0) ? maxe : bnd_elist[domain][n_bnd];
8091 for (idx1 = 0, idx2 = 0, j = 0; j < n_int + n_out; j++) {
8092 if (elem1 < elem2) {
8093 elem_group_local->
grp_item[counter++] = elem_global2local[elem1 - 1];
8095 elem1 = (idx1 == n_int) ? maxe : int_elist[domain][idx1];
8097 elem_group_local->
grp_item[counter++] = elem_global2local[elem2 - 1];
8099 elem2 = (idx2 == n_out) ? maxe : bnd_elist[domain][idx2 + n_bnd];
8103 if (egrp_idx[domain][i + 1] - egrp_idx[domain][i] == 0)
continue;
8104 for (j = egrp_idx[domain][i]; j < egrp_idx[domain][i + 1]; j++) {
8105 elem = egrp_item[domain][j];
8106 elem_group_local->
grp_item[counter++] = elem_global2local[elem - 1];
8120 const int *elem_global2local,
8121 int current_domain) {
8131 init_struct_elem_grp(local_mesh);
8135 rtc = const_elem_n_grp(global_mesh, local_mesh);
8138 rtc = const_elem_grp_name(global_mesh, local_mesh);
8141 if (is_spdup_available(global_mesh)) {
8142 rtc = const_elem_grp_index_mod(global_mesh, local_mesh, elem_global2local,
8145 rtc = const_elem_grp_item_mod(global_mesh, local_mesh, elem_global2local,
8150 rtc = const_elem_grp_index(global_mesh, local_mesh, elem_global2local);
8152 rtc = const_elem_grp_item(global_mesh, local_mesh, elem_global2local);
8181 const int *elem_global2local) {
8195 for (counter = 0, i = 0; i < surf_group_global->
n_grp; i++) {
8196 for (j = surf_group_global->
grp_index[i];
8197 j < surf_group_global->
grp_index[i + 1]; j++) {
8198 elem = surf_group_global->
grp_item[2 * j];
8199 if (elem_global2local[elem - 1]) counter++;
8201 surf_group_local->
grp_index[i + 1] = counter;
8212 const int *elem_global2local) {
8220 size =
sizeof(int) * surf_group_local->
grp_index[surf_group_local->
n_grp] * 2;
8227 for (counter = 0, i = 0; i < surf_group_global->
n_grp; i++) {
8228 for (j = surf_group_global->
grp_index[i];
8229 j < surf_group_global->
grp_index[i + 1]; j++) {
8230 elem = surf_group_global->
grp_item[2 * j];
8231 surf = surf_group_global->
grp_item[2 * j + 1];
8232 if (elem_global2local[elem - 1]) {
8233 surf_group_local->
grp_item[2 * counter] = elem_global2local[elem - 1];
8234 surf_group_local->
grp_item[2 * counter + 1] = surf;
8249 const int *elem_global2local) {
8259 init_struct_surf_grp(local_mesh);
8263 rtc = const_surf_n_grp(global_mesh, local_mesh);
8266 rtc = const_surf_grp_name(global_mesh, local_mesh);
8269 rtc = const_surf_grp_index(global_mesh, local_mesh, elem_global2local);
8272 rtc = const_surf_grp_item(global_mesh, local_mesh, elem_global2local);
8284 static int const_contact_pair_n_pair(
8311 for (i = 0; i < cpair_global->
n_pair; i++) {
8312 cpair_local->
type[i] = cpair_global->
type[i];
8321 static int const_contact_pair_slave_grp_id(
8335 for (i = 0; i < cpair_global->
n_pair; i++) {
8345 static int const_contact_pair_slave_orisgrp_id(
8359 for (i = 0; i < cpair_global->
n_pair; i++) {
8369 static int const_contact_pair_master_grp_id(
8383 for (i = 0; i < cpair_global->
n_pair; i++) {
8403 init_struct_contact_pair(local_mesh);
8407 rtc = const_contact_pair_n_pair(global_mesh, local_mesh);
8410 rtc = const_contact_pair_name(global_mesh, local_mesh);
8413 rtc = const_contact_pair_type(global_mesh, local_mesh);
8416 rtc = const_contact_pair_slave_grp_id(global_mesh, local_mesh);
8419 rtc = const_contact_pair_slave_orisgrp_id(global_mesh, local_mesh);
8422 rtc = const_contact_pair_master_grp_id(global_mesh, local_mesh);
8437 const char *node_flag,
const char *elem_flag,
8438 int *node_global2local,
int *elem_global2local,
8439 int current_domain) {
8440 int *node_local2global =
NULL;
8441 int *elem_local2global =
NULL;
8446 rtc = set_node_global2local(global_mesh, local_mesh, node_global2local,
8447 node_flag, current_domain);
8451 if (node_local2global ==
NULL) {
8456 if (is_spdup_available(global_mesh)) {
8457 rtc = set_node_local2global_mod(global_mesh, local_mesh, node_global2local,
8458 node_local2global, current_domain);
8460 rtc = set_node_local2global(global_mesh, local_mesh, node_global2local,
8466 rtc = set_elem_global2local(global_mesh, local_mesh, elem_global2local,
8467 elem_flag, current_domain);
8472 if (elem_local2global ==
NULL) {
8477 if (is_spdup_available(global_mesh)) {
8478 rtc = set_elem_local2global_mod(global_mesh, local_mesh, elem_global2local,
8479 elem_local2global, current_domain);
8481 rtc = set_elem_local2global(global_mesh, local_mesh, elem_global2local,
8487 rtc = const_global_info(global_mesh, local_mesh);
8490 rtc = const_node_info(global_mesh, local_mesh, node_local2global, node_flag,
8494 rtc = const_elem_info(global_mesh, local_mesh, node_global2local,
8495 elem_global2local, elem_local2global, current_domain);
8498 rtc = const_comm_info(global_mesh, local_mesh, node_global2local,
8499 elem_global2local, current_domain);
8502 rtc = const_adapt_info(global_mesh, local_mesh);
8505 rtc = const_sect_info(global_mesh, local_mesh);
8508 rtc = const_mat_info(global_mesh, local_mesh);
8511 rtc = const_mpc_info(global_mesh, local_mesh, node_global2local);
8514 rtc = const_amp_info(global_mesh, local_mesh);
8517 rtc = const_node_grp_info(global_mesh, local_mesh, node_global2local,
8521 rtc = const_elem_grp_info(global_mesh, local_mesh, elem_global2local,
8525 rtc = const_surf_grp_info(global_mesh, local_mesh, elem_global2local);
8528 rtc = const_contact_pair_info(global_mesh, local_mesh);
8531 rtc = clear_node_global2local(global_mesh, local_mesh, node_global2local,
8533 rtc = clear_elem_global2local(global_mesh, local_mesh, elem_global2local,
8546 clean_struct_local_mesh(local_mesh);
8557 static int print_ucd_entire_set_node_data(
8572 result_data->
nn_dof[0] = 1;
8592 strcpy(result_data->
node_label[0],
"rank_of_node");
8594 for (nn_item = 0, i = 0; i < result_data->
nn_component; i++) {
8595 nn_item += result_data->
nn_dof[i];
8598 size =
sizeof(double) * nn_item * global_mesh->
n_node;
8607 for (i = 0; i < global_mesh->
n_node; i++) {
8613 for (i = 0; i < global_mesh->
n_node; i++) {
8619 (double)global_mesh->
node_ID[2 * i + 1];
8633 free_struct_result_data(result_data);
8641 static int print_ucd_entire_set_elem_data(
8656 result_data->
ne_dof[0] = 1;
8676 strcpy(result_data->
elem_label[0],
"partitioning_image");
8679 for (i = 0; i < global_mesh->
n_elem; i++) {
8699 for (ne_item = 0, i = 0; i < result_data->
ne_component; i++) {
8700 ne_item += result_data->
ne_dof[i];
8703 size =
sizeof(double) * ne_item * global_mesh->
n_elem;
8712 for (i = 0; i < global_mesh->
n_elem; i++) {
8718 (double)global_mesh->
elem_ID[2 * i + 1];
8724 for (i = 0; i < global_mesh->
n_elem; i++) {
8738 free_struct_result_data(result_data);
8746 const char *node_flag,
const char *elem_flag,
8747 const char *ofname) {
8752 if (result_data ==
NULL) {
8756 init_struct_result_data(result_data);
8759 if (print_ucd_entire_set_node_data(global_mesh, result_data, node_flag)) {
8763 if (print_ucd_entire_set_elem_data(global_mesh, result_data, elem_flag)) {
8771 free_struct_result_data(result_data);
8776 free_struct_result_data(result_data);
8849 char *node_flag =
NULL;
8850 char *elem_flag =
NULL;
8851 char *node_flag_neighbor =
NULL;
8852 char *elem_flag_neighbor =
NULL;
8853 int *node_global2local =
NULL;
8854 int *elem_global2local =
NULL;
8856 int *num_elem, *num_node, *num_ielem, *num_inode, *num_nbpe;
8857 int *sum_elem, *sum_node, *sum_ielem, *sum_inode, *sum_nbpe;
8858 int current_domain,
nrank, iS, iE;
8861 int error_in_ompsection = 0;
8863 if (global_mesh ==
NULL) {
8872 rtc = init_partition(global_mesh,
cont_data);
8878 if (global_mesh->
my_rank == 0) {
8897 if (global_mesh->
my_rank == 0) {
8902 "part_out", global_mesh->
n_subdomain, current_domain);
8903 if (ofheader ==
NULL) {
8905 error_in_ompsection = 1;
8908 if (ofheader->
n_mesh == 0) {
8910 error_in_ompsection = 1;
8919 "Starting writing local mesh for domain #%d...",
8933 if (rtc != 0)
goto error;
8935 if (rtc != 0)
goto error;
8937 if (rtc != 0)
goto error;
8939 if (rtc != 0)
goto error;
8942 if (rtc)
goto error;
8950 if (num_elem ==
NULL) {
8955 if (num_node ==
NULL) {
8960 if (num_ielem ==
NULL) {
8965 if (num_inode ==
NULL) {
8970 if (num_nbpe ==
NULL) {
8975 if (sum_elem ==
NULL) {
8980 if (sum_node ==
NULL) {
8985 if (sum_ielem ==
NULL) {
8990 if (sum_inode ==
NULL) {
8995 if (sum_nbpe ==
NULL) {
9000 rtc = wnumbering(global_mesh,
cont_data);
9004 rtc = spdup_makelist_main(global_mesh);
9008 #pragma omp parallel default(none), \
9009 private(node_flag, elem_flag, local_mesh, nrank, iS, iE, i, \
9010 current_domain, rtc, ofheader, ofname), \
9011 private(node_global2local, elem_global2local, \
9012 node_flag_neighbor, elem_flag_neighbor), \
9013 shared(global_mesh, cont_data, num_elem, num_node, \
9014 num_ielem, num_inode, num_nbpe, error_in_ompsection)
9019 if (node_flag ==
NULL) {
9021 error_in_ompsection = 1;
9025 if (elem_flag ==
NULL) {
9027 error_in_ompsection = 1;
9033 if (node_global2local ==
NULL) {
9035 error_in_ompsection = 1;
9039 if (elem_global2local ==
NULL) {
9041 error_in_ompsection = 1;
9044 node_flag_neighbor =
9046 if (node_flag_neighbor ==
NULL) {
9048 error_in_ompsection = 1;
9051 elem_flag_neighbor =
9053 if (elem_flag_neighbor ==
NULL) {
9055 error_in_ompsection = 1;
9058 memset(node_flag_neighbor, 0,
sizeof(
char) * global_mesh->
n_node);
9059 memset(elem_flag_neighbor, 0,
sizeof(
char) * global_mesh->
n_elem);
9062 if (local_mesh ==
NULL) {
9063 error_in_ompsection = 1;
9074 #pragma omp for schedule(dynamic, 1), reduction(+ : error_in_ompsection)
9076 for (i = iS; i < iE; i++) {
9077 if (error_in_ompsection)
continue;
9084 rtc = create_neighbor_info(global_mesh, local_mesh, node_flag, elem_flag,
9087 error_in_ompsection = 1;
9092 rtc = create_comm_info(global_mesh, local_mesh, node_flag, elem_flag,
9093 node_flag_neighbor, elem_flag_neighbor,
9096 error_in_ompsection = 1;
9101 rtc = const_local_data(global_mesh, local_mesh,
cont_data, node_flag,
9102 elem_flag, node_global2local, elem_global2local,
9105 error_in_ompsection = 1;
9109 num_elem[i] = local_mesh->
n_elem;
9110 num_node[i] = local_mesh->
n_node;
9116 "part_out", global_mesh->
n_subdomain, current_domain);
9117 if (ofheader ==
NULL) {
9119 error_in_ompsection = 1;
9122 if (ofheader->
n_mesh == 0) {
9124 error_in_ompsection = 1;
9133 "Starting writing local mesh for domain #%d...",
9140 error_in_ompsection = 1;
9146 clean_struct_local_mesh(local_mesh);
9151 if (is_spdup_available(global_mesh)) {
9153 spdup_clear_IEB(node_flag, elem_flag, current_domain);
9156 for (j = 0; j < global_mesh->
n_node; j++) {
9159 for (j = 0; j < global_mesh->
n_elem; j++) {
9165 if (error_in_ompsection)
goto error_omp;
9170 if (global_mesh->
my_rank == 0) {
9171 print_ucd_entire(global_mesh, node_flag, elem_flag,
9188 if (error_in_ompsection)
goto error;
9193 if (rtc != 0)
goto error;
9196 if (rtc != 0)
goto error;
9199 if (rtc != 0)
goto error;
9202 if (rtc != 0)
goto error;
9205 if (rtc != 0)
goto error;
9207 if (global_mesh->
my_rank == 0) {
9210 if (rtc != 0)
goto error;
9212 if (rtc != 0)
goto error;
9214 if (rtc != 0)
goto error;
9216 if (rtc != 0)
goto error;
9218 if (rtc != 0)
goto error;
9221 if (rtc)
goto error;
9237 spdup_freelist(global_mesh);
9270 if (global_mesh ==
NULL) {
9279 if (local_mesh ==
NULL)
goto error;
HECMW_Comm HECMW_comm_get_comm(void)
int HECMW_Allreduce(void *sendbuf, void *recvbuf, int count, HECMW_Datatype datatype, HECMW_Op op, HECMW_Comm comm)
int HECMW_comm_get_rank(void)
int HECMW_comm_get_size(void)
#define HECMW_ETYPE_ROD31
#define HECMW_FILENAME_LEN
void HECMW_ctrl_free_meshfiles(struct hecmw_ctrl_meshfiles *meshfiles)
struct hecmw_ctrl_meshfiles * HECMW_ctrl_get_meshfiles_header_sub(char *name_ID, int n_rank, int i_rank)
struct hecmwST_local_mesh * HECMW_dist_alloc()
void HECMW_dist_free(struct hecmwST_local_mesh *mesh)
struct hecmwST_local_mesh * mesh
int HECMW_set_error(int errorno, const char *fmt,...)
int HECMW_is_etype_link(int etype)
int HECMW_graph_degeneGraph(struct hecmw_graph *graph, const struct hecmw_graph *refgraph, int num_part, const int *parttab)
const int * HECMW_graph_getEdgeIndex(const struct hecmw_graph *graph)
const int * HECMW_graph_getEdgeItem(const struct hecmw_graph *graph)
void HECMW_graph_finalize(struct hecmw_graph *graph)
int HECMW_graph_init_with_arrays(struct hecmw_graph *graph, int num_vertex, int *edge_index, int *edge_item)
int HECMW_graph_init(struct hecmw_graph *graph)
int HECMW_put_dist_mesh(const struct hecmwST_local_mesh *mesh, char *fname)
int HECMW_log(int loglv, const char *fmt,...)
#define HECMW_calloc(nmemb, size)
#define HECMW_malloc(size)
int HECMW_mesh_edge_info(struct hecmwST_local_mesh *local_mesh, struct hecmw_part_edge_data *edge_data)
long long int HECMW_mesh_hsort_edge(int node1, int node2)
long long int HECMW_mesh_hsort_edge_get_n(void)
void HECMW_mesh_hsort_edge_final(void)
int HECMW_mesh_hsort_edge_init(int n_node, int n_elem)
int * HECMW_mesh_hsort_edge_get_v(void)
#define HECMW_PART_METHOD_PMETIS
#define HECMW_PART_RCB_Z_AXIS
#define HECMW_PART_E_STACK_OVERFLOW
#define HECMW_PART_E_INVALID_RCB_DIR
#define HECMW_PART_RCB_Y_AXIS
#define HECMW_PART_E_INVALID_PMETHOD
#define HECMW_PART_E_INVALID_PTYPE
#define HECMW_PART_RCB_X_AXIS
#define HECMW_PART_METHOD_RCB
#define HECMW_PART_CONTACT_DEFAULT
#define HECMW_PART_E_INV_ARG
#define HECMW_PART_EQUATION_BLOCK_NAME
#define HECMW_PART_TYPE_NODE_BASED
#define HECMW_PART_METHOD_KMETIS
#define HECMW_PART_CONTACT_DISTRIBUTE
#define HECMW_PART_CONTACT_SIMPLE
#define HECMW_PART_CONTACT_AGGREGATE
#define HECMW_PART_E_NNEIGHBORPE_LOWER
#define HECMW_PART_TYPE_ELEMENT_BASED
void HECMW_part_free_control(struct hecmw_part_cont_data *cont_data)
struct hecmw_part_cont_data * HECMW_part_get_control(void)
int HECMW_part_set_log_n_neighbor_pe(int domain, int _n_neighbor_pe)
int HECMW_part_set_log_part_contact(int _part_contact)
int HECMW_part_set_log_part_type(int _part_type)
void HECMW_part_finalize_log(void)
int HECMW_part_set_log_n_node_g(int _n_node_g)
int HECMW_part_set_log_part_depth(int _depth)
int HECMW_part_set_log_n_node(int domain, int _n_node)
int HECMW_part_set_log_n_elem(int domain, int _n_elem)
int HECMW_part_init_log(int _n_domain)
int HECMW_part_print_log(void)
int HECMW_part_set_log_n_edgecut(long long int _n_edge, int _n_edgecut)
int HECMW_part_set_log_nn_internal(int domain, int _nn_internal)
int HECMW_part_set_log_n_elem_g(int _n_elem_g)
int HECMW_part_set_log_part_method(int _part_method)
int HECMW_part_set_log_ne_internal(int domain, int _ne_internal)
struct hecmwST_local_mesh * HECMW_partition(struct hecmwST_local_mesh *global_mesh)
#define CLEAR_BIT(map, bit)
#define EVAL_BIT(map, bit)
#define MASK_BIT(map, bit)
struct hecmwST_local_mesh * HECMW_partition_inner(struct hecmwST_local_mesh *global_mesh, struct hecmw_part_cont_data *cont_data)
struct result_list * node_list
#define HECMW_FLAG_PARTCONTACT_SIMPLE
#define HECMW_CONTACT_TYPE_NODE_SURF
#define HECMW_FLAG_PARTCONTACT_AGGREGATE
#define HECMW_FLAG_PARTCONTACT_DISTRIBUTE
#define HECMW_CONTACT_TYPE_SURF_SURF
#define HECMW_FLAG_PARTTYPE_NODEBASED
#define HECMW_FLAG_PARTTYPE_ELEMBASED
int HECMW_ucd_legacy_print(const struct hecmwST_local_mesh *mesh, const struct hecmwST_result_data *result, const char *ofname)
void HECMW_abort(HECMW_Comm comm)
#define HECMW_assert(cond)
struct option_rec options[]
specify command line option name and executing function name. \attension list must be terminated with...
struct hecmw_ctrl_meshfile * meshfiles
int * amp_type_definition
struct hecmwST_section * section
int * adapt_children_item
double * elem_mat_int_val
int * adapt_children_index
struct hecmwST_amplitude * amp
struct hecmwST_material * material
struct hecmwST_node_grp * node_group
double * node_init_val_item
struct hecmwST_contact_pair * contact_pair
struct hecmwST_surf_grp * surf_group
char gridfile[HECMW_FILENAME_LEN+1]
char header[HECMW_HEADER_LEN+1]
int hecmw_flag_partcontact
struct hecmwST_elem_grp * elem_group
int * node_init_val_index
int * when_i_was_refined_node
int * when_i_was_refined_elem
struct result_list * next