21 #define FRAC_1_2 (0.5)
23 #define FRAC_1_3 (0.33333333333333333)
25 #define FRAC_1_4 (0.25)
49 static void free_link_list(
struct link_list *r) {
52 for (p = r; p; p = q) {
62 cross_prod->
x = (coord1->
y - coord0->
y) * (coord2->
z - coord0->
z) -
63 (coord1->
z - coord0->
z) * (coord2->
y - coord0->
y);
64 cross_prod->
y = (coord1->
z - coord0->
z) * (coord2->
x - coord0->
x) -
65 (coord1->
x - coord0->
x) * (coord2->
z - coord0->
z);
66 cross_prod->
z = (coord1->
x - coord0->
x) * (coord2->
y - coord0->
y) -
67 (coord1->
y - coord0->
y) * (coord2->
x - coord0->
x);
71 return sqrt(cross_prod->
x * cross_prod->
x + cross_prod->
y * cross_prod->
y +
72 cross_prod->
z * cross_prod->
z) *
78 return tri_area(cross_prod1) + tri_area(cross_prod2);
88 int node_id[3], node,
n, i;
91 i < boundary->elem_node_index[
id + 1]; i++) {
95 coord[
n].y =
mesh->
node[3 * (node - 1) + 1];
96 coord[
n].z =
mesh->
node[3 * (node - 1) + 2];
100 area = tri_area(&cross_prod);
102 for (i = 0; i < 3; i++) {
109 p->
weight = 1.0 / (3.0 * area);
124 int node_id[4], node,
n, i;
127 i < boundary->elem_node_index[
id + 1]; i++) {
131 coord[
n].y =
mesh->
node[3 * (node - 1) + 1];
132 coord[
n].z =
mesh->
node[3 * (node - 1) + 2];
135 cross_product(&coord[0], &coord[1], &coord[3], &cross_prod1);
136 cross_product(&coord[2], &coord[3], &coord[1], &cross_prod2);
137 area = quad_area(&cross_prod1, &cross_prod2);
139 for (i = 0; i < 4; i++) {
146 p->
weight = 1.0 / (4.0 * area);
158 int elem, n_item, size,
n, i;
162 if (weight_list ==
NULL) {
166 for (i = 0; i < boundary->
surf->
n; i++) {
167 weight_list[i].
id = -1;
168 weight_list[i].
weight = 0.0;
176 for (i = 0; i < boundary->
surf->
n; i++) {
180 if (n2s_with_area_tet1(mesh, boundary, i, weight_list) !=
HECMW_SUCCESS)
183 if (n2s_with_area_hex1(mesh, boundary, i, weight_list) !=
HECMW_SUCCESS)
195 weight_info->
n = boundary->
surf->
n;
206 for (
n = 0, i = 0; i < boundary->
surf->
n; i++) {
207 for (p = weight_list[i].
next; p; p = p->
next) {
210 weight_info->
index[i + 1] =
n;
214 n_item = weight_info->
index[weight_info->
n];
216 if (weight_info->
id ==
NULL) {
225 for (
n = 0, i = 0; i < boundary->
surf->
n; i++) {
226 for (p = weight_list[i].
next; p; p = p->
next) {
227 weight_info->
id[
n] = p->id;
228 weight_info->
weight[
n] = p->weight;
236 for (i = 0; i < boundary->
surf->
n; i++) {
237 free_link_list(weight_list[i].
next);
244 for (i = 0; i < boundary->
surf->
n; i++) {
245 free_link_list(weight_list[i].
next);
259 "HECMW_couple_n2s_with_area(): 'mesh' is NULL");
262 if (boundary ==
NULL) {
264 "HECMW_couple_n2s_with_area(): 'boundary' is NULL");
272 weight_info_list->
info = weight_info;
274 if (n2s_with_area(
mesh, boundary, weight_info))
goto error;
276 return weight_info_list;