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)
52 static void free_link_list(
struct link_list *r) {
55 for (p = r; p; p = q) {
61 static int intercomm_d2s_coord(
67 int *sendbuf_index =
NULL, *recvbuf_index =
NULL;
68 double *sendbuf =
NULL;
74 if (sendbuf_index ==
NULL) {
82 size =
sizeof(double) *
86 if (sendbuf ==
NULL) {
103 if (recvbuf_index ==
NULL) {
111 size =
sizeof(double) *
115 if (*coord ==
NULL) {
126 if (rtc != 0)
goto error;
148 double d, r_d_surf, r_d_node[3], r_d_sum = 0.0;
149 int node_id[3], node, n, i;
152 i < boundary_src->elem_node_index[
id + 1]; i++) {
154 node = boundary_src->
node->
item[node_id[n]];
155 coord[n].x = mesh_src->
node[3 * (node - 1)];
156 coord[n].y = mesh_src->
node[3 * (node - 1) + 1];
157 coord[n].z = mesh_src->
node[3 * (node - 1) + 2];
160 gravity.x = (coord[0].x + coord[1].x + coord[2].x) *
FRAC_1_3;
161 gravity.y = (coord[0].y + coord[1].y + coord[2].y) *
FRAC_1_3;
162 gravity.z = (coord[0].z + coord[1].z + coord[2].z) *
FRAC_1_3;
164 d = sqrt((gravity.x - coord_dst->
x) * (gravity.x - coord_dst->
x) +
165 (gravity.y - coord_dst->
y) * (gravity.y - coord_dst->
y) +
166 (gravity.z - coord_dst->
z) * (gravity.z - coord_dst->
z));
170 for (i = 0; i < 3; i++) {
171 d = sqrt((coord[i].
x - coord_dst->
x) * (coord[i].x - coord_dst->
x) +
172 (coord[i].y - coord_dst->
y) * (coord[i].y - coord_dst->
y) +
173 (coord[i].z - coord_dst->
z) * (coord[i].z - coord_dst->
z));
175 r_d_sum += r_d_node[i];
184 p->
weight = r_d_surf / r_d_sum;
186 weight_list_surf->
next = p;
188 for (i = 0; i < 3; i++) {
195 p->
weight = r_d_node[i] / r_d_sum;
197 weight_list_node->
next = p;
211 double d, r_d_surf, r_d_node[4], r_d_sum = 0.0;
212 int node_id[4], node, n, i;
215 i < boundary_src->elem_node_index[
id + 1]; i++) {
217 node = boundary_src->
node->
item[node_id[n]];
218 coord[n].x = mesh_src->
node[3 * (node - 1)];
219 coord[n].y = mesh_src->
node[3 * (node - 1) + 1];
220 coord[n].z = mesh_src->
node[3 * (node - 1) + 2];
223 gravity.x = (coord[0].x + coord[1].x + coord[2].x + coord[3].x) *
FRAC_1_4;
224 gravity.y = (coord[0].y + coord[1].y + coord[2].y + coord[3].y) *
FRAC_1_4;
225 gravity.z = (coord[0].z + coord[1].z + coord[2].z + coord[3].z) *
FRAC_1_4;
227 d = sqrt((gravity.x - coord_dst->
x) * (gravity.x - coord_dst->
x) +
228 (gravity.y - coord_dst->
y) * (gravity.y - coord_dst->
y) +
229 (gravity.z - coord_dst->
z) * (gravity.z - coord_dst->
z));
233 for (i = 0; i < 4; i++) {
234 d = sqrt((coord[i].
x - coord_dst->
x) * (coord[i].x - coord_dst->
x) +
235 (coord[i].y - coord_dst->
y) * (coord[i].y - coord_dst->
y) +
236 (coord[i].z - coord_dst->
z) * (coord[i].z - coord_dst->
z));
238 r_d_sum += r_d_node[i];
247 p->
weight = r_d_surf / r_d_sum;
249 weight_list_surf->
next = p;
251 for (i = 0; i < 4; i++) {
258 p->
weight = r_d_node[i] / r_d_sum;
260 weight_list_node->
next = p;
274 int elem, n_item, id, rtc, n, i;
279 if (weight_list_surf ==
NULL) {
285 if (weight_list_node ==
NULL) {
289 for (i = 0; i < n_item; i++) {
290 weight_list_surf[i].
id = -1;
291 weight_list_surf[i].
weight = 0.0;
293 weight_list_node[i].id = -1;
294 weight_list_node[i].weight = 0.0;
295 weight_list_node[i].next =
NULL;
300 coord_dst.
x = coord[3 * i];
301 coord_dst.
y = coord[3 * i + 1];
302 coord_dst.
z = coord[3 * i + 2];
307 rtc = s2n_dist_surf_tet1(mesh_src, boundary_src,
id, &coord_dst,
308 &weight_list_surf[i], &weight_list_node[i]);
311 rtc = s2n_dist_surf_hex1(mesh_src, boundary_src,
id, &coord_dst,
312 &weight_list_surf[i], &weight_list_node[i]);
320 weight_info_node->
n =
324 weight_info_node->
index =
332 for (p = weight_list_node[i].
next; p; p = p->
next) {
335 weight_info_node->
index[i + 1] =
n;
338 n_item = weight_info_node->
index[weight_info_node->
n];
340 if (weight_info_node->
id ==
NULL) {
351 for (p = weight_list_node[i].
next; p; p = p->
next) {
352 weight_info_node->
id[
n] = p->id;
353 weight_info_node->
weight[
n] = p->weight;
358 weight_info_surf->
n =
362 weight_info_surf->
index =
370 for (p = weight_list_surf[i].
next; p; p = p->
next) {
373 weight_info_surf->
index[i + 1] =
n;
376 n_item = weight_info_surf->
index[weight_info_node->
n];
378 if (weight_info_surf->
id ==
NULL) {
389 for (p = weight_list_surf[i].
next; p; p = p->
next) {
390 weight_info_surf->
id[
n] = p->id;
391 weight_info_surf->
weight[
n] = p->weight;
398 free_link_list(weight_list_surf[i].
next);
399 free_link_list(weight_list_node[i].
next);
409 free_link_list(weight_list_surf[i].
next);
410 free_link_list(weight_list_node[i].
next);
431 double *coord =
NULL;
437 rtc = intercomm_d2s_coord(mapped_point, inter_tbl, comm_src, comm_dst,
448 weight_info_list->
info = weight_info_node;
449 weight_info_list->
next->
info = weight_info_surf;
451 rtc = s2n_dist_surf(mesh_src, boundary_src, inter_tbl, coord,
452 weight_info_surf, weight_info_node);
456 return weight_info_list;