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);
317 for (j = 1; j < counter; j++) {
318 if (bnd_nlist[domain][j - 1] != bnd_nlist[domain][j]) {
319 bnd_nlist[domain][i] = bnd_nlist[domain][j];
327 n_bnd_nlist[2 * domain + 1] = i;
336 int bnd_and_int, bnd_not_int;
337 int n_nlist, n_elist;
340 n_nlist = n_bnd_nlist[2 * domain + 1];
350 for (i = 0; i < n_nlist; i++) {
351 node = bnd_nlist[domain][i];
352 if (global_mesh->
node_ID[2 * node - 1] == domain) {
353 work[bnd_and_int] = node;
357 for (i = 0; i < n_nlist; i++) {
358 node = bnd_nlist[domain][i];
359 if (global_mesh->
node_ID[2 * node - 1] != domain) {
360 work[bnd_and_int + bnd_not_int] = node;
364 n_bnd_nlist[2 * domain] = bnd_and_int;
365 n_bnd_nlist[2 * domain + 1] = bnd_and_int + bnd_not_int;
370 bnd_nlist[domain] = (
int *)
HECMW_calloc(n_nlist,
sizeof(
int));
371 if (bnd_nlist[domain] ==
NULL) {
375 for (i = 0; i < n_nlist; i++) {
376 bnd_nlist[domain][i] = work[i];
381 n_elist = n_bnd_elist[2 * domain + 1];
391 for (i = 0; i < n_elist; i++) {
392 elem = bnd_elist[domain][i];
393 if (global_mesh->
elem_ID[2 * elem - 1] == domain) {
394 work[bnd_and_int] = elem;
398 for (i = 0; i < n_elist; i++) {
399 elem = bnd_elist[domain][i];
400 if (global_mesh->
elem_ID[2 * elem - 1] != domain) {
401 work[bnd_and_int + bnd_not_int] = elem;
405 n_bnd_elist[2 * domain] = bnd_and_int;
406 n_bnd_elist[2 * domain + 1] = bnd_and_int + bnd_not_int;
407 for (i = 0; i < n_elist; i++) {
408 bnd_elist[domain][i] = work[i];
422 int node, elem, n_domain, domain[20], flag;
429 n_bnd_nlist[2 * i] = 0;
430 n_bnd_nlist[2 * i + 1] = 0;
432 n_bnd_elist[2 * i] = 0;
433 n_bnd_elist[2 * i + 1] = 0;
437 for (i = 0; i < global_mesh->
n_node; i++) {
438 current_domain = global_mesh->
node_ID[2 * i + 1];
439 int_nlist[current_domain][n_int_nlist[current_domain]] = i + 1;
440 n_int_nlist[current_domain]++;
444 for (i = 0; i < global_mesh->
n_elem; i++) {
445 current_domain = global_mesh->
elem_ID[2 * i + 1];
446 int_elist[current_domain][n_int_elist[current_domain]] = i + 1;
447 n_int_elist[current_domain]++;
451 for (i = 0; i < global_mesh->
n_elem; i++) {
456 domain[0] = global_mesh->
node_ID[2 * node - 1];
457 for (j = js + 1; j < je; j++) {
459 for (flag = 0, k = 0; k < n_domain; k++) {
460 if (global_mesh->
node_ID[2 * node - 1] == domain[k]) {
466 domain[n_domain] = global_mesh->
node_ID[2 * node - 1];
472 for (j = 0; j < n_domain; j++) {
473 bnd_elist[domain[j]][n_bnd_elist[2 * domain[j] + 1]] = i + 1;
474 n_bnd_elist[2 * domain[j] + 1]++;
481 rtc = get_boundary_nodelist(global_mesh, i);
486 rtc = sort_and_resize_bndlist(global_mesh, i);
496 static int spdup_make_node_grouplist(
499 int i, j, k, node, n_bnd, n_out;
500 int *n_domain =
NULL;
507 if (n_domain ==
NULL) {
513 n_bnd = n_bnd_nlist[2 * i];
514 n_out = n_bnd_nlist[2 * i + 1] - n_bnd_nlist[2 * i];
515 if (n_out == 0)
continue;
516 for (j = 0; j < n_out; j++) {
517 node = bnd_nlist[i][n_bnd + j];
518 n_domain[node - 1]++;
523 if (domain ==
NULL) {
527 for (i = 0; i < global_mesh->
n_node; i++) {
530 if (domain[i] ==
NULL) {
534 domain[i][0] = global_mesh->
node_ID[2 * i + 1];
538 n_bnd = n_bnd_nlist[2 * i];
539 n_out = n_bnd_nlist[2 * i + 1] - n_bnd_nlist[2 * i];
540 if (n_out == 0)
continue;
541 for (j = 0; j < n_out; j++) {
542 node = bnd_nlist[i][n_bnd + j];
543 domain[node - 1][n_domain[node - 1]] = i;
544 n_domain[node - 1]++;
550 if (ngrp_idx ==
NULL) {
557 if (ngrp_idx[i] ==
NULL) {
562 for (i = 0; i < node_group_global->
n_grp; i++) {
564 ngrp_idx[j][i + 1] = ngrp_idx[j][i];
570 for (j = node_group_global->
grp_index[i];
571 j < node_group_global->
grp_index[i + 1]; j++) {
572 node = node_group_global->
grp_item[j];
573 for (k = 0; k < n_domain[node - 1]; k++) {
574 current_domain = domain[node - 1][k];
575 ngrp_idx[current_domain][i + 1]++;
582 if (ngrp_item ==
NULL) {
589 if (ngrp_item[i] ==
NULL) {
595 for (i = 0; i < node_group_global->
n_grp; i++) {
600 for (j = node_group_global->
grp_index[i];
601 j < node_group_global->
grp_index[i + 1]; j++) {
602 node = node_group_global->
grp_item[j];
603 for (k = 0; k < n_domain[node - 1]; k++) {
604 current_domain = domain[node - 1][k];
605 ngrp_item[current_domain][counter[current_domain]] = node;
606 counter[current_domain]++;
611 for (i = 0; i < global_mesh->
n_node; i++) {
622 static int spdup_make_element_grouplist(
625 int i, j, k, elem, n_bnd, n_out;
626 int *n_domain =
NULL;
633 if (n_domain ==
NULL) {
639 n_bnd = n_bnd_elist[2 * i];
640 n_out = n_bnd_elist[2 * i + 1] - n_bnd_elist[2 * i];
641 if (n_out == 0)
continue;
642 for (j = 0; j < n_out; j++) {
643 elem = bnd_elist[i][n_bnd + j];
644 n_domain[elem - 1]++;
649 if (domain ==
NULL) {
653 for (i = 0; i < global_mesh->
n_elem; i++) {
656 if (domain[i] ==
NULL) {
660 domain[i][0] = global_mesh->
elem_ID[2 * i + 1];
664 n_bnd = n_bnd_elist[2 * i];
665 n_out = n_bnd_elist[2 * i + 1] - n_bnd_elist[2 * i];
666 if (n_out == 0)
continue;
667 for (j = 0; j < n_out; j++) {
668 elem = bnd_elist[i][n_bnd + j];
669 domain[elem - 1][n_domain[elem - 1]] = i;
670 n_domain[elem - 1]++;
676 if (egrp_idx ==
NULL) {
683 if (egrp_idx[i] ==
NULL) {
688 for (i = 0; i < elem_group_global->
n_grp; i++) {
690 egrp_idx[j][i + 1] = egrp_idx[j][i];
696 for (j = elem_group_global->
grp_index[i];
697 j < elem_group_global->
grp_index[i + 1]; j++) {
698 elem = elem_group_global->
grp_item[j];
699 for (k = 0; k < n_domain[elem - 1]; k++) {
700 current_domain = domain[elem - 1][k];
701 egrp_idx[current_domain][i + 1]++;
708 if (egrp_item ==
NULL) {
715 if (egrp_item[i] ==
NULL) {
721 for (i = 0; i < elem_group_global->
n_grp; i++) {
726 for (j = elem_group_global->
grp_index[i];
727 j < elem_group_global->
grp_index[i + 1]; j++) {
728 elem = elem_group_global->
grp_item[j];
729 for (k = 0; k < n_domain[elem - 1]; k++) {
730 current_domain = domain[elem - 1][k];
731 egrp_item[current_domain][counter[current_domain]] = elem;
732 counter[current_domain]++;
737 for (i = 0; i < global_mesh->
n_elem; i++) {
751 rtc = spdup_init_list(global_mesh);
754 rtc = spdup_make_list(global_mesh);
757 rtc = spdup_make_node_grouplist(global_mesh);
760 rtc = spdup_make_element_grouplist(global_mesh);
806 static char *get_dist_file_name(
char *header,
int domain,
char *fname) {
809 sprintf(s_domain,
"%d", domain);
811 strcpy(fname, header);
813 strcat(fname, s_domain);
818 static void free_link_list(
struct link_unit *llist) {
821 for (p = llist; p; p = q) {
831 if (local_mesh ==
NULL) {
857 if (local_mesh ==
NULL) {
871 local_mesh->
n_dof = 0;
889 if (local_mesh ==
NULL) {
929 if (local_mesh ==
NULL) {
934 local_mesh->
zero = 0;
935 local_mesh->
PETOT = 0;
958 if (local_mesh ==
NULL) {
981 if (local_mesh ==
NULL) {
1007 if (local_mesh ==
NULL) {
1034 if (local_mesh ==
NULL) {
1038 if (local_mesh->
mpc ==
NULL) {
1057 if (local_mesh ==
NULL) {
1062 if (local_mesh->
amp ==
NULL) {
1083 if (local_mesh ==
NULL) {
1112 if (local_mesh ==
NULL) {
1140 if (local_mesh ==
NULL) {
1168 if (local_mesh ==
NULL) {
1175 "\'local_mesh->contact_pair\' is NULL");
1195 if (local_mesh ==
NULL)
return;
1197 init_struct_global(local_mesh);
1201 if (local_mesh ==
NULL)
return;
1206 if (local_mesh->
node) {
1225 init_struct_node(local_mesh);
1229 if (local_mesh ==
NULL)
return;
1262 init_struct_elem(local_mesh);
1266 if (local_mesh ==
NULL)
return;
1290 init_struct_comm(local_mesh);
1294 if (local_mesh ==
NULL)
return;
1296 init_struct_adapt(local_mesh);
1300 if (local_mesh ==
NULL)
return;
1303 init_struct_sect(local_mesh);
1307 if (local_mesh ==
NULL)
return;
1310 init_struct_mat(local_mesh);
1314 if (local_mesh ==
NULL)
return;
1315 if (local_mesh->
mpc ==
NULL)
return;
1323 init_struct_mpc(local_mesh);
1327 if (local_mesh ==
NULL)
return;
1328 if (local_mesh->
amp ==
NULL)
return;
1330 init_struct_amp(local_mesh);
1334 if (local_mesh ==
NULL)
return;
1344 init_struct_node_grp(local_mesh);
1348 if (local_mesh ==
NULL)
return;
1358 init_struct_elem_grp(local_mesh);
1362 if (local_mesh ==
NULL)
return;
1372 init_struct_surf_grp(local_mesh);
1376 if (local_mesh ==
NULL)
return;
1392 init_struct_contact_pair(local_mesh);
1396 if (local_mesh ==
NULL)
return;
1398 clean_struct_global(local_mesh);
1399 clean_struct_node(local_mesh);
1400 clean_struct_elem(local_mesh);
1401 clean_struct_comm(local_mesh);
1402 clean_struct_adapt(local_mesh);
1403 clean_struct_sect(local_mesh);
1404 clean_struct_mat(local_mesh);
1405 clean_struct_mpc(local_mesh);
1406 clean_struct_amp(local_mesh);
1407 clean_struct_node_grp(local_mesh);
1408 clean_struct_elem_grp(local_mesh);
1409 clean_struct_surf_grp(local_mesh);
1410 clean_struct_contact_pair(local_mesh);
1417 if (result_data ==
NULL) {
1439 if (result_data ==
NULL)
return;
1479 static int quick_sort(
int no,
int n,
double *arr,
int *brr,
int *istack) {
1492 for (j = l + 1; j <= ir; j++) {
1495 for (i = j - 1; i >= l; i--) {
1496 if (arr[i] <= a)
break;
1497 arr[i + 1] = arr[i];
1498 brr[i + 1] = brr[i];
1504 if (!jstack)
return 0;
1506 ir = istack[jstack];
1507 l = istack[jstack - 1];
1513 DSWAP(arr[k], arr[l + 1])
1514 ISWAP(brr[k], brr[l + 1])
1516 if (arr[l] > arr[ir]) {
1517 DSWAP(arr[l], arr[ir])
1518 ISWAP(brr[l], brr[ir])
1521 if (arr[l + 1] > arr[ir]) {
1522 DSWAP(arr[l + 1], arr[ir])
1523 ISWAP(brr[l + 1], brr[ir])
1526 if (arr[l] > arr[l + 1]) {
1527 DSWAP(arr[l], arr[l + 1])
1528 ISWAP(brr[l], brr[l + 1])
1546 DSWAP(arr[i], arr[j])
1547 ISWAP(brr[i], brr[j])
1550 arr[l + 1] = arr[j];
1552 brr[l + 1] = brr[j];
1557 if (jstack > nstack) {
1562 if (ir - i + 1 >= j - l) {
1563 istack[jstack] = ir;
1564 istack[jstack - 1] = i;
1567 istack[jstack] = j - 1;
1568 istack[jstack - 1] = l;
1578 static int rcb_partition(
int n,
const double *coord,
int *wnum,
1592 if (stack ==
NULL) {
1597 if (value ==
NULL) {
1602 for (i = 0; i <
cont_data->n_rcb_div; i++) {
1603 for (j = 0; j < pow(2, i); j++) {
1608 for (k = 0; k < n; k++) {
1609 if (wnum[2 * k + 1] == j) {
1611 value[counter] = coord[3 * k];
1618 for (k = 0; k < n; k++) {
1619 if (wnum[2 * k + 1] == j) {
1621 value[counter] = coord[3 * k + 1];
1628 for (k = 0; k < n; k++) {
1629 if (wnum[2 * k + 1] == j) {
1631 value[counter] = coord[3 * k + 2];
1643 rtc = quick_sort(n, counter, value,
id, stack);
1647 for (k = 0; k < counter *
F_1_2; k++) {
1648 wnum[2 *
id[k] + 1] = j + (int)pow(2, i);
1671 double coord_x, coord_y, coord_z;
1676 for (i = 0; i < global_mesh->
n_elem; i++) {
1680 for (coord_x = 0.0, coord_y = 0.0, coord_z = 0.0, j = js; j < je; j++) {
1683 coord_x += global_mesh->
node[3 * (node - 1)];
1684 coord_y += global_mesh->
node[3 * (node - 1) + 1];
1685 coord_z += global_mesh->
node[3 * (node - 1) + 2];
1688 coord[3 * i] = coord_x / (je - js);
1689 coord[3 * i + 1] = coord_y / (je - js);
1690 coord[3 * i + 2] = coord_z / (je - js);
1698 double *coord =
NULL;
1702 if (coord ==
NULL) {
1707 rtc = calc_gravity(global_mesh, coord);
1710 rtc = rcb_partition(global_mesh->
n_elem, coord, global_mesh->
elem_ID,
1726 static int create_node_graph_link_list(
1732 for (i = 0; i < edge_data->
n_edge; i++) {
1739 if (graph[node1 - 1]->last->next ==
NULL) {
1744 graph[node1 - 1]->
n += 1;
1752 if (graph[node2 - 1]->last->next ==
NULL) {
1757 graph[node2 - 1]->
n += 1;
1769 static int create_node_graph_compress(
1771 int *node_graph_index,
int *node_graph_item) {
1776 for (counter = 0, i = 0; i < global_mesh->
n_node; i++) {
1777 node_graph_index[i + 1] = node_graph_index[i] + graph[i]->
n;
1779 for (p = graph[i]->list, j = 0; j < graph[i]->
n; j++) {
1781 node_graph_item[counter++] = p->
id - 1;
1790 int *node_graph_index,
int *node_graph_item) {
1797 if (graph ==
NULL) {
1801 for (i = 0; i < global_mesh->
n_node; i++) {
1805 for (i = 0; i < global_mesh->
n_node; i++) {
1807 if (graph[i] ==
NULL) {
1814 for (i = 0; i < global_mesh->
n_node; i++) {
1816 if (graph[i]->list ==
NULL) {
1826 rtc = create_node_graph_link_list(global_mesh, edge_data, graph);
1829 rtc = create_node_graph_compress(global_mesh, graph, node_graph_index,
1833 for (i = 0; i < global_mesh->
n_node; i++) {
1834 free_link_list(graph[i]->list);
1843 for (i = 0; i < global_mesh->
n_node; i++) {
1845 free_link_list(graph[i]->list);
1870 if (node_list ==
NULL) {
1874 for (i = 0; i < global_mesh->
n_node; i++) {
1875 node_list[i] =
NULL;
1878 for (i = 0; i < global_mesh->
n_node; i++) {
1880 if (node_list[i] ==
NULL) {
1887 for (i = 0; i < global_mesh->
n_node; i++) {
1888 node_list[i]->
list =
1890 if (node_list[i]->list ==
NULL) {
1894 node_list[i]->
n = 0;
1896 node_list[i]->
last = node_list[i]->
list;
1900 for (i = 0; i < global_mesh->
n_elem; i++) {
1902 j < global_mesh->elem_node_index[i + 1]; j++) {
1907 if (node_list[node - 1]->last->next ==
NULL) {
1912 node_list[node - 1]->
last = node_list[node - 1]->
last->
next;
1913 node_list[node - 1]->
last->
id = i + 1;
1915 node_list[node - 1]->
n += 1;
1925 for (i = 0; i < global_mesh->
n_node; i++) {
1936 for (counter = 0, i = 0; i < global_mesh->
n_node; i++) {
1937 for (p = node_list[i]->list, j = 0; j < node_list[i]->
n; j++) {
1944 for (i = 0; i < global_mesh->
n_node; i++) {
1945 free_link_list(node_list[i]->list);
1954 for (i = 0; i < global_mesh->
n_node; i++) {
1956 free_link_list(node_list[i]->list);
1971 static int create_elem_graph_link_list(
1974 char *elem_flag =
NULL;
1981 if (elem_flag ==
NULL) {
1986 for (counter = 0, i = 0; i < global_mesh->
n_elem; i++) {
1987 memset(elem_flag, 0,
sizeof(
char) * global_mesh->
n_elem);
1991 j < global_mesh->elem_node_index[i + 1]; j++) {
1995 k < node_data->node_elem_index[node]; k++) {
2003 if (graph[i]->last->next ==
NULL) {
2028 static int create_elem_graph_compress(
2030 int *elem_graph_index,
int *elem_graph_item) {
2035 for (counter = 0, i = 0; i < global_mesh->
n_elem; i++) {
2036 elem_graph_index[i + 1] = elem_graph_index[i] + graph[i]->
n;
2038 for (p = graph[i]->list, j = 0; j < graph[i]->
n; j++) {
2040 elem_graph_item[counter++] = p->
id - 1;
2049 int *elem_graph_index) {
2052 int *elem_graph_item =
NULL;
2059 if (node_data ==
NULL) {
2067 rtc = set_node_belong_elem(global_mesh, node_data);
2072 if (graph ==
NULL) {
2076 for (i = 0; i < global_mesh->
n_elem; i++) {
2080 for (i = 0; i < global_mesh->
n_elem; i++) {
2082 if (graph[i] ==
NULL) {
2089 for (i = 0; i < global_mesh->
n_elem; i++) {
2091 if (graph[i]->list ==
NULL) {
2101 n_graph = create_elem_graph_link_list(global_mesh, node_data, graph);
2102 if (n_graph < 0)
goto error;
2104 elem_graph_item = (
int *)
HECMW_malloc(
sizeof(
int) * n_graph);
2105 if (elem_graph_item ==
NULL) {
2110 rtc = create_elem_graph_compress(global_mesh, graph, elem_graph_index,
2117 for (i = 0; i < global_mesh->
n_elem; i++) {
2118 free_link_list(graph[i]->list);
2123 return elem_graph_item;
2132 for (i = 0; i < global_mesh->
n_elem; i++) {
2134 free_link_list(graph[i]->list);
2148 static int pmetis_interface(
const int n_vertex,
const int n_domain,
int *xadj,
2149 int *adjncy,
int *part) {
2151 #ifdef HECMW_PART_WITH_METIS
2155 int nparts = n_domain;
2157 #if defined(METIS_VER_MAJOR) && (METIS_VER_MAJOR == 5)
2160 real_t *tpwgts =
NULL;
2161 real_t *ubvec =
NULL;
2165 METIS_PartGraphRecursive(&n, &ncon, xadj, adjncy, vwgt, vsize, adjwgt,
2166 &nparts, tpwgts, ubvec,
options, &edgecut, part);
2171 int options[5] = {0, 0, 0, 0, 0};
2174 METIS_PartGraphRecursive(&n, xadj, adjncy, vwgt, adjwgt, &wgtflag, &numflag,
2175 &nparts,
options, &edgecut, part);
2183 static int kmetis_interface(
const int n_vertex,
const int n_domain,
int *xadj,
2184 int *adjncy,
int *part) {
2186 #ifdef HECMW_PART_WITH_METIS
2190 int nparts = n_domain;
2192 #if defined(METIS_VER_MAJOR) && (METIS_VER_MAJOR == 5)
2195 real_t *tpwgts =
NULL;
2196 real_t *ubvec =
NULL;
2200 METIS_PartGraphKway(&n, &ncon, xadj, adjncy, vwgt, vsize, adjwgt, &nparts,
2201 tpwgts, ubvec,
options, &edgecut, part);
2206 int options[5] = {0, 0, 0, 0, 0};
2209 METIS_PartGraphKway(&n, xadj, adjncy, vwgt, adjwgt, &wgtflag, &numflag,
2210 &nparts,
options, &edgecut, part);
2218 static int pmetis_interface_with_weight(
int n_vertex,
int ncon,
int n_domain,
2219 const int *xadj,
const int *adjncy,
2220 const int *vwgt,
int *part) {
2222 #ifdef HECMW_PART_WITH_METIS
2225 int nparts = n_domain;
2227 #if defined(METIS_VER_MAJOR) && (METIS_VER_MAJOR == 5)
2229 real_t *tpwgts =
NULL;
2230 real_t *ubvec =
NULL;
2234 METIS_PartGraphRecursive(&n, &ncon, (
int *)xadj, (
int *)adjncy, (
int *)vwgt,
2235 vsize, adjwgt, &nparts, tpwgts, ubvec,
options,
2241 int options[5] = {0, 0, 0, 0, 0};
2243 if (vwgt !=
NULL) wgtflag = 2;
2247 METIS_PartGraphRecursive(&n, (
int *)xadj, (
int *)adjncy, (
int *)vwgt,
2248 adjwgt, &wgtflag, &numflag, &nparts,
options,
2251 METIS_mCPartGraphRecursive(&n, &ncon, (
int *)xadj, (
int *)adjncy,
2252 (
int *)vwgt, adjwgt, &wgtflag, &numflag, &nparts,
2262 static int kmetis_interface_with_weight(
int n_vertex,
int ncon,
int n_domain,
2263 const int *xadj,
const int *adjncy,
2264 const int *vwgt,
int *part) {
2266 #ifdef HECMW_PART_WITH_METIS
2269 int nparts = n_domain;
2271 #if defined(METIS_VER_MAJOR) && (METIS_VER_MAJOR == 5)
2273 real_t *tpwgts =
NULL;
2274 real_t *ubvec =
NULL;
2278 METIS_PartGraphKway(&n, &ncon, (
int *)xadj, (
int *)adjncy, (
int *)vwgt, vsize,
2279 adjwgt, &nparts, tpwgts, ubvec,
options, &edgecut, part);
2284 float *ubvec =
NULL;
2285 int options[5] = {0, 0, 0, 0, 0};
2287 if (vwgt !=
NULL) wgtflag = 2;
2291 if (ubvec ==
NULL) {
2299 METIS_PartGraphKway(&n, (
int *)xadj, (
int *)adjncy, (
int *)vwgt, adjwgt,
2300 &wgtflag, &numflag, &nparts,
options, &edgecut, part);
2302 METIS_mCPartGraphKway(&n, &ncon, (
int *)xadj, (
int *)adjncy, (
int *)vwgt,
2303 adjwgt, &wgtflag, &numflag, &nparts, ubvec,
options,
2315 static int contact_agg_mark_node_group(
int *mark,
2317 int gid,
int agg_id,
int *agg_dup) {
2319 int istart, iend, i;
2325 for (i = istart; i < iend; i++) {
2328 if (0 <= mark[nid] && mark[nid] < agg_id) {
2330 if (*agg_dup == -1) {
2331 *agg_dup = mark[nid];
2332 }
else if (mark[nid] != *agg_dup) {
2334 "ERROR: node included in multiple node groups in different "
2336 " which is not supported by CONTACT=AGGREGATE\n");
2345 static int HECMW_get_num_surf_node(
int etype,
int sid) {
2360 if (1 <= sid && sid <= 3)
return 4;
2361 if (4 <= sid && sid <= 5)
return 3;
2363 if (1 <= sid && sid <= 3)
return 8;
2364 if (4 <= sid && sid <= 5)
return 6;
2368 "ERROR: parallel contact analysis of elem type %d not supported\n",
2375 static const int *HECMW_get_surf_node(
int etype,
int sid) {
2378 static const int elem_surf_tet1[4][3] = {
2379 {1, 2, 3}, {0, 3, 2}, {0, 1, 3}, {0, 2, 1}};
2380 static const int elem_surf_tet2[4][6] = {{1, 4, 2, 9, 3, 8},
2383 {0, 5, 2, 4, 1, 6}};
2384 static const int elem_surf_hex1[6][4] = {{3, 0, 4, 7}, {1, 2, 6, 5},
2385 {0, 1, 5, 4}, {2, 3, 7, 6},
2386 {3, 2, 1, 0}, {4, 5, 6, 7}};
2387 static const int elem_surf_hex2[6][8] = {
2388 {3, 11, 0, 16, 4, 15, 7, 19}, {1, 9, 2, 18, 6, 13, 5, 17},
2389 {0, 8, 1, 17, 5, 12, 4, 16}, {2, 10, 3, 19, 7, 14, 6, 18},
2390 {3, 10, 2, 9, 1, 8, 0, 11}, {4, 12, 5, 13, 6, 14, 7, 15}};
2391 static const int elem_surf_pri1[5][4] = {
2392 {1, 2, 5, 4}, {2, 0, 3, 5}, {0, 1, 4, 3}, {2, 1, 0, -1}, {3, 4, 5, -1}};
2393 static const int elem_surf_pri2[5][8] = {{1, 6, 2, 14, 5, 9, 4, 13},
2394 {2, 7, 0, 12, 3, 10, 5, 14},
2395 {0, 8, 1, 13, 4, 11, 3, 12},
2396 {2, 6, 1, 8, 0, 7, -1, -1},
2397 {3, 11, 4, 9, 5, 10, -1, -1}};
2398 static const int elem_surf_ptt1[3] = {0, 1, 2};
2399 static const int elem_surf_ptt2[6] = {0, 1, 2, 3, 4, 5};
2400 static const int elem_surf_ptq1[4] = {0, 1, 2, 3};
2401 static const int elem_surf_ptq2[8] = {0, 1, 2, 3, 4, 5, 6, 7};
2404 return elem_surf_tet1[sid - 1];
2406 return elem_surf_tet2[sid - 1];
2408 return elem_surf_hex1[sid - 1];
2410 return elem_surf_hex2[sid - 1];
2412 return elem_surf_pri1[sid - 1];
2414 return elem_surf_pri2[sid - 1];
2416 return elem_surf_ptt1;
2418 return elem_surf_ptt2;
2420 return elem_surf_ptq1;
2422 return elem_surf_ptq2;
2425 "ERROR: parallel contact analysis of element type %d not supported\n",
2430 static int HECMW_fistr_get_num_surf_node(
int etype,
int sid) {
2445 if (1 <= sid && sid <= 2)
return 3;
2446 if (3 <= sid && sid <= 5)
return 4;
2448 if (1 <= sid && sid <= 2)
return 6;
2449 if (3 <= sid && sid <= 5)
return 8;
2453 "ERROR: parallel contact analysis of elem type %d not supported\n",
2460 static const int *HECMW_fistr_get_surf_node(
int etype,
int sid) {
2463 static const int elem_surf_tet1[4][3] = {
2464 {0, 1, 2}, {0, 1, 3}, {1, 2, 3}, {2, 0, 3}};
2465 static const int elem_surf_tet2[4][6] = {{0, 6, 1, 4, 2, 5},
2468 {2, 5, 0, 9, 3, 7}};
2469 static const int elem_surf_hex1[6][4] = {{0, 1, 2, 3}, {4, 5, 6, 7},
2470 {0, 1, 5, 4}, {1, 2, 6, 5},
2471 {2, 3, 7, 6}, {3, 0, 4, 7}};
2472 static const int elem_surf_hex2[6][8] = {
2473 {0, 8, 1, 9, 2, 10, 3, 11}, {4, 12, 5, 13, 6, 14, 7, 15},
2474 {0, 8, 1, 17, 5, 12, 4, 16}, {1, 9, 2, 18, 6, 13, 5, 17},
2475 {2, 10, 3, 19, 7, 14, 6, 18}, {3, 11, 0, 16, 4, 15, 7, 19}};
2476 static const int elem_surf_pri1[5][4] = {
2477 {0, 1, 2, -1}, {3, 4, 5, -1}, {0, 1, 4, 3}, {1, 2, 5, 4}, {2, 0, 3, 5}};
2478 static const int elem_surf_pri2[5][8] = {{0, 8, 1, 6, 2, 7, -1, -1},
2479 {3, 11, 4, 9, 5, 10, -1, -1},
2480 {0, 8, 1, 13, 4, 11, 3, 12},
2481 {1, 6, 2, 14, 5, 9, 4, 13},
2482 {2, 7, 0, 12, 3, 10, 5, 14}};
2483 static const int elem_surf_ptt1[3] = {0, 1, 2};
2484 static const int elem_surf_ptt2[6] = {0, 1, 2, 3, 4, 5};
2485 static const int elem_surf_ptq1[4] = {0, 1, 2, 3};
2486 static const int elem_surf_ptq2[8] = {0, 1, 2, 3, 4, 5, 6, 7};
2489 return elem_surf_tet1[sid - 1];
2491 return elem_surf_tet2[sid - 1];
2493 return elem_surf_hex1[sid - 1];
2495 return elem_surf_hex2[sid - 1];
2497 return elem_surf_pri1[sid - 1];
2499 return elem_surf_pri2[sid - 1];
2501 return elem_surf_ptt1;
2503 return elem_surf_ptt2;
2505 return elem_surf_ptq1;
2507 return elem_surf_ptq2;
2510 "ERROR: parallel contact analysis of element type %d not supported\n",
2521 for (i = 0; i < global_mesh->
n_node; i++) {
2525 for (i = 0; i < cp->
n_pair; i++) {
2529 for (j = jstart; j < jend; j++) {
2530 int eid = sgrp->
grp_item[j * 2] - 1;
2531 int sid = sgrp->
grp_item[j * 2 + 1];
2534 int etype = global_mesh->
elem_type[eid];
2540 int num_snode = HECMW_fistr_get_num_surf_node(etype, sid);
2541 const int *snode = HECMW_fistr_get_surf_node(etype, sid);
2545 for (k = 0; k < num_snode; k++) {
2546 int nid = nop[snode[k]] - 1;
2555 static int contact_agg_mark_surf_group(
int *mark,
2557 int gid,
int agg_id,
int *agg_dup) {
2559 int istart, iend, i, j;
2566 for (i = istart; i < iend; i++) {
2567 int eid = sgrp->
grp_item[i * 2] - 1;
2568 int sid = sgrp->
grp_item[i * 2 + 1];
2570 int etype = global_mesh->
elem_type[eid];
2575 int num_snode = HECMW_fistr_get_num_surf_node(etype, sid);
2576 const int *snode = HECMW_fistr_get_surf_node(etype, sid);
2579 for (j = 0; j < num_snode; j++) {
2580 int nid = nop[snode[j]] - 1;
2582 if (0 <= mark[nid] && mark[nid] < agg_id) {
2584 if (*agg_dup == -1) {
2585 *agg_dup = mark[nid];
2586 }
else if (mark[nid] != *agg_dup) {
2588 "ERROR: node included in multiple surface groups in "
2589 "different contact pairs,\n"
2590 " which is not supported by CONTACT=AGGREGATE\n");
2600 static int metis_partition_nb_contact_agg(
2605 int *node_graph_index =
NULL;
2606 int *node_graph_item =
NULL;
2607 int *belong_domain =
NULL;
2612 int agg_id, agg_dup, gid;
2614 const int *node_graph_index2;
2615 const int *node_graph_item2;
2624 if (node_graph_index ==
NULL) {
2629 if (node_graph_item ==
NULL) {
2636 rtc = create_node_graph(global_mesh, edge_data, node_graph_index,
2653 for (i = 0; i < global_mesh->
n_node; i++) {
2658 for (i = 0; i < cp->
n_pair; i++) {
2664 contact_agg_mark_node_group(mark, global_mesh, gid, agg_id, &agg_dup);
2669 contact_agg_mark_surf_group(mark, global_mesh, gid, agg_id, &agg_dup);
2674 contact_agg_mark_surf_group(mark, global_mesh, gid, agg_id, &agg_dup);
2679 rtc = contact_agg_mark_surf_group(mark, global_mesh, gid, agg_id, &agg_dup);
2683 for (i = 0; i < global_mesh->
n_node; i++) {
2684 if (mark[i] == agg_id) {
2693 for (i = 0; i < global_mesh->
n_node; i++) {
2702 node_graph_index, node_graph_item);
2712 node_weight2 = (
int *)
HECMW_calloc(n_node2,
sizeof(
int));
2713 if (node_weight2 ==
NULL) {
2717 for (i = 0; i < global_mesh->
n_node; i++) {
2718 node_weight2[mark[i]] += 1;
2723 belong_domain = (
int *)
HECMW_calloc(n_node2,
sizeof(
int));
2724 if (belong_domain ==
NULL) {
2731 n_edgecut = pmetis_interface_with_weight(
2732 n_node2, ncon, global_mesh->
n_subdomain, node_graph_index2,
2733 node_graph_item2, node_weight2, belong_domain);
2734 if (n_edgecut < 0)
goto error;
2738 n_edgecut = kmetis_interface_with_weight(
2739 n_node2, ncon, global_mesh->
n_subdomain, node_graph_index2,
2740 node_graph_item2, node_weight2, belong_domain);
2741 if (n_edgecut < 0)
goto error;
2749 for (i = 0; i < global_mesh->
n_node; i++) {
2750 global_mesh->
node_ID[2 * i + 1] = belong_domain[mark[i]];
2772 static int metis_partition_nb_contact_dist(
2777 int *node_graph_index =
NULL;
2778 int *node_graph_item =
NULL;
2779 int *belong_domain =
NULL;
2783 int *node_weight =
NULL;
2791 if (node_graph_index ==
NULL) {
2796 if (node_graph_item ==
NULL) {
2803 rtc = create_node_graph(global_mesh, edge_data, node_graph_index,
2826 rtc = mark_contact_master_nodes(global_mesh, mark);
2830 if (node_weight ==
NULL) {
2835 for (i = 0; i < global_mesh->
n_node; i++) {
2837 node_weight[i * ncon] = 1;
2839 node_weight[i * ncon + 1] = mark[i];
2846 if (belong_domain ==
NULL) {
2853 n_edgecut = pmetis_interface_with_weight(
2855 node_graph_item, node_weight, belong_domain);
2856 if (n_edgecut < 0)
goto error;
2860 n_edgecut = kmetis_interface_with_weight(
2862 node_graph_item, node_weight, belong_domain);
2863 if (n_edgecut < 0)
goto error;
2871 for (i = 0; i < global_mesh->
n_node; i++) {
2872 global_mesh->
node_ID[2 * i + 1] = belong_domain[i];
2892 static int metis_partition_nb_default(
2897 int *node_graph_index =
NULL;
2898 int *node_graph_item =
NULL;
2899 int *belong_domain =
NULL;
2904 if (node_graph_index ==
NULL) {
2909 if (node_graph_item ==
NULL) {
2916 rtc = create_node_graph(global_mesh, edge_data, node_graph_index,
2923 if (belong_domain ==
NULL) {
2934 node_graph_index, node_graph_item, belong_domain);
2935 if (n_edgecut < 0)
goto error;
2941 node_graph_index, node_graph_item, belong_domain);
2942 if (n_edgecut < 0)
goto error;
2950 for (i = 0; i < global_mesh->
n_node; i++) {
2951 global_mesh->
node_ID[2 * i + 1] = belong_domain[i];
2974 return metis_partition_nb_contact_agg(global_mesh,
cont_data,
2979 return metis_partition_nb_contact_dist(global_mesh,
cont_data,
2986 return metis_partition_nb_default(global_mesh,
cont_data, edge_data);
2992 int *elem_graph_index,
int *elem_graph_item) {
2994 int *belong_domain =
NULL;
2998 if (belong_domain ==
NULL) {
3007 elem_graph_index, elem_graph_item, belong_domain);
3008 if (n_edgecut < 0)
goto error;
3014 elem_graph_index, elem_graph_item, belong_domain);
3015 if (n_edgecut < 0)
goto error;
3023 for (i = 0; i < global_mesh->
n_elem; i++) {
3024 global_mesh->
elem_ID[2 * i + 1] = belong_domain[i];
3039 #define LINEBUF_SIZE 1023
3041 static int read_part_file(
3042 const char *part_file_name,
3048 int rtc, n_in, n_domain_in;
3052 fpart = fopen(part_file_name,
"r");
3053 if (fpart ==
NULL) {
3063 rtc = sscanf(linebuf,
"%d %d", &n_in, &n_domain_in);
3073 if (n_domain_in != n_domain) {
3078 count_dom = (
int *)
HECMW_calloc(n_domain,
sizeof(
int));
3079 if (count_dom ==
NULL) {
3085 for (i = 0; i < n; i++) {
3090 rtc = sscanf(linebuf,
"%d", &part);
3096 if (part < 0 || n_domain <= part) {
3107 for (i = 0; i < n_domain; i++) {
3108 if (count_dom[i] == 0) {
3122 static int write_part_file(
3123 const char *part_file_name,
3130 fpart = fopen(part_file_name,
"w");
3131 if (fpart ==
NULL) {
3136 fprintf(fpart,
"%d %d\n", n, n_domain);
3138 for (i = 0; i < n; i++) {
3139 fprintf(fpart,
"%d\n", wnum[2*i+1]);
3152 static int user_partition(
3156 const char *part_file_name) {
3159 rtc = read_part_file(part_file_name, n, n_domain, wnum);
3168 static int user_partition_nb(
3175 static int user_partition_eb(
3184 static int print_part(
3186 const char *part_file_name) {
3191 rtc = write_part_file(part_file_name, global_mesh->
n_node,
3198 rtc = write_part_file(part_file_name, global_mesh->
n_elem,
3217 static int count_edgecut(
3223 for (i = 0; i < edge_data->
n_edge; i++) {
3235 static int set_node_belong_domain_nb(
3245 if (edge_data ==
NULL) {
3256 if (rtc != 0)
goto error;
3262 rtc = rcb_partition(global_mesh->
n_node, global_mesh->
node,
3266 n_edgecut = count_edgecut(edge_data, global_mesh->
node_ID);
3272 n_edgecut = metis_partition_nb(global_mesh,
cont_data, edge_data);
3273 if (n_edgecut < 0)
goto error;
3278 rtc = user_partition_nb(global_mesh,
cont_data);
3281 n_edgecut = count_edgecut(edge_data, global_mesh->
node_ID);
3316 for (i = 0; i < global_mesh->
n_node; i++) {
3320 for (i = 0; i < global_mesh->
n_elem; i++) {
3322 j < global_mesh->elem_node_index[i + 1]; j++) {
3324 if (global_mesh->
elem_ID[2 * i + 1] <
3325 global_mesh->
node_ID[2 * (node - 1) + 1]) {
3326 global_mesh->
node_ID[2 * (node - 1) + 1] =
3327 global_mesh->
elem_ID[2 * i + 1];
3340 if (counter ==
NULL) {
3345 for (j = 0; j < global_mesh->
n_node; j++) {
3346 domain = global_mesh->
node_ID[2 * j + 1];
3347 global_mesh->
node_ID[2 * j] = ++counter[domain];
3370 for (i = 0; i < global_mesh->
n_node; i++) {
3371 global_mesh->
node_ID[2 * i] = i + 1;
3372 global_mesh->
node_ID[2 * i + 1] = 0;
3380 rtc = set_node_belong_domain_nb(global_mesh,
cont_data);
3385 rtc = set_node_belong_domain_eb(global_mesh);
3394 rtc = set_local_node_id(global_mesh);
3406 int node, node_domain, min_domain;
3409 for (i = 0; i < global_mesh->
n_elem; i++) {
3412 j < global_mesh->elem_node_index[i + 1]; j++) {
3414 node_domain = global_mesh->
node_ID[2 * (node - 1) + 1];
3415 if (node_domain < min_domain) {
3416 min_domain = node_domain;
3419 global_mesh->
elem_ID[2 * i + 1] = min_domain;
3427 int *elem_graph_index,
int *elem_graph_item) {
3435 for (i = 0; i < global_mesh->
n_elem; i++) {
3436 for (j = elem_graph_index[i]; j < elem_graph_index[i + 1]; j++) {
3438 if (eid < 0)
goto error;
3443 if (elem_data->
n_edge < 0)
goto error;
3458 static int set_elem_belong_domain_eb(
3462 int *elem_graph_index =
NULL;
3463 int *elem_graph_item =
NULL;
3469 if (elem_graph_index ==
NULL) {
3475 if (elem_data ==
NULL) {
3485 elem_graph_item = create_elem_graph(global_mesh, elem_graph_index);
3486 if (elem_graph_item ==
NULL)
goto error;
3490 rtc = count_edge_for_eb(global_mesh, elem_data, elem_graph_index,
3496 rtc = rcb_partition_eb(global_mesh,
cont_data);
3499 n_edgecut = count_edgecut(elem_data, global_mesh->
elem_ID);
3505 n_edgecut = metis_partition_eb(global_mesh,
cont_data, elem_graph_index,
3507 if (n_edgecut < 0)
goto error;
3512 rtc = user_partition_eb(global_mesh,
cont_data);
3515 n_edgecut = count_edgecut(elem_data, global_mesh->
elem_ID);
3550 if (counter ==
NULL) {
3555 for (j = 0; j < global_mesh->
n_elem; j++) {
3556 domain = global_mesh->
elem_ID[2 * j + 1];
3557 global_mesh->
elem_ID[2 * j] = ++counter[domain];
3580 for (i = 0; i < global_mesh->
n_elem; i++) {
3581 global_mesh->
elem_ID[2 * i] = i + 1;
3582 global_mesh->
elem_ID[2 * i + 1] = 0;
3590 rtc = set_elem_belong_domain_nb(global_mesh);
3596 rtc = set_elem_belong_domain_eb(global_mesh,
cont_data);
3606 rtc = set_local_elem_id(global_mesh);
3626 rtc = wnumbering_node(global_mesh,
cont_data);
3629 rtc = wnumbering_elem(global_mesh,
cont_data);
3636 rtc = wnumbering_elem(global_mesh,
cont_data);
3639 rtc = wnumbering_node(global_mesh,
cont_data);
3667 char *node_flag,
int current_domain) {
3670 for (i = 0; i < n_int_nlist[current_domain]; i++) {
3671 node = int_nlist[current_domain][i];
3679 char *elem_flag,
int current_domain) {
3682 for (i = 0; i < global_mesh->
n_elem; i++) {
3683 (global_mesh->
elem_ID[2 * i + 1] == current_domain)
3692 static int mask_elem_by_domain_mod(
char *elem_flag,
int current_domain) {
3695 for (i = 0; i < n_int_elist[current_domain]; i++) {
3696 elem = int_elist[current_domain][i];
3707 char *node_flag,
int current_domain) {
3710 for (i = 0; i < global_mesh->
mpc->
n_mpc; i++) {
3711 int j0, je, slave, master, j, evalsum;
3721 for (j = j0 + 1; j < je; j++) {
3740 static int mask_overlap_elem(
char *elem_flag,
int domain) {
3743 for (i = 0; i < n_bnd_elist[2 * domain + 1]; i++) {
3744 elem = bnd_elist[domain][i];
3753 char *node_flag,
const char *elem_flag) {
3757 for (i = 0; i < global_mesh->
n_elem; i++) {
3760 j < global_mesh->elem_node_index[i + 1]; j++) {
3773 char *node_flag,
char *elem_flag,
3777 for (i = 0; i < n_bnd_nlist[2 * domain + 1]; i++) {
3778 node = bnd_nlist[domain][i];
3789 static int mask_boundary_elem_with_slave(
3791 char *elem_flag,
int *added) {
3797 for (i = 0; i < global_mesh->
n_elem; i++) {
3804 j < global_mesh->elem_node_index[i + 1]; j++) {
3825 static int mask_boundary_link_elem_with_slave(
3827 char *elem_flag,
int *added) {
3833 for (i = 0; i < global_mesh->
n_elem; i++) {
3840 j < global_mesh->elem_node_index[i + 1]; j++) {
3860 static int mask_additional_overlap_elem(
3866 for (i = 0; i < global_mesh->
n_elem; i++) {
3869 j < global_mesh->elem_node_index[i + 1]; j++) {
3884 char *elem_flag,
char *node_flag) {
3886 int elem, node, selem;
3887 int evalsum, evalsum2;
3888 int master_gid, slave_gid;
3900 for (i = 0; i < cp->
n_pair; i++) {
3901 switch (cp->
type[i]) {
3906 jstart = sgrp->
grp_index[master_gid - 1];
3908 for (j = jstart; j < jend; j++) {
3918 jstart = ngrp->
grp_index[slave_gid - 1];
3920 for (j = jstart; j < jend; j++) {
3930 jstart = sgrp->
grp_index[master_gid - 1];
3932 for (j = jstart; j < jend; j++) {
3942 jstart = ngrp->
grp_index[slave_gid - 1];
3944 for (j = jstart; j < jend; j++) {
3957 jstart = sgrp->
grp_index[master_gid - 1];
3959 for (j = jstart; j < jend; j++) {
3970 jstart = sgrp->
grp_index[slave_gid - 1];
3972 for (j = jstart; j < jend; j++) {
3977 k < global_mesh->elem_node_index[selem]; k++) {
3987 jstart = sgrp->
grp_index[master_gid - 1];
3989 for (j = jstart; j < jend; j++) {
4000 jstart = sgrp->
grp_index[slave_gid - 1];
4002 for (j = jstart; j < jend; j++) {
4006 k < global_mesh->elem_node_index[selem]; k++) {
4016 k < global_mesh->elem_node_index[selem]; k++) {
4029 jstart = egrp->
grp_index[master_gid - 1];
4031 for (j = jstart; j < jend; j++) {
4041 jstart = ngrp->
grp_index[slave_gid - 1];
4043 for (j = jstart; j < jend; j++) {
4053 jstart = egrp->
grp_index[master_gid - 1];
4055 for (j = jstart; j < jend; j++) {
4065 jstart = ngrp->
grp_index[slave_gid - 1];
4067 for (j = jstart; j < jend; j++) {
4085 char *node_flag,
char *elem_flag,
4086 int current_domain) {
4090 rtc = mask_node_by_domain(global_mesh, node_flag, current_domain);
4093 rtc = mask_elem_by_domain_mod(elem_flag, current_domain);
4096 rtc = mask_overlap_elem(elem_flag, current_domain);
4100 mask_boundary_node_mod(global_mesh, node_flag, elem_flag, current_domain);
4109 rtc = mask_slave_node(global_mesh, node_flag, current_domain);
4112 rtc = mask_boundary_elem_with_slave(global_mesh, node_flag, elem_flag,
4117 rtc = mask_boundary_node(global_mesh, node_flag, elem_flag);
4122 rtc = mask_boundary_link_elem_with_slave(global_mesh, node_flag, elem_flag,
4127 rtc = mask_boundary_node(global_mesh, node_flag, elem_flag);
4131 for (i = 0; i < global_mesh->
n_node; i++) {
4139 rtc = mask_additional_overlap_elem(global_mesh, node_flag, elem_flag);
4142 rtc = mask_boundary_node(global_mesh, node_flag, elem_flag);
4147 rtc = mask_contact_slave_surf(global_mesh, elem_flag, node_flag);
4161 char *node_flag,
const char *elem_flag) {
4165 for (i = 0; i < global_mesh->
n_elem; i++) {
4168 j < global_mesh->elem_node_index[i + 1]; j++) {
4175 j < global_mesh->elem_node_index[i + 1]; j++) {
4189 for (i = 0; i < global_mesh->
n_node; i++) {
4200 char *node_flag,
const char *elem_flag) {
4204 rtc = mask_overlap_node_mark(global_mesh, node_flag, elem_flag);
4207 rtc = mask_overlap_node_inner(global_mesh, node_flag);
4210 for (i = 0; i < global_mesh->
n_node; i++) {
4222 const char *node_flag,
char *elem_flag) {
4226 for (i = 0; i < global_mesh->
n_elem; i++) {
4229 j < global_mesh->elem_node_index[i + 1]; j++) {
4244 char *node_flag,
char *elem_flag,
4245 int current_domain) {
4249 for (i = 0; i < global_mesh->
n_node; i++) {
4254 for (i = 0; i < global_mesh->
n_elem; i++) {
4260 rtc = mask_node_by_domain(global_mesh, node_flag, current_domain);
4263 rtc = mask_elem_by_domain(global_mesh, elem_flag, current_domain);
4266 rtc = mask_overlap_node(global_mesh, node_flag, elem_flag);
4269 rtc = mask_boundary_elem(global_mesh, node_flag, elem_flag);
4281 const char *node_flag,
char *domain_flag) {
4284 for (i = 0; i < global_mesh->
n_node; i++) {
4294 static int mask_neighbor_domain_nb_mod(
4296 char *domain_flag,
int domain) {
4299 for (i = n_bnd_nlist[2 * domain]; i < n_bnd_nlist[2 * domain + 1]; i++) {
4300 node = bnd_nlist[domain][i];
4307 static int mask_neighbor_domain_nb_contact(
4309 const char *elem_flag,
char *domain_flag) {
4311 int elem, node, selem;
4313 int master_gid, slave_gid;
4325 for (i = 0; i < cp->
n_pair; i++) {
4328 switch (cp->
type[i]) {
4331 jstart = ngrp->
grp_index[slave_gid - 1];
4333 for (j = jstart; j < jend; j++) {
4343 jstart = sgrp->
grp_index[slave_gid - 1];
4345 for (j = jstart; j < jend; j++) {
4348 k < global_mesh->elem_node_index[selem]; k++) {
4360 jstart = ngrp->
grp_index[slave_gid - 1];
4362 for (j = jstart; j < jend; j++) {
4377 jstart = egrp->
grp_index[master_gid - 1];
4379 for (j = jstart; j < jend; j++) {
4386 jstart = sgrp->
grp_index[master_gid - 1];
4388 for (j = jstart; j < jend; j++) {
4402 const char *elem_flag,
char *domain_flag) {
4405 for (i = 0; i < global_mesh->
n_elem; i++) {
4415 const char *domain_flag) {
4419 for (counter = 0, i = 0; i < global_mesh->
n_subdomain; i++) {
4428 const char *domain_flag) {
4432 for (counter = 0, i = 0; i < global_mesh->
n_subdomain; i++) {
4443 char *node_flag,
char *elem_flag,
4444 int current_domain) {
4446 char *domain_flag =
NULL;
4454 "Starting creation of neighboring domain information...");
4460 if (domain_flag ==
NULL) {
4467 rtc = mask_mesh_status_nb(global_mesh, node_flag, elem_flag,
4471 if (is_spdup_available(global_mesh)) {
4472 rtc = mask_neighbor_domain_nb_mod(global_mesh, node_flag, domain_flag,
4475 rtc = mask_neighbor_domain_nb(global_mesh, node_flag, domain_flag);
4479 rtc = mask_neighbor_domain_nb_contact(global_mesh, node_flag, elem_flag,
4486 rtc = mask_mesh_status_eb(global_mesh, node_flag, elem_flag,
4490 rtc = mask_neighbor_domain_eb(global_mesh, elem_flag, domain_flag);
4500 local_mesh->
n_neighbor_pe = count_neighbor_domain(global_mesh, domain_flag);
4518 rtc = set_neighbor_domain(global_mesh, local_mesh, domain_flag);
4539 char *node_flag_current,
char *node_flag_neighbor) {
4542 for (i = 0; i < global_mesh->
n_node; i++) {
4554 char *node_flag_current,
char *node_flag_neighbor,
4555 int current_domain) {
4558 for (i = 0; i < n_bnd_nlist[2 * current_domain + 1]; i++) {
4559 node = bnd_nlist[current_domain][i];
4569 char *elem_flag_current,
char *elem_flag_neighbor) {
4572 for (i = 0; i < global_mesh->
n_elem; i++) {
4584 char *elem_flag_current,
char *elem_flag_neighbor,
4585 int current_domain) {
4588 for (i = 0; i < n_bnd_elist[2 * current_domain + 1]; i++) {
4589 elem = bnd_elist[current_domain][i];
4600 const char *node_flag,
int domain) {
4604 for (counter = 0, i = 0; i < n_int_nlist[domain]; i++) {
4605 node = int_nlist[domain][i];
4613 const char *elem_flag,
int domain) {
4617 for (counter = 0, i = 0; i < global_mesh->
n_elem; i++) {
4619 global_mesh->
elem_ID[2 * i + 1] == domain)
4626 static int count_masked_shared_node(
4631 for (counter = 0, i = 0; i < global_mesh->
n_node; i++) {
4638 static int count_masked_shared_elem(
4643 for (counter = 0, i = 0; i < global_mesh->
n_elem; i++) {
4651 static int count_masked_shared_elem_mod(
4657 for (counter = 0, i = 0; i < n_bnd_elist[2 * domain + 1]; i++) {
4658 elem = bnd_elist[domain][i];
4667 const char *node_flag,
int **comm_node,
4668 int neighbor_idx,
int domain) {
4672 for (counter = 0, i = 0; i < n_int_nlist[domain]; i++) {
4673 node = int_nlist[domain][i];
4675 comm_node[neighbor_idx][counter++] = node;
4683 const char *elem_flag,
int **comm_elem,
4684 int neighbor_idx,
int domain) {
4688 for (counter = 0, i = 0; i < global_mesh->
n_elem; i++) {
4690 global_mesh->
elem_ID[2 * i + 1] == domain) {
4691 comm_elem[neighbor_idx][counter++] = i + 1;
4699 const char *node_flag,
int **shared_node,
4704 for (counter = 0, i = 0; i < global_mesh->
n_node; i++) {
4706 shared_node[neighbor_idx][counter++] = i + 1;
4714 const char *elem_flag,
int **shared_elem,
4719 for (counter = 0, i = 0; i < global_mesh->
n_elem; i++) {
4721 shared_elem[neighbor_idx][counter++] = i + 1;
4729 static int create_shared_elem_pre_mod(
4731 int **shared_elem,
int neighbor_idx,
int neighbor_domain) {
4733 int i, idx1, idx2, elem1, elem2, n_bnd, n_out, maxe;
4735 n_bnd = n_bnd_elist[2 * neighbor_domain];
4737 n_bnd_elist[2 * neighbor_domain + 1] - n_bnd_elist[2 * neighbor_domain];
4738 maxe = global_mesh->
n_elem + 1;
4740 elem1 = (n_bnd == 0) ? maxe : bnd_elist[neighbor_domain][0];
4741 elem2 = (n_out == 0) ? maxe : bnd_elist[neighbor_domain][n_bnd];
4742 for (counter = 0, idx1 = 0, idx2 = 0, i = 0; i < n_bnd + n_out; i++) {
4743 if (elem1 < elem2) {
4745 shared_elem[neighbor_idx][counter++] = elem1;
4748 elem1 = (idx1 == n_bnd) ? maxe : bnd_elist[neighbor_domain][idx1];
4751 shared_elem[neighbor_idx][counter++] = elem2;
4754 elem2 = (idx2 == n_out) ? maxe : bnd_elist[neighbor_domain][idx2 + n_bnd];
4761 static int create_comm_item(
int n_neighbor_pe,
int **comm_item_pre,
4762 int *comm_index,
int *comm_item) {
4765 for (i = 0; i < n_neighbor_pe; i++) {
4767 je = comm_index[i + 1];
4769 for (j = 0; j < je - js; j++) {
4770 comm_item[js + j] = comm_item_pre[i][j];
4781 const char *node_flag,
int **import_node,
4782 int neighbor_idx,
int neighbor_domain) {
4783 int n_import_node, rtc;
4786 count_masked_comm_node(global_mesh, node_flag, neighbor_domain);
4790 local_mesh->
import_index[neighbor_idx] + n_import_node;
4792 import_node[neighbor_idx] = (
int *)
HECMW_malloc(
sizeof(
int) * n_import_node);
4793 if (import_node[neighbor_idx] ==
NULL) {
4798 rtc = create_comm_node_pre(global_mesh, node_flag, import_node, neighbor_idx,
4810 const char *node_flag,
int **export_node,
4811 int neighbor_idx,
int current_domain,
4812 int neighbor_domain) {
4813 int n_export_node, rtc;
4816 count_masked_comm_node(global_mesh, node_flag, current_domain);
4820 local_mesh->
export_index[neighbor_idx] + n_export_node;
4822 export_node[neighbor_idx] = (
int *)
HECMW_malloc(
sizeof(
int) * n_export_node);
4823 if (export_node[neighbor_idx] ==
NULL) {
4828 rtc = create_comm_node_pre(global_mesh, node_flag, export_node, neighbor_idx,
4840 const char *elem_flag,
int **shared_elem,
4841 int neighbor_idx,
int neighbor_domain) {
4842 int n_shared_elem, rtc;
4844 if (is_spdup_available(global_mesh)) {
4846 count_masked_shared_elem_mod(global_mesh, elem_flag, neighbor_domain);
4848 n_shared_elem = count_masked_shared_elem(global_mesh, elem_flag);
4854 local_mesh->
shared_index[neighbor_idx] + n_shared_elem;
4856 shared_elem[neighbor_idx] = (
int *)
HECMW_malloc(
sizeof(
int) * n_shared_elem);
4857 if (shared_elem[neighbor_idx] ==
NULL) {
4862 if (is_spdup_available(global_mesh)) {
4863 rtc = create_shared_elem_pre_mod(global_mesh, elem_flag, shared_elem,
4864 neighbor_idx, neighbor_domain);
4866 rtc = create_shared_elem_pre(global_mesh, elem_flag, shared_elem,
4880 char *node_flag,
char *elem_flag,
4881 char *node_flag_neighbor,
4882 char *elem_flag_neighbor,
int current_domain) {
4883 int **import_node =
NULL;
4884 int **export_node =
NULL;
4885 int **shared_elem =
NULL;
4886 int neighbor_domain;
4899 if (import_node ==
NULL) {
4904 import_node[i] =
NULL;
4908 if (export_node ==
NULL) {
4913 export_node[i] =
NULL;
4917 if (shared_elem ==
NULL) {
4922 shared_elem[i] =
NULL;
4948 rtc = mask_mesh_status_nb(global_mesh, node_flag_neighbor,
4949 elem_flag_neighbor, neighbor_domain);
4952 if (is_spdup_available(global_mesh)) {
4953 rtc = mask_comm_node_mod(global_mesh, node_flag, node_flag_neighbor,
4956 rtc = mask_comm_node(global_mesh, node_flag, node_flag_neighbor);
4961 if (is_spdup_available(global_mesh)) {
4962 rtc = mask_comm_elem_mod(global_mesh, elem_flag, elem_flag_neighbor,
4965 rtc = mask_comm_elem(global_mesh, elem_flag, elem_flag_neighbor);
4970 rtc = create_import_info_nb(global_mesh, local_mesh, node_flag, import_node,
4971 i, neighbor_domain);
4974 rtc = create_export_info_nb(global_mesh, local_mesh, node_flag, export_node,
4975 i, current_domain, neighbor_domain);
4978 rtc = create_shared_info_nb(global_mesh, local_mesh, elem_flag, shared_elem,
4979 i, neighbor_domain);
4982 if (is_spdup_available(global_mesh)) {
4984 rtc = spdup_clear_IEB(node_flag_neighbor, elem_flag_neighbor,
4988 rtc = spdup_clear_MMbnd(node_flag_neighbor, elem_flag_neighbor,
4992 rtc = spdup_clear_MMbnd(node_flag, elem_flag, current_domain);
4995 for (j = 0; j < global_mesh->
n_node; j++) {
4998 for (j = 0; j < global_mesh->
n_elem; j++) {
5002 memset(node_flag_neighbor, 0,
sizeof(
char) * global_mesh->
n_node);
5003 memset(elem_flag_neighbor, 0,
sizeof(
char) * global_mesh->
n_elem);
5014 rtc = create_comm_item(local_mesh->
n_neighbor_pe, import_node,
5031 rtc = create_comm_item(local_mesh->
n_neighbor_pe, export_node,
5048 rtc = create_comm_item(local_mesh->
n_neighbor_pe, shared_elem,
5104 const char *elem_flag,
int **import_elem,
5105 int neighbor_idx,
int neighbor_domain) {
5106 int n_import_elem, rtc;
5109 count_masked_comm_elem(global_mesh, elem_flag, neighbor_domain);
5113 local_mesh->
import_index[neighbor_idx] + n_import_elem;
5115 import_elem[neighbor_idx] = (
int *)
HECMW_malloc(
sizeof(
int) * n_import_elem);
5116 if (import_elem[neighbor_idx] ==
NULL) {
5121 rtc = create_comm_elem_pre(global_mesh, elem_flag, import_elem, neighbor_idx,
5133 const char *elem_flag,
int **export_elem,
5134 int neighbor_idx,
int current_domain,
5135 int neighbor_domain) {
5136 int n_export_elem, rtc;
5139 count_masked_comm_elem(global_mesh, elem_flag, current_domain);
5143 local_mesh->
export_index[neighbor_idx] + n_export_elem;
5145 export_elem[neighbor_idx] = (
int *)
HECMW_malloc(
sizeof(
int) * n_export_elem);
5146 if (export_elem[neighbor_idx] ==
NULL) {
5151 rtc = create_comm_elem_pre(global_mesh, elem_flag, export_elem, neighbor_idx,
5163 const char *node_flag,
int **shared_node,
5164 int neighbor_idx,
int neighbor_domain) {
5165 int n_shared_node, rtc;
5167 n_shared_node = count_masked_shared_node(global_mesh, node_flag);
5171 local_mesh->
shared_index[neighbor_idx] + n_shared_node;
5173 shared_node[neighbor_idx] = (
int *)
HECMW_malloc(
sizeof(
int) * n_shared_node);
5174 if (shared_node[neighbor_idx] ==
NULL) {
5180 create_shared_node_pre(global_mesh, node_flag, shared_node, neighbor_idx);
5193 char *node_flag,
char *elem_flag,
5194 char *node_flag_neighbor,
5195 char *elem_flag_neighbor,
int current_domain) {
5196 int **import_elem =
NULL;
5197 int **export_elem =
NULL;
5198 int **shared_node =
NULL;
5199 int neighbor_domain;
5213 if (import_elem ==
NULL) {
5218 import_elem[i] =
NULL;
5222 if (export_elem ==
NULL) {
5227 export_elem[i] =
NULL;
5231 if (shared_node ==
NULL) {
5236 shared_node[i] =
NULL;
5263 for (j = 0; j < global_mesh->
n_node; j++) {
5267 for (j = 0; j < global_mesh->
n_elem; j++) {
5272 memset(node_flag_neighbor, 0,
sizeof(
char) * global_mesh->
n_node);
5273 memset(elem_flag_neighbor, 0,
sizeof(
char) * global_mesh->
n_elem);
5276 rtc = mask_mesh_status_eb(global_mesh, node_flag_neighbor,
5277 elem_flag_neighbor, neighbor_domain);
5280 rtc = mask_comm_node(global_mesh, node_flag, node_flag_neighbor);
5283 rtc = mask_comm_elem(global_mesh, elem_flag, elem_flag_neighbor);
5287 rtc = create_import_info_eb(global_mesh, local_mesh, elem_flag, import_elem,
5288 i, neighbor_domain);
5292 rtc = create_export_info_eb(global_mesh, local_mesh, elem_flag, export_elem,
5293 i, current_domain, neighbor_domain);
5297 rtc = create_shared_info_eb(global_mesh, local_mesh, node_flag, shared_node,
5298 i, neighbor_domain);
5310 rtc = create_comm_item(local_mesh->
n_neighbor_pe, import_elem,
5328 rtc = create_comm_item(local_mesh->
n_neighbor_pe, export_elem,
5346 rtc = create_comm_item(local_mesh->
n_neighbor_pe, shared_node,
5401 char *node_flag,
char *elem_flag,
5402 char *node_flag_neighbor,
char *elem_flag_neighbor,
5403 int current_domain) {
5415 rtc = create_comm_info_nb(global_mesh, local_mesh, node_flag, elem_flag,
5416 node_flag_neighbor, elem_flag_neighbor,
5423 rtc = create_comm_info_eb(global_mesh, local_mesh, node_flag, elem_flag,
5424 node_flag_neighbor, elem_flag_neighbor,
5450 static int set_node_global2local_internal(
5453 const char *node_flag,
int domain) {
5463 for (counter = 0, i = 0; i < n_int_nlist[domain]; i++) {
5464 node = int_nlist[domain][i];
5465 node_global2local[node - 1] = ++counter;
5472 static int set_node_global2local_external(
5475 const char *node_flag) {
5486 for (counter = local_mesh->
nn_internal, i = 0; i < global_mesh->n_node; i++) {
5489 node_global2local[i] = ++counter;
5496 for (i = 0; i < global_mesh->
n_node; i++) {
5499 node_global2local[i] = ++counter;
5502 local_mesh->
n_node = counter;
5511 static int set_node_global2local_external_mod(
5514 const char *node_flag,
int domain) {
5524 for (counter = local_mesh->
nn_internal, i = n_bnd_nlist[2 * domain];
5525 i < n_bnd_nlist[2 * domain + 1]; i++) {
5526 node = bnd_nlist[domain][i];
5527 node_global2local[node - 1] = ++counter;
5529 local_mesh->
n_node = counter;
5537 static int set_node_global2local_all(
5540 const char *node_flag) {
5550 for (counter = 0, i = 0; i < global_mesh->
n_node; i++) {
5552 node_global2local[i] = ++counter;
5555 local_mesh->
n_node = counter;
5565 const char *node_flag) {
5574 for (counter = 0, i = 0; i < global_mesh->
n_node; i++) {
5582 static int const_node_internal_list(
5585 const char *node_flag) {
5607 for (counter = 0, i = 0; i < global_mesh->
n_node; i++) {
5623 int *node_global2local,
const char *node_flag,
5624 int current_domain) {
5635 rtc = set_node_global2local_internal(global_mesh, local_mesh,
5636 node_global2local, node_flag,
5640 if (is_spdup_available(global_mesh)) {
5641 rtc = set_node_global2local_external_mod(global_mesh, local_mesh,
5642 node_global2local, node_flag,
5645 rtc = set_node_global2local_external(global_mesh, local_mesh,
5646 node_global2local, node_flag);
5657 rtc = const_nn_internal(global_mesh, local_mesh, node_flag);
5660 rtc = set_node_global2local_all(global_mesh, local_mesh,
5661 node_global2local, node_flag);
5664 rtc = const_node_internal_list(global_mesh, local_mesh, node_global2local,
5685 int *node_global2local,
int domain) {
5693 if (is_spdup_available(global_mesh)) {
5694 for (i = 0; i < n_int_nlist[domain]; i++) {
5695 node = int_nlist[domain][i];
5696 node_global2local[node - 1] = 0;
5698 for (i = n_bnd_nlist[2 * domain]; i < n_bnd_nlist[2 * domain + 1]; i++) {
5699 node = bnd_nlist[domain][i];
5700 node_global2local[node - 1] = 0;
5703 for (i = 0; i < global_mesh->
n_node; i++) {
5704 node_global2local[i] = 0;
5715 const int *node_global2local,
5716 int *node_local2global) {
5726 for (counter = 0, i = 0; i < global_mesh->
n_node; i++) {
5727 if (node_global2local[i]) {
5728 node_local2global[node_global2local[i] - 1] = i + 1;
5738 static int set_node_local2global_mod(
5741 int *node_local2global,
int domain) {
5743 int i, idx1, idx2, node1, node2, n_int, n_bnd, n_out, maxn;
5751 n_int = n_int_nlist[domain];
5752 n_bnd = n_bnd_nlist[2 * domain];
5753 n_out = n_bnd_nlist[2 * domain + 1] - n_bnd_nlist[2 * domain];
5754 maxn = global_mesh->
n_node + 1;
5756 node1 = (n_int == 0) ? maxn : int_nlist[domain][0];
5757 node2 = (n_out == 0) ? maxn : bnd_nlist[domain][n_bnd];
5758 for (counter = 0, idx1 = 0, idx2 = 0, i = 0; i < n_int + n_out; i++) {
5759 if (node1 < node2) {
5760 node_local2global[node_global2local[node1 - 1] - 1] = node1;
5762 node1 = (idx1 == n_int) ? maxn : int_nlist[domain][idx1];
5764 node_local2global[node_global2local[node2 - 1] - 1] = node2;
5766 node2 = (idx2 == n_out) ? maxn : bnd_nlist[domain][idx2 + n_bnd];
5778 static int set_elem_global2local_internal(
5781 const char *elem_flag) {
5791 for (counter = 0, i = 0; i < global_mesh->
n_elem; i++) {
5793 elem_global2local[i] = ++counter;
5801 static int set_elem_global2local_external(
5804 const char *elem_flag) {
5814 for (counter = local_mesh->
ne_internal, i = 0; i < global_mesh->n_elem; i++) {
5816 elem_global2local[i] = ++counter;
5819 local_mesh->
n_elem = counter;
5827 static int set_elem_global2local_all(
5830 const char *elem_flag) {
5840 for (counter = 0, i = 0; i < global_mesh->
n_elem; i++) {
5842 elem_global2local[i] = ++counter;
5845 local_mesh->
n_elem = counter;
5854 static int set_elem_global2local_all_mod(
5857 const char *elem_flag,
int domain) {
5859 int i, idx1, idx2, elem1, elem2, n_int, n_bnd, n_out, maxe;
5867 n_int = n_int_elist[domain];
5868 n_bnd = n_bnd_elist[2 * domain];
5869 n_out = n_bnd_elist[2 * domain + 1] - n_bnd_elist[2 * domain];
5870 maxe = global_mesh->
n_elem + 1;
5872 elem1 = (n_int == 0) ? maxe : int_elist[domain][0];
5873 elem2 = (n_out == 0) ? maxe : bnd_elist[domain][n_bnd];
5874 for (counter = 0, idx1 = 0, idx2 = 0, i = 0; i < n_int + n_out; i++) {
5875 if (elem1 < elem2) {
5876 elem_global2local[elem1 - 1] = ++counter;
5878 elem1 = (idx1 == n_int) ? maxe : int_elist[domain][idx1];
5880 elem_global2local[elem2 - 1] = ++counter;
5882 elem2 = (idx2 == n_out) ? maxe : bnd_elist[domain][idx2 + n_bnd];
5886 local_mesh->
n_elem = counter;
5896 const char *elem_flag) {
5902 for (counter = 0, i = 0; i < global_mesh->
n_elem; i++) {
5911 static int const_elem_internal_list(
5914 const char *elem_flag,
int domain) {
5936 for (counter = 0, i = 0; i < n_int_elist[domain]; i++) {
5937 elem = int_elist[domain][i];
5951 int *elem_global2local,
const char *elem_flag,
5952 int current_domain) {
5963 local_mesh->
ne_internal = n_int_elist[current_domain];
5965 if (is_spdup_available(global_mesh)) {
5966 rtc = set_elem_global2local_all_mod(global_mesh, local_mesh,
5967 elem_global2local, elem_flag,
5970 rtc = set_elem_global2local_all(global_mesh, local_mesh,
5971 elem_global2local, elem_flag);
5976 rtc = const_elem_internal_list(global_mesh, local_mesh, elem_global2local,
5977 elem_flag, current_domain);
5985 rtc = set_elem_global2local_internal(global_mesh, local_mesh,
5986 elem_global2local, elem_flag);
5989 rtc = set_elem_global2local_external(global_mesh, local_mesh,
5990 elem_global2local, elem_flag);
6011 int *elem_global2local,
int domain) {
6019 if (is_spdup_available(global_mesh)) {
6020 for (i = 0; i < n_int_elist[domain]; i++) {
6021 elem = int_elist[domain][i];
6022 elem_global2local[elem - 1] = 0;
6024 for (i = n_bnd_elist[2 * domain]; i < n_bnd_elist[2 * domain + 1]; i++) {
6025 elem = bnd_elist[domain][i];
6026 elem_global2local[elem - 1] = 0;
6030 for (i = 0; i < global_mesh->
n_elem; i++) {
6031 elem_global2local[i] = 0;
6042 const int *elem_global2local,
6043 int *elem_local2global) {
6053 for (counter = 0, i = 0; i < global_mesh->
n_elem; i++) {
6054 if (elem_global2local[i]) {
6055 elem_local2global[elem_global2local[i] - 1] = i + 1;
6065 static int set_elem_local2global_mod(
6068 int *elem_local2global,
int domain) {
6070 int i, idx1, idx2, elem1, elem2, n_int, n_bnd, n_out, maxe;
6078 n_int = n_int_elist[domain];
6079 n_bnd = n_bnd_elist[2 * domain];
6080 n_out = n_bnd_elist[2 * domain + 1] - n_bnd_elist[2 * domain];
6081 maxe = global_mesh->
n_elem + 1;
6083 elem1 = (n_int == 0) ? maxe : int_elist[domain][0];
6084 elem2 = (n_out == 0) ? maxe : bnd_elist[domain][n_bnd];
6085 for (counter = 0, idx1 = 0, idx2 = 0, i = 0; i < n_int + n_out; i++) {
6086 if (elem1 < elem2) {
6087 elem_local2global[elem_global2local[elem1 - 1] - 1] = elem1;
6089 elem1 = (idx1 == n_int) ? maxe : int_elist[domain][idx1];
6091 elem_local2global[elem_global2local[elem2 - 1] - 1] = elem2;
6093 elem2 = (idx2 == n_out) ? maxe : bnd_elist[domain][idx2 + n_bnd];
6140 static int const_hecmw_flag_initcon(
6148 static int const_hecmw_flag_parttype(
6156 static int const_hecmw_flag_partdepth(
6164 static int const_hecmw_flag_version(
6172 static int const_hecmw_flag_partcontact(
6194 rtc = const_gridfile(global_mesh, local_mesh);
6197 rtc = const_hecmw_n_file(global_mesh, local_mesh);
6200 rtc = const_files(global_mesh, local_mesh);
6203 rtc = const_header(global_mesh, local_mesh);
6206 rtc = const_hecmw_flag_adapt(global_mesh, local_mesh);
6209 rtc = const_hecmw_flag_initcon(global_mesh, local_mesh);
6212 rtc = const_hecmw_flag_parttype(global_mesh, local_mesh);
6215 rtc = const_hecmw_flag_partdepth(global_mesh, local_mesh);
6218 rtc = const_hecmw_flag_version(global_mesh, local_mesh);
6221 rtc = const_hecmw_flag_partcontact(global_mesh, local_mesh);
6224 rtc = const_zero_temp(global_mesh, local_mesh);
6260 const char *node_flag) {
6274 for (counter = 0, i = 0; i < global_mesh->
n_dof_grp; i++) {
6276 j < global_mesh->node_dof_index[i + 1]; j++) {
6291 static int const_node_dof_index_mod(
6307 for (counter = 0, i = 0; i < global_mesh->
n_dof_grp; i++) {
6308 for (j = 0; j < n_int_nlist[domain]; j++) {
6309 node = int_nlist[domain][j];
6310 if (node <= global_mesh->node_dof_index[i])
continue;
6334 const int *node_local2global) {
6347 for (i = 0; i < local_mesh->
n_node; i++) {
6348 local_mesh->
node[3 * i] = global_mesh->
node[3 * (node_local2global[i] - 1)];
6349 local_mesh->
node[3 * i + 1] =
6350 global_mesh->
node[3 * (node_local2global[i] - 1) + 1];
6351 local_mesh->
node[3 * i + 2] =
6352 global_mesh->
node[3 * (node_local2global[i] - 1) + 2];
6363 const int *node_local2global) {
6376 for (i = 0; i < local_mesh->
n_node; i++) {
6378 global_mesh->
node_ID[2 * (node_local2global[i] - 1)];
6379 local_mesh->
node_ID[2 * i + 1] =
6380 global_mesh->
node_ID[2 * (node_local2global[i] - 1) + 1];
6391 const int *node_local2global) {
6404 for (i = 0; i < local_mesh->
n_node; i++) {
6415 static int const_node_init_val_index(
6432 for (i = 0; i < local_mesh->
n_node; i++) {
6433 old_idx = node_local2global[i] - 1;
6447 static int const_node_init_val_item(
6452 int i, j, gstart, gend, lstart, lend;
6471 for (counter = 0, i = 0; i < local_mesh->
n_node; i++) {
6479 for (j = 0; j < lend - lstart; j++) {
6495 const int *node_local2global,
const char *node_flag,
6496 int current_domain) {
6504 rtc = const_n_dof(global_mesh, local_mesh);
6507 rtc = const_n_dof_grp(global_mesh, local_mesh);
6512 rtc = const_node_dof_index_mod(global_mesh, local_mesh, node_flag,
6516 rtc = const_node_dof_index(global_mesh, local_mesh, node_flag);
6525 rtc = const_node_dof_item(global_mesh, local_mesh);
6528 rtc = const_node(global_mesh, local_mesh, node_local2global);
6531 rtc = const_node_id(global_mesh, local_mesh, node_local2global);
6534 rtc = const_global_node_id(global_mesh, local_mesh, node_local2global);
6538 rtc = const_node_init_val_index(global_mesh, local_mesh, node_local2global);
6541 rtc = const_node_init_val_item(global_mesh, local_mesh, node_local2global);
6567 const int *elem_local2global) {
6579 for (i = 0; i < local_mesh->
n_elem; i++) {
6591 const int *elem_global2local) {
6606 for (counter = 0, i = 0; i < global_mesh->
n_elem_type; i++) {
6608 j < global_mesh->elem_type_index[i + 1]; j++) {
6609 if (elem_global2local[j]) counter++;
6623 static int const_elem_type_index_mod(
6628 int i, j, idx1, idx2, elem_tmp, elem1, elem2, n_int, n_bnd, n_out, maxe;
6641 n_int = n_int_elist[domain];
6642 n_bnd = n_bnd_elist[2 * domain];
6643 n_out = n_bnd_elist[2 * domain + 1] - n_bnd_elist[2 * domain];
6644 maxe = global_mesh->
n_elem + 1;
6646 for (counter = 0, i = 0; i < global_mesh->
n_elem_type; i++) {
6647 elem1 = (n_int == 0) ? maxe : int_elist[domain][0];
6648 elem2 = (n_out == 0) ? maxe : bnd_elist[domain][n_bnd];
6649 for (idx1 = 0, idx2 = 0, j = 0; j < n_int + n_out; j++) {
6650 if (elem1 < elem2) {
6651 elem_tmp = elem1 - 1;
6653 elem1 = (idx1 == n_int) ? maxe : int_elist[domain][idx1];
6655 elem_tmp = elem2 - 1;
6657 elem2 = (idx2 == n_out) ? maxe : bnd_elist[domain][idx2 + n_bnd];
6660 elem_tmp < global_mesh->elem_type_index[i + 1]) {
6687 const int *elem_local2global) {
6701 for (i = 0; i < local_mesh->
n_elem; i++) {
6702 old_idx = elem_local2global[i] - 1;
6718 const int *node_global2local,
6719 const int *elem_local2global) {
6723 int i, j, gstart, gend, lstart, lend;
6737 for (counter = 0, i = 0; i < local_mesh->
n_elem; i++) {
6743 for (j = 0; j < lend - lstart; j++) {
6745 local_mesh->
elem_node_item[lstart + j] = node_global2local[node - 1];
6759 const int *elem_local2global) {
6772 for (i = 0; i < local_mesh->
n_elem; i++) {
6774 global_mesh->
elem_ID[2 * (elem_local2global[i] - 1)];
6775 local_mesh->
elem_ID[2 * i + 1] =
6776 global_mesh->
elem_ID[2 * (elem_local2global[i] - 1) + 1];
6787 const int *elem_local2global) {
6800 for (i = 0; i < local_mesh->
n_elem; i++) {
6813 const int *elem_local2global) {
6826 for (i = 0; i < local_mesh->
n_elem; i++) {
6828 global_mesh->
section_ID[elem_local2global[i] - 1];
6839 const int *elem_local2global) {
6853 for (i = 0; i < local_mesh->
n_elem; i++) {
6854 old_idx = elem_local2global[i] - 1;
6879 const int *elem_local2global) {
6882 int i, j, gstart, gend, lstart, lend;
6899 for (counter = 0, i = 0; i < local_mesh->
n_elem; i++) {
6907 for (j = 0; j < lend - lstart; j++) {
6924 const int *node_global2local,
6925 const int *elem_global2local,
6926 const int *elem_local2global,
int current_domain) {
6935 rtc = const_n_elem_type(global_mesh, local_mesh);
6938 rtc = const_elem_type(global_mesh, local_mesh, elem_local2global);
6941 if (is_spdup_available(global_mesh)) {
6942 rtc = const_elem_type_index_mod(global_mesh, local_mesh, elem_global2local,
6945 rtc = const_elem_type_index(global_mesh, local_mesh, elem_global2local);
6950 rtc = const_elem_type_item(global_mesh, local_mesh);
6953 rtc = const_elem_node_index(global_mesh, local_mesh, elem_local2global);
6956 rtc = const_elem_node_item(global_mesh, local_mesh, node_global2local,
6960 rtc = const_elem_id(global_mesh, local_mesh, elem_local2global);
6963 rtc = const_global_elem_id(global_mesh, local_mesh, elem_local2global);
6966 rtc = const_section_id(global_mesh, local_mesh, elem_local2global);
6969 rtc = const_elem_mat_id_index(global_mesh, local_mesh, elem_local2global);
6972 rtc = const_n_elem_mat_id(local_mesh);
6975 rtc = const_elem_mat_id_item(global_mesh, local_mesh, elem_local2global);
6995 int current_domain) {
6996 local_mesh->
zero = (current_domain == 0) ? 1 : 0;
7016 int current_domain) {
7017 local_mesh->
my_rank = current_domain;
7037 const int *global2local) {
7052 new_id = global2local[local_mesh->
import_item[i] - 1];
7060 const int *global2local) {
7075 new_id = global2local[local_mesh->
export_item[i] - 1];
7083 const int *global2local) {
7098 new_id = global2local[local_mesh->
shared_item[i] - 1];
7107 const int *node_global2local,
7108 const int *elem_global2local,
int current_domain) {
7116 rtc = const_hecmw_comm(global_mesh, local_mesh);
7119 rtc = const_zero(local_mesh, current_domain);
7122 rtc = const_petot(global_mesh, local_mesh);
7125 rtc = const_pesmptot(global_mesh, local_mesh);
7128 rtc = const_my_rank(local_mesh, current_domain);
7131 rtc = const_errnof(global_mesh, local_mesh);
7134 rtc = const_n_subdomain(global_mesh, local_mesh);
7139 rtc = const_import_item(local_mesh, node_global2local);
7142 rtc = const_export_item(local_mesh, node_global2local);
7145 rtc = const_shared_item(local_mesh, elem_global2local);
7151 rtc = const_import_item(local_mesh, elem_global2local);
7154 rtc = const_export_item(local_mesh, elem_global2local);
7157 rtc = const_shared_item(local_mesh, node_global2local);
7191 static int const_when_i_was_refined_node(
7199 static int const_when_i_was_refined_elem(
7235 static int const_adapt_children_index(
7243 static int const_adapt_children_item(
7258 rtc = const_n_adapt(global_mesh, local_mesh);
7261 rtc = const_coarse_grid_level(global_mesh, local_mesh);
7264 rtc = const_when_i_was_refined_node(global_mesh, local_mesh);
7267 rtc = const_when_i_was_refined_elem(global_mesh, local_mesh);
7270 rtc = const_adapt_parent_type(global_mesh, local_mesh);
7273 rtc = const_adapt_type(global_mesh, local_mesh);
7276 rtc = const_adapt_level(global_mesh, local_mesh);
7279 rtc = const_adapt_parent(global_mesh, local_mesh);
7282 rtc = const_adapt_children_index(global_mesh, local_mesh);
7285 rtc = const_adapt_children_item(global_mesh, local_mesh);
7371 rtc = const_n_sect(global_mesh, local_mesh);
7374 rtc = const_sect_type(global_mesh, local_mesh);
7377 rtc = const_sect_opt(global_mesh, local_mesh);
7380 rtc = const_sect_mat_id_index(global_mesh, local_mesh);
7383 rtc = const_sect_mat_id_item(global_mesh, local_mesh);
7386 rtc = const_sect_i_index(global_mesh, local_mesh);
7389 rtc = const_sect_i_item(global_mesh, local_mesh);
7392 rtc = const_sect_r_index(global_mesh, local_mesh);
7395 rtc = const_sect_r_item(global_mesh, local_mesh);
7488 rtc = const_n_mat(global_mesh, local_mesh);
7491 rtc = const_n_mat_item(global_mesh, local_mesh);
7494 rtc = const_n_mat_subitem(global_mesh, local_mesh);
7497 rtc = const_n_mat_table(global_mesh, local_mesh);
7500 rtc = const_mat_name(global_mesh, local_mesh);
7503 rtc = const_mat_item_index(global_mesh, local_mesh);
7506 rtc = const_mat_subitem_index(global_mesh, local_mesh);
7509 rtc = const_mat_table_index(global_mesh, local_mesh);
7512 rtc = const_mat_val(global_mesh, local_mesh);
7515 rtc = const_mat_temp(global_mesh, local_mesh);
7529 const int *node_global2local,
char *mpc_flag) {
7532 int node, diff, evalsum, counter;
7535 for (counter = 0, i = 0; i < mpc_global->
n_mpc; i++) {
7542 if (node_global2local[node - 1] > 0) evalsum++;
7545 if (evalsum == diff) {
7550 mpc_local->
n_mpc = counter;
7557 const char *mpc_flag) {
7569 for (counter = 0, i = 0; i < mpc_global->
n_mpc; i++) {
7587 const int *node_global2local,
const char *mpc_flag) {
7590 int mcounter, icounter;
7600 for (mcounter = 0, icounter = 0, i = 0; i < mpc_global->
n_mpc; i++) {
7605 node_global2local[mpc_global->
mpc_item[j] - 1];
7621 const char *mpc_flag) {
7624 int mcounter, icounter;
7634 for (mcounter = 0, icounter = 0, i = 0; i < mpc_global->
n_mpc; i++) {
7654 const char *mpc_flag) {
7658 int mcounter, icounter;
7668 for (mcounter = 0, icounter = 0, i = 0; i < mpc_global->
n_mpc; i++) {
7688 const char *mpc_flag) {
7695 size =
sizeof(double) * mpc_local->
n_mpc;
7702 for (icounter = 0, i = 0; i < mpc_global->
n_mpc; i++) {
7718 const int *node_global2local) {
7719 char *mpc_flag =
NULL;
7728 if (global_mesh->
mpc->
n_mpc == 0) {
7729 init_struct_mpc(local_mesh);
7734 if (mpc_flag ==
NULL) {
7739 rtc = const_n_mpc(global_mesh, local_mesh, node_global2local, mpc_flag);
7743 init_struct_mpc(local_mesh);
7748 rtc = const_mpc_index(global_mesh, local_mesh, mpc_flag);
7751 rtc = const_mpc_item(global_mesh, local_mesh, node_global2local, mpc_flag);
7754 rtc = const_mpc_dof(global_mesh, local_mesh, mpc_flag);
7757 rtc = const_mpc_val(global_mesh, local_mesh, mpc_flag);
7760 rtc = const_mpc_const(global_mesh, local_mesh, mpc_flag);
7790 static int const_amp_type_definition(
7842 if (global_mesh->
amp->
n_amp == 0) {
7843 init_struct_amp(local_mesh);
7847 rtc = const_n_amp(global_mesh, local_mesh);
7850 rtc = const_amp_name(global_mesh, local_mesh);
7853 rtc = const_amp_type_definition(global_mesh, local_mesh);
7856 rtc = const_amp_type_time(global_mesh, local_mesh);
7859 rtc = const_amp_type_value(global_mesh, local_mesh);
7862 rtc = const_amp_index(global_mesh, local_mesh);
7865 rtc = const_amp_val(global_mesh, local_mesh);
7868 rtc = const_amp_table(global_mesh, local_mesh);
7880 static int *const_node_grp_mask_eqn(
7883 int eqn_block_idx) {
7885 int *n_eqn_item =
NULL;
7887 int i, j, is, ie, js;
7889 is = node_group_global->
grp_index[eqn_block_idx];
7890 ie = node_group_global->
grp_index[eqn_block_idx + 1];
7892 n_eqn_item = (
int *)
HECMW_malloc(
sizeof(
int) * (ie - is));
7893 if (n_eqn_item ==
NULL) {
7898 for (js = 0, i = 0; i < ie - is; i++) {
7899 diff = node_group_global->
grp_item[is + i] - js;
7900 for (evalsum = 0, j = js; j < node_group_global->
grp_item[is + i]; j++) {
7901 if (node_global2local[j] > 0 &&
7908 n_eqn_item[i] = diff;
7913 js = node_group_global->
grp_item[is + i];
7938 const int *node_global2local,
7939 const int *n_eqn_item,
int eqn_block_idx) {
7953 for (counter = 0, i = 0; i < node_group_global->
n_grp; i++) {
7954 if (i != eqn_block_idx) {
7955 for (j = node_group_global->
grp_index[i];
7956 j < node_group_global->
grp_index[i + 1]; j++) {
7957 node = node_group_global->
grp_item[j];
7958 if (node_global2local[node - 1]) counter++;
7964 for (j = 0; j < diff; j++) {
7965 if (n_eqn_item[j] > 0) counter++;
7969 node_group_local->
grp_index[i + 1] = counter;
7979 static int const_node_grp_index_mod(
7982 const int *n_eqn_item,
int eqn_block_idx,
int domain) {
7996 for (counter = 0, i = 0; i < node_group_global->
n_grp; i++) {
7997 if (i != eqn_block_idx) {
7998 if (node_group_global->
grp_index[i + 1] -
8001 counter += n_int_nlist[domain];
8002 counter += n_bnd_nlist[2 * domain + 1] - n_bnd_nlist[2 * domain];
8004 counter += ngrp_idx[domain][i + 1] - ngrp_idx[domain][i];
8017 for (j = 0; j < diff; j++) {
8018 if (n_eqn_item[j] > 0) counter++;
8022 node_group_local->
grp_index[i + 1] = counter;
8033 const int *node_global2local,
8034 const int *n_eqn_item,
int eqn_block_idx) {
8040 int i, j, k, js, je, ks, ls;
8042 size =
sizeof(int) * node_group_local->
grp_index[node_group_local->
n_grp];
8049 for (counter = 0, i = 0; i < node_group_global->
n_grp; i++) {
8050 if (i != eqn_block_idx) {
8051 for (j = node_group_global->
grp_index[i];
8052 j < node_group_global->
grp_index[i + 1]; j++) {
8053 node = node_group_global->
grp_item[j];
8054 if (node_global2local[node - 1]) {
8055 node_group_local->
grp_item[counter++] = node_global2local[node - 1];
8061 je = node_group_global->
grp_index[i + 1];
8062 for (ks = 0, ls = 0, j = js; j < je; j++) {
8063 if (n_eqn_item[j - js]) {
8065 node_group_global->
grp_item[j] - ks);
8066 node_group_local->
grp_item[counter] = ls + n_eqn_item[j - js];
8068 for (k = ks; k < node_group_global->
grp_item[j]; k++) {
8070 node_global2local[k] <=
8071 node_group_local->
grp_item[counter]);
8073 ls = node_group_local->
grp_item[counter];
8076 ks = node_group_global->
grp_item[j];
8091 const int *node_global2local,
8092 const int *n_eqn_item,
int eqn_block_idx,
8099 int i, j, k, js, je, ks, ls;
8100 int idx1, idx2, node1, node2, n_int, n_bnd, n_out, maxn;
8102 size =
sizeof(int) * node_group_local->
grp_index[node_group_local->
n_grp];
8109 n_int = n_int_nlist[domain];
8110 n_bnd = n_bnd_nlist[2 * domain];
8111 n_out = n_bnd_nlist[2 * domain + 1] - n_bnd_nlist[2 * domain];
8112 maxn = global_mesh->
n_node + 1;
8114 for (counter = 0, i = 0; i < node_group_global->
n_grp; i++) {
8115 if (i != eqn_block_idx) {
8116 if (node_group_global->
grp_index[i + 1] -
8121 node1 = (n_int == 0) ? maxn : int_nlist[domain][0];
8122 node2 = (n_out == 0) ? maxn : bnd_nlist[domain][n_bnd];
8123 for (j = 0; j < n_int + n_out; j++) {
8124 if (node1 < node2) {
8125 node_group_local->
grp_item[counter++] =
8126 node_global2local[node1 - 1];
8128 node1 = (idx1 == n_int) ? maxn : int_nlist[domain][idx1];
8130 node_group_local->
grp_item[counter++] =
8131 node_global2local[node2 - 1];
8133 node2 = (idx2 == n_out) ? maxn : bnd_nlist[domain][idx2 + n_bnd];
8137 if (ngrp_idx[domain][i + 1] - ngrp_idx[domain][i] == 0)
continue;
8138 for (j = ngrp_idx[domain][i]; j < ngrp_idx[domain][i + 1]; j++) {
8139 node = ngrp_item[domain][j];
8140 node_group_local->
grp_item[counter++] = node_global2local[node - 1];
8145 je = node_group_global->
grp_index[i + 1];
8146 for (ks = 0, ls = 0, j = js; j < je; j++) {
8147 if (n_eqn_item[j - js]) {
8149 node_group_global->
grp_item[j] - ks);
8150 node_group_local->
grp_item[counter] = ls + n_eqn_item[j - js];
8152 for (k = ks; k < node_group_global->
grp_item[j]; k++) {
8154 node_global2local[k] <=
8155 node_group_local->
grp_item[counter]);
8157 ls = node_group_local->
grp_item[counter];
8160 ks = node_group_global->
grp_item[j];
8174 const int *node_global2local,
8175 int current_domain) {
8176 int *n_eqn_item =
NULL;
8187 init_struct_node_grp(local_mesh);
8191 eqn_block_idx = search_eqn_block_idx(global_mesh);
8193 if (eqn_block_idx >= 0) {
8194 n_eqn_item = const_node_grp_mask_eqn(global_mesh, local_mesh,
8195 node_global2local, eqn_block_idx);
8196 if (n_eqn_item ==
NULL)
goto error;
8199 rtc = const_node_n_grp(global_mesh, local_mesh);
8202 rtc = const_node_grp_name(global_mesh, local_mesh);
8205 if (is_spdup_available(global_mesh)) {
8206 rtc = const_node_grp_index_mod(global_mesh, local_mesh, node_global2local,
8207 n_eqn_item, eqn_block_idx, current_domain);
8209 rtc = const_node_grp_item_mod(global_mesh, local_mesh, node_global2local,
8210 n_eqn_item, eqn_block_idx, current_domain);
8214 rtc = const_node_grp_index(global_mesh, local_mesh, node_global2local,
8215 n_eqn_item, eqn_block_idx);
8217 rtc = const_node_grp_item(global_mesh, local_mesh, node_global2local,
8218 n_eqn_item, eqn_block_idx);
8251 const int *elem_global2local) {
8265 for (counter = 0, i = 0; i < elem_group_global->
n_grp; i++) {
8266 for (j = elem_group_global->
grp_index[i];
8267 j < elem_group_global->
grp_index[i + 1]; j++) {
8268 elem = elem_group_global->
grp_item[j];
8269 if (elem_global2local[elem - 1]) counter++;
8271 elem_group_local->
grp_index[i + 1] = counter;
8281 static int const_elem_grp_index_mod(
8289 int i, j, idx1, idx2, elem1, elem2;
8298 for (counter = 0, i = 0; i < elem_group_global->
n_grp; i++) {
8301 counter += n_int_elist[domain];
8302 counter += n_bnd_elist[2 * domain + 1] - n_bnd_elist[2 * domain];
8304 counter += egrp_idx[domain][i + 1] - egrp_idx[domain][i];
8306 elem_group_local->
grp_index[i + 1] = counter;
8317 const int *elem_global2local) {
8325 size =
sizeof(int) * elem_group_local->
grp_index[elem_group_local->
n_grp];
8332 for (counter = 0, i = 0; i < elem_group_global->
n_grp; i++) {
8333 for (j = elem_group_global->
grp_index[i];
8334 j < elem_group_global->
grp_index[i + 1]; j++) {
8335 elem = elem_group_global->
grp_item[j];
8336 if (elem_global2local[elem - 1]) {
8337 elem_group_local->
grp_item[counter++] = elem_global2local[elem - 1];
8352 const int *elem_global2local,
int domain) {
8358 int i, j, idx1, idx2, elem1, elem2, n_int, n_bnd, n_out, maxe;
8360 size =
sizeof(int) * elem_group_local->
grp_index[elem_group_local->
n_grp];
8367 n_int = n_int_elist[domain];
8368 n_bnd = n_bnd_elist[2 * domain];
8369 n_out = n_bnd_elist[2 * domain + 1] - n_bnd_elist[2 * domain];
8370 maxe = global_mesh->
n_elem + 1;
8372 for (counter = 0, i = 0; i < elem_group_global->
n_grp; i++) {
8375 elem1 = (n_int == 0) ? maxe : int_elist[domain][0];
8376 elem2 = (n_out == 0) ? maxe : bnd_elist[domain][n_bnd];
8377 for (idx1 = 0, idx2 = 0, j = 0; j < n_int + n_out; j++) {
8378 if (elem1 < elem2) {
8379 elem_group_local->
grp_item[counter++] = elem_global2local[elem1 - 1];
8381 elem1 = (idx1 == n_int) ? maxe : int_elist[domain][idx1];
8383 elem_group_local->
grp_item[counter++] = elem_global2local[elem2 - 1];
8385 elem2 = (idx2 == n_out) ? maxe : bnd_elist[domain][idx2 + n_bnd];
8389 if (egrp_idx[domain][i + 1] - egrp_idx[domain][i] == 0)
continue;
8390 for (j = egrp_idx[domain][i]; j < egrp_idx[domain][i + 1]; j++) {
8391 elem = egrp_item[domain][j];
8392 elem_group_local->
grp_item[counter++] = elem_global2local[elem - 1];
8406 const int *elem_global2local,
8407 int current_domain) {
8417 init_struct_elem_grp(local_mesh);
8421 rtc = const_elem_n_grp(global_mesh, local_mesh);
8424 rtc = const_elem_grp_name(global_mesh, local_mesh);
8427 if (is_spdup_available(global_mesh)) {
8428 rtc = const_elem_grp_index_mod(global_mesh, local_mesh, elem_global2local,
8431 rtc = const_elem_grp_item_mod(global_mesh, local_mesh, elem_global2local,
8436 rtc = const_elem_grp_index(global_mesh, local_mesh, elem_global2local);
8438 rtc = const_elem_grp_item(global_mesh, local_mesh, elem_global2local);
8467 const int *elem_global2local) {
8481 for (counter = 0, i = 0; i < surf_group_global->
n_grp; i++) {
8482 for (j = surf_group_global->
grp_index[i];
8483 j < surf_group_global->
grp_index[i + 1]; j++) {
8484 elem = surf_group_global->
grp_item[2 * j];
8485 if (elem_global2local[elem - 1]) counter++;
8487 surf_group_local->
grp_index[i + 1] = counter;
8498 const int *elem_global2local) {
8506 size =
sizeof(int) * surf_group_local->
grp_index[surf_group_local->
n_grp] * 2;
8513 for (counter = 0, i = 0; i < surf_group_global->
n_grp; i++) {
8514 for (j = surf_group_global->
grp_index[i];
8515 j < surf_group_global->
grp_index[i + 1]; j++) {
8516 elem = surf_group_global->
grp_item[2 * j];
8517 surf = surf_group_global->
grp_item[2 * j + 1];
8518 if (elem_global2local[elem - 1]) {
8519 surf_group_local->
grp_item[2 * counter] = elem_global2local[elem - 1];
8520 surf_group_local->
grp_item[2 * counter + 1] = surf;
8535 const int *elem_global2local) {
8545 init_struct_surf_grp(local_mesh);
8549 rtc = const_surf_n_grp(global_mesh, local_mesh);
8552 rtc = const_surf_grp_name(global_mesh, local_mesh);
8555 rtc = const_surf_grp_index(global_mesh, local_mesh, elem_global2local);
8558 rtc = const_surf_grp_item(global_mesh, local_mesh, elem_global2local);
8570 static int const_contact_pair_n_pair(
8597 for (i = 0; i < cpair_global->
n_pair; i++) {
8598 cpair_local->
type[i] = cpair_global->
type[i];
8607 static int const_contact_pair_slave_grp_id(
8621 for (i = 0; i < cpair_global->
n_pair; i++) {
8631 static int const_contact_pair_slave_orisgrp_id(
8645 for (i = 0; i < cpair_global->
n_pair; i++) {
8655 static int const_contact_pair_master_grp_id(
8669 for (i = 0; i < cpair_global->
n_pair; i++) {
8689 init_struct_contact_pair(local_mesh);
8693 rtc = const_contact_pair_n_pair(global_mesh, local_mesh);
8696 rtc = const_contact_pair_name(global_mesh, local_mesh);
8699 rtc = const_contact_pair_type(global_mesh, local_mesh);
8702 rtc = const_contact_pair_slave_grp_id(global_mesh, local_mesh);
8705 rtc = const_contact_pair_slave_orisgrp_id(global_mesh, local_mesh);
8708 rtc = const_contact_pair_master_grp_id(global_mesh, local_mesh);
8723 const char *node_flag,
const char *elem_flag,
8724 int *node_global2local,
int *elem_global2local,
8725 int current_domain) {
8726 int *node_local2global =
NULL;
8727 int *elem_local2global =
NULL;
8732 rtc = set_node_global2local(global_mesh, local_mesh, node_global2local,
8733 node_flag, current_domain);
8737 if (node_local2global ==
NULL) {
8742 if (is_spdup_available(global_mesh)) {
8743 rtc = set_node_local2global_mod(global_mesh, local_mesh, node_global2local,
8744 node_local2global, current_domain);
8746 rtc = set_node_local2global(global_mesh, local_mesh, node_global2local,
8752 rtc = set_elem_global2local(global_mesh, local_mesh, elem_global2local,
8753 elem_flag, current_domain);
8758 if (elem_local2global ==
NULL) {
8763 if (is_spdup_available(global_mesh)) {
8764 rtc = set_elem_local2global_mod(global_mesh, local_mesh, elem_global2local,
8765 elem_local2global, current_domain);
8767 rtc = set_elem_local2global(global_mesh, local_mesh, elem_global2local,
8773 rtc = const_global_info(global_mesh, local_mesh);
8776 rtc = const_node_info(global_mesh, local_mesh, node_local2global, node_flag,
8780 rtc = const_elem_info(global_mesh, local_mesh, node_global2local,
8781 elem_global2local, elem_local2global, current_domain);
8784 rtc = const_comm_info(global_mesh, local_mesh, node_global2local,
8785 elem_global2local, current_domain);
8788 rtc = const_adapt_info(global_mesh, local_mesh);
8791 rtc = const_sect_info(global_mesh, local_mesh);
8794 rtc = const_mat_info(global_mesh, local_mesh);
8797 rtc = const_mpc_info(global_mesh, local_mesh, node_global2local);
8800 rtc = const_amp_info(global_mesh, local_mesh);
8803 rtc = const_node_grp_info(global_mesh, local_mesh, node_global2local,
8807 rtc = const_elem_grp_info(global_mesh, local_mesh, elem_global2local,
8811 rtc = const_surf_grp_info(global_mesh, local_mesh, elem_global2local);
8814 rtc = const_contact_pair_info(global_mesh, local_mesh);
8817 rtc = clear_node_global2local(global_mesh, local_mesh, node_global2local,
8819 rtc = clear_elem_global2local(global_mesh, local_mesh, elem_global2local,
8832 clean_struct_local_mesh(local_mesh);
8843 static int print_ucd_entire_set_node_data(
8858 result_data->
nn_dof[0] = 1;
8878 strcpy(result_data->
node_label[0],
"rank_of_node");
8880 for (nn_item = 0, i = 0; i < result_data->
nn_component; i++) {
8881 nn_item += result_data->
nn_dof[i];
8884 size =
sizeof(double) * nn_item * global_mesh->
n_node;
8893 for (i = 0; i < global_mesh->
n_node; i++) {
8899 for (i = 0; i < global_mesh->
n_node; i++) {
8905 (double)global_mesh->
node_ID[2 * i + 1];
8919 free_struct_result_data(result_data);
8927 static int print_ucd_entire_set_elem_data(
8942 result_data->
ne_dof[0] = 1;
8962 strcpy(result_data->
elem_label[0],
"partitioning_image");
8965 for (i = 0; i < global_mesh->
n_elem; i++) {
8986 for (ne_item = 0, i = 0; i < result_data->
ne_component; i++) {
8987 ne_item += result_data->
ne_dof[i];
8990 size =
sizeof(double) * ne_item * global_mesh->
n_elem;
8999 for (i = 0; i < global_mesh->
n_elem; i++) {
9005 (double)global_mesh->
elem_ID[2 * i + 1];
9011 for (i = 0; i < global_mesh->
n_elem; i++) {
9025 free_struct_result_data(result_data);
9033 const char *node_flag,
const char *elem_flag,
9034 const char *ofname) {
9039 if (result_data ==
NULL) {
9043 init_struct_result_data(result_data);
9046 if (print_ucd_entire_set_node_data(global_mesh, result_data, node_flag)) {
9050 if (print_ucd_entire_set_elem_data(global_mesh, result_data, elem_flag)) {
9058 free_struct_result_data(result_data);
9063 free_struct_result_data(result_data);
9136 char *node_flag =
NULL;
9137 char *elem_flag =
NULL;
9138 char *node_flag_neighbor =
NULL;
9139 char *elem_flag_neighbor =
NULL;
9140 int *node_global2local =
NULL;
9141 int *elem_global2local =
NULL;
9143 int *num_elem, *num_node, *num_ielem, *num_inode, *num_nbpe;
9144 int *sum_elem, *sum_node, *sum_ielem, *sum_inode, *sum_nbpe;
9145 int current_domain, nrank, iS, iE;
9148 int error_in_ompsection = 0;
9150 if (global_mesh ==
NULL) {
9159 rtc = init_partition(global_mesh,
cont_data);
9165 if (global_mesh->
my_rank == 0) {
9184 if (global_mesh->
my_rank == 0) {
9189 "part_out", global_mesh->
n_subdomain, current_domain);
9190 if (ofheader ==
NULL) {
9192 error_in_ompsection = 1;
9195 if (ofheader->
n_mesh == 0) {
9197 error_in_ompsection = 1;
9206 "Starting writing local mesh for domain #%d...",
9220 if (rtc != 0)
goto error;
9222 if (rtc != 0)
goto error;
9224 if (rtc != 0)
goto error;
9226 if (rtc != 0)
goto error;
9229 if (rtc)
goto error;
9237 if (num_elem ==
NULL) {
9242 if (num_node ==
NULL) {
9247 if (num_ielem ==
NULL) {
9252 if (num_inode ==
NULL) {
9257 if (num_nbpe ==
NULL) {
9262 if (sum_elem ==
NULL) {
9267 if (sum_node ==
NULL) {
9272 if (sum_ielem ==
NULL) {
9277 if (sum_inode ==
NULL) {
9282 if (sum_nbpe ==
NULL) {
9287 rtc = wnumbering(global_mesh,
cont_data);
9291 if (global_mesh->
my_rank == 0) {
9292 print_part(global_mesh,
cont_data->part_file_name);
9297 rtc = spdup_makelist_main(global_mesh);
9301 #pragma omp parallel default(none), \
9302 private(node_flag, elem_flag, local_mesh, nrank, iS, iE, i, \
9303 current_domain, rtc, ofheader, ofname), \
9304 private(node_global2local, elem_global2local, \
9305 node_flag_neighbor, elem_flag_neighbor), \
9306 shared(global_mesh, cont_data, num_elem, num_node, \
9307 num_ielem, num_inode, num_nbpe, error_in_ompsection)
9312 if (node_flag ==
NULL) {
9314 error_in_ompsection = 1;
9318 if (elem_flag ==
NULL) {
9320 error_in_ompsection = 1;
9326 if (node_global2local ==
NULL) {
9328 error_in_ompsection = 1;
9332 if (elem_global2local ==
NULL) {
9334 error_in_ompsection = 1;
9337 node_flag_neighbor =
9339 if (node_flag_neighbor ==
NULL) {
9341 error_in_ompsection = 1;
9344 elem_flag_neighbor =
9346 if (elem_flag_neighbor ==
NULL) {
9348 error_in_ompsection = 1;
9351 memset(node_flag_neighbor, 0,
sizeof(
char) * global_mesh->
n_node);
9352 memset(elem_flag_neighbor, 0,
sizeof(
char) * global_mesh->
n_elem);
9355 if (local_mesh ==
NULL) {
9356 error_in_ompsection = 1;
9367 #pragma omp for schedule(dynamic, 1), reduction(+ : error_in_ompsection)
9369 for (i = iS; i < iE; i++) {
9370 if (error_in_ompsection)
continue;
9377 rtc = create_neighbor_info(global_mesh, local_mesh, node_flag, elem_flag,
9380 error_in_ompsection = 1;
9385 rtc = create_comm_info(global_mesh, local_mesh, node_flag, elem_flag,
9386 node_flag_neighbor, elem_flag_neighbor,
9389 error_in_ompsection = 1;
9394 rtc = const_local_data(global_mesh, local_mesh,
cont_data, node_flag,
9395 elem_flag, node_global2local, elem_global2local,
9398 error_in_ompsection = 1;
9402 num_elem[i] = local_mesh->
n_elem;
9403 num_node[i] = local_mesh->
n_node;
9409 "part_out", global_mesh->
n_subdomain, current_domain);
9410 if (ofheader ==
NULL) {
9412 error_in_ompsection = 1;
9415 if (ofheader->
n_mesh == 0) {
9417 error_in_ompsection = 1;
9426 "Starting writing local mesh for domain #%d...",
9433 error_in_ompsection = 1;
9439 clean_struct_local_mesh(local_mesh);
9444 if (is_spdup_available(global_mesh)) {
9446 spdup_clear_IEB(node_flag, elem_flag, current_domain);
9449 for (j = 0; j < global_mesh->
n_node; j++) {
9452 for (j = 0; j < global_mesh->
n_elem; j++) {
9458 if (error_in_ompsection)
goto error_omp;
9463 if (global_mesh->
my_rank == 0) {
9464 print_ucd_entire(global_mesh, node_flag, elem_flag,
9481 if (error_in_ompsection)
goto error;
9486 if (rtc != 0)
goto error;
9489 if (rtc != 0)
goto error;
9492 if (rtc != 0)
goto error;
9495 if (rtc != 0)
goto error;
9498 if (rtc != 0)
goto error;
9500 if (global_mesh->
my_rank == 0) {
9503 if (rtc != 0)
goto error;
9505 if (rtc != 0)
goto error;
9507 if (rtc != 0)
goto error;
9509 if (rtc != 0)
goto error;
9511 if (rtc != 0)
goto error;
9514 if (rtc)
goto error;
9530 spdup_freelist(global_mesh);
9563 if (global_mesh ==
NULL) {
9572 if (local_mesh ==
NULL)
goto error;