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,
813 snprintf(fname, fname_size,
"%s.%d", header, domain);
817 static void free_link_list(
struct link_unit *llist) {
820 for (p = llist; p; p = q) {
830 if (local_mesh ==
NULL) {
856 if (local_mesh ==
NULL) {
870 local_mesh->
n_dof = 0;
888 if (local_mesh ==
NULL) {
928 if (local_mesh ==
NULL) {
933 local_mesh->
zero = 0;
934 local_mesh->
PETOT = 0;
957 if (local_mesh ==
NULL) {
980 if (local_mesh ==
NULL) {
1006 if (local_mesh ==
NULL) {
1033 if (local_mesh ==
NULL) {
1037 if (local_mesh->
mpc ==
NULL) {
1056 if (local_mesh ==
NULL) {
1061 if (local_mesh->
amp ==
NULL) {
1082 if (local_mesh ==
NULL) {
1111 if (local_mesh ==
NULL) {
1139 if (local_mesh ==
NULL) {
1167 if (local_mesh ==
NULL) {
1174 "\'local_mesh->contact_pair\' is NULL");
1194 if (local_mesh ==
NULL)
return;
1196 init_struct_global(local_mesh);
1200 if (local_mesh ==
NULL)
return;
1205 if (local_mesh->
node) {
1224 init_struct_node(local_mesh);
1228 if (local_mesh ==
NULL)
return;
1261 init_struct_elem(local_mesh);
1265 if (local_mesh ==
NULL)
return;
1289 init_struct_comm(local_mesh);
1293 if (local_mesh ==
NULL)
return;
1295 init_struct_adapt(local_mesh);
1299 if (local_mesh ==
NULL)
return;
1302 init_struct_sect(local_mesh);
1306 if (local_mesh ==
NULL)
return;
1309 init_struct_mat(local_mesh);
1313 if (local_mesh ==
NULL)
return;
1314 if (local_mesh->
mpc ==
NULL)
return;
1322 init_struct_mpc(local_mesh);
1326 if (local_mesh ==
NULL)
return;
1327 if (local_mesh->
amp ==
NULL)
return;
1329 init_struct_amp(local_mesh);
1333 if (local_mesh ==
NULL)
return;
1343 init_struct_node_grp(local_mesh);
1347 if (local_mesh ==
NULL)
return;
1357 init_struct_elem_grp(local_mesh);
1361 if (local_mesh ==
NULL)
return;
1371 init_struct_surf_grp(local_mesh);
1375 if (local_mesh ==
NULL)
return;
1391 init_struct_contact_pair(local_mesh);
1395 if (local_mesh ==
NULL)
return;
1397 clean_struct_global(local_mesh);
1398 clean_struct_node(local_mesh);
1399 clean_struct_elem(local_mesh);
1400 clean_struct_comm(local_mesh);
1401 clean_struct_adapt(local_mesh);
1402 clean_struct_sect(local_mesh);
1403 clean_struct_mat(local_mesh);
1404 clean_struct_mpc(local_mesh);
1405 clean_struct_amp(local_mesh);
1406 clean_struct_node_grp(local_mesh);
1407 clean_struct_elem_grp(local_mesh);
1408 clean_struct_surf_grp(local_mesh);
1409 clean_struct_contact_pair(local_mesh);
1416 if (result_data ==
NULL) {
1438 if (result_data ==
NULL)
return;
1478 static int quick_sort(
int no,
int n,
double *arr,
int *brr,
int *istack) {
1491 for (j = l + 1; j <= ir; j++) {
1494 for (i = j - 1; i >= l; i--) {
1495 if (arr[i] <= a)
break;
1496 arr[i + 1] = arr[i];
1497 brr[i + 1] = brr[i];
1503 if (!jstack)
return 0;
1505 ir = istack[jstack];
1506 l = istack[jstack - 1];
1512 DSWAP(arr[k], arr[l + 1])
1513 ISWAP(brr[k], brr[l + 1])
1515 if (arr[l] > arr[ir]) {
1516 DSWAP(arr[l], arr[ir])
1517 ISWAP(brr[l], brr[ir])
1520 if (arr[l + 1] > arr[ir]) {
1521 DSWAP(arr[l + 1], arr[ir])
1522 ISWAP(brr[l + 1], brr[ir])
1525 if (arr[l] > arr[l + 1]) {
1526 DSWAP(arr[l], arr[l + 1])
1527 ISWAP(brr[l], brr[l + 1])
1545 DSWAP(arr[i], arr[j])
1546 ISWAP(brr[i], brr[j])
1549 arr[l + 1] = arr[j];
1551 brr[l + 1] = brr[j];
1556 if (jstack > nstack) {
1561 if (ir - i + 1 >= j - l) {
1562 istack[jstack] = ir;
1563 istack[jstack - 1] = i;
1566 istack[jstack] = j - 1;
1567 istack[jstack - 1] = l;
1577 static int rcb_partition(
int n,
const double *coord,
int *wnum,
1591 if (stack ==
NULL) {
1596 if (value ==
NULL) {
1601 for (i = 0; i <
cont_data->n_rcb_div; i++) {
1602 for (j = 0; j < pow(2, i); j++) {
1607 for (k = 0; k < n; k++) {
1608 if (wnum[2 * k + 1] == j) {
1610 value[counter] = coord[3 * k];
1617 for (k = 0; k < n; k++) {
1618 if (wnum[2 * k + 1] == j) {
1620 value[counter] = coord[3 * k + 1];
1627 for (k = 0; k < n; k++) {
1628 if (wnum[2 * k + 1] == j) {
1630 value[counter] = coord[3 * k + 2];
1642 rtc = quick_sort(n, counter, value,
id, stack);
1646 for (k = 0; k < counter *
F_1_2; k++) {
1647 wnum[2 *
id[k] + 1] = j + (int)pow(2, i);
1670 double coord_x, coord_y, coord_z;
1675 for (i = 0; i < global_mesh->
n_elem; i++) {
1679 for (coord_x = 0.0, coord_y = 0.0, coord_z = 0.0, j = js; j < je; j++) {
1682 coord_x += global_mesh->
node[3 * (node - 1)];
1683 coord_y += global_mesh->
node[3 * (node - 1) + 1];
1684 coord_z += global_mesh->
node[3 * (node - 1) + 2];
1687 coord[3 * i] = coord_x / (je - js);
1688 coord[3 * i + 1] = coord_y / (je - js);
1689 coord[3 * i + 2] = coord_z / (je - js);
1697 double *coord =
NULL;
1701 if (coord ==
NULL) {
1706 rtc = calc_gravity(global_mesh, coord);
1709 rtc = rcb_partition(global_mesh->
n_elem, coord, global_mesh->
elem_ID,
1725 static int create_node_graph_link_list(
1731 for (i = 0; i < edge_data->
n_edge; i++) {
1738 if (graph[node1 - 1]->last->next ==
NULL) {
1743 graph[node1 - 1]->
n += 1;
1751 if (graph[node2 - 1]->last->next ==
NULL) {
1756 graph[node2 - 1]->
n += 1;
1768 static int create_node_graph_compress(
1770 idx_t *node_graph_index,
idx_t *node_graph_item) {
1771 long long int counter;
1775 for (counter = 0, i = 0; i < global_mesh->
n_node; i++) {
1776 node_graph_index[i + 1] = node_graph_index[i] + graph[i]->
n;
1778 for (p = graph[i]->list, j = 0; j < graph[i]->
n; j++) {
1780 node_graph_item[counter++] = p->
id - 1;
1789 idx_t *node_graph_index,
idx_t *node_graph_item) {
1795 (size_t)global_mesh->
n_node);
1796 if (graph ==
NULL) {
1800 for (i = 0; i < global_mesh->
n_node; i++) {
1804 for (i = 0; i < global_mesh->
n_node; i++) {
1806 if (graph[i] ==
NULL) {
1813 for (i = 0; i < global_mesh->
n_node; i++) {
1815 if (graph[i]->list ==
NULL) {
1825 rtc = create_node_graph_link_list(global_mesh, edge_data, graph);
1828 rtc = create_node_graph_compress(global_mesh, graph, node_graph_index,
1832 for (i = 0; i < global_mesh->
n_node; i++) {
1833 free_link_list(graph[i]->list);
1842 for (i = 0; i < global_mesh->
n_node; i++) {
1844 free_link_list(graph[i]->list);
1869 (size_t)global_mesh->
n_node);
1870 if (node_list ==
NULL) {
1874 for (i = 0; i < global_mesh->
n_node; i++) {
1875 node_list[i] =
NULL;
1878 for (i = 0; i < global_mesh->
n_node; i++) {
1880 if (node_list[i] ==
NULL) {
1887 for (i = 0; i < global_mesh->
n_node; i++) {
1888 node_list[i]->
list =
1890 if (node_list[i]->list ==
NULL) {
1894 node_list[i]->
n = 0;
1896 node_list[i]->
last = node_list[i]->
list;
1900 for (i = 0; i < global_mesh->
n_elem; i++) {
1902 j < global_mesh->elem_node_index[i + 1]; j++) {
1907 if (node_list[node - 1]->last->next ==
NULL) {
1912 node_list[node - 1]->
last = node_list[node - 1]->
last->
next;
1913 node_list[node - 1]->
last->
id = i + 1;
1915 node_list[node - 1]->
n += 1;
1925 for (i = 0; i < global_mesh->
n_node; i++) {
1936 for (counter = 0, i = 0; i < global_mesh->
n_node; i++) {
1937 for (p = node_list[i]->list, j = 0; j < node_list[i]->
n; j++) {
1944 for (i = 0; i < global_mesh->
n_node; i++) {
1945 free_link_list(node_list[i]->list);
1954 for (i = 0; i < global_mesh->
n_node; i++) {
1956 free_link_list(node_list[i]->list);
1971 static int create_elem_graph_link_list(
1974 char *elem_flag =
NULL;
1982 if (elem_flag ==
NULL) {
1987 for (counter = 0, i = 0; i < global_mesh->
n_elem; i++) {
1988 memset(elem_flag, 0,
sizeof(
char) * global_mesh->
n_elem);
1992 j < global_mesh->elem_node_index[i + 1]; j++) {
1996 k < node_data->node_elem_index[node]; k++) {
2004 if (graph[i]->last->next ==
NULL) {
2029 static int create_elem_graph_compress(
2031 int *elem_graph_index,
int *elem_graph_item) {
2036 for (counter = 0, i = 0; i < global_mesh->
n_elem; i++) {
2037 elem_graph_index[i + 1] = elem_graph_index[i] + graph[i]->
n;
2039 for (p = graph[i]->list, j = 0; j < graph[i]->
n; j++) {
2041 elem_graph_item[counter++] = p->
id - 1;
2050 int *elem_graph_index) {
2053 int *elem_graph_item =
NULL;
2060 if (node_data ==
NULL) {
2068 rtc = set_node_belong_elem(global_mesh, node_data);
2072 (size_t)global_mesh->
n_elem);
2073 if (graph ==
NULL) {
2077 for (i = 0; i < global_mesh->
n_elem; i++) {
2081 for (i = 0; i < global_mesh->
n_elem; i++) {
2083 if (graph[i] ==
NULL) {
2090 for (i = 0; i < global_mesh->
n_elem; i++) {
2092 if (graph[i]->list ==
NULL) {
2102 n_graph = create_elem_graph_link_list(global_mesh, node_data, graph);
2103 if (n_graph < 0)
goto error;
2105 elem_graph_item = (
int *)
HECMW_malloc(
sizeof(
int) * n_graph);
2106 if (elem_graph_item ==
NULL) {
2111 rtc = create_elem_graph_compress(global_mesh, graph, elem_graph_index,
2118 for (i = 0; i < global_mesh->
n_elem; i++) {
2119 free_link_list(graph[i]->list);
2124 return elem_graph_item;
2133 for (i = 0; i < global_mesh->
n_elem; i++) {
2135 free_link_list(graph[i]->list);
2149 static int pmetis_interface(
const int n_vertex,
const int n_domain,
idx_t *xadj,
2152 #ifdef HECMW_PART_WITH_METIS
2158 #if defined(METIS_VER_MAJOR) && (METIS_VER_MAJOR == 5)
2161 real_t *tpwgts =
NULL;
2162 real_t *ubvec =
NULL;
2166 METIS_PartGraphRecursive(&n, &ncon, xadj, adjncy, vwgt, vsize,
NULL,
2167 &nparts, tpwgts, ubvec,
options, &edgecut, part);
2172 int options[5] = {0, 0, 0, 0, 0};
2175 METIS_PartGraphRecursive(&n, xadj, adjncy, vwgt, adjwgt, &wgtflag, &numflag,
2176 &nparts,
options, &edgecut, part);
2181 return (
int)edgecut;
2184 static int kmetis_interface(
const int n_vertex,
const int n_domain,
idx_t *xadj,
2187 #ifdef HECMW_PART_WITH_METIS
2193 #if defined(METIS_VER_MAJOR) && (METIS_VER_MAJOR == 5)
2196 real_t *tpwgts =
NULL;
2197 real_t *ubvec =
NULL;
2201 METIS_PartGraphKway(&n, &ncon, xadj, adjncy, vwgt, vsize,
NULL, &nparts,
2202 tpwgts, ubvec,
options, &edgecut, part);
2207 int options[5] = {0, 0, 0, 0, 0};
2210 METIS_PartGraphKway(&n, xadj, adjncy, vwgt, adjwgt, &wgtflag, &numflag,
2211 &nparts,
options, &edgecut, part);
2216 return (
int)edgecut;
2219 static int pmetis_interface_with_weight(
int n_vertex,
int ncon,
int n_domain,
2221 const int *vwgt,
idx_t *part) {
2223 #ifdef HECMW_PART_WITH_METIS
2228 #if defined(METIS_VER_MAJOR) && (METIS_VER_MAJOR == 5)
2230 real_t *tpwgts =
NULL;
2231 real_t *ubvec =
NULL;
2236 vsize, adjwgt, &nparts, tpwgts, ubvec,
options,
2242 int options[5] = {0, 0, 0, 0, 0};
2244 if (vwgt !=
NULL) wgtflag = 2;
2248 METIS_PartGraphRecursive((
int *)&n, (
idx_t *)xadj, (
idx_t *)adjncy, (
idx_t *)vwgt,
2249 (
idx_t *)adjwgt, &wgtflag, &numflag, (
int *)&nparts,
options,
2250 (
int *)&edgecut, (
idx_t *)part);
2252 METIS_mCPartGraphRecursive((
int *)&n, &ncon, (
idx_t *)xadj, (
idx_t *)adjncy,
2253 (
idx_t *)vwgt, (
idx_t *)adjwgt, &wgtflag, &numflag, (
int *)&nparts,
2260 return (
int)edgecut;
2263 static int kmetis_interface_with_weight(
int n_vertex,
int ncon,
int n_domain,
2265 const int *vwgt,
idx_t *part) {
2267 #ifdef HECMW_PART_WITH_METIS
2272 #if defined(METIS_VER_MAJOR) && (METIS_VER_MAJOR == 5)
2274 real_t *tpwgts =
NULL;
2275 real_t *ubvec =
NULL;
2280 adjwgt, &nparts, tpwgts, ubvec,
options, &edgecut, part);
2285 float *ubvec =
NULL;
2286 int options[5] = {0, 0, 0, 0, 0};
2288 if (vwgt !=
NULL) wgtflag = 2;
2292 if (ubvec ==
NULL) {
2301 &wgtflag, &numflag, (
int *)&nparts,
options, (
int *)&edgecut, (
idx_t *)part);
2303 METIS_mCPartGraphKway((
int *)&n, &ncon, (
idx_t *)xadj, (
idx_t *)adjncy, (
idx_t *)vwgt,
2304 (
idx_t *)adjwgt, &wgtflag, &numflag, (
int *)&nparts, ubvec,
options,
2305 (
int *)&edgecut, (
idx_t *)part);
2313 return (
int)edgecut;
2316 static int contact_agg_mark_node_group(
int *mark,
2318 int gid,
int agg_id,
int *agg_dup) {
2320 int istart, iend, i;
2326 for (i = istart; i < iend; i++) {
2329 if (0 <= mark[nid] && mark[nid] < agg_id) {
2331 if (*agg_dup == -1) {
2332 *agg_dup = mark[nid];
2333 }
else if (mark[nid] != *agg_dup) {
2335 "ERROR: node included in multiple node groups in different "
2337 " which is not supported by CONTACT=AGGREGATE\n");
2346 static int HECMW_get_num_surf_node(
int etype,
int sid) {
2361 if (1 <= sid && sid <= 3)
return 4;
2362 if (4 <= sid && sid <= 5)
return 3;
2364 if (1 <= sid && sid <= 3)
return 8;
2365 if (4 <= sid && sid <= 5)
return 6;
2369 "ERROR: parallel contact analysis of elem type %d not supported\n",
2376 static const int *HECMW_get_surf_node(
int etype,
int sid) {
2379 static const int elem_surf_tet1[4][3] = {
2380 {1, 2, 3}, {0, 3, 2}, {0, 1, 3}, {0, 2, 1}};
2381 static const int elem_surf_tet2[4][6] = {{1, 4, 2, 9, 3, 8},
2384 {0, 5, 2, 4, 1, 6}};
2385 static const int elem_surf_hex1[6][4] = {{3, 0, 4, 7}, {1, 2, 6, 5},
2386 {0, 1, 5, 4}, {2, 3, 7, 6},
2387 {3, 2, 1, 0}, {4, 5, 6, 7}};
2388 static const int elem_surf_hex2[6][8] = {
2389 {3, 11, 0, 16, 4, 15, 7, 19}, {1, 9, 2, 18, 6, 13, 5, 17},
2390 {0, 8, 1, 17, 5, 12, 4, 16}, {2, 10, 3, 19, 7, 14, 6, 18},
2391 {3, 10, 2, 9, 1, 8, 0, 11}, {4, 12, 5, 13, 6, 14, 7, 15}};
2392 static const int elem_surf_pri1[5][4] = {
2393 {1, 2, 5, 4}, {2, 0, 3, 5}, {0, 1, 4, 3}, {2, 1, 0, -1}, {3, 4, 5, -1}};
2394 static const int elem_surf_pri2[5][8] = {{1, 6, 2, 14, 5, 9, 4, 13},
2395 {2, 7, 0, 12, 3, 10, 5, 14},
2396 {0, 8, 1, 13, 4, 11, 3, 12},
2397 {2, 6, 1, 8, 0, 7, -1, -1},
2398 {3, 11, 4, 9, 5, 10, -1, -1}};
2399 static const int elem_surf_ptt1[3] = {0, 1, 2};
2400 static const int elem_surf_ptt2[6] = {0, 1, 2, 3, 4, 5};
2401 static const int elem_surf_ptq1[4] = {0, 1, 2, 3};
2402 static const int elem_surf_ptq2[8] = {0, 1, 2, 3, 4, 5, 6, 7};
2405 return elem_surf_tet1[sid - 1];
2407 return elem_surf_tet2[sid - 1];
2409 return elem_surf_hex1[sid - 1];
2411 return elem_surf_hex2[sid - 1];
2413 return elem_surf_pri1[sid - 1];
2415 return elem_surf_pri2[sid - 1];
2417 return elem_surf_ptt1;
2419 return elem_surf_ptt2;
2421 return elem_surf_ptq1;
2423 return elem_surf_ptq2;
2426 "ERROR: parallel contact analysis of element type %d not supported\n",
2431 static int HECMW_fistr_get_num_surf_node(
int etype,
int sid) {
2446 if (1 <= sid && sid <= 2)
return 3;
2447 if (3 <= sid && sid <= 5)
return 4;
2449 if (1 <= sid && sid <= 2)
return 6;
2450 if (3 <= sid && sid <= 5)
return 8;
2454 "ERROR: parallel contact analysis of elem type %d not supported\n",
2461 static const int *HECMW_fistr_get_surf_node(
int etype,
int sid) {
2464 static const int elem_surf_tet1[4][3] = {
2465 {0, 1, 2}, {0, 1, 3}, {1, 2, 3}, {2, 0, 3}};
2466 static const int elem_surf_tet2[4][6] = {{0, 6, 1, 4, 2, 5},
2469 {2, 5, 0, 9, 3, 7}};
2470 static const int elem_surf_hex1[6][4] = {{0, 1, 2, 3}, {4, 5, 6, 7},
2471 {0, 1, 5, 4}, {1, 2, 6, 5},
2472 {2, 3, 7, 6}, {3, 0, 4, 7}};
2473 static const int elem_surf_hex2[6][8] = {
2474 {0, 8, 1, 9, 2, 10, 3, 11}, {4, 12, 5, 13, 6, 14, 7, 15},
2475 {0, 8, 1, 17, 5, 12, 4, 16}, {1, 9, 2, 18, 6, 13, 5, 17},
2476 {2, 10, 3, 19, 7, 14, 6, 18}, {3, 11, 0, 16, 4, 15, 7, 19}};
2477 static const int elem_surf_pri1[5][4] = {
2478 {0, 1, 2, -1}, {3, 4, 5, -1}, {0, 1, 4, 3}, {1, 2, 5, 4}, {2, 0, 3, 5}};
2479 static const int elem_surf_pri2[5][8] = {{0, 8, 1, 6, 2, 7, -1, -1},
2480 {3, 11, 4, 9, 5, 10, -1, -1},
2481 {0, 8, 1, 13, 4, 11, 3, 12},
2482 {1, 6, 2, 14, 5, 9, 4, 13},
2483 {2, 7, 0, 12, 3, 10, 5, 14}};
2484 static const int elem_surf_ptt1[3] = {0, 1, 2};
2485 static const int elem_surf_ptt2[6] = {0, 1, 2, 3, 4, 5};
2486 static const int elem_surf_ptq1[4] = {0, 1, 2, 3};
2487 static const int elem_surf_ptq2[8] = {0, 1, 2, 3, 4, 5, 6, 7};
2490 return elem_surf_tet1[sid - 1];
2492 return elem_surf_tet2[sid - 1];
2494 return elem_surf_hex1[sid - 1];
2496 return elem_surf_hex2[sid - 1];
2498 return elem_surf_pri1[sid - 1];
2500 return elem_surf_pri2[sid - 1];
2502 return elem_surf_ptt1;
2504 return elem_surf_ptt2;
2506 return elem_surf_ptq1;
2508 return elem_surf_ptq2;
2511 "ERROR: parallel contact analysis of element type %d not supported\n",
2522 for (i = 0; i < global_mesh->
n_node; i++) {
2526 for (i = 0; i < cp->
n_pair; i++) {
2530 for (j = jstart; j < jend; j++) {
2531 int eid = sgrp->
grp_item[j * 2] - 1;
2532 int sid = sgrp->
grp_item[j * 2 + 1];
2535 int etype = global_mesh->
elem_type[eid];
2541 int num_snode = HECMW_fistr_get_num_surf_node(etype, sid);
2542 const int *snode = HECMW_fistr_get_surf_node(etype, sid);
2546 for (k = 0; k < num_snode; k++) {
2547 int nid = nop[snode[k]] - 1;
2556 static int contact_agg_mark_surf_group(
int *mark,
2558 int gid,
int agg_id,
int *agg_dup) {
2560 int istart, iend, i, j;
2567 for (i = istart; i < iend; i++) {
2568 int eid = sgrp->
grp_item[i * 2] - 1;
2569 int sid = sgrp->
grp_item[i * 2 + 1];
2571 int etype = global_mesh->
elem_type[eid];
2576 int num_snode = HECMW_fistr_get_num_surf_node(etype, sid);
2577 const int *snode = HECMW_fistr_get_surf_node(etype, sid);
2580 for (j = 0; j < num_snode; j++) {
2581 int nid = nop[snode[j]] - 1;
2583 if (0 <= mark[nid] && mark[nid] < agg_id) {
2585 if (*agg_dup == -1) {
2586 *agg_dup = mark[nid];
2587 }
else if (mark[nid] != *agg_dup) {
2589 "ERROR: node included in multiple surface groups in "
2590 "different contact pairs,\n"
2591 " which is not supported by CONTACT=AGGREGATE\n");
2601 static int metis_partition_nb_contact_agg(
2613 int agg_id, agg_dup, gid;
2615 const int *node_graph_index2;
2616 const int *node_graph_item2;
2625 if (node_graph_index ==
NULL) {
2630 if (node_graph_item ==
NULL) {
2637 rtc = create_node_graph(global_mesh, edge_data, node_graph_index,
2654 for (i = 0; i < global_mesh->
n_node; i++) {
2659 for (i = 0; i < cp->
n_pair; i++) {
2665 contact_agg_mark_node_group(mark, global_mesh, gid, agg_id, &agg_dup);
2670 contact_agg_mark_surf_group(mark, global_mesh, gid, agg_id, &agg_dup);
2675 contact_agg_mark_surf_group(mark, global_mesh, gid, agg_id, &agg_dup);
2680 rtc = contact_agg_mark_surf_group(mark, global_mesh, gid, agg_id, &agg_dup);
2684 for (i = 0; i < global_mesh->
n_node; i++) {
2685 if (mark[i] == agg_id) {
2694 for (i = 0; i < global_mesh->
n_node; i++) {
2703 node_graph_index, node_graph_item);
2713 node_weight2 = (
int *)
HECMW_calloc(n_node2,
sizeof(
int));
2714 if (node_weight2 ==
NULL) {
2718 for (i = 0; i < global_mesh->
n_node; i++) {
2719 node_weight2[mark[i]] += 1;
2725 if (belong_domain ==
NULL) {
2732 n_edgecut = pmetis_interface_with_weight(
2734 (
idx_t *)node_graph_item2, node_weight2, belong_domain);
2735 if (n_edgecut < 0)
goto error;
2739 n_edgecut = kmetis_interface_with_weight(
2741 (
idx_t *)node_graph_item2, node_weight2, belong_domain);
2742 if (n_edgecut < 0)
goto error;
2750 for (i = 0; i < global_mesh->
n_node; i++) {
2751 global_mesh->
node_ID[2 * i + 1] = (int)belong_domain[mark[i]];
2773 static int metis_partition_nb_contact_dist(
2784 int *node_weight =
NULL;
2792 if (node_graph_index ==
NULL) {
2797 if (node_graph_item ==
NULL) {
2804 rtc = create_node_graph(global_mesh, edge_data, node_graph_index,
2827 rtc = mark_contact_master_nodes(global_mesh, mark);
2831 if (node_weight ==
NULL) {
2836 for (i = 0; i < global_mesh->
n_node; i++) {
2838 node_weight[i * ncon] = 1;
2840 node_weight[i * ncon + 1] = mark[i];
2847 if (belong_domain ==
NULL) {
2854 n_edgecut = pmetis_interface_with_weight(
2856 node_graph_item, node_weight, belong_domain);
2857 if (n_edgecut < 0)
goto error;
2861 n_edgecut = kmetis_interface_with_weight(
2863 node_graph_item, node_weight, belong_domain);
2864 if (n_edgecut < 0)
goto error;
2872 for (i = 0; i < global_mesh->
n_node; i++) {
2873 global_mesh->
node_ID[2 * i + 1] = (int)belong_domain[i];
2893 static int metis_partition_nb_default(
2905 if (node_graph_index ==
NULL) {
2910 if (node_graph_item ==
NULL) {
2917 rtc = create_node_graph(global_mesh, edge_data, node_graph_index,
2924 if (belong_domain ==
NULL) {
2935 node_graph_index, node_graph_item, belong_domain);
2936 if (n_edgecut < 0)
goto error;
2942 node_graph_index, node_graph_item, belong_domain);
2943 if (n_edgecut < 0)
goto error;
2951 for (i = 0; i < global_mesh->
n_node; i++) {
2952 global_mesh->
node_ID[2 * i + 1] = (int)belong_domain[i];
2975 return metis_partition_nb_contact_agg(global_mesh,
cont_data,
2980 return metis_partition_nb_contact_dist(global_mesh,
cont_data,
2987 return metis_partition_nb_default(global_mesh,
cont_data, edge_data);
2993 int *elem_graph_index,
int *elem_graph_item) {
2995 int *belong_domain =
NULL;
2999 if (belong_domain ==
NULL) {
3008 elem_graph_index, elem_graph_item, belong_domain);
3009 if (n_edgecut < 0)
goto error;
3015 elem_graph_index, elem_graph_item, belong_domain);
3016 if (n_edgecut < 0)
goto error;
3024 for (i = 0; i < global_mesh->
n_elem; i++) {
3025 global_mesh->
elem_ID[2 * i + 1] = belong_domain[i];
3040 #define LINEBUF_SIZE 1023
3042 static int read_part_file(
3043 const char *part_file_name,
3049 int rtc, n_in, n_domain_in;
3053 fpart = fopen(part_file_name,
"r");
3054 if (fpart ==
NULL) {
3064 rtc = sscanf(linebuf,
"%d %d", &n_in, &n_domain_in);
3074 if (n_domain_in != n_domain) {
3079 count_dom = (
int *)
HECMW_calloc(n_domain,
sizeof(
int));
3080 if (count_dom ==
NULL) {
3086 for (i = 0; i < n; i++) {
3091 rtc = sscanf(linebuf,
"%d", &part);
3097 if (part < 0 || n_domain <= part) {
3108 for (i = 0; i < n_domain; i++) {
3109 if (count_dom[i] == 0) {
3123 static int write_part_file(
3124 const char *part_file_name,
3131 fpart = fopen(part_file_name,
"w");
3132 if (fpart ==
NULL) {
3137 fprintf(fpart,
"%d %d\n", n, n_domain);
3139 for (i = 0; i < n; i++) {
3140 fprintf(fpart,
"%d\n", wnum[2*i+1]);
3153 static int user_partition(
3157 const char *part_file_name) {
3160 rtc = read_part_file(part_file_name, n, n_domain, wnum);
3169 static int user_partition_nb(
3176 static int user_partition_eb(
3185 static int print_part(
3187 const char *part_file_name) {
3192 rtc = write_part_file(part_file_name, global_mesh->
n_node,
3199 rtc = write_part_file(part_file_name, global_mesh->
n_elem,
3218 static int count_edgecut(
3224 for (i = 0; i < edge_data->
n_edge; i++) {
3236 static int set_node_belong_domain_nb(
3246 if (edge_data ==
NULL) {
3257 if (rtc != 0)
goto error;
3263 rtc = rcb_partition(global_mesh->
n_node, global_mesh->
node,
3267 n_edgecut = count_edgecut(edge_data, global_mesh->
node_ID);
3273 n_edgecut = metis_partition_nb(global_mesh,
cont_data, edge_data);
3274 if (n_edgecut < 0)
goto error;
3279 rtc = user_partition_nb(global_mesh,
cont_data);
3282 n_edgecut = count_edgecut(edge_data, global_mesh->
node_ID);
3318 for (i = 0; i < global_mesh->
n_node; i++) {
3322 for (i = 0; i < global_mesh->
n_elem; i++) {
3324 j < global_mesh->elem_node_index[i + 1]; j++) {
3326 if (global_mesh->
elem_ID[2 * i + 1] <
3327 global_mesh->
node_ID[2 * (node - 1) + 1]) {
3328 global_mesh->
node_ID[2 * (node - 1) + 1] =
3329 global_mesh->
elem_ID[2 * i + 1];
3342 if (counter ==
NULL) {
3347 for (j = 0; j < global_mesh->
n_node; j++) {
3348 domain = global_mesh->
node_ID[2 * j + 1];
3349 global_mesh->
node_ID[2 * j] = ++counter[domain];
3372 for (i = 0; i < global_mesh->
n_node; i++) {
3373 global_mesh->
node_ID[2 * i] = i + 1;
3374 global_mesh->
node_ID[2 * i + 1] = 0;
3382 rtc = set_node_belong_domain_nb(global_mesh,
cont_data);
3387 rtc = set_node_belong_domain_eb(global_mesh);
3396 rtc = set_local_node_id(global_mesh);
3408 int node, node_domain, min_domain;
3412 for (i = 0; i < global_mesh->
n_elem; i++) {
3415 j < global_mesh->elem_node_index[i + 1]; j++) {
3417 node_domain = global_mesh->
node_ID[2 * (node - 1) + 1];
3418 if (node_domain < min_domain) {
3419 min_domain = node_domain;
3422 global_mesh->
elem_ID[2 * i + 1] = min_domain;
3430 int *elem_graph_index,
int *elem_graph_item) {
3438 for (i = 0; i < global_mesh->
n_elem; i++) {
3439 for (j = elem_graph_index[i]; j < elem_graph_index[i + 1]; j++) {
3441 if (eid < 0)
goto error;
3446 if (elem_data->
n_edge < 0)
goto error;
3461 static int set_elem_belong_domain_eb(
3465 int *elem_graph_index =
NULL;
3466 int *elem_graph_item =
NULL;
3472 if (elem_graph_index ==
NULL) {
3478 if (elem_data ==
NULL) {
3488 elem_graph_item = create_elem_graph(global_mesh, elem_graph_index);
3489 if (elem_graph_item ==
NULL)
goto error;
3493 rtc = count_edge_for_eb(global_mesh, elem_data, elem_graph_index,
3499 rtc = rcb_partition_eb(global_mesh,
cont_data);
3502 n_edgecut = count_edgecut(elem_data, global_mesh->
elem_ID);
3508 n_edgecut = metis_partition_eb(global_mesh,
cont_data, elem_graph_index,
3510 if (n_edgecut < 0)
goto error;
3515 rtc = user_partition_eb(global_mesh,
cont_data);
3518 n_edgecut = count_edgecut(elem_data, global_mesh->
elem_ID);
3553 if (counter ==
NULL) {
3558 for (j = 0; j < global_mesh->
n_elem; j++) {
3559 domain = global_mesh->
elem_ID[2 * j + 1];
3560 global_mesh->
elem_ID[2 * j] = ++counter[domain];
3583 for (i = 0; i < global_mesh->
n_elem; i++) {
3584 global_mesh->
elem_ID[2 * i] = i + 1;
3585 global_mesh->
elem_ID[2 * i + 1] = 0;
3593 rtc = set_elem_belong_domain_nb(global_mesh);
3599 rtc = set_elem_belong_domain_eb(global_mesh,
cont_data);
3609 rtc = set_local_elem_id(global_mesh);
3629 rtc = wnumbering_node(global_mesh,
cont_data);
3632 rtc = wnumbering_elem(global_mesh,
cont_data);
3639 rtc = wnumbering_elem(global_mesh,
cont_data);
3642 rtc = wnumbering_node(global_mesh,
cont_data);
3669 char *node_flag,
int current_domain) {
3672 for (i = 0; i < n_int_nlist[current_domain]; i++) {
3673 node = int_nlist[current_domain][i];
3681 char *elem_flag,
int current_domain) {
3684 for (i = 0; i < global_mesh->
n_elem; i++) {
3685 (global_mesh->
elem_ID[2 * i + 1] == current_domain)
3693 static int mask_elem_by_domain_mod(
char *elem_flag,
int current_domain) {
3696 for (i = 0; i < n_int_elist[current_domain]; i++) {
3697 elem = int_elist[current_domain][i];
3708 char *node_flag,
int current_domain) {
3711 for (i = 0; i < global_mesh->
mpc->
n_mpc; i++) {
3712 int j0, je, slave, master, j, evalsum;
3722 for (j = j0 + 1; j < je; j++) {
3740 static int mask_overlap_elem(
char *elem_flag,
int domain) {
3743 for (i = 0; i < n_bnd_elist[2 * domain + 1]; i++) {
3744 elem = bnd_elist[domain][i];
3753 char *node_flag,
const char *elem_flag) {
3758 for (i = 0; i < global_mesh->
n_elem; i++) {
3761 j < global_mesh->elem_node_index[i + 1]; j++) {
3773 char *node_flag,
char *elem_flag,
3777 for (i = 0; i < n_bnd_nlist[2 * domain + 1]; i++) {
3778 node = bnd_nlist[domain][i];
3789 static int mask_boundary_elem_with_slave(
3791 char *elem_flag,
int *added) {
3797 for (i = 0; i < global_mesh->
n_elem; i++) {
3804 j < global_mesh->elem_node_index[i + 1]; j++) {
3825 static int mask_boundary_link_elem_with_slave(
3827 char *elem_flag,
int *added) {
3833 for (i = 0; i < global_mesh->
n_elem; i++) {
3840 j < global_mesh->elem_node_index[i + 1]; j++) {
3860 static int mask_additional_overlap_elem(
3867 for (i = 0; i < global_mesh->
n_elem; i++) {
3870 j < global_mesh->elem_node_index[i + 1]; j++) {
3885 char *elem_flag,
char *node_flag) {
3888 int elem, node, selem;
3889 int evalsum, evalsum2;
3890 int master_gid, slave_gid;
3902 for (i = 0; i < cp->
n_pair; i++) {
3903 switch (cp->
type[i]) {
3908 jstart = sgrp->
grp_index[master_gid - 1];
3910 for (j = jstart; j < jend; j++) {
3920 jstart = ngrp->
grp_index[slave_gid - 1];
3922 for (j = jstart; j < jend; j++) {
3932 jstart = sgrp->
grp_index[master_gid - 1];
3934 for (j = jstart; j < jend; j++) {
3944 jstart = ngrp->
grp_index[slave_gid - 1];
3946 for (j = jstart; j < jend; j++) {
3959 jstart = sgrp->
grp_index[master_gid - 1];
3961 for (j = jstart; j < jend; j++) {
3972 jstart = sgrp->
grp_index[slave_gid - 1];
3974 for (j = jstart; j < jend; j++) {
3979 k < global_mesh->elem_node_index[selem]; k++) {
3989 jstart = sgrp->
grp_index[master_gid - 1];
3991 for (j = jstart; j < jend; j++) {
4002 jstart = sgrp->
grp_index[slave_gid - 1];
4004 for (j = jstart; j < jend; j++) {
4008 k < global_mesh->elem_node_index[selem]; k++) {
4018 k < global_mesh->elem_node_index[selem]; k++) {
4031 jstart = egrp->
grp_index[master_gid - 1];
4033 for (j = jstart; j < jend; j++) {
4043 jstart = ngrp->
grp_index[slave_gid - 1];
4045 for (j = jstart; j < jend; j++) {
4055 jstart = egrp->
grp_index[master_gid - 1];
4057 for (j = jstart; j < jend; j++) {
4067 jstart = ngrp->
grp_index[slave_gid - 1];
4069 for (j = jstart; j < jend; j++) {
4087 char *node_flag,
char *elem_flag,
4088 int current_domain) {
4092 rtc = mask_node_by_domain(global_mesh, node_flag, current_domain);
4095 rtc = mask_elem_by_domain_mod(elem_flag, current_domain);
4098 rtc = mask_overlap_elem(elem_flag, current_domain);
4102 mask_boundary_node_mod(global_mesh, node_flag, elem_flag, current_domain);
4111 rtc = mask_slave_node(global_mesh, node_flag, current_domain);
4114 rtc = mask_boundary_elem_with_slave(global_mesh, node_flag, elem_flag,
4119 rtc = mask_boundary_node(global_mesh, node_flag, elem_flag);
4124 rtc = mask_boundary_link_elem_with_slave(global_mesh, node_flag, elem_flag,
4129 rtc = mask_boundary_node(global_mesh, node_flag, elem_flag);
4133 for (i = 0; i < global_mesh->
n_node; i++) {
4141 rtc = mask_additional_overlap_elem(global_mesh, node_flag, elem_flag);
4144 rtc = mask_boundary_node(global_mesh, node_flag, elem_flag);
4149 rtc = mask_contact_slave_surf(global_mesh, elem_flag, node_flag);
4163 char *node_flag,
const char *elem_flag) {
4168 for (i = 0; i < global_mesh->
n_elem; i++) {
4171 j < global_mesh->elem_node_index[i + 1]; j++) {
4178 j < global_mesh->elem_node_index[i + 1]; j++) {
4192 for (i = 0; i < global_mesh->
n_node; i++) {
4203 char *node_flag,
const char *elem_flag) {
4207 rtc = mask_overlap_node_mark(global_mesh, node_flag, elem_flag);
4210 rtc = mask_overlap_node_inner(global_mesh, node_flag);
4213 for (i = 0; i < global_mesh->
n_node; i++) {
4225 const char *node_flag,
char *elem_flag) {
4230 for (i = 0; i < global_mesh->
n_elem; i++) {
4233 j < global_mesh->elem_node_index[i + 1]; j++) {
4248 char *node_flag,
char *elem_flag,
4249 int current_domain) {
4253 for (i = 0; i < global_mesh->
n_node; i++) {
4258 for (i = 0; i < global_mesh->
n_elem; i++) {
4264 rtc = mask_node_by_domain(global_mesh, node_flag, current_domain);
4267 rtc = mask_elem_by_domain(global_mesh, elem_flag, current_domain);
4270 rtc = mask_overlap_node(global_mesh, node_flag, elem_flag);
4273 rtc = mask_boundary_elem(global_mesh, node_flag, elem_flag);
4285 const char *node_flag,
char *domain_flag) {
4288 for (i = 0; i < global_mesh->
n_node; i++) {
4297 static int mask_neighbor_domain_nb_mod(
4299 char *domain_flag,
int domain) {
4302 for (i = n_bnd_nlist[2 * domain]; i < n_bnd_nlist[2 * domain + 1]; i++) {
4303 node = bnd_nlist[domain][i];
4310 static int mask_neighbor_domain_nb_contact(
4312 const char *elem_flag,
char *domain_flag) {
4315 int elem, node, selem;
4317 int master_gid, slave_gid;
4329 for (i = 0; i < cp->
n_pair; i++) {
4332 switch (cp->
type[i]) {
4335 jstart = ngrp->
grp_index[slave_gid - 1];
4337 for (j = jstart; j < jend; j++) {
4347 jstart = sgrp->
grp_index[slave_gid - 1];
4349 for (j = jstart; j < jend; j++) {
4352 k < global_mesh->elem_node_index[selem]; k++) {
4364 jstart = ngrp->
grp_index[slave_gid - 1];
4366 for (j = jstart; j < jend; j++) {
4381 jstart = egrp->
grp_index[master_gid - 1];
4383 for (j = jstart; j < jend; j++) {
4390 jstart = sgrp->
grp_index[master_gid - 1];
4392 for (j = jstart; j < jend; j++) {
4406 const char *elem_flag,
char *domain_flag) {
4409 for (i = 0; i < global_mesh->
n_elem; i++) {
4419 const char *domain_flag) {
4423 for (counter = 0, i = 0; i < global_mesh->
n_subdomain; i++) {
4432 const char *domain_flag) {
4436 for (counter = 0, i = 0; i < global_mesh->
n_subdomain; i++) {
4447 char *node_flag,
char *elem_flag,
4448 int current_domain) {
4450 char *domain_flag =
NULL;
4458 "Starting creation of neighboring domain information...");
4464 if (domain_flag ==
NULL) {
4471 rtc = mask_mesh_status_nb(global_mesh, node_flag, elem_flag,
4475 if (is_spdup_available(global_mesh)) {
4476 rtc = mask_neighbor_domain_nb_mod(global_mesh, node_flag, domain_flag,
4479 rtc = mask_neighbor_domain_nb(global_mesh, node_flag, domain_flag);
4483 rtc = mask_neighbor_domain_nb_contact(global_mesh, node_flag, elem_flag,
4490 rtc = mask_mesh_status_eb(global_mesh, node_flag, elem_flag,
4494 rtc = mask_neighbor_domain_eb(global_mesh, elem_flag, domain_flag);
4504 local_mesh->
n_neighbor_pe = count_neighbor_domain(global_mesh, domain_flag);
4522 rtc = set_neighbor_domain(global_mesh, local_mesh, domain_flag);
4543 char *node_flag_current,
char *node_flag_neighbor) {
4546 for (i = 0; i < global_mesh->
n_node; i++) {
4557 char *node_flag_current,
char *node_flag_neighbor,
4558 int current_domain) {
4561 for (i = 0; i < n_bnd_nlist[2 * current_domain + 1]; i++) {
4562 node = bnd_nlist[current_domain][i];
4572 char *elem_flag_current,
char *elem_flag_neighbor) {
4575 for (i = 0; i < global_mesh->
n_elem; i++) {
4586 char *elem_flag_current,
char *elem_flag_neighbor,
4587 int current_domain) {
4590 for (i = 0; i < n_bnd_elist[2 * current_domain + 1]; i++) {
4591 elem = bnd_elist[current_domain][i];
4601 const char *node_flag,
int domain) {
4605 for (counter = 0, i = 0; i < n_int_nlist[domain]; i++) {
4606 node = int_nlist[domain][i];
4614 const char *elem_flag,
int domain) {
4618 for (counter = 0, i = 0; i < global_mesh->
n_elem; i++) {
4620 global_mesh->
elem_ID[2 * i + 1] == domain)
4627 static int count_masked_shared_node(
4632 for (counter = 0, i = 0; i < global_mesh->
n_node; i++) {
4639 static int count_masked_shared_elem(
4644 for (counter = 0, i = 0; i < global_mesh->
n_elem; i++) {
4651 static int count_masked_shared_elem_mod(
4657 for (counter = 0, i = 0; i < n_bnd_elist[2 * domain + 1]; i++) {
4658 elem = bnd_elist[domain][i];
4666 const char *node_flag,
int **comm_node,
4667 int neighbor_idx,
int domain) {
4671 for (counter = 0, i = 0; i < n_int_nlist[domain]; i++) {
4672 node = int_nlist[domain][i];
4674 comm_node[neighbor_idx][counter++] = node;
4682 const char *elem_flag,
int **comm_elem,
4683 int neighbor_idx,
int domain) {
4687 for (counter = 0, i = 0; i < global_mesh->
n_elem; i++) {
4689 global_mesh->
elem_ID[2 * i + 1] == domain) {
4690 comm_elem[neighbor_idx][counter++] = i + 1;
4698 const char *node_flag,
int **shared_node,
4703 for (counter = 0, i = 0; i < global_mesh->
n_node; i++) {
4705 shared_node[neighbor_idx][counter++] = i + 1;
4713 const char *elem_flag,
int **shared_elem,
4718 for (counter = 0, i = 0; i < global_mesh->
n_elem; i++) {
4720 shared_elem[neighbor_idx][counter++] = i + 1;
4727 static int create_shared_elem_pre_mod(
4729 int **shared_elem,
int neighbor_idx,
int neighbor_domain) {
4731 int i, idx1, idx2, elem1, elem2, n_bnd, n_out, maxe;
4733 n_bnd = n_bnd_elist[2 * neighbor_domain];
4735 n_bnd_elist[2 * neighbor_domain + 1] - n_bnd_elist[2 * neighbor_domain];
4736 maxe = global_mesh->
n_elem + 1;
4738 elem1 = (n_bnd == 0) ? maxe : bnd_elist[neighbor_domain][0];
4739 elem2 = (n_out == 0) ? maxe : bnd_elist[neighbor_domain][n_bnd];
4740 for (counter = 0, idx1 = 0, idx2 = 0, i = 0; i < n_bnd + n_out; i++) {
4741 if (elem1 < elem2) {
4743 shared_elem[neighbor_idx][counter++] = elem1;
4746 elem1 = (idx1 == n_bnd) ? maxe : bnd_elist[neighbor_domain][idx1];
4749 shared_elem[neighbor_idx][counter++] = elem2;
4752 elem2 = (idx2 == n_out) ? maxe : bnd_elist[neighbor_domain][idx2 + n_bnd];
4759 static int create_comm_item(
int n_neighbor_pe,
int **comm_item_pre,
4760 int *comm_index,
int *comm_item) {
4763 for (i = 0; i < n_neighbor_pe; i++) {
4765 je = comm_index[i + 1];
4767 for (j = 0; j < je - js; j++) {
4768 comm_item[js + j] = comm_item_pre[i][j];
4779 const char *node_flag,
int **import_node,
4780 int neighbor_idx,
int neighbor_domain) {
4781 int n_import_node, rtc;
4784 count_masked_comm_node(global_mesh, node_flag, neighbor_domain);
4788 local_mesh->
import_index[neighbor_idx] + n_import_node;
4790 import_node[neighbor_idx] = (
int *)
HECMW_malloc(
sizeof(
int) * n_import_node);
4791 if (import_node[neighbor_idx] ==
NULL) {
4796 rtc = create_comm_node_pre(global_mesh, node_flag, import_node, neighbor_idx,
4808 const char *node_flag,
int **export_node,
4809 int neighbor_idx,
int current_domain,
4810 int neighbor_domain) {
4811 int n_export_node, rtc;
4814 count_masked_comm_node(global_mesh, node_flag, current_domain);
4818 local_mesh->
export_index[neighbor_idx] + n_export_node;
4820 export_node[neighbor_idx] = (
int *)
HECMW_malloc(
sizeof(
int) * n_export_node);
4821 if (export_node[neighbor_idx] ==
NULL) {
4826 rtc = create_comm_node_pre(global_mesh, node_flag, export_node, neighbor_idx,
4838 const char *elem_flag,
int **shared_elem,
4839 int neighbor_idx,
int neighbor_domain) {
4840 int n_shared_elem, rtc;
4842 if (is_spdup_available(global_mesh)) {
4844 count_masked_shared_elem_mod(global_mesh, elem_flag, neighbor_domain);
4846 n_shared_elem = count_masked_shared_elem(global_mesh, elem_flag);
4852 local_mesh->
shared_index[neighbor_idx] + n_shared_elem;
4854 shared_elem[neighbor_idx] = (
int *)
HECMW_malloc(
sizeof(
int) * n_shared_elem);
4855 if (shared_elem[neighbor_idx] ==
NULL) {
4860 if (is_spdup_available(global_mesh)) {
4861 rtc = create_shared_elem_pre_mod(global_mesh, elem_flag, shared_elem,
4862 neighbor_idx, neighbor_domain);
4864 rtc = create_shared_elem_pre(global_mesh, elem_flag, shared_elem,
4878 char *node_flag,
char *elem_flag,
4879 char *node_flag_neighbor,
4880 char *elem_flag_neighbor,
int current_domain) {
4881 int **import_node =
NULL;
4882 int **export_node =
NULL;
4883 int **shared_elem =
NULL;
4884 int neighbor_domain;
4897 if (import_node ==
NULL) {
4902 import_node[i] =
NULL;
4906 if (export_node ==
NULL) {
4911 export_node[i] =
NULL;
4915 if (shared_elem ==
NULL) {
4920 shared_elem[i] =
NULL;
4946 rtc = mask_mesh_status_nb(global_mesh, node_flag_neighbor,
4947 elem_flag_neighbor, neighbor_domain);
4950 if (is_spdup_available(global_mesh)) {
4951 rtc = mask_comm_node_mod(global_mesh, node_flag, node_flag_neighbor,
4954 rtc = mask_comm_node(global_mesh, node_flag, node_flag_neighbor);
4959 if (is_spdup_available(global_mesh)) {
4960 rtc = mask_comm_elem_mod(global_mesh, elem_flag, elem_flag_neighbor,
4963 rtc = mask_comm_elem(global_mesh, elem_flag, elem_flag_neighbor);
4968 rtc = create_import_info_nb(global_mesh, local_mesh, node_flag, import_node,
4969 i, neighbor_domain);
4972 rtc = create_export_info_nb(global_mesh, local_mesh, node_flag, export_node,
4973 i, current_domain, neighbor_domain);
4976 rtc = create_shared_info_nb(global_mesh, local_mesh, elem_flag, shared_elem,
4977 i, neighbor_domain);
4980 if (is_spdup_available(global_mesh)) {
4981 rtc = spdup_clear_IEB(node_flag_neighbor, elem_flag_neighbor,
4985 rtc = spdup_clear_MMbnd(node_flag_neighbor, elem_flag_neighbor,
4989 rtc = spdup_clear_MMbnd(node_flag, elem_flag, current_domain);
4992 for (j = 0; j < global_mesh->
n_node; j++) {
4995 for (j = 0; j < global_mesh->
n_elem; j++) {
4999 memset(node_flag_neighbor, 0,
sizeof(
char) * global_mesh->
n_node);
5000 memset(elem_flag_neighbor, 0,
sizeof(
char) * global_mesh->
n_elem);
5011 rtc = create_comm_item(local_mesh->
n_neighbor_pe, import_node,
5028 rtc = create_comm_item(local_mesh->
n_neighbor_pe, export_node,
5045 rtc = create_comm_item(local_mesh->
n_neighbor_pe, shared_elem,
5101 const char *elem_flag,
int **import_elem,
5102 int neighbor_idx,
int neighbor_domain) {
5103 int n_import_elem, rtc;
5106 count_masked_comm_elem(global_mesh, elem_flag, neighbor_domain);
5110 local_mesh->
import_index[neighbor_idx] + n_import_elem;
5112 import_elem[neighbor_idx] = (
int *)
HECMW_malloc(
sizeof(
int) * n_import_elem);
5113 if (import_elem[neighbor_idx] ==
NULL) {
5118 rtc = create_comm_elem_pre(global_mesh, elem_flag, import_elem, neighbor_idx,
5130 const char *elem_flag,
int **export_elem,
5131 int neighbor_idx,
int current_domain,
5132 int neighbor_domain) {
5133 int n_export_elem, rtc;
5136 count_masked_comm_elem(global_mesh, elem_flag, current_domain);
5140 local_mesh->
export_index[neighbor_idx] + n_export_elem;
5142 export_elem[neighbor_idx] = (
int *)
HECMW_malloc(
sizeof(
int) * n_export_elem);
5143 if (export_elem[neighbor_idx] ==
NULL) {
5148 rtc = create_comm_elem_pre(global_mesh, elem_flag, export_elem, neighbor_idx,
5160 const char *node_flag,
int **shared_node,
5161 int neighbor_idx,
int neighbor_domain) {
5162 int n_shared_node, rtc;
5164 n_shared_node = count_masked_shared_node(global_mesh, node_flag);
5168 local_mesh->
shared_index[neighbor_idx] + n_shared_node;
5170 shared_node[neighbor_idx] = (
int *)
HECMW_malloc(
sizeof(
int) * n_shared_node);
5171 if (shared_node[neighbor_idx] ==
NULL) {
5177 create_shared_node_pre(global_mesh, node_flag, shared_node, neighbor_idx);
5190 char *node_flag,
char *elem_flag,
5191 char *node_flag_neighbor,
5192 char *elem_flag_neighbor,
int current_domain) {
5193 int **import_elem =
NULL;
5194 int **export_elem =
NULL;
5195 int **shared_node =
NULL;
5196 int neighbor_domain;
5210 if (import_elem ==
NULL) {
5215 import_elem[i] =
NULL;
5219 if (export_elem ==
NULL) {
5224 export_elem[i] =
NULL;
5228 if (shared_node ==
NULL) {
5233 shared_node[i] =
NULL;
5260 for (j = 0; j < global_mesh->
n_node; j++) {
5264 for (j = 0; j < global_mesh->
n_elem; j++) {
5269 memset(node_flag_neighbor, 0,
sizeof(
char) * global_mesh->
n_node);
5270 memset(elem_flag_neighbor, 0,
sizeof(
char) * global_mesh->
n_elem);
5273 rtc = mask_mesh_status_eb(global_mesh, node_flag_neighbor,
5274 elem_flag_neighbor, neighbor_domain);
5277 rtc = mask_comm_node(global_mesh, node_flag, node_flag_neighbor);
5280 rtc = mask_comm_elem(global_mesh, elem_flag, elem_flag_neighbor);
5284 rtc = create_import_info_eb(global_mesh, local_mesh, elem_flag, import_elem,
5285 i, neighbor_domain);
5289 rtc = create_export_info_eb(global_mesh, local_mesh, elem_flag, export_elem,
5290 i, current_domain, neighbor_domain);
5294 rtc = create_shared_info_eb(global_mesh, local_mesh, node_flag, shared_node,
5295 i, neighbor_domain);
5307 rtc = create_comm_item(local_mesh->
n_neighbor_pe, import_elem,
5325 rtc = create_comm_item(local_mesh->
n_neighbor_pe, export_elem,
5343 rtc = create_comm_item(local_mesh->
n_neighbor_pe, shared_node,
5398 char *node_flag,
char *elem_flag,
5399 char *node_flag_neighbor,
char *elem_flag_neighbor,
5400 int current_domain) {
5412 rtc = create_comm_info_nb(global_mesh, local_mesh, node_flag, elem_flag,
5413 node_flag_neighbor, elem_flag_neighbor,
5420 rtc = create_comm_info_eb(global_mesh, local_mesh, node_flag, elem_flag,
5421 node_flag_neighbor, elem_flag_neighbor,
5446 static int set_node_global2local_internal(
5449 const char *node_flag,
int domain) {
5459 for (counter = 0, i = 0; i < n_int_nlist[domain]; i++) {
5460 node = int_nlist[domain][i];
5461 node_global2local[node - 1] = ++counter;
5468 static int set_node_global2local_external(
5471 const char *node_flag) {
5482 for (counter = local_mesh->
nn_internal, i = 0; i < global_mesh->n_node; i++) {
5485 node_global2local[i] = ++counter;
5492 for (i = 0; i < global_mesh->
n_node; i++) {
5495 node_global2local[i] = ++counter;
5498 local_mesh->
n_node = counter;
5506 static int set_node_global2local_external_mod(
5509 const char *node_flag,
int domain) {
5519 for (counter = local_mesh->
nn_internal, i = n_bnd_nlist[2 * domain];
5520 i < n_bnd_nlist[2 * domain + 1]; i++) {
5521 node = bnd_nlist[domain][i];
5522 node_global2local[node - 1] = ++counter;
5524 local_mesh->
n_node = counter;
5532 static int set_node_global2local_all(
5535 const char *node_flag) {
5545 for (counter = 0, i = 0; i < global_mesh->
n_node; i++) {
5547 node_global2local[i] = ++counter;
5550 local_mesh->
n_node = counter;
5560 const char *node_flag) {
5569 for (counter = 0, i = 0; i < global_mesh->
n_node; i++) {
5577 static int const_node_internal_list(
5580 const char *node_flag) {
5602 for (counter = 0, i = 0; i < global_mesh->
n_node; i++) {
5617 int *node_global2local,
const char *node_flag,
5618 int current_domain) {
5629 rtc = set_node_global2local_internal(global_mesh, local_mesh,
5630 node_global2local, node_flag,
5634 if (is_spdup_available(global_mesh)) {
5635 rtc = set_node_global2local_external_mod(global_mesh, local_mesh,
5636 node_global2local, node_flag,
5639 rtc = set_node_global2local_external(global_mesh, local_mesh,
5640 node_global2local, node_flag);
5651 rtc = const_nn_internal(global_mesh, local_mesh, node_flag);
5654 rtc = set_node_global2local_all(global_mesh, local_mesh,
5655 node_global2local, node_flag);
5658 rtc = const_node_internal_list(global_mesh, local_mesh, node_global2local,
5678 int *node_global2local,
int domain) {
5686 if (is_spdup_available(global_mesh)) {
5687 for (i = 0; i < n_int_nlist[domain]; i++) {
5688 node = int_nlist[domain][i];
5689 node_global2local[node - 1] = 0;
5691 for (i = n_bnd_nlist[2 * domain]; i < n_bnd_nlist[2 * domain + 1]; i++) {
5692 node = bnd_nlist[domain][i];
5693 node_global2local[node - 1] = 0;
5696 for (i = 0; i < global_mesh->
n_node; i++) {
5697 node_global2local[i] = 0;
5708 const int *node_global2local,
5709 int *node_local2global) {
5719 for (counter = 0, i = 0; i < global_mesh->
n_node; i++) {
5720 if (node_global2local[i]) {
5721 node_local2global[node_global2local[i] - 1] = i + 1;
5730 static int set_node_local2global_mod(
5733 int *node_local2global,
int domain) {
5735 int i, idx1, idx2, node1, node2, n_int, n_bnd, n_out, maxn;
5743 n_int = n_int_nlist[domain];
5744 n_bnd = n_bnd_nlist[2 * domain];
5745 n_out = n_bnd_nlist[2 * domain + 1] - n_bnd_nlist[2 * domain];
5746 maxn = global_mesh->
n_node + 1;
5748 node1 = (n_int == 0) ? maxn : int_nlist[domain][0];
5749 node2 = (n_out == 0) ? maxn : bnd_nlist[domain][n_bnd];
5750 for (counter = 0, idx1 = 0, idx2 = 0, i = 0; i < n_int + n_out; i++) {
5751 if (node1 < node2) {
5752 node_local2global[node_global2local[node1 - 1] - 1] = node1;
5754 node1 = (idx1 == n_int) ? maxn : int_nlist[domain][idx1];
5756 node_local2global[node_global2local[node2 - 1] - 1] = node2;
5758 node2 = (idx2 == n_out) ? maxn : bnd_nlist[domain][idx2 + n_bnd];
5770 static int set_elem_global2local_internal(
5773 const char *elem_flag) {
5783 for (counter = 0, i = 0; i < global_mesh->
n_elem; i++) {
5785 elem_global2local[i] = ++counter;
5793 static int set_elem_global2local_external(
5796 const char *elem_flag) {
5806 for (counter = local_mesh->
ne_internal, i = 0; i < global_mesh->n_elem; i++) {
5808 elem_global2local[i] = ++counter;
5811 local_mesh->
n_elem = counter;
5819 static int set_elem_global2local_all(
5822 const char *elem_flag) {
5832 for (counter = 0, i = 0; i < global_mesh->
n_elem; i++) {
5834 elem_global2local[i] = ++counter;
5837 local_mesh->
n_elem = counter;
5845 static int set_elem_global2local_all_mod(
5848 const char *elem_flag,
int domain) {
5850 int i, idx1, idx2, elem1, elem2, n_int, n_bnd, n_out, maxe;
5858 n_int = n_int_elist[domain];
5859 n_bnd = n_bnd_elist[2 * domain];
5860 n_out = n_bnd_elist[2 * domain + 1] - n_bnd_elist[2 * domain];
5861 maxe = global_mesh->
n_elem + 1;
5863 elem1 = (n_int == 0) ? maxe : int_elist[domain][0];
5864 elem2 = (n_out == 0) ? maxe : bnd_elist[domain][n_bnd];
5865 for (counter = 0, idx1 = 0, idx2 = 0, i = 0; i < n_int + n_out; i++) {
5866 if (elem1 < elem2) {
5867 elem_global2local[elem1 - 1] = ++counter;
5869 elem1 = (idx1 == n_int) ? maxe : int_elist[domain][idx1];
5871 elem_global2local[elem2 - 1] = ++counter;
5873 elem2 = (idx2 == n_out) ? maxe : bnd_elist[domain][idx2 + n_bnd];
5877 local_mesh->
n_elem = counter;
5887 const char *elem_flag) {
5893 for (counter = 0, i = 0; i < global_mesh->
n_elem; i++) {
5901 static int const_elem_internal_list(
5904 const char *elem_flag,
int domain) {
5926 for (counter = 0, i = 0; i < n_int_elist[domain]; i++) {
5927 elem = int_elist[domain][i];
5941 int *elem_global2local,
const char *elem_flag,
5942 int current_domain) {
5953 local_mesh->
ne_internal = n_int_elist[current_domain];
5955 if (is_spdup_available(global_mesh)) {
5956 rtc = set_elem_global2local_all_mod(global_mesh, local_mesh,
5957 elem_global2local, elem_flag,
5960 rtc = set_elem_global2local_all(global_mesh, local_mesh,
5961 elem_global2local, elem_flag);
5966 rtc = const_elem_internal_list(global_mesh, local_mesh, elem_global2local,
5967 elem_flag, current_domain);
5975 rtc = set_elem_global2local_internal(global_mesh, local_mesh,
5976 elem_global2local, elem_flag);
5979 rtc = set_elem_global2local_external(global_mesh, local_mesh,
5980 elem_global2local, elem_flag);
6001 int *elem_global2local,
int domain) {
6009 if (is_spdup_available(global_mesh)) {
6010 for (i = 0; i < n_int_elist[domain]; i++) {
6011 elem = int_elist[domain][i];
6012 elem_global2local[elem - 1] = 0;
6014 for (i = n_bnd_elist[2 * domain]; i < n_bnd_elist[2 * domain + 1]; i++) {
6015 elem = bnd_elist[domain][i];
6016 elem_global2local[elem - 1] = 0;
6020 for (i = 0; i < global_mesh->
n_elem; i++) {
6021 elem_global2local[i] = 0;
6032 const int *elem_global2local,
6033 int *elem_local2global) {
6043 for (counter = 0, i = 0; i < global_mesh->
n_elem; i++) {
6044 if (elem_global2local[i]) {
6045 elem_local2global[elem_global2local[i] - 1] = i + 1;
6054 static int set_elem_local2global_mod(
6057 int *elem_local2global,
int domain) {
6059 int i, idx1, idx2, elem1, elem2, n_int, n_bnd, n_out, maxe;
6067 n_int = n_int_elist[domain];
6068 n_bnd = n_bnd_elist[2 * domain];
6069 n_out = n_bnd_elist[2 * domain + 1] - n_bnd_elist[2 * domain];
6070 maxe = global_mesh->
n_elem + 1;
6072 elem1 = (n_int == 0) ? maxe : int_elist[domain][0];
6073 elem2 = (n_out == 0) ? maxe : bnd_elist[domain][n_bnd];
6074 for (counter = 0, idx1 = 0, idx2 = 0, i = 0; i < n_int + n_out; i++) {
6075 if (elem1 < elem2) {
6076 elem_local2global[elem_global2local[elem1 - 1] - 1] = elem1;
6078 elem1 = (idx1 == n_int) ? maxe : int_elist[domain][idx1];
6080 elem_local2global[elem_global2local[elem2 - 1] - 1] = elem2;
6082 elem2 = (idx2 == n_out) ? maxe : bnd_elist[domain][idx2 + n_bnd];
6118 snprintf(local_mesh->
header,
sizeof(local_mesh->
header),
"%s",
6131 static int const_hecmw_flag_initcon(
6139 static int const_hecmw_flag_parttype(
6147 static int const_hecmw_flag_partdepth(
6155 static int const_hecmw_flag_version(
6163 static int const_hecmw_flag_partcontact(
6185 rtc = const_gridfile(global_mesh, local_mesh);
6188 rtc = const_hecmw_n_file(global_mesh, local_mesh);
6191 rtc = const_files(global_mesh, local_mesh);
6194 rtc = const_header(global_mesh, local_mesh);
6197 rtc = const_hecmw_flag_adapt(global_mesh, local_mesh);
6200 rtc = const_hecmw_flag_initcon(global_mesh, local_mesh);
6203 rtc = const_hecmw_flag_parttype(global_mesh, local_mesh);
6206 rtc = const_hecmw_flag_partdepth(global_mesh, local_mesh);
6209 rtc = const_hecmw_flag_version(global_mesh, local_mesh);
6212 rtc = const_hecmw_flag_partcontact(global_mesh, local_mesh);
6215 rtc = const_zero_temp(global_mesh, local_mesh);
6251 const char *node_flag) {
6265 for (counter = 0, i = 0; i < global_mesh->
n_dof_grp; i++) {
6267 j < global_mesh->node_dof_index[i + 1]; j++) {
6281 static int const_node_dof_index_mod(
6297 for (counter = 0, i = 0; i < global_mesh->
n_dof_grp; i++) {
6298 for (j = 0; j < n_int_nlist[domain]; j++) {
6299 node = int_nlist[domain][j];
6300 if (node <= global_mesh->node_dof_index[i])
continue;
6324 const int *node_local2global) {
6337 for (i = 0; i < local_mesh->
n_node; i++) {
6338 local_mesh->
node[3 * i] = global_mesh->
node[3 * (node_local2global[i] - 1)];
6339 local_mesh->
node[3 * i + 1] =
6340 global_mesh->
node[3 * (node_local2global[i] - 1) + 1];
6341 local_mesh->
node[3 * i + 2] =
6342 global_mesh->
node[3 * (node_local2global[i] - 1) + 2];
6353 const int *node_local2global) {
6366 for (i = 0; i < local_mesh->
n_node; i++) {
6368 global_mesh->
node_ID[2 * (node_local2global[i] - 1)];
6369 local_mesh->
node_ID[2 * i + 1] =
6370 global_mesh->
node_ID[2 * (node_local2global[i] - 1) + 1];
6381 const int *node_local2global) {
6394 for (i = 0; i < local_mesh->
n_node; i++) {
6405 static int const_node_init_val_index(
6422 for (i = 0; i < local_mesh->
n_node; i++) {
6423 old_idx = node_local2global[i] - 1;
6437 static int const_node_init_val_item(
6442 int i, j, gstart, gend, lstart, lend;
6461 for (counter = 0, i = 0; i < local_mesh->
n_node; i++) {
6469 for (j = 0; j < lend - lstart; j++) {
6485 const int *node_local2global,
const char *node_flag,
6486 int current_domain) {
6494 rtc = const_n_dof(global_mesh, local_mesh);
6497 rtc = const_n_dof_grp(global_mesh, local_mesh);
6502 rtc = const_node_dof_index_mod(global_mesh, local_mesh, node_flag,
6506 rtc = const_node_dof_index(global_mesh, local_mesh, node_flag);
6515 rtc = const_node_dof_item(global_mesh, local_mesh);
6518 rtc = const_node(global_mesh, local_mesh, node_local2global);
6521 rtc = const_node_id(global_mesh, local_mesh, node_local2global);
6524 rtc = const_global_node_id(global_mesh, local_mesh, node_local2global);
6528 rtc = const_node_init_val_index(global_mesh, local_mesh, node_local2global);
6531 rtc = const_node_init_val_item(global_mesh, local_mesh, node_local2global);
6557 const int *elem_local2global) {
6569 for (i = 0; i < local_mesh->
n_elem; i++) {
6581 const int *elem_global2local) {
6596 for (counter = 0, i = 0; i < global_mesh->
n_elem_type; i++) {
6598 j < global_mesh->elem_type_index[i + 1]; j++) {
6599 if (elem_global2local[j]) counter++;
6612 static int const_elem_type_index_mod(
6617 int i, j, idx1, idx2, elem_tmp, elem1, elem2, n_int, n_bnd, n_out, maxe;
6630 n_int = n_int_elist[domain];
6631 n_bnd = n_bnd_elist[2 * domain];
6632 n_out = n_bnd_elist[2 * domain + 1] - n_bnd_elist[2 * domain];
6633 maxe = global_mesh->
n_elem + 1;
6635 for (counter = 0, i = 0; i < global_mesh->
n_elem_type; i++) {
6636 elem1 = (n_int == 0) ? maxe : int_elist[domain][0];
6637 elem2 = (n_out == 0) ? maxe : bnd_elist[domain][n_bnd];
6638 for (idx1 = 0, idx2 = 0, j = 0; j < n_int + n_out; j++) {
6639 if (elem1 < elem2) {
6640 elem_tmp = elem1 - 1;
6642 elem1 = (idx1 == n_int) ? maxe : int_elist[domain][idx1];
6644 elem_tmp = elem2 - 1;
6646 elem2 = (idx2 == n_out) ? maxe : bnd_elist[domain][idx2 + n_bnd];
6649 elem_tmp < global_mesh->elem_type_index[i + 1]) {
6676 const int *elem_local2global) {
6690 for (i = 0; i < local_mesh->
n_elem; i++) {
6691 old_idx = elem_local2global[i] - 1;
6707 const int *node_global2local,
6708 const int *elem_local2global) {
6713 long long gstart, gend, lstart, lend;
6727 for (counter = 0, i = 0; i < local_mesh->
n_elem; i++) {
6733 for (j = 0; j < lend - lstart; j++) {
6735 local_mesh->
elem_node_item[lstart + j] = node_global2local[node - 1];
6749 const int *elem_local2global) {
6762 for (i = 0; i < local_mesh->
n_elem; i++) {
6764 global_mesh->
elem_ID[2 * (elem_local2global[i] - 1)];
6765 local_mesh->
elem_ID[2 * i + 1] =
6766 global_mesh->
elem_ID[2 * (elem_local2global[i] - 1) + 1];
6777 const int *elem_local2global) {
6790 for (i = 0; i < local_mesh->
n_elem; i++) {
6803 const int *elem_local2global) {
6816 for (i = 0; i < local_mesh->
n_elem; i++) {
6818 global_mesh->
section_ID[elem_local2global[i] - 1];
6829 const int *elem_local2global) {
6843 for (i = 0; i < local_mesh->
n_elem; i++) {
6844 old_idx = elem_local2global[i] - 1;
6869 const int *elem_local2global) {
6872 int i, j, gstart, gend, lstart, lend;
6889 for (counter = 0, i = 0; i < local_mesh->
n_elem; i++) {
6897 for (j = 0; j < lend - lstart; j++) {
6914 const int *node_global2local,
6915 const int *elem_global2local,
6916 const int *elem_local2global,
int current_domain) {
6925 rtc = const_n_elem_type(global_mesh, local_mesh);
6928 rtc = const_elem_type(global_mesh, local_mesh, elem_local2global);
6931 if (is_spdup_available(global_mesh)) {
6932 rtc = const_elem_type_index_mod(global_mesh, local_mesh, elem_global2local,
6935 rtc = const_elem_type_index(global_mesh, local_mesh, elem_global2local);
6940 rtc = const_elem_type_item(global_mesh, local_mesh);
6943 rtc = const_elem_node_index(global_mesh, local_mesh, elem_local2global);
6946 rtc = const_elem_node_item(global_mesh, local_mesh, node_global2local,
6950 rtc = const_elem_id(global_mesh, local_mesh, elem_local2global);
6953 rtc = const_global_elem_id(global_mesh, local_mesh, elem_local2global);
6956 rtc = const_section_id(global_mesh, local_mesh, elem_local2global);
6959 rtc = const_elem_mat_id_index(global_mesh, local_mesh, elem_local2global);
6962 rtc = const_n_elem_mat_id(local_mesh);
6965 rtc = const_elem_mat_id_item(global_mesh, local_mesh, elem_local2global);
6985 int current_domain) {
6986 local_mesh->
zero = (current_domain == 0) ? 1 : 0;
7006 int current_domain) {
7007 local_mesh->
my_rank = current_domain;
7027 const int *global2local) {
7042 new_id = global2local[local_mesh->
import_item[i] - 1];
7050 const int *global2local) {
7065 new_id = global2local[local_mesh->
export_item[i] - 1];
7073 const int *global2local) {
7088 new_id = global2local[local_mesh->
shared_item[i] - 1];
7097 const int *node_global2local,
7098 const int *elem_global2local,
int current_domain) {
7106 rtc = const_hecmw_comm(global_mesh, local_mesh);
7109 rtc = const_zero(local_mesh, current_domain);
7112 rtc = const_petot(global_mesh, local_mesh);
7115 rtc = const_pesmptot(global_mesh, local_mesh);
7118 rtc = const_my_rank(local_mesh, current_domain);
7121 rtc = const_errnof(global_mesh, local_mesh);
7124 rtc = const_n_subdomain(global_mesh, local_mesh);
7129 rtc = const_import_item(local_mesh, node_global2local);
7132 rtc = const_export_item(local_mesh, node_global2local);
7135 rtc = const_shared_item(local_mesh, elem_global2local);
7141 rtc = const_import_item(local_mesh, elem_global2local);
7144 rtc = const_export_item(local_mesh, elem_global2local);
7147 rtc = const_shared_item(local_mesh, node_global2local);
7181 static int const_when_i_was_refined_node(
7189 static int const_when_i_was_refined_elem(
7225 static int const_adapt_children_index(
7233 static int const_adapt_children_item(
7248 rtc = const_n_adapt(global_mesh, local_mesh);
7251 rtc = const_coarse_grid_level(global_mesh, local_mesh);
7254 rtc = const_when_i_was_refined_node(global_mesh, local_mesh);
7257 rtc = const_when_i_was_refined_elem(global_mesh, local_mesh);
7260 rtc = const_adapt_parent_type(global_mesh, local_mesh);
7263 rtc = const_adapt_type(global_mesh, local_mesh);
7266 rtc = const_adapt_level(global_mesh, local_mesh);
7269 rtc = const_adapt_parent(global_mesh, local_mesh);
7272 rtc = const_adapt_children_index(global_mesh, local_mesh);
7275 rtc = const_adapt_children_item(global_mesh, local_mesh);
7361 rtc = const_n_sect(global_mesh, local_mesh);
7364 rtc = const_sect_type(global_mesh, local_mesh);
7367 rtc = const_sect_opt(global_mesh, local_mesh);
7370 rtc = const_sect_mat_id_index(global_mesh, local_mesh);
7373 rtc = const_sect_mat_id_item(global_mesh, local_mesh);
7376 rtc = const_sect_i_index(global_mesh, local_mesh);
7379 rtc = const_sect_i_item(global_mesh, local_mesh);
7382 rtc = const_sect_r_index(global_mesh, local_mesh);
7385 rtc = const_sect_r_item(global_mesh, local_mesh);
7478 rtc = const_n_mat(global_mesh, local_mesh);
7481 rtc = const_n_mat_item(global_mesh, local_mesh);
7484 rtc = const_n_mat_subitem(global_mesh, local_mesh);
7487 rtc = const_n_mat_table(global_mesh, local_mesh);
7490 rtc = const_mat_name(global_mesh, local_mesh);
7493 rtc = const_mat_item_index(global_mesh, local_mesh);
7496 rtc = const_mat_subitem_index(global_mesh, local_mesh);
7499 rtc = const_mat_table_index(global_mesh, local_mesh);
7502 rtc = const_mat_val(global_mesh, local_mesh);
7505 rtc = const_mat_temp(global_mesh, local_mesh);
7519 const int *node_global2local,
char *mpc_flag) {
7522 int node, diff, evalsum, counter;
7525 for (counter = 0, i = 0; i < mpc_global->
n_mpc; i++) {
7532 if (node_global2local[node - 1] > 0) evalsum++;
7535 if (evalsum == diff) {
7540 mpc_local->
n_mpc = counter;
7547 const char *mpc_flag) {
7559 for (counter = 0, i = 0; i < mpc_global->
n_mpc; i++) {
7577 const int *node_global2local,
const char *mpc_flag) {
7580 int mcounter, icounter;
7590 for (mcounter = 0, icounter = 0, i = 0; i < mpc_global->
n_mpc; i++) {
7595 node_global2local[mpc_global->
mpc_item[j] - 1];
7611 const char *mpc_flag) {
7614 int mcounter, icounter;
7624 for (mcounter = 0, icounter = 0, i = 0; i < mpc_global->
n_mpc; i++) {
7644 const char *mpc_flag) {
7648 int mcounter, icounter;
7658 for (mcounter = 0, icounter = 0, i = 0; i < mpc_global->
n_mpc; i++) {
7678 const char *mpc_flag) {
7685 size =
sizeof(double) * mpc_local->
n_mpc;
7692 for (icounter = 0, i = 0; i < mpc_global->
n_mpc; i++) {
7708 const int *node_global2local) {
7709 char *mpc_flag =
NULL;
7718 if (global_mesh->
mpc->
n_mpc == 0) {
7719 init_struct_mpc(local_mesh);
7724 if (mpc_flag ==
NULL) {
7729 rtc = const_n_mpc(global_mesh, local_mesh, node_global2local, mpc_flag);
7733 init_struct_mpc(local_mesh);
7738 rtc = const_mpc_index(global_mesh, local_mesh, mpc_flag);
7741 rtc = const_mpc_item(global_mesh, local_mesh, node_global2local, mpc_flag);
7744 rtc = const_mpc_dof(global_mesh, local_mesh, mpc_flag);
7747 rtc = const_mpc_val(global_mesh, local_mesh, mpc_flag);
7750 rtc = const_mpc_const(global_mesh, local_mesh, mpc_flag);
7780 static int const_amp_type_definition(
7832 if (global_mesh->
amp->
n_amp == 0) {
7833 init_struct_amp(local_mesh);
7837 rtc = const_n_amp(global_mesh, local_mesh);
7840 rtc = const_amp_name(global_mesh, local_mesh);
7843 rtc = const_amp_type_definition(global_mesh, local_mesh);
7846 rtc = const_amp_type_time(global_mesh, local_mesh);
7849 rtc = const_amp_type_value(global_mesh, local_mesh);
7852 rtc = const_amp_index(global_mesh, local_mesh);
7855 rtc = const_amp_val(global_mesh, local_mesh);
7858 rtc = const_amp_table(global_mesh, local_mesh);
7870 static int *const_node_grp_mask_eqn(
7873 int eqn_block_idx) {
7875 int *n_eqn_item =
NULL;
7877 int i, j, is, ie, js;
7879 is = node_group_global->
grp_index[eqn_block_idx];
7880 ie = node_group_global->
grp_index[eqn_block_idx + 1];
7882 n_eqn_item = (
int *)
HECMW_malloc(
sizeof(
int) * (ie - is));
7883 if (n_eqn_item ==
NULL) {
7888 for (js = 0, i = 0; i < ie - is; i++) {
7889 diff = node_group_global->
grp_item[is + i] - js;
7890 for (evalsum = 0, j = js; j < node_group_global->
grp_item[is + i]; j++) {
7891 if (node_global2local[j] > 0 &&
7898 n_eqn_item[i] = diff;
7903 js = node_group_global->
grp_item[is + i];
7928 const int *node_global2local,
7929 const int *n_eqn_item,
int eqn_block_idx) {
7943 for (counter = 0, i = 0; i < node_group_global->
n_grp; i++) {
7944 if (i != eqn_block_idx) {
7945 for (j = node_group_global->
grp_index[i];
7946 j < node_group_global->
grp_index[i + 1]; j++) {
7947 node = node_group_global->
grp_item[j];
7948 if (node_global2local[node - 1]) counter++;
7954 for (j = 0; j < diff; j++) {
7955 if (n_eqn_item[j] > 0) counter++;
7959 node_group_local->
grp_index[i + 1] = counter;
7968 static int const_node_grp_index_mod(
7971 const int *n_eqn_item,
int eqn_block_idx,
int domain) {
7985 for (counter = 0, i = 0; i < node_group_global->
n_grp; i++) {
7986 if (i != eqn_block_idx) {
7987 if (node_group_global->
grp_index[i + 1] -
7990 counter += n_int_nlist[domain];
7991 counter += n_bnd_nlist[2 * domain + 1] - n_bnd_nlist[2 * domain];
7993 counter += ngrp_idx[domain][i + 1] - ngrp_idx[domain][i];
8006 for (j = 0; j < diff; j++) {
8007 if (n_eqn_item[j] > 0) counter++;
8011 node_group_local->
grp_index[i + 1] = counter;
8022 const int *node_global2local,
8023 const int *n_eqn_item,
int eqn_block_idx) {
8029 int i, j, k, js, je, ks, ls;
8031 size =
sizeof(int) * node_group_local->
grp_index[node_group_local->
n_grp];
8038 for (counter = 0, i = 0; i < node_group_global->
n_grp; i++) {
8039 if (i != eqn_block_idx) {
8040 for (j = node_group_global->
grp_index[i];
8041 j < node_group_global->
grp_index[i + 1]; j++) {
8042 node = node_group_global->
grp_item[j];
8043 if (node_global2local[node - 1]) {
8044 node_group_local->
grp_item[counter++] = node_global2local[node - 1];
8050 je = node_group_global->
grp_index[i + 1];
8051 for (ks = 0, ls = 0, j = js; j < je; j++) {
8052 if (n_eqn_item[j - js]) {
8054 node_group_global->
grp_item[j] - ks);
8055 node_group_local->
grp_item[counter] = ls + n_eqn_item[j - js];
8057 for (k = ks; k < node_group_global->
grp_item[j]; k++) {
8059 node_global2local[k] <=
8060 node_group_local->
grp_item[counter]);
8062 ls = node_group_local->
grp_item[counter];
8065 ks = node_group_global->
grp_item[j];
8079 const int *node_global2local,
8080 const int *n_eqn_item,
int eqn_block_idx,
8087 int i, j, k, js, je, ks, ls;
8088 int idx1, idx2, node1, node2, n_int, n_bnd, n_out, maxn;
8090 size =
sizeof(int) * node_group_local->
grp_index[node_group_local->
n_grp];
8097 n_int = n_int_nlist[domain];
8098 n_bnd = n_bnd_nlist[2 * domain];
8099 n_out = n_bnd_nlist[2 * domain + 1] - n_bnd_nlist[2 * domain];
8100 maxn = global_mesh->
n_node + 1;
8102 for (counter = 0, i = 0; i < node_group_global->
n_grp; i++) {
8103 if (i != eqn_block_idx) {
8104 if (node_group_global->
grp_index[i + 1] -
8109 node1 = (n_int == 0) ? maxn : int_nlist[domain][0];
8110 node2 = (n_out == 0) ? maxn : bnd_nlist[domain][n_bnd];
8111 for (j = 0; j < n_int + n_out; j++) {
8112 if (node1 < node2) {
8113 node_group_local->
grp_item[counter++] =
8114 node_global2local[node1 - 1];
8116 node1 = (idx1 == n_int) ? maxn : int_nlist[domain][idx1];
8118 node_group_local->
grp_item[counter++] =
8119 node_global2local[node2 - 1];
8121 node2 = (idx2 == n_out) ? maxn : bnd_nlist[domain][idx2 + n_bnd];
8125 if (ngrp_idx[domain][i + 1] - ngrp_idx[domain][i] == 0)
continue;
8126 for (j = ngrp_idx[domain][i]; j < ngrp_idx[domain][i + 1]; j++) {
8127 node = ngrp_item[domain][j];
8128 node_group_local->
grp_item[counter++] = node_global2local[node - 1];
8133 je = node_group_global->
grp_index[i + 1];
8134 for (ks = 0, ls = 0, j = js; j < je; j++) {
8135 if (n_eqn_item[j - js]) {
8137 node_group_global->
grp_item[j] - ks);
8138 node_group_local->
grp_item[counter] = ls + n_eqn_item[j - js];
8140 for (k = ks; k < node_group_global->
grp_item[j]; k++) {
8142 node_global2local[k] <=
8143 node_group_local->
grp_item[counter]);
8145 ls = node_group_local->
grp_item[counter];
8148 ks = node_group_global->
grp_item[j];
8162 const int *node_global2local,
8163 int current_domain) {
8164 int *n_eqn_item =
NULL;
8175 init_struct_node_grp(local_mesh);
8179 eqn_block_idx = search_eqn_block_idx(global_mesh);
8181 if (eqn_block_idx >= 0) {
8182 n_eqn_item = const_node_grp_mask_eqn(global_mesh, local_mesh,
8183 node_global2local, eqn_block_idx);
8184 if (n_eqn_item ==
NULL)
goto error;
8187 rtc = const_node_n_grp(global_mesh, local_mesh);
8190 rtc = const_node_grp_name(global_mesh, local_mesh);
8193 if (is_spdup_available(global_mesh)) {
8194 rtc = const_node_grp_index_mod(global_mesh, local_mesh, node_global2local,
8195 n_eqn_item, eqn_block_idx, current_domain);
8197 rtc = const_node_grp_item_mod(global_mesh, local_mesh, node_global2local,
8198 n_eqn_item, eqn_block_idx, current_domain);
8202 rtc = const_node_grp_index(global_mesh, local_mesh, node_global2local,
8203 n_eqn_item, eqn_block_idx);
8205 rtc = const_node_grp_item(global_mesh, local_mesh, node_global2local,
8206 n_eqn_item, eqn_block_idx);
8239 const int *elem_global2local) {
8253 for (counter = 0, i = 0; i < elem_group_global->
n_grp; i++) {
8254 for (j = elem_group_global->
grp_index[i];
8255 j < elem_group_global->
grp_index[i + 1]; j++) {
8256 elem = elem_group_global->
grp_item[j];
8257 if (elem_global2local[elem - 1]) counter++;
8259 elem_group_local->
grp_index[i + 1] = counter;
8268 static int const_elem_grp_index_mod(
8276 int i, j, idx1, idx2, elem1, elem2;
8285 for (counter = 0, i = 0; i < elem_group_global->
n_grp; i++) {
8288 counter += n_int_elist[domain];
8289 counter += n_bnd_elist[2 * domain + 1] - n_bnd_elist[2 * domain];
8291 counter += egrp_idx[domain][i + 1] - egrp_idx[domain][i];
8293 elem_group_local->
grp_index[i + 1] = counter;
8304 const int *elem_global2local) {
8312 size =
sizeof(int) * elem_group_local->
grp_index[elem_group_local->
n_grp];
8319 for (counter = 0, i = 0; i < elem_group_global->
n_grp; i++) {
8320 for (j = elem_group_global->
grp_index[i];
8321 j < elem_group_global->
grp_index[i + 1]; j++) {
8322 elem = elem_group_global->
grp_item[j];
8323 if (elem_global2local[elem - 1]) {
8324 elem_group_local->
grp_item[counter++] = elem_global2local[elem - 1];
8338 const int *elem_global2local,
int domain) {
8344 int i, j, idx1, idx2, elem1, elem2, n_int, n_bnd, n_out, maxe;
8346 size =
sizeof(int) * elem_group_local->
grp_index[elem_group_local->
n_grp];
8353 n_int = n_int_elist[domain];
8354 n_bnd = n_bnd_elist[2 * domain];
8355 n_out = n_bnd_elist[2 * domain + 1] - n_bnd_elist[2 * domain];
8356 maxe = global_mesh->
n_elem + 1;
8358 for (counter = 0, i = 0; i < elem_group_global->
n_grp; i++) {
8361 elem1 = (n_int == 0) ? maxe : int_elist[domain][0];
8362 elem2 = (n_out == 0) ? maxe : bnd_elist[domain][n_bnd];
8363 for (idx1 = 0, idx2 = 0, j = 0; j < n_int + n_out; j++) {
8364 if (elem1 < elem2) {
8365 elem_group_local->
grp_item[counter++] = elem_global2local[elem1 - 1];
8367 elem1 = (idx1 == n_int) ? maxe : int_elist[domain][idx1];
8369 elem_group_local->
grp_item[counter++] = elem_global2local[elem2 - 1];
8371 elem2 = (idx2 == n_out) ? maxe : bnd_elist[domain][idx2 + n_bnd];
8375 if (egrp_idx[domain][i + 1] - egrp_idx[domain][i] == 0)
continue;
8376 for (j = egrp_idx[domain][i]; j < egrp_idx[domain][i + 1]; j++) {
8377 elem = egrp_item[domain][j];
8378 elem_group_local->
grp_item[counter++] = elem_global2local[elem - 1];
8392 const int *elem_global2local,
8393 int current_domain) {
8403 init_struct_elem_grp(local_mesh);
8407 rtc = const_elem_n_grp(global_mesh, local_mesh);
8410 rtc = const_elem_grp_name(global_mesh, local_mesh);
8413 if (is_spdup_available(global_mesh)) {
8414 rtc = const_elem_grp_index_mod(global_mesh, local_mesh, elem_global2local,
8417 rtc = const_elem_grp_item_mod(global_mesh, local_mesh, elem_global2local,
8422 rtc = const_elem_grp_index(global_mesh, local_mesh, elem_global2local);
8424 rtc = const_elem_grp_item(global_mesh, local_mesh, elem_global2local);
8453 const int *elem_global2local) {
8467 for (counter = 0, i = 0; i < surf_group_global->
n_grp; i++) {
8468 for (j = surf_group_global->
grp_index[i];
8469 j < surf_group_global->
grp_index[i + 1]; j++) {
8470 elem = surf_group_global->
grp_item[2 * j];
8471 if (elem_global2local[elem - 1]) counter++;
8473 surf_group_local->
grp_index[i + 1] = counter;
8484 const int *elem_global2local) {
8492 size =
sizeof(int) * (
size_t)surf_group_local->
grp_index[surf_group_local->
n_grp] * 2;
8499 for (counter = 0, i = 0; i < surf_group_global->
n_grp; i++) {
8500 for (j = surf_group_global->
grp_index[i];
8501 j < surf_group_global->
grp_index[i + 1]; j++) {
8502 elem = surf_group_global->
grp_item[2 * j];
8503 surf = surf_group_global->
grp_item[2 * j + 1];
8504 if (elem_global2local[elem - 1]) {
8505 surf_group_local->
grp_item[2 * counter] = elem_global2local[elem - 1];
8506 surf_group_local->
grp_item[2 * counter + 1] = surf;
8521 const int *elem_global2local) {
8531 init_struct_surf_grp(local_mesh);
8535 rtc = const_surf_n_grp(global_mesh, local_mesh);
8538 rtc = const_surf_grp_name(global_mesh, local_mesh);
8541 rtc = const_surf_grp_index(global_mesh, local_mesh, elem_global2local);
8544 rtc = const_surf_grp_item(global_mesh, local_mesh, elem_global2local);
8556 static int const_contact_pair_n_pair(
8583 for (i = 0; i < cpair_global->
n_pair; i++) {
8584 cpair_local->
type[i] = cpair_global->
type[i];
8593 static int const_contact_pair_slave_grp_id(
8607 for (i = 0; i < cpair_global->
n_pair; i++) {
8617 static int const_contact_pair_slave_orisgrp_id(
8631 for (i = 0; i < cpair_global->
n_pair; i++) {
8641 static int const_contact_pair_master_grp_id(
8655 for (i = 0; i < cpair_global->
n_pair; i++) {
8675 init_struct_contact_pair(local_mesh);
8679 rtc = const_contact_pair_n_pair(global_mesh, local_mesh);
8682 rtc = const_contact_pair_name(global_mesh, local_mesh);
8685 rtc = const_contact_pair_type(global_mesh, local_mesh);
8688 rtc = const_contact_pair_slave_grp_id(global_mesh, local_mesh);
8691 rtc = const_contact_pair_slave_orisgrp_id(global_mesh, local_mesh);
8694 rtc = const_contact_pair_master_grp_id(global_mesh, local_mesh);
8709 const char *node_flag,
const char *elem_flag,
8710 int *node_global2local,
int *elem_global2local,
8711 int current_domain) {
8712 int *node_local2global =
NULL;
8713 int *elem_local2global =
NULL;
8718 rtc = set_node_global2local(global_mesh, local_mesh, node_global2local,
8719 node_flag, current_domain);
8723 if (node_local2global ==
NULL) {
8728 if (is_spdup_available(global_mesh)) {
8729 rtc = set_node_local2global_mod(global_mesh, local_mesh, node_global2local,
8730 node_local2global, current_domain);
8732 rtc = set_node_local2global(global_mesh, local_mesh, node_global2local,
8738 rtc = set_elem_global2local(global_mesh, local_mesh, elem_global2local,
8739 elem_flag, current_domain);
8744 if (elem_local2global ==
NULL) {
8749 if (is_spdup_available(global_mesh)) {
8750 rtc = set_elem_local2global_mod(global_mesh, local_mesh, elem_global2local,
8751 elem_local2global, current_domain);
8753 rtc = set_elem_local2global(global_mesh, local_mesh, elem_global2local,
8759 rtc = const_global_info(global_mesh, local_mesh);
8762 rtc = const_node_info(global_mesh, local_mesh, node_local2global, node_flag,
8766 rtc = const_elem_info(global_mesh, local_mesh, node_global2local,
8767 elem_global2local, elem_local2global, current_domain);
8770 rtc = const_comm_info(global_mesh, local_mesh, node_global2local,
8771 elem_global2local, current_domain);
8774 rtc = const_adapt_info(global_mesh, local_mesh);
8777 rtc = const_sect_info(global_mesh, local_mesh);
8780 rtc = const_mat_info(global_mesh, local_mesh);
8783 rtc = const_mpc_info(global_mesh, local_mesh, node_global2local);
8786 rtc = const_amp_info(global_mesh, local_mesh);
8789 rtc = const_node_grp_info(global_mesh, local_mesh, node_global2local,
8793 rtc = const_elem_grp_info(global_mesh, local_mesh, elem_global2local,
8797 rtc = const_surf_grp_info(global_mesh, local_mesh, elem_global2local);
8800 rtc = const_contact_pair_info(global_mesh, local_mesh);
8803 rtc = clear_node_global2local(global_mesh, local_mesh, node_global2local,
8805 rtc = clear_elem_global2local(global_mesh, local_mesh, elem_global2local,
8818 clean_struct_local_mesh(local_mesh);
8829 static int print_ucd_entire_set_node_data(
8845 result_data->
nn_dof[0] = 1;
8865 snprintf(result_data->
node_label[0], label_len,
"rank_of_node");
8867 for (nn_item = 0, i = 0; i < result_data->
nn_component; i++) {
8868 nn_item += result_data->
nn_dof[i];
8871 size =
sizeof(double) * nn_item * global_mesh->
n_node;
8880 for (i = 0; i < global_mesh->
n_node; i++) {
8886 for (i = 0; i < global_mesh->
n_node; i++) {
8892 (double)global_mesh->
node_ID[2 * i + 1];
8906 free_struct_result_data(result_data);
8914 static int print_ucd_entire_set_elem_data(
8930 result_data->
ne_dof[0] = 1;
8950 snprintf(result_data->
elem_label[0], label_len,
"partitioning_image");
8953 for (i = 0; i < global_mesh->
n_elem; i++) {
8974 for (ne_item = 0, i = 0; i < result_data->
ne_component; i++) {
8975 ne_item += result_data->
ne_dof[i];
8978 size =
sizeof(double) * ne_item * global_mesh->
n_elem;
8987 for (i = 0; i < global_mesh->
n_elem; i++) {
8993 (double)global_mesh->
elem_ID[2 * i + 1];
8999 for (i = 0; i < global_mesh->
n_elem; i++) {
9013 free_struct_result_data(result_data);
9021 const char *node_flag,
const char *elem_flag,
9022 const char *ofname) {
9027 if (result_data ==
NULL) {
9031 init_struct_result_data(result_data);
9034 if (print_ucd_entire_set_node_data(global_mesh, result_data, node_flag)) {
9038 if (print_ucd_entire_set_elem_data(global_mesh, result_data, elem_flag)) {
9046 free_struct_result_data(result_data);
9051 free_struct_result_data(result_data);
9124 char *node_flag =
NULL;
9125 char *elem_flag =
NULL;
9126 char *node_flag_neighbor =
NULL;
9127 char *elem_flag_neighbor =
NULL;
9128 int *node_global2local =
NULL;
9129 int *elem_global2local =
NULL;
9131 int *num_elem, *num_node, *num_ielem, *num_inode, *num_nbpe;
9132 int *sum_elem, *sum_node, *sum_ielem, *sum_inode, *sum_nbpe;
9133 int current_domain, nrank, iS, iE;
9136 int error_in_ompsection = 0;
9138 if (global_mesh ==
NULL) {
9147 rtc = init_partition(global_mesh,
cont_data);
9153 if (global_mesh->
my_rank == 0) {
9172 if (global_mesh->
my_rank == 0) {
9177 "part_out", global_mesh->
n_subdomain, current_domain);
9178 if (ofheader ==
NULL) {
9180 error_in_ompsection = 1;
9183 if (ofheader->
n_mesh == 0) {
9185 error_in_ompsection = 1;
9190 ofname,
sizeof(ofname));
9194 "Starting writing local mesh for domain #%d...",
9208 if (rtc != 0)
goto error;
9210 if (rtc != 0)
goto error;
9212 if (rtc != 0)
goto error;
9214 if (rtc != 0)
goto error;
9217 if (rtc)
goto error;
9225 if (num_elem ==
NULL) {
9230 if (num_node ==
NULL) {
9235 if (num_ielem ==
NULL) {
9240 if (num_inode ==
NULL) {
9245 if (num_nbpe ==
NULL) {
9250 if (sum_elem ==
NULL) {
9255 if (sum_node ==
NULL) {
9260 if (sum_ielem ==
NULL) {
9265 if (sum_inode ==
NULL) {
9270 if (sum_nbpe ==
NULL) {
9275 rtc = wnumbering(global_mesh,
cont_data);
9279 if (global_mesh->
my_rank == 0) {
9280 print_part(global_mesh,
cont_data->part_file_name);
9284 rtc = spdup_makelist_main(global_mesh);
9288 #pragma omp parallel default(none), \
9289 private(node_flag, elem_flag, local_mesh, nrank, iS, iE, i, \
9290 current_domain, rtc, ofheader, ofname), \
9291 private(node_global2local, elem_global2local, \
9292 node_flag_neighbor, elem_flag_neighbor), \
9293 shared(global_mesh, cont_data, num_elem, num_node, \
9294 num_ielem, num_inode, num_nbpe, error_in_ompsection)
9299 if (node_flag ==
NULL) {
9301 error_in_ompsection = 1;
9305 if (elem_flag ==
NULL) {
9307 error_in_ompsection = 1;
9312 if (node_global2local ==
NULL) {
9314 error_in_ompsection = 1;
9318 if (elem_global2local ==
NULL) {
9320 error_in_ompsection = 1;
9323 node_flag_neighbor =
9325 if (node_flag_neighbor ==
NULL) {
9327 error_in_ompsection = 1;
9330 elem_flag_neighbor =
9332 if (elem_flag_neighbor ==
NULL) {
9334 error_in_ompsection = 1;
9337 memset(node_flag_neighbor, 0,
sizeof(
char) * global_mesh->
n_node);
9338 memset(elem_flag_neighbor, 0,
sizeof(
char) * global_mesh->
n_elem);
9341 if (local_mesh ==
NULL) {
9342 error_in_ompsection = 1;
9353 #pragma omp for schedule(dynamic, 1), reduction(+ : error_in_ompsection)
9355 for (i = iS; i < iE; i++) {
9356 if (error_in_ompsection)
continue;
9363 rtc = create_neighbor_info(global_mesh, local_mesh, node_flag, elem_flag,
9366 error_in_ompsection = 1;
9371 rtc = create_comm_info(global_mesh, local_mesh, node_flag, elem_flag,
9372 node_flag_neighbor, elem_flag_neighbor,
9375 error_in_ompsection = 1;
9380 rtc = const_local_data(global_mesh, local_mesh,
cont_data, node_flag,
9381 elem_flag, node_global2local, elem_global2local,
9384 error_in_ompsection = 1;
9388 num_elem[i] = local_mesh->
n_elem;
9389 num_node[i] = local_mesh->
n_node;
9395 "part_out", global_mesh->
n_subdomain, current_domain);
9396 if (ofheader ==
NULL) {
9398 error_in_ompsection = 1;
9401 if (ofheader->
n_mesh == 0) {
9403 error_in_ompsection = 1;
9408 ofname,
sizeof(ofname));
9412 "Starting writing local mesh for domain #%d...",
9419 error_in_ompsection = 1;
9425 clean_struct_local_mesh(local_mesh);
9430 if (is_spdup_available(global_mesh)) {
9431 spdup_clear_IEB(node_flag, elem_flag, current_domain);
9434 for (j = 0; j < global_mesh->
n_node; j++) {
9437 for (j = 0; j < global_mesh->
n_elem; j++) {
9443 if (error_in_ompsection)
goto error_omp;
9448 if (global_mesh->
my_rank == 0) {
9449 print_ucd_entire(global_mesh, node_flag, elem_flag,
9465 if (error_in_ompsection)
goto error;
9470 if (rtc != 0)
goto error;
9473 if (rtc != 0)
goto error;
9476 if (rtc != 0)
goto error;
9479 if (rtc != 0)
goto error;
9482 if (rtc != 0)
goto error;
9484 if (global_mesh->
my_rank == 0) {
9487 if (rtc != 0)
goto error;
9489 if (rtc != 0)
goto error;
9491 if (rtc != 0)
goto error;
9493 if (rtc != 0)
goto error;
9495 if (rtc != 0)
goto error;
9498 if (rtc)
goto error;
9513 spdup_freelist(global_mesh);
9546 if (global_mesh ==
NULL) {
9555 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