24 #define FRAC_1_2 (0.5)
26 #define FRAC_1_3 (0.33333333333333333)
28 #define FRAC_1_4 (0.25)
30 #define EPS_ZERO (1.0E-24)
54 static void free_link_list(
struct link_list *r) {
57 for (p = r; p; p = q) {
63 static int intercomm_d2s_coord(
69 int *sendbuf_index =
NULL, *recvbuf_index =
NULL;
70 double *sendbuf =
NULL;
76 if (sendbuf_index ==
NULL) {
84 size =
sizeof(double) *
87 if (sendbuf ==
NULL) {
104 if (recvbuf_index ==
NULL) {
112 size =
sizeof(double) *
115 if (*coord ==
NULL) {
126 if (rtc != 0)
goto error;
147 double d, r_d_surf, r_d_node[3], r_d_sum = 0.0;
148 int node_id[3], node, n, i;
151 i < boundary_src->elem_node_index[
id + 1]; i++) {
153 node = boundary_src->
node->
item[node_id[n]];
154 coord[n].x = mesh_src->
node[3 * (node - 1)];
155 coord[n].y = mesh_src->
node[3 * (node - 1) + 1];
156 coord[n].z = mesh_src->
node[3 * (node - 1) + 2];
160 for (i = 0; i < 3; i++) {
161 d = sqrt((coord[i].
x - coord_dst->
x) * (coord[i].x - coord_dst->
x) +
162 (coord[i].y - coord_dst->
y) * (coord[i].y - coord_dst->
y) +
163 (coord[i].z - coord_dst->
z) * (coord[i].z - coord_dst->
z));
165 r_d_sum += r_d_node[i];
168 for (i = 0; i < 3; i++) {
175 p->
weight = r_d_node[i] / r_d_sum;
177 weight_list->
next = p;
190 double d, r_d_surf, r_d_node[4], r_d_sum = 0.0;
191 int node_id[4], node, n, i;
194 i < boundary_src->elem_node_index[
id + 1]; i++) {
196 node = boundary_src->
node->
item[node_id[n]];
197 coord[n].x = mesh_src->
node[3 * (node - 1)];
198 coord[n].y = mesh_src->
node[3 * (node - 1) + 1];
199 coord[n].z = mesh_src->
node[3 * (node - 1) + 2];
203 for (i = 0; i < 4; i++) {
204 d = sqrt((coord[i].
x - coord_dst->
x) * (coord[i].x - coord_dst->
x) +
205 (coord[i].y - coord_dst->
y) * (coord[i].y - coord_dst->
y) +
206 (coord[i].z - coord_dst->
z) * (coord[i].z - coord_dst->
z));
208 r_d_sum += r_d_node[i];
211 for (i = 0; i < 4; i++) {
218 p->
weight = r_d_node[i] / r_d_sum;
220 weight_list->
next = p;
233 int elem, n_item, id, rtc, n, i;
238 if (weight_list ==
NULL) {
242 for (i = 0; i < n_item; i++) {
243 weight_list[i].
id = -1;
244 weight_list[i].
weight = 0.0;
250 coord_dst.
x = coord[3 * i];
251 coord_dst.
y = coord[3 * i + 1];
252 coord_dst.
z = coord[3 * i + 2];
257 rtc = s2n_dist_node_tet1(mesh_src, boundary_src,
id, &coord_dst,
261 rtc = s2n_dist_node_hex1(mesh_src, boundary_src,
id, &coord_dst,
280 for (p = weight_list[i].
next; p; p = p->
next) {
283 weight_info->
index[i + 1] =
n;
286 n_item = weight_info->
index[weight_info->
n];
288 if (weight_info->
id ==
NULL) {
299 for (p = weight_list[i].
next; p; p = p->
next) {
300 weight_info->
id[
n] = p->id;
301 weight_info->
weight[
n] = p->weight;
308 free_link_list(weight_list[i].
next);
317 free_link_list(weight_list[i].
next);
336 double *coord =
NULL;
342 rtc = intercomm_d2s_coord(mapped_point, inter_tbl, comm_src, comm_dst,
348 weight_info_list->
info = weight_info;
350 if (s2n_dist_node(mesh_src, boundary_src, inter_tbl, coord, weight_info))
354 return weight_info_list;