6 #define INAGAKI_PARTITIONER
30 #ifdef HECMW_PART_WITH_METIS
54 #define NEIGHBOR_DOMAIN 2
66 #define QSORT_LOWER 50
68 #define MASK_BIT(map, bit) ((map) |= (bit))
70 #define EVAL_BIT(map, bit) ((map) & (bit))
72 #define INV_BIT(map, bit) ((map) ^= (bit))
74 #define CLEAR_BIT(map, bit) \
78 #define CLEAR_IEB(map) \
82 #define CLEAR_MM(map) \
86 #define DSWAP(a, aa) \
91 #define ISWAP(b, bb) \
98 #define RTC_ERROR (-1)
102 #define MAX_NODE_SIZE 20
119 static int *n_int_nlist =
NULL;
120 static int *n_bnd_nlist =
NULL;
121 static int *n_int_elist =
NULL;
122 static int *n_bnd_elist =
NULL;
123 static int **int_nlist =
NULL;
124 static int **bnd_nlist =
NULL;
125 static int **int_elist =
NULL;
126 static int **bnd_elist =
NULL;
127 static int **ngrp_idx =
NULL;
128 static int **ngrp_item =
NULL;
129 static int **egrp_idx =
NULL;
130 static int **egrp_item =
NULL;
132 static int spdup_clear_MMbnd(
char *node_flag,
char *elem_flag,
133 int current_domain) {
136 for (i = 0; i < n_bnd_nlist[2 * current_domain + 1]; i++) {
137 node = bnd_nlist[current_domain][i];
140 for (i = 0; i < n_bnd_elist[2 * current_domain + 1]; i++) {
141 elem = bnd_elist[current_domain][i];
147 static int spdup_clear_IEB(
char *node_flag,
char *elem_flag,
148 int current_domain) {
151 for (i = 0; i < n_int_nlist[current_domain]; i++) {
152 node = int_nlist[current_domain][i];
155 for (i = 0; i < n_bnd_nlist[2 * current_domain + 1]; i++) {
156 node = bnd_nlist[current_domain][i];
159 for (i = 0; i < n_int_elist[current_domain]; i++) {
160 elem = int_elist[current_domain][i];
163 for (i = 0; i < n_bnd_elist[2 * current_domain + 1]; i++) {
164 elem = bnd_elist[current_domain][i];
175 int node, n_domain, domain[20], flag;
179 if (n_int_nlist ==
NULL) {
184 if (n_bnd_nlist ==
NULL) {
189 if (n_int_elist ==
NULL) {
194 if (n_bnd_elist ==
NULL) {
199 if (int_nlist ==
NULL) {
204 if (bnd_nlist ==
NULL) {
209 if (int_elist ==
NULL) {
214 if (bnd_elist ==
NULL) {
220 for (i = 0; i < global_mesh->
n_node; i++) {
221 n_int_nlist[global_mesh->
node_ID[2 * i + 1]]++;
225 for (i = 0; i < global_mesh->
n_elem; i++) {
226 n_int_elist[global_mesh->
elem_ID[2 * i + 1]]++;
230 for (i = 0; i < global_mesh->
n_elem; i++) {
235 domain[0] = global_mesh->
node_ID[2 * node - 1];
236 for (j = js + 1; j < je; j++) {
238 for (flag = 0, k = 0; k < n_domain; k++) {
239 if (global_mesh->
node_ID[2 * node - 1] == domain[k]) {
245 domain[n_domain] = global_mesh->
node_ID[2 * node - 1];
251 for (j = 0; j < n_domain; j++) {
252 n_bnd_elist[domain[j]]++;
253 n_bnd_nlist[domain[j]] += (int)(je - js);
260 int_nlist[i] = (
int *)
HECMW_calloc(n_int_nlist[i],
sizeof(
int));
261 if (int_nlist[i] ==
NULL) {
265 bnd_nlist[i] = (
int *)
HECMW_calloc(n_bnd_nlist[i],
sizeof(
int));
266 if (bnd_nlist[i] ==
NULL) {
270 int_elist[i] = (
int *)
HECMW_calloc(n_int_elist[i],
sizeof(
int));
271 if (int_elist[i] ==
NULL) {
275 bnd_elist[i] = (
int *)
HECMW_calloc(n_bnd_elist[i],
sizeof(
int));
276 if (bnd_elist[i] ==
NULL) {
288 static int int_cmp(
const void *v1,
const void *v2) {
291 i1 = (
const int *)v1;
292 i2 = (
const int *)v2;
294 if (*i1 < *i2)
return -1;
295 if (*i1 > *i2)
return 1;
303 int node, elem, counter;
306 for (counter = 0, j = 0; j < n_bnd_elist[2 * domain + 1]; j++) {
307 elem = bnd_elist[domain][j];
310 for (k = ks; k < ke; k++) {
312 bnd_nlist[domain][counter] = node;
317 qsort(bnd_nlist[domain], counter,
sizeof(
int), int_cmp);
321 for (j = 1; j < counter; j++) {
322 if (bnd_nlist[domain][j - 1] != bnd_nlist[domain][j]) {
323 bnd_nlist[domain][i] = bnd_nlist[domain][j];
331 n_bnd_nlist[2 * domain + 1] = i;
340 int bnd_and_int, bnd_not_int;
341 int n_nlist, n_elist;
344 n_nlist = n_bnd_nlist[2 * domain + 1];
354 for (i = 0; i < n_nlist; i++) {
355 node = bnd_nlist[domain][i];
356 if (global_mesh->
node_ID[2 * node - 1] == domain) {
357 work[bnd_and_int] = node;
361 for (i = 0; i < n_nlist; i++) {
362 node = bnd_nlist[domain][i];
363 if (global_mesh->
node_ID[2 * node - 1] != domain) {
364 work[bnd_and_int + bnd_not_int] = node;
368 n_bnd_nlist[2 * domain] = bnd_and_int;
369 n_bnd_nlist[2 * domain + 1] = bnd_and_int + bnd_not_int;
374 bnd_nlist[domain] = (
int *)
HECMW_calloc(n_nlist,
sizeof(
int));
375 if (bnd_nlist[domain] ==
NULL) {
379 for (i = 0; i < n_nlist; i++) {
380 bnd_nlist[domain][i] = work[i];
385 n_elist = n_bnd_elist[2 * domain + 1];
395 for (i = 0; i < n_elist; i++) {
396 elem = bnd_elist[domain][i];
397 if (global_mesh->
elem_ID[2 * elem - 1] == domain) {
398 work[bnd_and_int] = elem;
402 for (i = 0; i < n_elist; i++) {
403 elem = bnd_elist[domain][i];
404 if (global_mesh->
elem_ID[2 * elem - 1] != domain) {
405 work[bnd_and_int + bnd_not_int] = elem;
409 n_bnd_elist[2 * domain] = bnd_and_int;
410 n_bnd_elist[2 * domain + 1] = bnd_and_int + bnd_not_int;
411 for (i = 0; i < n_elist; i++) {
412 bnd_elist[domain][i] = work[i];
427 int node, elem, n_domain, domain[20], flag;
434 n_bnd_nlist[2 * i] = 0;
435 n_bnd_nlist[2 * i + 1] = 0;
437 n_bnd_elist[2 * i] = 0;
438 n_bnd_elist[2 * i + 1] = 0;
442 for (i = 0; i < global_mesh->
n_node; i++) {
443 current_domain = global_mesh->
node_ID[2 * i + 1];
444 int_nlist[current_domain][n_int_nlist[current_domain]] = i + 1;
445 n_int_nlist[current_domain]++;
449 for (i = 0; i < global_mesh->
n_elem; i++) {
450 current_domain = global_mesh->
elem_ID[2 * i + 1];
451 int_elist[current_domain][n_int_elist[current_domain]] = i + 1;
452 n_int_elist[current_domain]++;
456 for (i = 0; i < global_mesh->
n_elem; i++) {
461 domain[0] = global_mesh->
node_ID[2 * node - 1];
462 for (j = js + 1; j < je; j++) {
464 for (flag = 0, k = 0; k < n_domain; k++) {
465 if (global_mesh->
node_ID[2 * node - 1] == domain[k]) {
471 domain[n_domain] = global_mesh->
node_ID[2 * node - 1];
477 for (j = 0; j < n_domain; j++) {
478 bnd_elist[domain[j]][n_bnd_elist[2 * domain[j] + 1]] = i + 1;
479 n_bnd_elist[2 * domain[j] + 1]++;
486 rtc = get_boundary_nodelist(global_mesh, i);
491 rtc = sort_and_resize_bndlist(global_mesh, i);
501 static int spdup_make_node_grouplist(
504 int i, j, k, node, n_bnd, n_out;
505 int *n_domain =
NULL;
512 if (n_domain ==
NULL) {
518 n_bnd = n_bnd_nlist[2 * i];
519 n_out = n_bnd_nlist[2 * i + 1] - n_bnd_nlist[2 * i];
520 if (n_out == 0)
continue;
521 for (j = 0; j < n_out; j++) {
522 node = bnd_nlist[i][n_bnd + j];
523 n_domain[node - 1]++;
528 if (domain ==
NULL) {
532 for (i = 0; i < global_mesh->
n_node; i++) {
535 if (domain[i] ==
NULL) {
539 domain[i][0] = global_mesh->
node_ID[2 * i + 1];
543 n_bnd = n_bnd_nlist[2 * i];
544 n_out = n_bnd_nlist[2 * i + 1] - n_bnd_nlist[2 * i];
545 if (n_out == 0)
continue;
546 for (j = 0; j < n_out; j++) {
547 node = bnd_nlist[i][n_bnd + j];
548 domain[node - 1][n_domain[node - 1]] = i;
549 n_domain[node - 1]++;
555 if (ngrp_idx ==
NULL) {
562 if (ngrp_idx[i] ==
NULL) {
567 for (i = 0; i < node_group_global->
n_grp; i++) {
569 ngrp_idx[j][i + 1] = ngrp_idx[j][i];
575 for (j = node_group_global->
grp_index[i];
576 j < node_group_global->
grp_index[i + 1]; j++) {
577 node = node_group_global->
grp_item[j];
578 for (k = 0; k < n_domain[node - 1]; k++) {
579 current_domain = domain[node - 1][k];
580 ngrp_idx[current_domain][i + 1]++;
587 if (ngrp_item ==
NULL) {
594 if (ngrp_item[i] ==
NULL) {
600 for (i = 0; i < node_group_global->
n_grp; i++) {
605 for (j = node_group_global->
grp_index[i];
606 j < node_group_global->
grp_index[i + 1]; j++) {
607 node = node_group_global->
grp_item[j];
608 for (k = 0; k < n_domain[node - 1]; k++) {
609 current_domain = domain[node - 1][k];
610 ngrp_item[current_domain][counter[current_domain]] = node;
611 counter[current_domain]++;
616 for (i = 0; i < global_mesh->
n_node; i++) {
627 static int spdup_make_element_grouplist(
630 int i, j, k, elem, n_bnd, n_out;
631 int *n_domain =
NULL;
638 if (n_domain ==
NULL) {
644 n_bnd = n_bnd_elist[2 * i];
645 n_out = n_bnd_elist[2 * i + 1] - n_bnd_elist[2 * i];
646 if (n_out == 0)
continue;
647 for (j = 0; j < n_out; j++) {
648 elem = bnd_elist[i][n_bnd + j];
649 n_domain[elem - 1]++;
654 if (domain ==
NULL) {
658 for (i = 0; i < global_mesh->
n_elem; i++) {
661 if (domain[i] ==
NULL) {
665 domain[i][0] = global_mesh->
elem_ID[2 * i + 1];
669 n_bnd = n_bnd_elist[2 * i];
670 n_out = n_bnd_elist[2 * i + 1] - n_bnd_elist[2 * i];
671 if (n_out == 0)
continue;
672 for (j = 0; j < n_out; j++) {
673 elem = bnd_elist[i][n_bnd + j];
674 domain[elem - 1][n_domain[elem - 1]] = i;
675 n_domain[elem - 1]++;
681 if (egrp_idx ==
NULL) {
688 if (egrp_idx[i] ==
NULL) {
693 for (i = 0; i < elem_group_global->
n_grp; i++) {
695 egrp_idx[j][i + 1] = egrp_idx[j][i];
701 for (j = elem_group_global->
grp_index[i];
702 j < elem_group_global->
grp_index[i + 1]; j++) {
703 elem = elem_group_global->
grp_item[j];
704 for (k = 0; k < n_domain[elem - 1]; k++) {
705 current_domain = domain[elem - 1][k];
706 egrp_idx[current_domain][i + 1]++;
713 if (egrp_item ==
NULL) {
720 if (egrp_item[i] ==
NULL) {
726 for (i = 0; i < elem_group_global->
n_grp; i++) {
731 for (j = elem_group_global->
grp_index[i];
732 j < elem_group_global->
grp_index[i + 1]; j++) {
733 elem = elem_group_global->
grp_item[j];
734 for (k = 0; k < n_domain[elem - 1]; k++) {
735 current_domain = domain[elem - 1][k];
736 egrp_item[current_domain][counter[current_domain]] = elem;
737 counter[current_domain]++;
742 for (i = 0; i < global_mesh->
n_elem; i++) {
756 rtc = spdup_init_list(global_mesh);
759 rtc = spdup_make_list(global_mesh);
762 rtc = spdup_make_node_grouplist(global_mesh);
765 rtc = spdup_make_element_grouplist(global_mesh);
811 static char *get_dist_file_name(
char *header,
int domain,
char *fname) {
814 sprintf(s_domain,
"%d", domain);
816 strcpy(fname, header);
818 strcat(fname, s_domain);
823 static void free_link_list(
struct link_unit *llist) {
826 for (p = llist; p; p = q) {
836 if (local_mesh ==
NULL) {
862 if (local_mesh ==
NULL) {
876 local_mesh->
n_dof = 0;
894 if (local_mesh ==
NULL) {
934 if (local_mesh ==
NULL) {
939 local_mesh->
zero = 0;
940 local_mesh->
PETOT = 0;
963 if (local_mesh ==
NULL) {
986 if (local_mesh ==
NULL) {
1012 if (local_mesh ==
NULL) {
1039 if (local_mesh ==
NULL) {
1043 if (local_mesh->
mpc ==
NULL) {
1062 if (local_mesh ==
NULL) {
1067 if (local_mesh->
amp ==
NULL) {
1088 if (local_mesh ==
NULL) {
1117 if (local_mesh ==
NULL) {
1145 if (local_mesh ==
NULL) {
1173 if (local_mesh ==
NULL) {
1180 "\'local_mesh->contact_pair\' is NULL");
1200 if (local_mesh ==
NULL)
return;
1202 init_struct_global(local_mesh);
1206 if (local_mesh ==
NULL)
return;
1211 if (local_mesh->
node) {
1230 init_struct_node(local_mesh);
1234 if (local_mesh ==
NULL)
return;
1267 init_struct_elem(local_mesh);
1271 if (local_mesh ==
NULL)
return;
1295 init_struct_comm(local_mesh);
1299 if (local_mesh ==
NULL)
return;
1301 init_struct_adapt(local_mesh);
1305 if (local_mesh ==
NULL)
return;
1308 init_struct_sect(local_mesh);
1312 if (local_mesh ==
NULL)
return;
1315 init_struct_mat(local_mesh);
1319 if (local_mesh ==
NULL)
return;
1320 if (local_mesh->
mpc ==
NULL)
return;
1328 init_struct_mpc(local_mesh);
1332 if (local_mesh ==
NULL)
return;
1333 if (local_mesh->
amp ==
NULL)
return;
1335 init_struct_amp(local_mesh);
1339 if (local_mesh ==
NULL)
return;
1349 init_struct_node_grp(local_mesh);
1353 if (local_mesh ==
NULL)
return;
1363 init_struct_elem_grp(local_mesh);
1367 if (local_mesh ==
NULL)
return;
1377 init_struct_surf_grp(local_mesh);
1381 if (local_mesh ==
NULL)
return;
1397 init_struct_contact_pair(local_mesh);
1401 if (local_mesh ==
NULL)
return;
1403 clean_struct_global(local_mesh);
1404 clean_struct_node(local_mesh);
1405 clean_struct_elem(local_mesh);
1406 clean_struct_comm(local_mesh);
1407 clean_struct_adapt(local_mesh);
1408 clean_struct_sect(local_mesh);
1409 clean_struct_mat(local_mesh);
1410 clean_struct_mpc(local_mesh);
1411 clean_struct_amp(local_mesh);
1412 clean_struct_node_grp(local_mesh);
1413 clean_struct_elem_grp(local_mesh);
1414 clean_struct_surf_grp(local_mesh);
1415 clean_struct_contact_pair(local_mesh);
1422 if (result_data ==
NULL) {
1444 if (result_data ==
NULL)
return;
1484 static int quick_sort(
int no,
int n,
double *arr,
int *brr,
int *istack) {
1497 for (j = l + 1; j <= ir; j++) {
1500 for (i = j - 1; i >= l; i--) {
1501 if (arr[i] <= a)
break;
1502 arr[i + 1] = arr[i];
1503 brr[i + 1] = brr[i];
1509 if (!jstack)
return 0;
1511 ir = istack[jstack];
1512 l = istack[jstack - 1];
1518 DSWAP(arr[k], arr[l + 1])
1519 ISWAP(brr[k], brr[l + 1])
1521 if (arr[l] > arr[ir]) {
1522 DSWAP(arr[l], arr[ir])
1523 ISWAP(brr[l], brr[ir])
1526 if (arr[l + 1] > arr[ir]) {
1527 DSWAP(arr[l + 1], arr[ir])
1528 ISWAP(brr[l + 1], brr[ir])
1531 if (arr[l] > arr[l + 1]) {
1532 DSWAP(arr[l], arr[l + 1])
1533 ISWAP(brr[l], brr[l + 1])
1551 DSWAP(arr[i], arr[j])
1552 ISWAP(brr[i], brr[j])
1555 arr[l + 1] = arr[j];
1557 brr[l + 1] = brr[j];
1562 if (jstack > nstack) {
1567 if (ir - i + 1 >= j - l) {
1568 istack[jstack] = ir;
1569 istack[jstack - 1] = i;
1572 istack[jstack] = j - 1;
1573 istack[jstack - 1] = l;
1583 static int rcb_partition(
int n,
const double *coord,
int *wnum,
1597 if (stack ==
NULL) {
1602 if (value ==
NULL) {
1607 for (i = 0; i <
cont_data->n_rcb_div; i++) {
1608 for (j = 0; j < pow(2, i); j++) {
1613 for (k = 0; k < n; k++) {
1614 if (wnum[2 * k + 1] == j) {
1616 value[counter] = coord[3 * k];
1623 for (k = 0; k < n; k++) {
1624 if (wnum[2 * k + 1] == j) {
1626 value[counter] = coord[3 * k + 1];
1633 for (k = 0; k < n; k++) {
1634 if (wnum[2 * k + 1] == j) {
1636 value[counter] = coord[3 * k + 2];
1648 rtc = quick_sort(n, counter, value,
id, stack);
1652 for (k = 0; k < counter *
F_1_2; k++) {
1653 wnum[2 *
id[k] + 1] = j + (int)pow(2, i);
1676 double coord_x, coord_y, coord_z;
1681 for (i = 0; i < global_mesh->
n_elem; i++) {
1685 for (coord_x = 0.0, coord_y = 0.0, coord_z = 0.0, j = js; j < je; j++) {
1688 coord_x += global_mesh->
node[3 * (node - 1)];
1689 coord_y += global_mesh->
node[3 * (node - 1) + 1];
1690 coord_z += global_mesh->
node[3 * (node - 1) + 2];
1693 coord[3 * i] = coord_x / (je - js);
1694 coord[3 * i + 1] = coord_y / (je - js);
1695 coord[3 * i + 2] = coord_z / (je - js);
1703 double *coord =
NULL;
1707 if (coord ==
NULL) {
1712 rtc = calc_gravity(global_mesh, coord);
1715 rtc = rcb_partition(global_mesh->
n_elem, coord, global_mesh->
elem_ID,
1731 static int create_node_graph_link_list(
1737 for (i = 0; i < edge_data->
n_edge; i++) {
1744 if (graph[node1 - 1]->last->next ==
NULL) {
1749 graph[node1 - 1]->
n += 1;
1757 if (graph[node2 - 1]->last->next ==
NULL) {
1762 graph[node2 - 1]->
n += 1;
1774 static int create_node_graph_compress(
1776 idx_t *node_graph_index,
idx_t *node_graph_item) {
1777 long long int counter;
1781 for (counter = 0, i = 0; i < global_mesh->
n_node; i++) {
1782 node_graph_index[i + 1] = node_graph_index[i] + graph[i]->
n;
1784 for (p = graph[i]->list, j = 0; j < graph[i]->
n; j++) {
1786 node_graph_item[counter++] = p->
id - 1;
1795 idx_t *node_graph_index,
idx_t *node_graph_item) {
1801 (size_t)global_mesh->
n_node);
1802 if (graph ==
NULL) {
1806 for (i = 0; i < global_mesh->
n_node; i++) {
1810 for (i = 0; i < global_mesh->
n_node; i++) {
1812 if (graph[i] ==
NULL) {
1819 for (i = 0; i < global_mesh->
n_node; i++) {
1821 if (graph[i]->list ==
NULL) {
1831 rtc = create_node_graph_link_list(global_mesh, edge_data, graph);
1834 rtc = create_node_graph_compress(global_mesh, graph, node_graph_index,
1838 for (i = 0; i < global_mesh->
n_node; i++) {
1839 free_link_list(graph[i]->list);
1848 for (i = 0; i < global_mesh->
n_node; i++) {
1850 free_link_list(graph[i]->list);
1875 (size_t)global_mesh->
n_node);
1876 if (node_list ==
NULL) {
1880 for (i = 0; i < global_mesh->
n_node; i++) {
1881 node_list[i] =
NULL;
1884 for (i = 0; i < global_mesh->
n_node; i++) {
1886 if (node_list[i] ==
NULL) {
1893 for (i = 0; i < global_mesh->
n_node; i++) {
1894 node_list[i]->
list =
1896 if (node_list[i]->list ==
NULL) {
1900 node_list[i]->
n = 0;
1902 node_list[i]->
last = node_list[i]->
list;
1906 for (i = 0; i < global_mesh->
n_elem; i++) {
1908 j < global_mesh->elem_node_index[i + 1]; j++) {
1913 if (node_list[node - 1]->last->next ==
NULL) {
1918 node_list[node - 1]->
last = node_list[node - 1]->
last->
next;
1919 node_list[node - 1]->
last->
id = i + 1;
1921 node_list[node - 1]->
n += 1;
1931 for (i = 0; i < global_mesh->
n_node; i++) {
1942 for (counter = 0, i = 0; i < global_mesh->
n_node; i++) {
1943 for (p = node_list[i]->list, j = 0; j < node_list[i]->
n; j++) {
1950 for (i = 0; i < global_mesh->
n_node; i++) {
1951 free_link_list(node_list[i]->list);
1960 for (i = 0; i < global_mesh->
n_node; i++) {
1962 free_link_list(node_list[i]->list);
1977 static int create_elem_graph_link_list(
1980 char *elem_flag =
NULL;
1988 if (elem_flag ==
NULL) {
1993 for (counter = 0, i = 0; i < global_mesh->
n_elem; i++) {
1994 memset(elem_flag, 0,
sizeof(
char) * global_mesh->
n_elem);
1998 j < global_mesh->elem_node_index[i + 1]; j++) {
2002 k < node_data->node_elem_index[node]; k++) {
2010 if (graph[i]->last->next ==
NULL) {
2035 static int create_elem_graph_compress(
2037 int *elem_graph_index,
int *elem_graph_item) {
2042 for (counter = 0, i = 0; i < global_mesh->
n_elem; i++) {
2043 elem_graph_index[i + 1] = elem_graph_index[i] + graph[i]->
n;
2045 for (p = graph[i]->list, j = 0; j < graph[i]->
n; j++) {
2047 elem_graph_item[counter++] = p->
id - 1;
2056 int *elem_graph_index) {
2059 int *elem_graph_item =
NULL;
2066 if (node_data ==
NULL) {
2074 rtc = set_node_belong_elem(global_mesh, node_data);
2078 (size_t)global_mesh->
n_elem);
2079 if (graph ==
NULL) {
2083 for (i = 0; i < global_mesh->
n_elem; i++) {
2087 for (i = 0; i < global_mesh->
n_elem; i++) {
2089 if (graph[i] ==
NULL) {
2096 for (i = 0; i < global_mesh->
n_elem; i++) {
2098 if (graph[i]->list ==
NULL) {
2108 n_graph = create_elem_graph_link_list(global_mesh, node_data, graph);
2109 if (n_graph < 0)
goto error;
2111 elem_graph_item = (
int *)
HECMW_malloc(
sizeof(
int) * n_graph);
2112 if (elem_graph_item ==
NULL) {
2117 rtc = create_elem_graph_compress(global_mesh, graph, elem_graph_index,
2124 for (i = 0; i < global_mesh->
n_elem; i++) {
2125 free_link_list(graph[i]->list);
2130 return elem_graph_item;
2139 for (i = 0; i < global_mesh->
n_elem; i++) {
2141 free_link_list(graph[i]->list);
2155 static int pmetis_interface(
const int n_vertex,
const int n_domain,
idx_t *xadj,
2158 #ifdef HECMW_PART_WITH_METIS
2164 #if defined(METIS_VER_MAJOR) && (METIS_VER_MAJOR == 5)
2167 real_t *tpwgts =
NULL;
2168 real_t *ubvec =
NULL;
2172 METIS_PartGraphRecursive(&n, &ncon, xadj, adjncy, vwgt, vsize,
NULL,
2173 &nparts, tpwgts, ubvec,
options, &edgecut, part);
2178 int options[5] = {0, 0, 0, 0, 0};
2181 METIS_PartGraphRecursive(&n, xadj, adjncy, vwgt, adjwgt, &wgtflag, &numflag,
2182 &nparts,
options, &edgecut, part);
2187 return (
int)edgecut;
2190 static int kmetis_interface(
const int n_vertex,
const int n_domain,
idx_t *xadj,
2193 #ifdef HECMW_PART_WITH_METIS
2199 #if defined(METIS_VER_MAJOR) && (METIS_VER_MAJOR == 5)
2202 real_t *tpwgts =
NULL;
2203 real_t *ubvec =
NULL;
2207 METIS_PartGraphKway(&n, &ncon, xadj, adjncy, vwgt, vsize,
NULL, &nparts,
2208 tpwgts, ubvec,
options, &edgecut, part);
2213 int options[5] = {0, 0, 0, 0, 0};
2216 METIS_PartGraphKway(&n, xadj, adjncy, vwgt, adjwgt, &wgtflag, &numflag,
2217 &nparts,
options, &edgecut, part);
2222 return (
int)edgecut;
2225 static int pmetis_interface_with_weight(
int n_vertex,
int ncon,
int n_domain,
2227 const int *vwgt,
idx_t *part) {
2229 #ifdef HECMW_PART_WITH_METIS
2234 #if defined(METIS_VER_MAJOR) && (METIS_VER_MAJOR == 5)
2236 real_t *tpwgts =
NULL;
2237 real_t *ubvec =
NULL;
2242 vsize, adjwgt, &nparts, tpwgts, ubvec,
options,
2248 int options[5] = {0, 0, 0, 0, 0};
2250 if (vwgt !=
NULL) wgtflag = 2;
2254 METIS_PartGraphRecursive((
int *)&n, (
idx_t *)xadj, (
idx_t *)adjncy, (
idx_t *)vwgt,
2255 (
idx_t *)adjwgt, &wgtflag, &numflag, (
int *)&nparts,
options,
2256 (
int *)&edgecut, (
idx_t *)part);
2258 METIS_mCPartGraphRecursive((
int *)&n, &ncon, (
idx_t *)xadj, (
idx_t *)adjncy,
2259 (
idx_t *)vwgt, (
idx_t *)adjwgt, &wgtflag, &numflag, (
int *)&nparts,
2266 return (
int)edgecut;
2269 static int kmetis_interface_with_weight(
int n_vertex,
int ncon,
int n_domain,
2271 const int *vwgt,
idx_t *part) {
2273 #ifdef HECMW_PART_WITH_METIS
2278 #if defined(METIS_VER_MAJOR) && (METIS_VER_MAJOR == 5)
2280 real_t *tpwgts =
NULL;
2281 real_t *ubvec =
NULL;
2286 adjwgt, &nparts, tpwgts, ubvec,
options, &edgecut, part);
2291 float *ubvec =
NULL;
2292 int options[5] = {0, 0, 0, 0, 0};
2294 if (vwgt !=
NULL) wgtflag = 2;
2298 if (ubvec ==
NULL) {
2307 &wgtflag, &numflag, (
int *)&nparts,
options, (
int *)&edgecut, (
idx_t *)part);
2309 METIS_mCPartGraphKway((
int *)&n, &ncon, (
idx_t *)xadj, (
idx_t *)adjncy, (
idx_t *)vwgt,
2310 (
idx_t *)adjwgt, &wgtflag, &numflag, (
int *)&nparts, ubvec,
options,
2311 (
int *)&edgecut, (
idx_t *)part);
2319 return (
int)edgecut;
2322 static int contact_agg_mark_node_group(
int *mark,
2324 int gid,
int agg_id,
int *agg_dup) {
2326 int istart, iend, i;
2332 for (i = istart; i < iend; i++) {
2335 if (0 <= mark[nid] && mark[nid] < agg_id) {
2337 if (*agg_dup == -1) {
2338 *agg_dup = mark[nid];
2339 }
else if (mark[nid] != *agg_dup) {
2341 "ERROR: node included in multiple node groups in different "
2343 " which is not supported by CONTACT=AGGREGATE\n");
2352 static int HECMW_get_num_surf_node(
int etype,
int sid) {
2367 if (1 <= sid && sid <= 3)
return 4;
2368 if (4 <= sid && sid <= 5)
return 3;
2370 if (1 <= sid && sid <= 3)
return 8;
2371 if (4 <= sid && sid <= 5)
return 6;
2375 "ERROR: parallel contact analysis of elem type %d not supported\n",
2382 static const int *HECMW_get_surf_node(
int etype,
int sid) {
2385 static const int elem_surf_tet1[4][3] = {
2386 {1, 2, 3}, {0, 3, 2}, {0, 1, 3}, {0, 2, 1}};
2387 static const int elem_surf_tet2[4][6] = {{1, 4, 2, 9, 3, 8},
2390 {0, 5, 2, 4, 1, 6}};
2391 static const int elem_surf_hex1[6][4] = {{3, 0, 4, 7}, {1, 2, 6, 5},
2392 {0, 1, 5, 4}, {2, 3, 7, 6},
2393 {3, 2, 1, 0}, {4, 5, 6, 7}};
2394 static const int elem_surf_hex2[6][8] = {
2395 {3, 11, 0, 16, 4, 15, 7, 19}, {1, 9, 2, 18, 6, 13, 5, 17},
2396 {0, 8, 1, 17, 5, 12, 4, 16}, {2, 10, 3, 19, 7, 14, 6, 18},
2397 {3, 10, 2, 9, 1, 8, 0, 11}, {4, 12, 5, 13, 6, 14, 7, 15}};
2398 static const int elem_surf_pri1[5][4] = {
2399 {1, 2, 5, 4}, {2, 0, 3, 5}, {0, 1, 4, 3}, {2, 1, 0, -1}, {3, 4, 5, -1}};
2400 static const int elem_surf_pri2[5][8] = {{1, 6, 2, 14, 5, 9, 4, 13},
2401 {2, 7, 0, 12, 3, 10, 5, 14},
2402 {0, 8, 1, 13, 4, 11, 3, 12},
2403 {2, 6, 1, 8, 0, 7, -1, -1},
2404 {3, 11, 4, 9, 5, 10, -1, -1}};
2405 static const int elem_surf_ptt1[3] = {0, 1, 2};
2406 static const int elem_surf_ptt2[6] = {0, 1, 2, 3, 4, 5};
2407 static const int elem_surf_ptq1[4] = {0, 1, 2, 3};
2408 static const int elem_surf_ptq2[8] = {0, 1, 2, 3, 4, 5, 6, 7};
2411 return elem_surf_tet1[sid - 1];
2413 return elem_surf_tet2[sid - 1];
2415 return elem_surf_hex1[sid - 1];
2417 return elem_surf_hex2[sid - 1];
2419 return elem_surf_pri1[sid - 1];
2421 return elem_surf_pri2[sid - 1];
2423 return elem_surf_ptt1;
2425 return elem_surf_ptt2;
2427 return elem_surf_ptq1;
2429 return elem_surf_ptq2;
2432 "ERROR: parallel contact analysis of element type %d not supported\n",
2437 static int HECMW_fistr_get_num_surf_node(
int etype,
int sid) {
2452 if (1 <= sid && sid <= 2)
return 3;
2453 if (3 <= sid && sid <= 5)
return 4;
2455 if (1 <= sid && sid <= 2)
return 6;
2456 if (3 <= sid && sid <= 5)
return 8;
2460 "ERROR: parallel contact analysis of elem type %d not supported\n",
2467 static const int *HECMW_fistr_get_surf_node(
int etype,
int sid) {
2470 static const int elem_surf_tet1[4][3] = {
2471 {0, 1, 2}, {0, 1, 3}, {1, 2, 3}, {2, 0, 3}};
2472 static const int elem_surf_tet2[4][6] = {{0, 6, 1, 4, 2, 5},
2475 {2, 5, 0, 9, 3, 7}};
2476 static const int elem_surf_hex1[6][4] = {{0, 1, 2, 3}, {4, 5, 6, 7},
2477 {0, 1, 5, 4}, {1, 2, 6, 5},
2478 {2, 3, 7, 6}, {3, 0, 4, 7}};
2479 static const int elem_surf_hex2[6][8] = {
2480 {0, 8, 1, 9, 2, 10, 3, 11}, {4, 12, 5, 13, 6, 14, 7, 15},
2481 {0, 8, 1, 17, 5, 12, 4, 16}, {1, 9, 2, 18, 6, 13, 5, 17},
2482 {2, 10, 3, 19, 7, 14, 6, 18}, {3, 11, 0, 16, 4, 15, 7, 19}};
2483 static const int elem_surf_pri1[5][4] = {
2484 {0, 1, 2, -1}, {3, 4, 5, -1}, {0, 1, 4, 3}, {1, 2, 5, 4}, {2, 0, 3, 5}};
2485 static const int elem_surf_pri2[5][8] = {{0, 8, 1, 6, 2, 7, -1, -1},
2486 {3, 11, 4, 9, 5, 10, -1, -1},
2487 {0, 8, 1, 13, 4, 11, 3, 12},
2488 {1, 6, 2, 14, 5, 9, 4, 13},
2489 {2, 7, 0, 12, 3, 10, 5, 14}};
2490 static const int elem_surf_ptt1[3] = {0, 1, 2};
2491 static const int elem_surf_ptt2[6] = {0, 1, 2, 3, 4, 5};
2492 static const int elem_surf_ptq1[4] = {0, 1, 2, 3};
2493 static const int elem_surf_ptq2[8] = {0, 1, 2, 3, 4, 5, 6, 7};
2496 return elem_surf_tet1[sid - 1];
2498 return elem_surf_tet2[sid - 1];
2500 return elem_surf_hex1[sid - 1];
2502 return elem_surf_hex2[sid - 1];
2504 return elem_surf_pri1[sid - 1];
2506 return elem_surf_pri2[sid - 1];
2508 return elem_surf_ptt1;
2510 return elem_surf_ptt2;
2512 return elem_surf_ptq1;
2514 return elem_surf_ptq2;
2517 "ERROR: parallel contact analysis of element type %d not supported\n",
2528 for (i = 0; i < global_mesh->
n_node; i++) {
2532 for (i = 0; i < cp->
n_pair; i++) {
2536 for (j = jstart; j < jend; j++) {
2537 int eid = sgrp->
grp_item[j * 2] - 1;
2538 int sid = sgrp->
grp_item[j * 2 + 1];
2541 int etype = global_mesh->
elem_type[eid];
2547 int num_snode = HECMW_fistr_get_num_surf_node(etype, sid);
2548 const int *snode = HECMW_fistr_get_surf_node(etype, sid);
2552 for (k = 0; k < num_snode; k++) {
2553 int nid = nop[snode[k]] - 1;
2562 static int contact_agg_mark_surf_group(
int *mark,
2564 int gid,
int agg_id,
int *agg_dup) {
2566 int istart, iend, i, j;
2573 for (i = istart; i < iend; i++) {
2574 int eid = sgrp->
grp_item[i * 2] - 1;
2575 int sid = sgrp->
grp_item[i * 2 + 1];
2577 int etype = global_mesh->
elem_type[eid];
2582 int num_snode = HECMW_fistr_get_num_surf_node(etype, sid);
2583 const int *snode = HECMW_fistr_get_surf_node(etype, sid);
2586 for (j = 0; j < num_snode; j++) {
2587 int nid = nop[snode[j]] - 1;
2589 if (0 <= mark[nid] && mark[nid] < agg_id) {
2591 if (*agg_dup == -1) {
2592 *agg_dup = mark[nid];
2593 }
else if (mark[nid] != *agg_dup) {
2595 "ERROR: node included in multiple surface groups in "
2596 "different contact pairs,\n"
2597 " which is not supported by CONTACT=AGGREGATE\n");
2607 static int metis_partition_nb_contact_agg(
2619 int agg_id, agg_dup, gid;
2621 const int *node_graph_index2;
2622 const int *node_graph_item2;
2631 if (node_graph_index ==
NULL) {
2636 if (node_graph_item ==
NULL) {
2643 rtc = create_node_graph(global_mesh, edge_data, node_graph_index,
2660 for (i = 0; i < global_mesh->
n_node; i++) {
2665 for (i = 0; i < cp->
n_pair; i++) {
2671 contact_agg_mark_node_group(mark, global_mesh, gid, agg_id, &agg_dup);
2676 contact_agg_mark_surf_group(mark, global_mesh, gid, agg_id, &agg_dup);
2681 contact_agg_mark_surf_group(mark, global_mesh, gid, agg_id, &agg_dup);
2686 rtc = contact_agg_mark_surf_group(mark, global_mesh, gid, agg_id, &agg_dup);
2690 for (i = 0; i < global_mesh->
n_node; i++) {
2691 if (mark[i] == agg_id) {
2700 for (i = 0; i < global_mesh->
n_node; i++) {
2709 node_graph_index, node_graph_item);
2719 node_weight2 = (
int *)
HECMW_calloc(n_node2,
sizeof(
int));
2720 if (node_weight2 ==
NULL) {
2724 for (i = 0; i < global_mesh->
n_node; i++) {
2725 node_weight2[mark[i]] += 1;
2731 if (belong_domain ==
NULL) {
2738 n_edgecut = pmetis_interface_with_weight(
2740 (
idx_t *)node_graph_item2, node_weight2, belong_domain);
2741 if (n_edgecut < 0)
goto error;
2745 n_edgecut = kmetis_interface_with_weight(
2747 (
idx_t *)node_graph_item2, node_weight2, belong_domain);
2748 if (n_edgecut < 0)
goto error;
2756 for (i = 0; i < global_mesh->
n_node; i++) {
2757 global_mesh->
node_ID[2 * i + 1] = (int)belong_domain[mark[i]];
2779 static int metis_partition_nb_contact_dist(
2790 int *node_weight =
NULL;
2798 if (node_graph_index ==
NULL) {
2803 if (node_graph_item ==
NULL) {
2810 rtc = create_node_graph(global_mesh, edge_data, node_graph_index,
2833 rtc = mark_contact_master_nodes(global_mesh, mark);
2837 if (node_weight ==
NULL) {
2842 for (i = 0; i < global_mesh->
n_node; i++) {
2844 node_weight[i * ncon] = 1;
2846 node_weight[i * ncon + 1] = mark[i];
2853 if (belong_domain ==
NULL) {
2860 n_edgecut = pmetis_interface_with_weight(
2862 node_graph_item, node_weight, belong_domain);
2863 if (n_edgecut < 0)
goto error;
2867 n_edgecut = kmetis_interface_with_weight(
2869 node_graph_item, node_weight, belong_domain);
2870 if (n_edgecut < 0)
goto error;
2878 for (i = 0; i < global_mesh->
n_node; i++) {
2879 global_mesh->
node_ID[2 * i + 1] = (int)belong_domain[i];
2899 static int metis_partition_nb_default(
2911 if (node_graph_index ==
NULL) {
2916 if (node_graph_item ==
NULL) {
2923 rtc = create_node_graph(global_mesh, edge_data, node_graph_index,
2930 if (belong_domain ==
NULL) {
2941 node_graph_index, node_graph_item, belong_domain);
2942 if (n_edgecut < 0)
goto error;
2948 node_graph_index, node_graph_item, belong_domain);
2949 if (n_edgecut < 0)
goto error;
2957 for (i = 0; i < global_mesh->
n_node; i++) {
2958 global_mesh->
node_ID[2 * i + 1] = (int)belong_domain[i];
2981 return metis_partition_nb_contact_agg(global_mesh,
cont_data,
2986 return metis_partition_nb_contact_dist(global_mesh,
cont_data,
2993 return metis_partition_nb_default(global_mesh,
cont_data, edge_data);
2999 int *elem_graph_index,
int *elem_graph_item) {
3001 int *belong_domain =
NULL;
3005 if (belong_domain ==
NULL) {
3014 elem_graph_index, elem_graph_item, belong_domain);
3015 if (n_edgecut < 0)
goto error;
3021 elem_graph_index, elem_graph_item, belong_domain);
3022 if (n_edgecut < 0)
goto error;
3030 for (i = 0; i < global_mesh->
n_elem; i++) {
3031 global_mesh->
elem_ID[2 * i + 1] = belong_domain[i];
3046 #define LINEBUF_SIZE 1023
3048 static int read_part_file(
3049 const char *part_file_name,
3055 int rtc, n_in, n_domain_in;
3059 fpart = fopen(part_file_name,
"r");
3060 if (fpart ==
NULL) {
3070 rtc = sscanf(linebuf,
"%d %d", &n_in, &n_domain_in);
3080 if (n_domain_in != n_domain) {
3085 count_dom = (
int *)
HECMW_calloc(n_domain,
sizeof(
int));
3086 if (count_dom ==
NULL) {
3092 for (i = 0; i < n; i++) {
3097 rtc = sscanf(linebuf,
"%d", &part);
3103 if (part < 0 || n_domain <= part) {
3114 for (i = 0; i < n_domain; i++) {
3115 if (count_dom[i] == 0) {
3129 static int write_part_file(
3130 const char *part_file_name,
3137 fpart = fopen(part_file_name,
"w");
3138 if (fpart ==
NULL) {
3143 fprintf(fpart,
"%d %d\n", n, n_domain);
3145 for (i = 0; i < n; i++) {
3146 fprintf(fpart,
"%d\n", wnum[2*i+1]);
3159 static int user_partition(
3163 const char *part_file_name) {
3166 rtc = read_part_file(part_file_name, n, n_domain, wnum);
3175 static int user_partition_nb(
3182 static int user_partition_eb(
3191 static int print_part(
3193 const char *part_file_name) {
3198 rtc = write_part_file(part_file_name, global_mesh->
n_node,
3205 rtc = write_part_file(part_file_name, global_mesh->
n_elem,
3224 static int count_edgecut(
3230 for (i = 0; i < edge_data->
n_edge; i++) {
3242 static int set_node_belong_domain_nb(
3252 if (edge_data ==
NULL) {
3263 if (rtc != 0)
goto error;
3269 rtc = rcb_partition(global_mesh->
n_node, global_mesh->
node,
3273 n_edgecut = count_edgecut(edge_data, global_mesh->
node_ID);
3279 n_edgecut = metis_partition_nb(global_mesh,
cont_data, edge_data);
3280 if (n_edgecut < 0)
goto error;
3285 rtc = user_partition_nb(global_mesh,
cont_data);
3288 n_edgecut = count_edgecut(edge_data, global_mesh->
node_ID);
3324 for (i = 0; i < global_mesh->
n_node; i++) {
3328 for (i = 0; i < global_mesh->
n_elem; i++) {
3330 j < global_mesh->elem_node_index[i + 1]; j++) {
3332 if (global_mesh->
elem_ID[2 * i + 1] <
3333 global_mesh->
node_ID[2 * (node - 1) + 1]) {
3334 global_mesh->
node_ID[2 * (node - 1) + 1] =
3335 global_mesh->
elem_ID[2 * i + 1];
3348 if (counter ==
NULL) {
3353 for (j = 0; j < global_mesh->
n_node; j++) {
3354 domain = global_mesh->
node_ID[2 * j + 1];
3355 global_mesh->
node_ID[2 * j] = ++counter[domain];
3378 for (i = 0; i < global_mesh->
n_node; i++) {
3379 global_mesh->
node_ID[2 * i] = i + 1;
3380 global_mesh->
node_ID[2 * i + 1] = 0;
3388 rtc = set_node_belong_domain_nb(global_mesh,
cont_data);
3393 rtc = set_node_belong_domain_eb(global_mesh);
3402 rtc = set_local_node_id(global_mesh);
3414 int node, node_domain, min_domain;
3418 for (i = 0; i < global_mesh->
n_elem; i++) {
3421 j < global_mesh->elem_node_index[i + 1]; j++) {
3423 node_domain = global_mesh->
node_ID[2 * (node - 1) + 1];
3424 if (node_domain < min_domain) {
3425 min_domain = node_domain;
3428 global_mesh->
elem_ID[2 * i + 1] = min_domain;
3436 int *elem_graph_index,
int *elem_graph_item) {
3444 for (i = 0; i < global_mesh->
n_elem; i++) {
3445 for (j = elem_graph_index[i]; j < elem_graph_index[i + 1]; j++) {
3447 if (eid < 0)
goto error;
3452 if (elem_data->
n_edge < 0)
goto error;
3467 static int set_elem_belong_domain_eb(
3471 int *elem_graph_index =
NULL;
3472 int *elem_graph_item =
NULL;
3478 if (elem_graph_index ==
NULL) {
3484 if (elem_data ==
NULL) {
3494 elem_graph_item = create_elem_graph(global_mesh, elem_graph_index);
3495 if (elem_graph_item ==
NULL)
goto error;
3499 rtc = count_edge_for_eb(global_mesh, elem_data, elem_graph_index,
3505 rtc = rcb_partition_eb(global_mesh,
cont_data);
3508 n_edgecut = count_edgecut(elem_data, global_mesh->
elem_ID);
3514 n_edgecut = metis_partition_eb(global_mesh,
cont_data, elem_graph_index,
3516 if (n_edgecut < 0)
goto error;
3521 rtc = user_partition_eb(global_mesh,
cont_data);
3524 n_edgecut = count_edgecut(elem_data, global_mesh->
elem_ID);
3559 if (counter ==
NULL) {
3564 for (j = 0; j < global_mesh->
n_elem; j++) {
3565 domain = global_mesh->
elem_ID[2 * j + 1];
3566 global_mesh->
elem_ID[2 * j] = ++counter[domain];
3589 for (i = 0; i < global_mesh->
n_elem; i++) {
3590 global_mesh->
elem_ID[2 * i] = i + 1;
3591 global_mesh->
elem_ID[2 * i + 1] = 0;
3599 rtc = set_elem_belong_domain_nb(global_mesh);
3605 rtc = set_elem_belong_domain_eb(global_mesh,
cont_data);
3615 rtc = set_local_elem_id(global_mesh);
3635 rtc = wnumbering_node(global_mesh,
cont_data);
3638 rtc = wnumbering_elem(global_mesh,
cont_data);
3645 rtc = wnumbering_elem(global_mesh,
cont_data);
3648 rtc = wnumbering_node(global_mesh,
cont_data);
3675 char *node_flag,
int current_domain) {
3678 for (i = 0; i < n_int_nlist[current_domain]; i++) {
3679 node = int_nlist[current_domain][i];
3687 char *elem_flag,
int current_domain) {
3690 for (i = 0; i < global_mesh->
n_elem; i++) {
3691 (global_mesh->
elem_ID[2 * i + 1] == current_domain)
3699 static int mask_elem_by_domain_mod(
char *elem_flag,
int current_domain) {
3702 for (i = 0; i < n_int_elist[current_domain]; i++) {
3703 elem = int_elist[current_domain][i];
3714 char *node_flag,
int current_domain) {
3717 for (i = 0; i < global_mesh->
mpc->
n_mpc; i++) {
3718 int j0, je, slave, master, j, evalsum;
3728 for (j = j0 + 1; j < je; j++) {
3746 static int mask_overlap_elem(
char *elem_flag,
int domain) {
3749 for (i = 0; i < n_bnd_elist[2 * domain + 1]; i++) {
3750 elem = bnd_elist[domain][i];
3759 char *node_flag,
const char *elem_flag) {
3764 for (i = 0; i < global_mesh->
n_elem; i++) {
3767 j < global_mesh->elem_node_index[i + 1]; j++) {
3779 char *node_flag,
char *elem_flag,
3783 for (i = 0; i < n_bnd_nlist[2 * domain + 1]; i++) {
3784 node = bnd_nlist[domain][i];
3795 static int mask_boundary_elem_with_slave(
3797 char *elem_flag,
int *added) {
3803 for (i = 0; i < global_mesh->
n_elem; i++) {
3810 j < global_mesh->elem_node_index[i + 1]; j++) {
3831 static int mask_boundary_link_elem_with_slave(
3833 char *elem_flag,
int *added) {
3839 for (i = 0; i < global_mesh->
n_elem; i++) {
3846 j < global_mesh->elem_node_index[i + 1]; j++) {
3866 static int mask_additional_overlap_elem(
3873 for (i = 0; i < global_mesh->
n_elem; i++) {
3876 j < global_mesh->elem_node_index[i + 1]; j++) {
3891 char *elem_flag,
char *node_flag) {
3894 int elem, node, selem;
3895 int evalsum, evalsum2;
3896 int master_gid, slave_gid;
3908 for (i = 0; i < cp->
n_pair; i++) {
3909 switch (cp->
type[i]) {
3914 jstart = sgrp->
grp_index[master_gid - 1];
3916 for (j = jstart; j < jend; j++) {
3926 jstart = ngrp->
grp_index[slave_gid - 1];
3928 for (j = jstart; j < jend; j++) {
3938 jstart = sgrp->
grp_index[master_gid - 1];
3940 for (j = jstart; j < jend; j++) {
3950 jstart = ngrp->
grp_index[slave_gid - 1];
3952 for (j = jstart; j < jend; j++) {
3965 jstart = sgrp->
grp_index[master_gid - 1];
3967 for (j = jstart; j < jend; j++) {
3978 jstart = sgrp->
grp_index[slave_gid - 1];
3980 for (j = jstart; j < jend; j++) {
3985 k < global_mesh->elem_node_index[selem]; k++) {
3995 jstart = sgrp->
grp_index[master_gid - 1];
3997 for (j = jstart; j < jend; j++) {
4008 jstart = sgrp->
grp_index[slave_gid - 1];
4010 for (j = jstart; j < jend; j++) {
4014 k < global_mesh->elem_node_index[selem]; k++) {
4024 k < global_mesh->elem_node_index[selem]; k++) {
4037 jstart = egrp->
grp_index[master_gid - 1];
4039 for (j = jstart; j < jend; j++) {
4049 jstart = ngrp->
grp_index[slave_gid - 1];
4051 for (j = jstart; j < jend; j++) {
4061 jstart = egrp->
grp_index[master_gid - 1];
4063 for (j = jstart; j < jend; j++) {
4073 jstart = ngrp->
grp_index[slave_gid - 1];
4075 for (j = jstart; j < jend; j++) {
4093 char *node_flag,
char *elem_flag,
4094 int current_domain) {
4098 rtc = mask_node_by_domain(global_mesh, node_flag, current_domain);
4101 rtc = mask_elem_by_domain_mod(elem_flag, current_domain);
4104 rtc = mask_overlap_elem(elem_flag, current_domain);
4108 mask_boundary_node_mod(global_mesh, node_flag, elem_flag, current_domain);
4117 rtc = mask_slave_node(global_mesh, node_flag, current_domain);
4120 rtc = mask_boundary_elem_with_slave(global_mesh, node_flag, elem_flag,
4125 rtc = mask_boundary_node(global_mesh, node_flag, elem_flag);
4130 rtc = mask_boundary_link_elem_with_slave(global_mesh, node_flag, elem_flag,
4135 rtc = mask_boundary_node(global_mesh, node_flag, elem_flag);
4139 for (i = 0; i < global_mesh->
n_node; i++) {
4147 rtc = mask_additional_overlap_elem(global_mesh, node_flag, elem_flag);
4150 rtc = mask_boundary_node(global_mesh, node_flag, elem_flag);
4155 rtc = mask_contact_slave_surf(global_mesh, elem_flag, node_flag);
4169 char *node_flag,
const char *elem_flag) {
4174 for (i = 0; i < global_mesh->
n_elem; i++) {
4177 j < global_mesh->elem_node_index[i + 1]; j++) {
4184 j < global_mesh->elem_node_index[i + 1]; j++) {
4198 for (i = 0; i < global_mesh->
n_node; i++) {
4209 char *node_flag,
const char *elem_flag) {
4213 rtc = mask_overlap_node_mark(global_mesh, node_flag, elem_flag);
4216 rtc = mask_overlap_node_inner(global_mesh, node_flag);
4219 for (i = 0; i < global_mesh->
n_node; i++) {
4231 const char *node_flag,
char *elem_flag) {
4236 for (i = 0; i < global_mesh->
n_elem; i++) {
4239 j < global_mesh->elem_node_index[i + 1]; j++) {
4254 char *node_flag,
char *elem_flag,
4255 int current_domain) {
4259 for (i = 0; i < global_mesh->
n_node; i++) {
4264 for (i = 0; i < global_mesh->
n_elem; i++) {
4270 rtc = mask_node_by_domain(global_mesh, node_flag, current_domain);
4273 rtc = mask_elem_by_domain(global_mesh, elem_flag, current_domain);
4276 rtc = mask_overlap_node(global_mesh, node_flag, elem_flag);
4279 rtc = mask_boundary_elem(global_mesh, node_flag, elem_flag);
4291 const char *node_flag,
char *domain_flag) {
4294 for (i = 0; i < global_mesh->
n_node; i++) {
4303 static int mask_neighbor_domain_nb_mod(
4305 char *domain_flag,
int domain) {
4308 for (i = n_bnd_nlist[2 * domain]; i < n_bnd_nlist[2 * domain + 1]; i++) {
4309 node = bnd_nlist[domain][i];
4316 static int mask_neighbor_domain_nb_contact(
4318 const char *elem_flag,
char *domain_flag) {
4321 int elem, node, selem;
4323 int master_gid, slave_gid;
4335 for (i = 0; i < cp->
n_pair; i++) {
4338 switch (cp->
type[i]) {
4341 jstart = ngrp->
grp_index[slave_gid - 1];
4343 for (j = jstart; j < jend; j++) {
4353 jstart = sgrp->
grp_index[slave_gid - 1];
4355 for (j = jstart; j < jend; j++) {
4358 k < global_mesh->elem_node_index[selem]; k++) {
4370 jstart = ngrp->
grp_index[slave_gid - 1];
4372 for (j = jstart; j < jend; j++) {
4387 jstart = egrp->
grp_index[master_gid - 1];
4389 for (j = jstart; j < jend; j++) {
4396 jstart = sgrp->
grp_index[master_gid - 1];
4398 for (j = jstart; j < jend; j++) {
4412 const char *elem_flag,
char *domain_flag) {
4415 for (i = 0; i < global_mesh->
n_elem; i++) {
4425 const char *domain_flag) {
4429 for (counter = 0, i = 0; i < global_mesh->
n_subdomain; i++) {
4438 const char *domain_flag) {
4442 for (counter = 0, i = 0; i < global_mesh->
n_subdomain; i++) {
4453 char *node_flag,
char *elem_flag,
4454 int current_domain) {
4456 char *domain_flag =
NULL;
4464 "Starting creation of neighboring domain information...");
4470 if (domain_flag ==
NULL) {
4477 rtc = mask_mesh_status_nb(global_mesh, node_flag, elem_flag,
4481 if (is_spdup_available(global_mesh)) {
4482 rtc = mask_neighbor_domain_nb_mod(global_mesh, node_flag, domain_flag,
4485 rtc = mask_neighbor_domain_nb(global_mesh, node_flag, domain_flag);
4489 rtc = mask_neighbor_domain_nb_contact(global_mesh, node_flag, elem_flag,
4496 rtc = mask_mesh_status_eb(global_mesh, node_flag, elem_flag,
4500 rtc = mask_neighbor_domain_eb(global_mesh, elem_flag, domain_flag);
4510 local_mesh->
n_neighbor_pe = count_neighbor_domain(global_mesh, domain_flag);
4528 rtc = set_neighbor_domain(global_mesh, local_mesh, domain_flag);
4549 char *node_flag_current,
char *node_flag_neighbor) {
4552 for (i = 0; i < global_mesh->
n_node; i++) {
4563 char *node_flag_current,
char *node_flag_neighbor,
4564 int current_domain) {
4567 for (i = 0; i < n_bnd_nlist[2 * current_domain + 1]; i++) {
4568 node = bnd_nlist[current_domain][i];
4578 char *elem_flag_current,
char *elem_flag_neighbor) {
4581 for (i = 0; i < global_mesh->
n_elem; i++) {
4592 char *elem_flag_current,
char *elem_flag_neighbor,
4593 int current_domain) {
4596 for (i = 0; i < n_bnd_elist[2 * current_domain + 1]; i++) {
4597 elem = bnd_elist[current_domain][i];
4607 const char *node_flag,
int domain) {
4611 for (counter = 0, i = 0; i < n_int_nlist[domain]; i++) {
4612 node = int_nlist[domain][i];
4620 const char *elem_flag,
int domain) {
4624 for (counter = 0, i = 0; i < global_mesh->
n_elem; i++) {
4626 global_mesh->
elem_ID[2 * i + 1] == domain)
4633 static int count_masked_shared_node(
4638 for (counter = 0, i = 0; i < global_mesh->
n_node; i++) {
4645 static int count_masked_shared_elem(
4650 for (counter = 0, i = 0; i < global_mesh->
n_elem; i++) {
4657 static int count_masked_shared_elem_mod(
4663 for (counter = 0, i = 0; i < n_bnd_elist[2 * domain + 1]; i++) {
4664 elem = bnd_elist[domain][i];
4672 const char *node_flag,
int **comm_node,
4673 int neighbor_idx,
int domain) {
4677 for (counter = 0, i = 0; i < n_int_nlist[domain]; i++) {
4678 node = int_nlist[domain][i];
4680 comm_node[neighbor_idx][counter++] = node;
4688 const char *elem_flag,
int **comm_elem,
4689 int neighbor_idx,
int domain) {
4693 for (counter = 0, i = 0; i < global_mesh->
n_elem; i++) {
4695 global_mesh->
elem_ID[2 * i + 1] == domain) {
4696 comm_elem[neighbor_idx][counter++] = i + 1;
4704 const char *node_flag,
int **shared_node,
4709 for (counter = 0, i = 0; i < global_mesh->
n_node; i++) {
4711 shared_node[neighbor_idx][counter++] = i + 1;
4719 const char *elem_flag,
int **shared_elem,
4724 for (counter = 0, i = 0; i < global_mesh->
n_elem; i++) {
4726 shared_elem[neighbor_idx][counter++] = i + 1;
4733 static int create_shared_elem_pre_mod(
4735 int **shared_elem,
int neighbor_idx,
int neighbor_domain) {
4737 int i, idx1, idx2, elem1, elem2, n_bnd, n_out, maxe;
4739 n_bnd = n_bnd_elist[2 * neighbor_domain];
4741 n_bnd_elist[2 * neighbor_domain + 1] - n_bnd_elist[2 * neighbor_domain];
4742 maxe = global_mesh->
n_elem + 1;
4744 elem1 = (n_bnd == 0) ? maxe : bnd_elist[neighbor_domain][0];
4745 elem2 = (n_out == 0) ? maxe : bnd_elist[neighbor_domain][n_bnd];
4746 for (counter = 0, idx1 = 0, idx2 = 0, i = 0; i < n_bnd + n_out; i++) {
4747 if (elem1 < elem2) {
4749 shared_elem[neighbor_idx][counter++] = elem1;
4752 elem1 = (idx1 == n_bnd) ? maxe : bnd_elist[neighbor_domain][idx1];
4755 shared_elem[neighbor_idx][counter++] = elem2;
4758 elem2 = (idx2 == n_out) ? maxe : bnd_elist[neighbor_domain][idx2 + n_bnd];
4765 static int create_comm_item(
int n_neighbor_pe,
int **comm_item_pre,
4766 int *comm_index,
int *comm_item) {
4769 for (i = 0; i < n_neighbor_pe; i++) {
4771 je = comm_index[i + 1];
4773 for (j = 0; j < je - js; j++) {
4774 comm_item[js + j] = comm_item_pre[i][j];
4785 const char *node_flag,
int **import_node,
4786 int neighbor_idx,
int neighbor_domain) {
4787 int n_import_node, rtc;
4790 count_masked_comm_node(global_mesh, node_flag, neighbor_domain);
4794 local_mesh->
import_index[neighbor_idx] + n_import_node;
4796 import_node[neighbor_idx] = (
int *)
HECMW_malloc(
sizeof(
int) * n_import_node);
4797 if (import_node[neighbor_idx] ==
NULL) {
4802 rtc = create_comm_node_pre(global_mesh, node_flag, import_node, neighbor_idx,
4814 const char *node_flag,
int **export_node,
4815 int neighbor_idx,
int current_domain,
4816 int neighbor_domain) {
4817 int n_export_node, rtc;
4820 count_masked_comm_node(global_mesh, node_flag, current_domain);
4824 local_mesh->
export_index[neighbor_idx] + n_export_node;
4826 export_node[neighbor_idx] = (
int *)
HECMW_malloc(
sizeof(
int) * n_export_node);
4827 if (export_node[neighbor_idx] ==
NULL) {
4832 rtc = create_comm_node_pre(global_mesh, node_flag, export_node, neighbor_idx,
4844 const char *elem_flag,
int **shared_elem,
4845 int neighbor_idx,
int neighbor_domain) {
4846 int n_shared_elem, rtc;
4848 if (is_spdup_available(global_mesh)) {
4850 count_masked_shared_elem_mod(global_mesh, elem_flag, neighbor_domain);
4852 n_shared_elem = count_masked_shared_elem(global_mesh, elem_flag);
4858 local_mesh->
shared_index[neighbor_idx] + n_shared_elem;
4860 shared_elem[neighbor_idx] = (
int *)
HECMW_malloc(
sizeof(
int) * n_shared_elem);
4861 if (shared_elem[neighbor_idx] ==
NULL) {
4866 if (is_spdup_available(global_mesh)) {
4867 rtc = create_shared_elem_pre_mod(global_mesh, elem_flag, shared_elem,
4868 neighbor_idx, neighbor_domain);
4870 rtc = create_shared_elem_pre(global_mesh, elem_flag, shared_elem,
4884 char *node_flag,
char *elem_flag,
4885 char *node_flag_neighbor,
4886 char *elem_flag_neighbor,
int current_domain) {
4887 int **import_node =
NULL;
4888 int **export_node =
NULL;
4889 int **shared_elem =
NULL;
4890 int neighbor_domain;
4903 if (import_node ==
NULL) {
4908 import_node[i] =
NULL;
4912 if (export_node ==
NULL) {
4917 export_node[i] =
NULL;
4921 if (shared_elem ==
NULL) {
4926 shared_elem[i] =
NULL;
4952 rtc = mask_mesh_status_nb(global_mesh, node_flag_neighbor,
4953 elem_flag_neighbor, neighbor_domain);
4956 if (is_spdup_available(global_mesh)) {
4957 rtc = mask_comm_node_mod(global_mesh, node_flag, node_flag_neighbor,
4960 rtc = mask_comm_node(global_mesh, node_flag, node_flag_neighbor);
4965 if (is_spdup_available(global_mesh)) {
4966 rtc = mask_comm_elem_mod(global_mesh, elem_flag, elem_flag_neighbor,
4969 rtc = mask_comm_elem(global_mesh, elem_flag, elem_flag_neighbor);
4974 rtc = create_import_info_nb(global_mesh, local_mesh, node_flag, import_node,
4975 i, neighbor_domain);
4978 rtc = create_export_info_nb(global_mesh, local_mesh, node_flag, export_node,
4979 i, current_domain, neighbor_domain);
4982 rtc = create_shared_info_nb(global_mesh, local_mesh, elem_flag, shared_elem,
4983 i, neighbor_domain);
4986 if (is_spdup_available(global_mesh)) {
4987 rtc = spdup_clear_IEB(node_flag_neighbor, elem_flag_neighbor,
4991 rtc = spdup_clear_MMbnd(node_flag_neighbor, elem_flag_neighbor,
4995 rtc = spdup_clear_MMbnd(node_flag, elem_flag, current_domain);
4998 for (j = 0; j < global_mesh->
n_node; j++) {
5001 for (j = 0; j < global_mesh->
n_elem; j++) {
5005 memset(node_flag_neighbor, 0,
sizeof(
char) * global_mesh->
n_node);
5006 memset(elem_flag_neighbor, 0,
sizeof(
char) * global_mesh->
n_elem);
5017 rtc = create_comm_item(local_mesh->
n_neighbor_pe, import_node,
5034 rtc = create_comm_item(local_mesh->
n_neighbor_pe, export_node,
5051 rtc = create_comm_item(local_mesh->
n_neighbor_pe, shared_elem,
5107 const char *elem_flag,
int **import_elem,
5108 int neighbor_idx,
int neighbor_domain) {
5109 int n_import_elem, rtc;
5112 count_masked_comm_elem(global_mesh, elem_flag, neighbor_domain);
5116 local_mesh->
import_index[neighbor_idx] + n_import_elem;
5118 import_elem[neighbor_idx] = (
int *)
HECMW_malloc(
sizeof(
int) * n_import_elem);
5119 if (import_elem[neighbor_idx] ==
NULL) {
5124 rtc = create_comm_elem_pre(global_mesh, elem_flag, import_elem, neighbor_idx,
5136 const char *elem_flag,
int **export_elem,
5137 int neighbor_idx,
int current_domain,
5138 int neighbor_domain) {
5139 int n_export_elem, rtc;
5142 count_masked_comm_elem(global_mesh, elem_flag, current_domain);
5146 local_mesh->
export_index[neighbor_idx] + n_export_elem;
5148 export_elem[neighbor_idx] = (
int *)
HECMW_malloc(
sizeof(
int) * n_export_elem);
5149 if (export_elem[neighbor_idx] ==
NULL) {
5154 rtc = create_comm_elem_pre(global_mesh, elem_flag, export_elem, neighbor_idx,
5166 const char *node_flag,
int **shared_node,
5167 int neighbor_idx,
int neighbor_domain) {
5168 int n_shared_node, rtc;
5170 n_shared_node = count_masked_shared_node(global_mesh, node_flag);
5174 local_mesh->
shared_index[neighbor_idx] + n_shared_node;
5176 shared_node[neighbor_idx] = (
int *)
HECMW_malloc(
sizeof(
int) * n_shared_node);
5177 if (shared_node[neighbor_idx] ==
NULL) {
5183 create_shared_node_pre(global_mesh, node_flag, shared_node, neighbor_idx);
5196 char *node_flag,
char *elem_flag,
5197 char *node_flag_neighbor,
5198 char *elem_flag_neighbor,
int current_domain) {
5199 int **import_elem =
NULL;
5200 int **export_elem =
NULL;
5201 int **shared_node =
NULL;
5202 int neighbor_domain;
5216 if (import_elem ==
NULL) {
5221 import_elem[i] =
NULL;
5225 if (export_elem ==
NULL) {
5230 export_elem[i] =
NULL;
5234 if (shared_node ==
NULL) {
5239 shared_node[i] =
NULL;
5266 for (j = 0; j < global_mesh->
n_node; j++) {
5270 for (j = 0; j < global_mesh->
n_elem; j++) {
5275 memset(node_flag_neighbor, 0,
sizeof(
char) * global_mesh->
n_node);
5276 memset(elem_flag_neighbor, 0,
sizeof(
char) * global_mesh->
n_elem);
5279 rtc = mask_mesh_status_eb(global_mesh, node_flag_neighbor,
5280 elem_flag_neighbor, neighbor_domain);
5283 rtc = mask_comm_node(global_mesh, node_flag, node_flag_neighbor);
5286 rtc = mask_comm_elem(global_mesh, elem_flag, elem_flag_neighbor);
5290 rtc = create_import_info_eb(global_mesh, local_mesh, elem_flag, import_elem,
5291 i, neighbor_domain);
5295 rtc = create_export_info_eb(global_mesh, local_mesh, elem_flag, export_elem,
5296 i, current_domain, neighbor_domain);
5300 rtc = create_shared_info_eb(global_mesh, local_mesh, node_flag, shared_node,
5301 i, neighbor_domain);
5313 rtc = create_comm_item(local_mesh->
n_neighbor_pe, import_elem,
5331 rtc = create_comm_item(local_mesh->
n_neighbor_pe, export_elem,
5349 rtc = create_comm_item(local_mesh->
n_neighbor_pe, shared_node,
5404 char *node_flag,
char *elem_flag,
5405 char *node_flag_neighbor,
char *elem_flag_neighbor,
5406 int current_domain) {
5418 rtc = create_comm_info_nb(global_mesh, local_mesh, node_flag, elem_flag,
5419 node_flag_neighbor, elem_flag_neighbor,
5426 rtc = create_comm_info_eb(global_mesh, local_mesh, node_flag, elem_flag,
5427 node_flag_neighbor, elem_flag_neighbor,
5452 static int set_node_global2local_internal(
5455 const char *node_flag,
int domain) {
5465 for (counter = 0, i = 0; i < n_int_nlist[domain]; i++) {
5466 node = int_nlist[domain][i];
5467 node_global2local[node - 1] = ++counter;
5474 static int set_node_global2local_external(
5477 const char *node_flag) {
5488 for (counter = local_mesh->
nn_internal, i = 0; i < global_mesh->n_node; i++) {
5491 node_global2local[i] = ++counter;
5498 for (i = 0; i < global_mesh->
n_node; i++) {
5501 node_global2local[i] = ++counter;
5504 local_mesh->
n_node = counter;
5512 static int set_node_global2local_external_mod(
5515 const char *node_flag,
int domain) {
5525 for (counter = local_mesh->
nn_internal, i = n_bnd_nlist[2 * domain];
5526 i < n_bnd_nlist[2 * domain + 1]; i++) {
5527 node = bnd_nlist[domain][i];
5528 node_global2local[node - 1] = ++counter;
5530 local_mesh->
n_node = counter;
5538 static int set_node_global2local_all(
5541 const char *node_flag) {
5551 for (counter = 0, i = 0; i < global_mesh->
n_node; i++) {
5553 node_global2local[i] = ++counter;
5556 local_mesh->
n_node = counter;
5566 const char *node_flag) {
5575 for (counter = 0, i = 0; i < global_mesh->
n_node; i++) {
5583 static int const_node_internal_list(
5586 const char *node_flag) {
5608 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,
5684 int *node_global2local,
int domain) {
5692 if (is_spdup_available(global_mesh)) {
5693 for (i = 0; i < n_int_nlist[domain]; i++) {
5694 node = int_nlist[domain][i];
5695 node_global2local[node - 1] = 0;
5697 for (i = n_bnd_nlist[2 * domain]; i < n_bnd_nlist[2 * domain + 1]; i++) {
5698 node = bnd_nlist[domain][i];
5699 node_global2local[node - 1] = 0;
5702 for (i = 0; i < global_mesh->
n_node; i++) {
5703 node_global2local[i] = 0;
5714 const int *node_global2local,
5715 int *node_local2global) {
5725 for (counter = 0, i = 0; i < global_mesh->
n_node; i++) {
5726 if (node_global2local[i]) {
5727 node_local2global[node_global2local[i] - 1] = i + 1;
5736 static int set_node_local2global_mod(
5739 int *node_local2global,
int domain) {
5741 int i, idx1, idx2, node1, node2, n_int, n_bnd, n_out, maxn;
5749 n_int = n_int_nlist[domain];
5750 n_bnd = n_bnd_nlist[2 * domain];
5751 n_out = n_bnd_nlist[2 * domain + 1] - n_bnd_nlist[2 * domain];
5752 maxn = global_mesh->
n_node + 1;
5754 node1 = (n_int == 0) ? maxn : int_nlist[domain][0];
5755 node2 = (n_out == 0) ? maxn : bnd_nlist[domain][n_bnd];
5756 for (counter = 0, idx1 = 0, idx2 = 0, i = 0; i < n_int + n_out; i++) {
5757 if (node1 < node2) {
5758 node_local2global[node_global2local[node1 - 1] - 1] = node1;
5760 node1 = (idx1 == n_int) ? maxn : int_nlist[domain][idx1];
5762 node_local2global[node_global2local[node2 - 1] - 1] = node2;
5764 node2 = (idx2 == n_out) ? maxn : bnd_nlist[domain][idx2 + n_bnd];
5776 static int set_elem_global2local_internal(
5779 const char *elem_flag) {
5789 for (counter = 0, i = 0; i < global_mesh->
n_elem; i++) {
5791 elem_global2local[i] = ++counter;
5799 static int set_elem_global2local_external(
5802 const char *elem_flag) {
5812 for (counter = local_mesh->
ne_internal, i = 0; i < global_mesh->n_elem; i++) {
5814 elem_global2local[i] = ++counter;
5817 local_mesh->
n_elem = counter;
5825 static int set_elem_global2local_all(
5828 const char *elem_flag) {
5838 for (counter = 0, i = 0; i < global_mesh->
n_elem; i++) {
5840 elem_global2local[i] = ++counter;
5843 local_mesh->
n_elem = counter;
5851 static int set_elem_global2local_all_mod(
5854 const char *elem_flag,
int domain) {
5856 int i, idx1, idx2, elem1, elem2, n_int, n_bnd, n_out, maxe;
5864 n_int = n_int_elist[domain];
5865 n_bnd = n_bnd_elist[2 * domain];
5866 n_out = n_bnd_elist[2 * domain + 1] - n_bnd_elist[2 * domain];
5867 maxe = global_mesh->
n_elem + 1;
5869 elem1 = (n_int == 0) ? maxe : int_elist[domain][0];
5870 elem2 = (n_out == 0) ? maxe : bnd_elist[domain][n_bnd];
5871 for (counter = 0, idx1 = 0, idx2 = 0, i = 0; i < n_int + n_out; i++) {
5872 if (elem1 < elem2) {
5873 elem_global2local[elem1 - 1] = ++counter;
5875 elem1 = (idx1 == n_int) ? maxe : int_elist[domain][idx1];
5877 elem_global2local[elem2 - 1] = ++counter;
5879 elem2 = (idx2 == n_out) ? maxe : bnd_elist[domain][idx2 + n_bnd];
5883 local_mesh->
n_elem = counter;
5893 const char *elem_flag) {
5899 for (counter = 0, i = 0; i < global_mesh->
n_elem; i++) {
5907 static int const_elem_internal_list(
5910 const char *elem_flag,
int domain) {
5932 for (counter = 0, i = 0; i < n_int_elist[domain]; i++) {
5933 elem = int_elist[domain][i];
5947 int *elem_global2local,
const char *elem_flag,
5948 int current_domain) {
5959 local_mesh->
ne_internal = n_int_elist[current_domain];
5961 if (is_spdup_available(global_mesh)) {
5962 rtc = set_elem_global2local_all_mod(global_mesh, local_mesh,
5963 elem_global2local, elem_flag,
5966 rtc = set_elem_global2local_all(global_mesh, local_mesh,
5967 elem_global2local, elem_flag);
5972 rtc = const_elem_internal_list(global_mesh, local_mesh, elem_global2local,
5973 elem_flag, current_domain);
5981 rtc = set_elem_global2local_internal(global_mesh, local_mesh,
5982 elem_global2local, elem_flag);
5985 rtc = set_elem_global2local_external(global_mesh, local_mesh,
5986 elem_global2local, elem_flag);
6007 int *elem_global2local,
int domain) {
6015 if (is_spdup_available(global_mesh)) {
6016 for (i = 0; i < n_int_elist[domain]; i++) {
6017 elem = int_elist[domain][i];
6018 elem_global2local[elem - 1] = 0;
6020 for (i = n_bnd_elist[2 * domain]; i < n_bnd_elist[2 * domain + 1]; i++) {
6021 elem = bnd_elist[domain][i];
6022 elem_global2local[elem - 1] = 0;
6026 for (i = 0; i < global_mesh->
n_elem; i++) {
6027 elem_global2local[i] = 0;
6038 const int *elem_global2local,
6039 int *elem_local2global) {
6049 for (counter = 0, i = 0; i < global_mesh->
n_elem; i++) {
6050 if (elem_global2local[i]) {
6051 elem_local2global[elem_global2local[i] - 1] = i + 1;
6060 static int set_elem_local2global_mod(
6063 int *elem_local2global,
int domain) {
6065 int i, idx1, idx2, elem1, elem2, n_int, n_bnd, n_out, maxe;
6073 n_int = n_int_elist[domain];
6074 n_bnd = n_bnd_elist[2 * domain];
6075 n_out = n_bnd_elist[2 * domain + 1] - n_bnd_elist[2 * domain];
6076 maxe = global_mesh->
n_elem + 1;
6078 elem1 = (n_int == 0) ? maxe : int_elist[domain][0];
6079 elem2 = (n_out == 0) ? maxe : bnd_elist[domain][n_bnd];
6080 for (counter = 0, idx1 = 0, idx2 = 0, i = 0; i < n_int + n_out; i++) {
6081 if (elem1 < elem2) {
6082 elem_local2global[elem_global2local[elem1 - 1] - 1] = elem1;
6084 elem1 = (idx1 == n_int) ? maxe : int_elist[domain][idx1];
6086 elem_local2global[elem_global2local[elem2 - 1] - 1] = elem2;
6088 elem2 = (idx2 == n_out) ? maxe : bnd_elist[domain][idx2 + n_bnd];
6135 static int const_hecmw_flag_initcon(
6143 static int const_hecmw_flag_parttype(
6151 static int const_hecmw_flag_partdepth(
6159 static int const_hecmw_flag_version(
6167 static int const_hecmw_flag_partcontact(
6189 rtc = const_gridfile(global_mesh, local_mesh);
6192 rtc = const_hecmw_n_file(global_mesh, local_mesh);
6195 rtc = const_files(global_mesh, local_mesh);
6198 rtc = const_header(global_mesh, local_mesh);
6201 rtc = const_hecmw_flag_adapt(global_mesh, local_mesh);
6204 rtc = const_hecmw_flag_initcon(global_mesh, local_mesh);
6207 rtc = const_hecmw_flag_parttype(global_mesh, local_mesh);
6210 rtc = const_hecmw_flag_partdepth(global_mesh, local_mesh);
6213 rtc = const_hecmw_flag_version(global_mesh, local_mesh);
6216 rtc = const_hecmw_flag_partcontact(global_mesh, local_mesh);
6219 rtc = const_zero_temp(global_mesh, local_mesh);
6255 const char *node_flag) {
6269 for (counter = 0, i = 0; i < global_mesh->
n_dof_grp; i++) {
6271 j < global_mesh->node_dof_index[i + 1]; j++) {
6285 static int const_node_dof_index_mod(
6301 for (counter = 0, i = 0; i < global_mesh->
n_dof_grp; i++) {
6302 for (j = 0; j < n_int_nlist[domain]; j++) {
6303 node = int_nlist[domain][j];
6304 if (node <= global_mesh->node_dof_index[i])
continue;
6328 const int *node_local2global) {
6341 for (i = 0; i < local_mesh->
n_node; i++) {
6342 local_mesh->
node[3 * i] = global_mesh->
node[3 * (node_local2global[i] - 1)];
6343 local_mesh->
node[3 * i + 1] =
6344 global_mesh->
node[3 * (node_local2global[i] - 1) + 1];
6345 local_mesh->
node[3 * i + 2] =
6346 global_mesh->
node[3 * (node_local2global[i] - 1) + 2];
6357 const int *node_local2global) {
6370 for (i = 0; i < local_mesh->
n_node; i++) {
6372 global_mesh->
node_ID[2 * (node_local2global[i] - 1)];
6373 local_mesh->
node_ID[2 * i + 1] =
6374 global_mesh->
node_ID[2 * (node_local2global[i] - 1) + 1];
6385 const int *node_local2global) {
6398 for (i = 0; i < local_mesh->
n_node; i++) {
6409 static int const_node_init_val_index(
6426 for (i = 0; i < local_mesh->
n_node; i++) {
6427 old_idx = node_local2global[i] - 1;
6441 static int const_node_init_val_item(
6446 int i, j, gstart, gend, lstart, lend;
6465 for (counter = 0, i = 0; i < local_mesh->
n_node; i++) {
6473 for (j = 0; j < lend - lstart; j++) {
6489 const int *node_local2global,
const char *node_flag,
6490 int current_domain) {
6498 rtc = const_n_dof(global_mesh, local_mesh);
6501 rtc = const_n_dof_grp(global_mesh, local_mesh);
6506 rtc = const_node_dof_index_mod(global_mesh, local_mesh, node_flag,
6510 rtc = const_node_dof_index(global_mesh, local_mesh, node_flag);
6519 rtc = const_node_dof_item(global_mesh, local_mesh);
6522 rtc = const_node(global_mesh, local_mesh, node_local2global);
6525 rtc = const_node_id(global_mesh, local_mesh, node_local2global);
6528 rtc = const_global_node_id(global_mesh, local_mesh, node_local2global);
6532 rtc = const_node_init_val_index(global_mesh, local_mesh, node_local2global);
6535 rtc = const_node_init_val_item(global_mesh, local_mesh, node_local2global);
6561 const int *elem_local2global) {
6573 for (i = 0; i < local_mesh->
n_elem; i++) {
6585 const int *elem_global2local) {
6600 for (counter = 0, i = 0; i < global_mesh->
n_elem_type; i++) {
6602 j < global_mesh->elem_type_index[i + 1]; j++) {
6603 if (elem_global2local[j]) counter++;
6616 static int const_elem_type_index_mod(
6621 int i, j, idx1, idx2, elem_tmp, elem1, elem2, n_int, n_bnd, n_out, maxe;
6634 n_int = n_int_elist[domain];
6635 n_bnd = n_bnd_elist[2 * domain];
6636 n_out = n_bnd_elist[2 * domain + 1] - n_bnd_elist[2 * domain];
6637 maxe = global_mesh->
n_elem + 1;
6639 for (counter = 0, i = 0; i < global_mesh->
n_elem_type; i++) {
6640 elem1 = (n_int == 0) ? maxe : int_elist[domain][0];
6641 elem2 = (n_out == 0) ? maxe : bnd_elist[domain][n_bnd];
6642 for (idx1 = 0, idx2 = 0, j = 0; j < n_int + n_out; j++) {
6643 if (elem1 < elem2) {
6644 elem_tmp = elem1 - 1;
6646 elem1 = (idx1 == n_int) ? maxe : int_elist[domain][idx1];
6648 elem_tmp = elem2 - 1;
6650 elem2 = (idx2 == n_out) ? maxe : bnd_elist[domain][idx2 + n_bnd];
6653 elem_tmp < global_mesh->elem_type_index[i + 1]) {
6680 const int *elem_local2global) {
6694 for (i = 0; i < local_mesh->
n_elem; i++) {
6695 old_idx = elem_local2global[i] - 1;
6711 const int *node_global2local,
6712 const int *elem_local2global) {
6717 long long gstart, gend, lstart, lend;
6731 for (counter = 0, i = 0; i < local_mesh->
n_elem; i++) {
6737 for (j = 0; j < lend - lstart; j++) {
6739 local_mesh->
elem_node_item[lstart + j] = node_global2local[node - 1];
6753 const int *elem_local2global) {
6766 for (i = 0; i < local_mesh->
n_elem; i++) {
6768 global_mesh->
elem_ID[2 * (elem_local2global[i] - 1)];
6769 local_mesh->
elem_ID[2 * i + 1] =
6770 global_mesh->
elem_ID[2 * (elem_local2global[i] - 1) + 1];
6781 const int *elem_local2global) {
6794 for (i = 0; i < local_mesh->
n_elem; i++) {
6807 const int *elem_local2global) {
6820 for (i = 0; i < local_mesh->
n_elem; i++) {
6822 global_mesh->
section_ID[elem_local2global[i] - 1];
6833 const int *elem_local2global) {
6847 for (i = 0; i < local_mesh->
n_elem; i++) {
6848 old_idx = elem_local2global[i] - 1;
6873 const int *elem_local2global) {
6876 int i, j, gstart, gend, lstart, lend;
6893 for (counter = 0, i = 0; i < local_mesh->
n_elem; i++) {
6901 for (j = 0; j < lend - lstart; j++) {
6918 const int *node_global2local,
6919 const int *elem_global2local,
6920 const int *elem_local2global,
int current_domain) {
6929 rtc = const_n_elem_type(global_mesh, local_mesh);
6932 rtc = const_elem_type(global_mesh, local_mesh, elem_local2global);
6935 if (is_spdup_available(global_mesh)) {
6936 rtc = const_elem_type_index_mod(global_mesh, local_mesh, elem_global2local,
6939 rtc = const_elem_type_index(global_mesh, local_mesh, elem_global2local);
6944 rtc = const_elem_type_item(global_mesh, local_mesh);
6947 rtc = const_elem_node_index(global_mesh, local_mesh, elem_local2global);
6950 rtc = const_elem_node_item(global_mesh, local_mesh, node_global2local,
6954 rtc = const_elem_id(global_mesh, local_mesh, elem_local2global);
6957 rtc = const_global_elem_id(global_mesh, local_mesh, elem_local2global);
6960 rtc = const_section_id(global_mesh, local_mesh, elem_local2global);
6963 rtc = const_elem_mat_id_index(global_mesh, local_mesh, elem_local2global);
6966 rtc = const_n_elem_mat_id(local_mesh);
6969 rtc = const_elem_mat_id_item(global_mesh, local_mesh, elem_local2global);
6989 int current_domain) {
6990 local_mesh->
zero = (current_domain == 0) ? 1 : 0;
7010 int current_domain) {
7011 local_mesh->
my_rank = current_domain;
7031 const int *global2local) {
7046 new_id = global2local[local_mesh->
import_item[i] - 1];
7054 const int *global2local) {
7069 new_id = global2local[local_mesh->
export_item[i] - 1];
7077 const int *global2local) {
7092 new_id = global2local[local_mesh->
shared_item[i] - 1];
7101 const int *node_global2local,
7102 const int *elem_global2local,
int current_domain) {
7110 rtc = const_hecmw_comm(global_mesh, local_mesh);
7113 rtc = const_zero(local_mesh, current_domain);
7116 rtc = const_petot(global_mesh, local_mesh);
7119 rtc = const_pesmptot(global_mesh, local_mesh);
7122 rtc = const_my_rank(local_mesh, current_domain);
7125 rtc = const_errnof(global_mesh, local_mesh);
7128 rtc = const_n_subdomain(global_mesh, local_mesh);
7133 rtc = const_import_item(local_mesh, node_global2local);
7136 rtc = const_export_item(local_mesh, node_global2local);
7139 rtc = const_shared_item(local_mesh, elem_global2local);
7145 rtc = const_import_item(local_mesh, elem_global2local);
7148 rtc = const_export_item(local_mesh, elem_global2local);
7151 rtc = const_shared_item(local_mesh, node_global2local);
7185 static int const_when_i_was_refined_node(
7193 static int const_when_i_was_refined_elem(
7229 static int const_adapt_children_index(
7237 static int const_adapt_children_item(
7252 rtc = const_n_adapt(global_mesh, local_mesh);
7255 rtc = const_coarse_grid_level(global_mesh, local_mesh);
7258 rtc = const_when_i_was_refined_node(global_mesh, local_mesh);
7261 rtc = const_when_i_was_refined_elem(global_mesh, local_mesh);
7264 rtc = const_adapt_parent_type(global_mesh, local_mesh);
7267 rtc = const_adapt_type(global_mesh, local_mesh);
7270 rtc = const_adapt_level(global_mesh, local_mesh);
7273 rtc = const_adapt_parent(global_mesh, local_mesh);
7276 rtc = const_adapt_children_index(global_mesh, local_mesh);
7279 rtc = const_adapt_children_item(global_mesh, local_mesh);
7365 rtc = const_n_sect(global_mesh, local_mesh);
7368 rtc = const_sect_type(global_mesh, local_mesh);
7371 rtc = const_sect_opt(global_mesh, local_mesh);
7374 rtc = const_sect_mat_id_index(global_mesh, local_mesh);
7377 rtc = const_sect_mat_id_item(global_mesh, local_mesh);
7380 rtc = const_sect_i_index(global_mesh, local_mesh);
7383 rtc = const_sect_i_item(global_mesh, local_mesh);
7386 rtc = const_sect_r_index(global_mesh, local_mesh);
7389 rtc = const_sect_r_item(global_mesh, local_mesh);
7482 rtc = const_n_mat(global_mesh, local_mesh);
7485 rtc = const_n_mat_item(global_mesh, local_mesh);
7488 rtc = const_n_mat_subitem(global_mesh, local_mesh);
7491 rtc = const_n_mat_table(global_mesh, local_mesh);
7494 rtc = const_mat_name(global_mesh, local_mesh);
7497 rtc = const_mat_item_index(global_mesh, local_mesh);
7500 rtc = const_mat_subitem_index(global_mesh, local_mesh);
7503 rtc = const_mat_table_index(global_mesh, local_mesh);
7506 rtc = const_mat_val(global_mesh, local_mesh);
7509 rtc = const_mat_temp(global_mesh, local_mesh);
7523 const int *node_global2local,
char *mpc_flag) {
7526 int node, diff, evalsum, counter;
7529 for (counter = 0, i = 0; i < mpc_global->
n_mpc; i++) {
7536 if (node_global2local[node - 1] > 0) evalsum++;
7539 if (evalsum == diff) {
7544 mpc_local->
n_mpc = counter;
7551 const char *mpc_flag) {
7563 for (counter = 0, i = 0; i < mpc_global->
n_mpc; i++) {
7581 const int *node_global2local,
const char *mpc_flag) {
7584 int mcounter, icounter;
7594 for (mcounter = 0, icounter = 0, i = 0; i < mpc_global->
n_mpc; i++) {
7599 node_global2local[mpc_global->
mpc_item[j] - 1];
7615 const char *mpc_flag) {
7618 int mcounter, icounter;
7628 for (mcounter = 0, icounter = 0, i = 0; i < mpc_global->
n_mpc; i++) {
7648 const char *mpc_flag) {
7652 int mcounter, icounter;
7662 for (mcounter = 0, icounter = 0, i = 0; i < mpc_global->
n_mpc; i++) {
7682 const char *mpc_flag) {
7689 size =
sizeof(double) * mpc_local->
n_mpc;
7696 for (icounter = 0, i = 0; i < mpc_global->
n_mpc; i++) {
7712 const int *node_global2local) {
7713 char *mpc_flag =
NULL;
7722 if (global_mesh->
mpc->
n_mpc == 0) {
7723 init_struct_mpc(local_mesh);
7728 if (mpc_flag ==
NULL) {
7733 rtc = const_n_mpc(global_mesh, local_mesh, node_global2local, mpc_flag);
7737 init_struct_mpc(local_mesh);
7742 rtc = const_mpc_index(global_mesh, local_mesh, mpc_flag);
7745 rtc = const_mpc_item(global_mesh, local_mesh, node_global2local, mpc_flag);
7748 rtc = const_mpc_dof(global_mesh, local_mesh, mpc_flag);
7751 rtc = const_mpc_val(global_mesh, local_mesh, mpc_flag);
7754 rtc = const_mpc_const(global_mesh, local_mesh, mpc_flag);
7784 static int const_amp_type_definition(
7836 if (global_mesh->
amp->
n_amp == 0) {
7837 init_struct_amp(local_mesh);
7841 rtc = const_n_amp(global_mesh, local_mesh);
7844 rtc = const_amp_name(global_mesh, local_mesh);
7847 rtc = const_amp_type_definition(global_mesh, local_mesh);
7850 rtc = const_amp_type_time(global_mesh, local_mesh);
7853 rtc = const_amp_type_value(global_mesh, local_mesh);
7856 rtc = const_amp_index(global_mesh, local_mesh);
7859 rtc = const_amp_val(global_mesh, local_mesh);
7862 rtc = const_amp_table(global_mesh, local_mesh);
7874 static int *const_node_grp_mask_eqn(
7877 int eqn_block_idx) {
7879 int *n_eqn_item =
NULL;
7881 int i, j, is, ie, js;
7883 is = node_group_global->
grp_index[eqn_block_idx];
7884 ie = node_group_global->
grp_index[eqn_block_idx + 1];
7886 n_eqn_item = (
int *)
HECMW_malloc(
sizeof(
int) * (ie - is));
7887 if (n_eqn_item ==
NULL) {
7892 for (js = 0, i = 0; i < ie - is; i++) {
7893 diff = node_group_global->
grp_item[is + i] - js;
7894 for (evalsum = 0, j = js; j < node_group_global->
grp_item[is + i]; j++) {
7895 if (node_global2local[j] > 0 &&
7902 n_eqn_item[i] = diff;
7907 js = node_group_global->
grp_item[is + i];
7932 const int *node_global2local,
7933 const int *n_eqn_item,
int eqn_block_idx) {
7947 for (counter = 0, i = 0; i < node_group_global->
n_grp; i++) {
7948 if (i != eqn_block_idx) {
7949 for (j = node_group_global->
grp_index[i];
7950 j < node_group_global->
grp_index[i + 1]; j++) {
7951 node = node_group_global->
grp_item[j];
7952 if (node_global2local[node - 1]) counter++;
7958 for (j = 0; j < diff; j++) {
7959 if (n_eqn_item[j] > 0) counter++;
7963 node_group_local->
grp_index[i + 1] = counter;
7972 static int const_node_grp_index_mod(
7975 const int *n_eqn_item,
int eqn_block_idx,
int domain) {
7989 for (counter = 0, i = 0; i < node_group_global->
n_grp; i++) {
7990 if (i != eqn_block_idx) {
7991 if (node_group_global->
grp_index[i + 1] -
7994 counter += n_int_nlist[domain];
7995 counter += n_bnd_nlist[2 * domain + 1] - n_bnd_nlist[2 * domain];
7997 counter += ngrp_idx[domain][i + 1] - ngrp_idx[domain][i];
8010 for (j = 0; j < diff; j++) {
8011 if (n_eqn_item[j] > 0) counter++;
8015 node_group_local->
grp_index[i + 1] = counter;
8026 const int *node_global2local,
8027 const int *n_eqn_item,
int eqn_block_idx) {
8033 int i, j, k, js, je, ks, ls;
8035 size =
sizeof(int) * node_group_local->
grp_index[node_group_local->
n_grp];
8042 for (counter = 0, i = 0; i < node_group_global->
n_grp; i++) {
8043 if (i != eqn_block_idx) {
8044 for (j = node_group_global->
grp_index[i];
8045 j < node_group_global->
grp_index[i + 1]; j++) {
8046 node = node_group_global->
grp_item[j];
8047 if (node_global2local[node - 1]) {
8048 node_group_local->
grp_item[counter++] = node_global2local[node - 1];
8054 je = node_group_global->
grp_index[i + 1];
8055 for (ks = 0, ls = 0, j = js; j < je; j++) {
8056 if (n_eqn_item[j - js]) {
8058 node_group_global->
grp_item[j] - ks);
8059 node_group_local->
grp_item[counter] = ls + n_eqn_item[j - js];
8061 for (k = ks; k < node_group_global->
grp_item[j]; k++) {
8063 node_global2local[k] <=
8064 node_group_local->
grp_item[counter]);
8066 ls = node_group_local->
grp_item[counter];
8069 ks = node_group_global->
grp_item[j];
8083 const int *node_global2local,
8084 const int *n_eqn_item,
int eqn_block_idx,
8091 int i, j, k, js, je, ks, ls;
8092 int idx1, idx2, node1, node2, n_int, n_bnd, n_out, maxn;
8094 size =
sizeof(int) * node_group_local->
grp_index[node_group_local->
n_grp];
8101 n_int = n_int_nlist[domain];
8102 n_bnd = n_bnd_nlist[2 * domain];
8103 n_out = n_bnd_nlist[2 * domain + 1] - n_bnd_nlist[2 * domain];
8104 maxn = global_mesh->
n_node + 1;
8106 for (counter = 0, i = 0; i < node_group_global->
n_grp; i++) {
8107 if (i != eqn_block_idx) {
8108 if (node_group_global->
grp_index[i + 1] -
8113 node1 = (n_int == 0) ? maxn : int_nlist[domain][0];
8114 node2 = (n_out == 0) ? maxn : bnd_nlist[domain][n_bnd];
8115 for (j = 0; j < n_int + n_out; j++) {
8116 if (node1 < node2) {
8117 node_group_local->
grp_item[counter++] =
8118 node_global2local[node1 - 1];
8120 node1 = (idx1 == n_int) ? maxn : int_nlist[domain][idx1];
8122 node_group_local->
grp_item[counter++] =
8123 node_global2local[node2 - 1];
8125 node2 = (idx2 == n_out) ? maxn : bnd_nlist[domain][idx2 + n_bnd];
8129 if (ngrp_idx[domain][i + 1] - ngrp_idx[domain][i] == 0)
continue;
8130 for (j = ngrp_idx[domain][i]; j < ngrp_idx[domain][i + 1]; j++) {
8131 node = ngrp_item[domain][j];
8132 node_group_local->
grp_item[counter++] = node_global2local[node - 1];
8137 je = node_group_global->
grp_index[i + 1];
8138 for (ks = 0, ls = 0, j = js; j < je; j++) {
8139 if (n_eqn_item[j - js]) {
8141 node_group_global->
grp_item[j] - ks);
8142 node_group_local->
grp_item[counter] = ls + n_eqn_item[j - js];
8144 for (k = ks; k < node_group_global->
grp_item[j]; k++) {
8146 node_global2local[k] <=
8147 node_group_local->
grp_item[counter]);
8149 ls = node_group_local->
grp_item[counter];
8152 ks = node_group_global->
grp_item[j];
8166 const int *node_global2local,
8167 int current_domain) {
8168 int *n_eqn_item =
NULL;
8179 init_struct_node_grp(local_mesh);
8183 eqn_block_idx = search_eqn_block_idx(global_mesh);
8185 if (eqn_block_idx >= 0) {
8186 n_eqn_item = const_node_grp_mask_eqn(global_mesh, local_mesh,
8187 node_global2local, eqn_block_idx);
8188 if (n_eqn_item ==
NULL)
goto error;
8191 rtc = const_node_n_grp(global_mesh, local_mesh);
8194 rtc = const_node_grp_name(global_mesh, local_mesh);
8197 if (is_spdup_available(global_mesh)) {
8198 rtc = const_node_grp_index_mod(global_mesh, local_mesh, node_global2local,
8199 n_eqn_item, eqn_block_idx, current_domain);
8201 rtc = const_node_grp_item_mod(global_mesh, local_mesh, node_global2local,
8202 n_eqn_item, eqn_block_idx, current_domain);
8206 rtc = const_node_grp_index(global_mesh, local_mesh, node_global2local,
8207 n_eqn_item, eqn_block_idx);
8209 rtc = const_node_grp_item(global_mesh, local_mesh, node_global2local,
8210 n_eqn_item, eqn_block_idx);
8243 const int *elem_global2local) {
8257 for (counter = 0, i = 0; i < elem_group_global->
n_grp; i++) {
8258 for (j = elem_group_global->
grp_index[i];
8259 j < elem_group_global->
grp_index[i + 1]; j++) {
8260 elem = elem_group_global->
grp_item[j];
8261 if (elem_global2local[elem - 1]) counter++;
8263 elem_group_local->
grp_index[i + 1] = counter;
8272 static int const_elem_grp_index_mod(
8280 int i, j, idx1, idx2, elem1, elem2;
8289 for (counter = 0, i = 0; i < elem_group_global->
n_grp; i++) {
8292 counter += n_int_elist[domain];
8293 counter += n_bnd_elist[2 * domain + 1] - n_bnd_elist[2 * domain];
8295 counter += egrp_idx[domain][i + 1] - egrp_idx[domain][i];
8297 elem_group_local->
grp_index[i + 1] = counter;
8308 const int *elem_global2local) {
8316 size =
sizeof(int) * elem_group_local->
grp_index[elem_group_local->
n_grp];
8323 for (counter = 0, i = 0; i < elem_group_global->
n_grp; i++) {
8324 for (j = elem_group_global->
grp_index[i];
8325 j < elem_group_global->
grp_index[i + 1]; j++) {
8326 elem = elem_group_global->
grp_item[j];
8327 if (elem_global2local[elem - 1]) {
8328 elem_group_local->
grp_item[counter++] = elem_global2local[elem - 1];
8342 const int *elem_global2local,
int domain) {
8348 int i, j, idx1, idx2, elem1, elem2, n_int, n_bnd, n_out, maxe;
8350 size =
sizeof(int) * elem_group_local->
grp_index[elem_group_local->
n_grp];
8357 n_int = n_int_elist[domain];
8358 n_bnd = n_bnd_elist[2 * domain];
8359 n_out = n_bnd_elist[2 * domain + 1] - n_bnd_elist[2 * domain];
8360 maxe = global_mesh->
n_elem + 1;
8362 for (counter = 0, i = 0; i < elem_group_global->
n_grp; i++) {
8365 elem1 = (n_int == 0) ? maxe : int_elist[domain][0];
8366 elem2 = (n_out == 0) ? maxe : bnd_elist[domain][n_bnd];
8367 for (idx1 = 0, idx2 = 0, j = 0; j < n_int + n_out; j++) {
8368 if (elem1 < elem2) {
8369 elem_group_local->
grp_item[counter++] = elem_global2local[elem1 - 1];
8371 elem1 = (idx1 == n_int) ? maxe : int_elist[domain][idx1];
8373 elem_group_local->
grp_item[counter++] = elem_global2local[elem2 - 1];
8375 elem2 = (idx2 == n_out) ? maxe : bnd_elist[domain][idx2 + n_bnd];
8379 if (egrp_idx[domain][i + 1] - egrp_idx[domain][i] == 0)
continue;
8380 for (j = egrp_idx[domain][i]; j < egrp_idx[domain][i + 1]; j++) {
8381 elem = egrp_item[domain][j];
8382 elem_group_local->
grp_item[counter++] = elem_global2local[elem - 1];
8396 const int *elem_global2local,
8397 int current_domain) {
8407 init_struct_elem_grp(local_mesh);
8411 rtc = const_elem_n_grp(global_mesh, local_mesh);
8414 rtc = const_elem_grp_name(global_mesh, local_mesh);
8417 if (is_spdup_available(global_mesh)) {
8418 rtc = const_elem_grp_index_mod(global_mesh, local_mesh, elem_global2local,
8421 rtc = const_elem_grp_item_mod(global_mesh, local_mesh, elem_global2local,
8426 rtc = const_elem_grp_index(global_mesh, local_mesh, elem_global2local);
8428 rtc = const_elem_grp_item(global_mesh, local_mesh, elem_global2local);
8457 const int *elem_global2local) {
8471 for (counter = 0, i = 0; i < surf_group_global->
n_grp; i++) {
8472 for (j = surf_group_global->
grp_index[i];
8473 j < surf_group_global->
grp_index[i + 1]; j++) {
8474 elem = surf_group_global->
grp_item[2 * j];
8475 if (elem_global2local[elem - 1]) counter++;
8477 surf_group_local->
grp_index[i + 1] = counter;
8488 const int *elem_global2local) {
8496 size =
sizeof(int) * (
size_t)surf_group_local->
grp_index[surf_group_local->
n_grp] * 2;
8503 for (counter = 0, i = 0; i < surf_group_global->
n_grp; i++) {
8504 for (j = surf_group_global->
grp_index[i];
8505 j < surf_group_global->
grp_index[i + 1]; j++) {
8506 elem = surf_group_global->
grp_item[2 * j];
8507 surf = surf_group_global->
grp_item[2 * j + 1];
8508 if (elem_global2local[elem - 1]) {
8509 surf_group_local->
grp_item[2 * counter] = elem_global2local[elem - 1];
8510 surf_group_local->
grp_item[2 * counter + 1] = surf;
8525 const int *elem_global2local) {
8535 init_struct_surf_grp(local_mesh);
8539 rtc = const_surf_n_grp(global_mesh, local_mesh);
8542 rtc = const_surf_grp_name(global_mesh, local_mesh);
8545 rtc = const_surf_grp_index(global_mesh, local_mesh, elem_global2local);
8548 rtc = const_surf_grp_item(global_mesh, local_mesh, elem_global2local);
8560 static int const_contact_pair_n_pair(
8587 for (i = 0; i < cpair_global->
n_pair; i++) {
8588 cpair_local->
type[i] = cpair_global->
type[i];
8597 static int const_contact_pair_slave_grp_id(
8611 for (i = 0; i < cpair_global->
n_pair; i++) {
8621 static int const_contact_pair_slave_orisgrp_id(
8635 for (i = 0; i < cpair_global->
n_pair; i++) {
8645 static int const_contact_pair_master_grp_id(
8659 for (i = 0; i < cpair_global->
n_pair; i++) {
8679 init_struct_contact_pair(local_mesh);
8683 rtc = const_contact_pair_n_pair(global_mesh, local_mesh);
8686 rtc = const_contact_pair_name(global_mesh, local_mesh);
8689 rtc = const_contact_pair_type(global_mesh, local_mesh);
8692 rtc = const_contact_pair_slave_grp_id(global_mesh, local_mesh);
8695 rtc = const_contact_pair_slave_orisgrp_id(global_mesh, local_mesh);
8698 rtc = const_contact_pair_master_grp_id(global_mesh, local_mesh);
8713 const char *node_flag,
const char *elem_flag,
8714 int *node_global2local,
int *elem_global2local,
8715 int current_domain) {
8716 int *node_local2global =
NULL;
8717 int *elem_local2global =
NULL;
8722 rtc = set_node_global2local(global_mesh, local_mesh, node_global2local,
8723 node_flag, current_domain);
8727 if (node_local2global ==
NULL) {
8732 if (is_spdup_available(global_mesh)) {
8733 rtc = set_node_local2global_mod(global_mesh, local_mesh, node_global2local,
8734 node_local2global, current_domain);
8736 rtc = set_node_local2global(global_mesh, local_mesh, node_global2local,
8742 rtc = set_elem_global2local(global_mesh, local_mesh, elem_global2local,
8743 elem_flag, current_domain);
8748 if (elem_local2global ==
NULL) {
8753 if (is_spdup_available(global_mesh)) {
8754 rtc = set_elem_local2global_mod(global_mesh, local_mesh, elem_global2local,
8755 elem_local2global, current_domain);
8757 rtc = set_elem_local2global(global_mesh, local_mesh, elem_global2local,
8763 rtc = const_global_info(global_mesh, local_mesh);
8766 rtc = const_node_info(global_mesh, local_mesh, node_local2global, node_flag,
8770 rtc = const_elem_info(global_mesh, local_mesh, node_global2local,
8771 elem_global2local, elem_local2global, current_domain);
8774 rtc = const_comm_info(global_mesh, local_mesh, node_global2local,
8775 elem_global2local, current_domain);
8778 rtc = const_adapt_info(global_mesh, local_mesh);
8781 rtc = const_sect_info(global_mesh, local_mesh);
8784 rtc = const_mat_info(global_mesh, local_mesh);
8787 rtc = const_mpc_info(global_mesh, local_mesh, node_global2local);
8790 rtc = const_amp_info(global_mesh, local_mesh);
8793 rtc = const_node_grp_info(global_mesh, local_mesh, node_global2local,
8797 rtc = const_elem_grp_info(global_mesh, local_mesh, elem_global2local,
8801 rtc = const_surf_grp_info(global_mesh, local_mesh, elem_global2local);
8804 rtc = const_contact_pair_info(global_mesh, local_mesh);
8807 rtc = clear_node_global2local(global_mesh, local_mesh, node_global2local,
8809 rtc = clear_elem_global2local(global_mesh, local_mesh, elem_global2local,
8822 clean_struct_local_mesh(local_mesh);
8833 static int print_ucd_entire_set_node_data(
8848 result_data->
nn_dof[0] = 1;
8868 strcpy(result_data->
node_label[0],
"rank_of_node");
8870 for (nn_item = 0, i = 0; i < result_data->
nn_component; i++) {
8871 nn_item += result_data->
nn_dof[i];
8874 size =
sizeof(double) * nn_item * global_mesh->
n_node;
8883 for (i = 0; i < global_mesh->
n_node; i++) {
8889 for (i = 0; i < global_mesh->
n_node; i++) {
8895 (double)global_mesh->
node_ID[2 * i + 1];
8909 free_struct_result_data(result_data);
8917 static int print_ucd_entire_set_elem_data(
8932 result_data->
ne_dof[0] = 1;
8952 strcpy(result_data->
elem_label[0],
"partitioning_image");
8955 for (i = 0; i < global_mesh->
n_elem; i++) {
8976 for (ne_item = 0, i = 0; i < result_data->
ne_component; i++) {
8977 ne_item += result_data->
ne_dof[i];
8980 size =
sizeof(double) * ne_item * global_mesh->
n_elem;
8989 for (i = 0; i < global_mesh->
n_elem; i++) {
8995 (double)global_mesh->
elem_ID[2 * i + 1];
9001 for (i = 0; i < global_mesh->
n_elem; i++) {
9015 free_struct_result_data(result_data);
9023 const char *node_flag,
const char *elem_flag,
9024 const char *ofname) {
9029 if (result_data ==
NULL) {
9033 init_struct_result_data(result_data);
9036 if (print_ucd_entire_set_node_data(global_mesh, result_data, node_flag)) {
9040 if (print_ucd_entire_set_elem_data(global_mesh, result_data, elem_flag)) {
9048 free_struct_result_data(result_data);
9053 free_struct_result_data(result_data);
9126 char *node_flag =
NULL;
9127 char *elem_flag =
NULL;
9128 char *node_flag_neighbor =
NULL;
9129 char *elem_flag_neighbor =
NULL;
9130 int *node_global2local =
NULL;
9131 int *elem_global2local =
NULL;
9133 int *num_elem, *num_node, *num_ielem, *num_inode, *num_nbpe;
9134 int *sum_elem, *sum_node, *sum_ielem, *sum_inode, *sum_nbpe;
9135 int current_domain, nrank, iS, iE;
9138 int error_in_ompsection = 0;
9140 if (global_mesh ==
NULL) {
9149 rtc = init_partition(global_mesh,
cont_data);
9155 if (global_mesh->
my_rank == 0) {
9174 if (global_mesh->
my_rank == 0) {
9179 "part_out", global_mesh->
n_subdomain, current_domain);
9180 if (ofheader ==
NULL) {
9182 error_in_ompsection = 1;
9185 if (ofheader->
n_mesh == 0) {
9187 error_in_ompsection = 1;
9196 "Starting writing local mesh for domain #%d...",
9210 if (rtc != 0)
goto error;
9212 if (rtc != 0)
goto error;
9214 if (rtc != 0)
goto error;
9216 if (rtc != 0)
goto error;
9219 if (rtc)
goto error;
9227 if (num_elem ==
NULL) {
9232 if (num_node ==
NULL) {
9237 if (num_ielem ==
NULL) {
9242 if (num_inode ==
NULL) {
9247 if (num_nbpe ==
NULL) {
9252 if (sum_elem ==
NULL) {
9257 if (sum_node ==
NULL) {
9262 if (sum_ielem ==
NULL) {
9267 if (sum_inode ==
NULL) {
9272 if (sum_nbpe ==
NULL) {
9277 rtc = wnumbering(global_mesh,
cont_data);
9281 if (global_mesh->
my_rank == 0) {
9282 print_part(global_mesh,
cont_data->part_file_name);
9286 rtc = spdup_makelist_main(global_mesh);
9290 #pragma omp parallel default(none), \
9291 private(node_flag, elem_flag, local_mesh, nrank, iS, iE, i, \
9292 current_domain, rtc, ofheader, ofname), \
9293 private(node_global2local, elem_global2local, \
9294 node_flag_neighbor, elem_flag_neighbor), \
9295 shared(global_mesh, cont_data, num_elem, num_node, \
9296 num_ielem, num_inode, num_nbpe, error_in_ompsection)
9301 if (node_flag ==
NULL) {
9303 error_in_ompsection = 1;
9307 if (elem_flag ==
NULL) {
9309 error_in_ompsection = 1;
9314 if (node_global2local ==
NULL) {
9316 error_in_ompsection = 1;
9320 if (elem_global2local ==
NULL) {
9322 error_in_ompsection = 1;
9325 node_flag_neighbor =
9327 if (node_flag_neighbor ==
NULL) {
9329 error_in_ompsection = 1;
9332 elem_flag_neighbor =
9334 if (elem_flag_neighbor ==
NULL) {
9336 error_in_ompsection = 1;
9339 memset(node_flag_neighbor, 0,
sizeof(
char) * global_mesh->
n_node);
9340 memset(elem_flag_neighbor, 0,
sizeof(
char) * global_mesh->
n_elem);
9343 if (local_mesh ==
NULL) {
9344 error_in_ompsection = 1;
9355 #pragma omp for schedule(dynamic, 1), reduction(+ : error_in_ompsection)
9357 for (i = iS; i < iE; i++) {
9358 if (error_in_ompsection)
continue;
9365 rtc = create_neighbor_info(global_mesh, local_mesh, node_flag, elem_flag,
9368 error_in_ompsection = 1;
9373 rtc = create_comm_info(global_mesh, local_mesh, node_flag, elem_flag,
9374 node_flag_neighbor, elem_flag_neighbor,
9377 error_in_ompsection = 1;
9382 rtc = const_local_data(global_mesh, local_mesh,
cont_data, node_flag,
9383 elem_flag, node_global2local, elem_global2local,
9386 error_in_ompsection = 1;
9390 num_elem[i] = local_mesh->
n_elem;
9391 num_node[i] = local_mesh->
n_node;
9397 "part_out", global_mesh->
n_subdomain, current_domain);
9398 if (ofheader ==
NULL) {
9400 error_in_ompsection = 1;
9403 if (ofheader->
n_mesh == 0) {
9405 error_in_ompsection = 1;
9414 "Starting writing local mesh for domain #%d...",
9421 error_in_ompsection = 1;
9427 clean_struct_local_mesh(local_mesh);
9432 if (is_spdup_available(global_mesh)) {
9433 spdup_clear_IEB(node_flag, elem_flag, current_domain);
9436 for (j = 0; j < global_mesh->
n_node; j++) {
9439 for (j = 0; j < global_mesh->
n_elem; j++) {
9445 if (error_in_ompsection)
goto error_omp;
9450 if (global_mesh->
my_rank == 0) {
9451 print_ucd_entire(global_mesh, node_flag, elem_flag,
9467 if (error_in_ompsection)
goto error;
9472 if (rtc != 0)
goto error;
9475 if (rtc != 0)
goto error;
9478 if (rtc != 0)
goto error;
9481 if (rtc != 0)
goto error;
9484 if (rtc != 0)
goto error;
9486 if (global_mesh->
my_rank == 0) {
9489 if (rtc != 0)
goto error;
9491 if (rtc != 0)
goto error;
9493 if (rtc != 0)
goto error;
9495 if (rtc != 0)
goto error;
9497 if (rtc != 0)
goto error;
9500 if (rtc)
goto error;
9515 spdup_freelist(global_mesh);
9548 if (global_mesh ==
NULL) {
9557 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_SPGDPT1
#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_PART_N
#define HECMW_PART_E_INVALID_PMETHOD
#define HECMW_PART_E_INVALID_PTYPE
#define HECMW_PART_RCB_X_AXIS
#define HECMW_PART_E_PART_NDOMAIN
#define HECMW_PART_E_NO_SUCH_FILE
#define HECMW_PART_E_PART_EOF
#define HECMW_PART_METHOD_RCB
#define HECMW_PART_CONTACT_DEFAULT
#define HECMW_PART_E_INV_ARG
#define HECMW_PART_E_PART_EMPTY_DOMAIN
#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_E_PART_INVALID_FORMAT
#define HECMW_PART_METHOD_USER
#define HECMW_PART_E_PART_INVALID_PART
#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)
#define HECMW_FLAG_PARTCONTACT_SIMPLE
#define HECMW_CONTACT_TYPE_NODE_SURF
#define HECMW_FLAG_PARTCONTACT_AGGREGATE
#define HECMW_CONTACT_TYPE_NODE_ELEM
#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.
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
long long * elem_node_index
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