40 if (p ==
NULL)
return;
73 free_couple_values(p);
79 static int update_import_node_value(
83 int *sendbuf_index =
NULL, *recvbuf_index =
NULL;
84 double *sendbuf =
NULL, *recvbuf =
NULL;
85 int nmemb, rtc, id, i, j;
95 if (sendbuf_index ==
NULL) {
106 sendbuf = (
double *)
HECMW_malloc(
sizeof(
double) * nmemb);
107 if (sendbuf ==
NULL) {
113 for (j = 0; j < node_value->
n_dof; j++) {
114 sendbuf[node_value->
n_dof * i + j] =
115 node_value->
value[node_value->
n_dof *
id + j];
125 if (recvbuf_index ==
NULL) {
136 recvbuf = (
double *)
HECMW_malloc(
sizeof(
double) * nmemb);
137 if (recvbuf ==
NULL) {
148 if (rtc != 0)
goto error;
155 for (j = 0; j < node_value->
n_dof; j++) {
156 node_value->
value[node_value->
n_dof *
id + j] =
157 recvbuf[node_value->
n_dof * i + j];
180 n_dof = value_dst->
n_dof;
181 for (i = 0; i < p->
n; i++) {
182 for (j = p->
index[i]; j < p->index[i + 1]; j++) {
183 for (k = 0; k < n_dof; k++) {
184 value_dst->
value[i * n_dof + k] +=
197 for (p = ip_list_pre->
next; p; p = p->
next) {
211 static int main_interpolation(
217 for (p = ip_list_main->
next; p; p = p->
next) {
220 if (interpolation(p->
info, values_src->
node, value_send))
return -1;
224 if (interpolation(p->
info, values_src->
surf, value_send))
return -1;
235 static int post_interpolation(
240 for (p = ip_list_post->
next; p; p = p->
next) {
262 int n_send_pe = 0, n_recv_pe = 0, *send_pe =
NULL, *recv_pe =
NULL;
263 int *sendbuf_index =
NULL, *recvbuf_index =
NULL, *sendbuf =
NULL,
265 int n_dof, size, rtc, i;
275 if (sendbuf_index ==
NULL) {
280 sendbuf_index[i + 1] = sendbuf_index[i] + 1;
286 if (sendbuf ==
NULL) {
291 sendbuf[i] = value_src->
n_dof;
304 if (recvbuf_index ==
NULL) {
309 recvbuf_index[i + 1] = recvbuf_index[i] + 1;
315 if (recvbuf ==
NULL) {
330 if (rtc != 0)
goto error;
340 value_dst->
n_dof = n_dof;
361 static int send_recv_couple_value(
368 int n_send_pe = 0, n_recv_pe = 0, *send_pe =
NULL, *recv_pe =
NULL;
369 int *sendbuf_index =
NULL, *recvbuf_index =
NULL;
370 double *sendbuf =
NULL, *recvbuf =
NULL;
371 int boundary_index, id, n_dof, size, rtc, i, j;
377 n_dof = value_src->
n_dof;
383 if (sendbuf_index ==
NULL) {
388 sendbuf_index[i + 1] = inter_tbl->
export_index[i + 1] * n_dof;
395 if (sendbuf ==
NULL) {
402 sendbuf[i] = value_src->
value[i];
415 if (recvbuf_index ==
NULL) {
420 recvbuf_index[i + 1] =
428 if (recvbuf ==
NULL) {
445 if (rtc != 0)
goto error;
451 n_dof = value_dst->
n_dof;
453 size =
sizeof(double) *
464 for (j = 0; j < n_dof; j++) {
465 value_dst->
value[n_dof *
id + j] = recvbuf[n_dof * i + j];
494 if (send_recv_n_dof(inter_tbl, value_src, value_dst, comm_src, comm_dst,
497 if (send_recv_couple_value(inter_tbl, value_src, value_dst, comm_src,
498 comm_dst, intercomm))
512 nmemb = couple_value->
n * couple_value->
n_dof;
513 for (i = 0; i < nmemb; i++) {
519 nmemb = couple_value->
n * couple_value->
n_dof;
520 for (i = 0; i < nmemb; i++) {
526 nmemb = couple_value->
n * couple_value->
n_dof;
527 for (i = 0; i < nmemb; i++) {
539 couple_value->
n_dof = 0;
567 for (i = 0; i < value_send->
n; i++) {
572 nmemb = value_send->
n * value_send->
n_dof + 1;
578 for (i = 0; i < nmemb; i++) {
579 value_send->
value[i] = 0.0;
593 value_recv->
n_dof = 0;
604 for (i = 0; i < value_recv->
n; i++) {
618 couple_value->
n = values_dst->
node->
n;
628 couple_value->
n = values_dst->
elem->
n;
638 couple_value->
n = values_dst->
surf->
n;
662 if (boundary->
node->
n > 0) {
673 for (i = 0; i < couple_values->
node->
n; i++) {
683 for (i = 0; i < nmemb; i++) {
689 if (boundary->
elem->
n > 0) {
700 for (i = 0; i < couple_values->
elem->
n; i++) {
710 for (i = 0; i < nmemb; i++) {
716 if (boundary->
surf->
n > 0) {
727 for (i = 0; i < couple_values->
surf->
n; i++) {
738 for (i = 0; i < nmemb; i++) {
754 if (boundary_id ==
NULL) {
756 "HECMW_couple(): 'boundary_id' is NULL");
763 if (couple_value ==
NULL) {
765 "HECMW_couple(): 'couple_value' is NULL");
770 if (couple_value ==
NULL) {
779 if (init_send_value(couple_info->
inter_tbl, couple_value, value_send))
783 if (init_recv_value(couple_info->
inter_tbl, value_recv))
goto error;
790 if ((values_src = alloc_couple_values()) ==
NULL)
goto error;
792 if (init_values(couple_info->
boundary_src, couple_value, values_src))
794 if (set_default_value(couple_value, values_src))
goto error;
795 if (pre_interpolation(couple_info->
ip_list_pre, values_src))
goto error;
796 if (update_import_node_value(couple_info->
comm_src,
799 if (main_interpolation(couple_info->
ip_list_main, values_src, value_send))
802 free_couple_values(values_src);
807 if (send_recv(couple_info->
inter_tbl, value_send, value_recv,
816 if ((values_dst = alloc_couple_values()) ==
NULL)
goto error;
818 if (init_values(couple_info->
boundary_dst, value_recv, values_dst))
820 if (set_default_value(value_recv, values_dst))
goto error;
821 if (post_interpolation(couple_info->
ip_list_post, values_dst))
goto error;
822 if (set_result_value(couple_value, values_dst))
goto error;
824 free_couple_values(values_dst);
831 free_couple_values(values_src);
832 free_couple_values(values_dst);