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++) {
110 p->
next = weight_list[node_id[i]].
next;
111 weight_list[node_id[i]].
next = p;
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++) {
147 p->
next = weight_list[node_id[i]].
next;
148 weight_list[node_id[i]].
next = p;
158 int elem, n_item, size,
n, i;
162 if (weight_list ==
NULL) {
166 for (i = 0; i < boundary->
node->
n; i++) {
167 weight_list[i].
id = -1;
168 weight_list[i].
weight = 0.0;
175 for (i = 0; i < boundary->
surf->
n; i++) {
179 if (s2n_with_area_tet1(mesh, boundary, i, weight_list))
goto error;
181 if (s2n_with_area_hex1(mesh, boundary, i, weight_list))
goto error;
192 weight_info->
n = boundary->
node->
n;
203 for (
n = 0, i = 0; i < boundary->
node->
n; i++) {
204 for (p = weight_list[i].
next; p; p = p->
next) {
207 weight_info->
index[i + 1] =
n;
211 n_item = weight_info->
index[weight_info->
n];
213 if (weight_info->
id ==
NULL) {
222 for (
n = 0, i = 0; i < boundary->
node->
n; i++) {
223 for (p = weight_list[i].
next; p; p = p->
next) {
224 weight_info->
id[
n] = p->id;
225 weight_info->
weight[
n] = p->weight;
233 for (i = 0; i < boundary->
node->
n; i++) {
234 free_link_list(weight_list[i].
next);
241 for (i = 0; i < boundary->
node->
n; i++) {
242 free_link_list(weight_list[i].
next);
254 int elem, n_item, size,
n, i;
258 "HECMW_couple_s2n_by_area(): 'mesh' is NULL");
261 if (boundary ==
NULL) {
263 "HECMW_couple_s2n_by_area(): 'boundary' is NULL");
271 weight_info_list->
info = weight_info;
273 if (s2n_with_area(
mesh, boundary, weight_info))
goto error;
275 return weight_info_list;