29 double large_distance,
45 for (dg = 0; dg < nb; dg++) {
58 double dist_min = large_distance;
61 for (n = 0; n < nf; n++) {
65 x1 = surface[n].
x1; x2 = surface[n].
x2; x3 = surface[n].
x3;
66 y1 = surface[n].
y1; y2 = surface[n].
y2; y3 = surface[n].
y3;
67 z1 = surface[n].
z1; z2 = surface[n].
z2; z3 = surface[n].
z3;
68 double dist = surface[n].
nx*(xp-surface[n].
x1)
69 + surface[n].ny*(yp-surface[n].y1)
70 + surface[n].
nz*(zp-surface[n].
z1);
71 if (dist > 0)
continue;
74 double x_int, y_int, z_int;
75 x_int = xp - dist * surface[n].
nx;
76 y_int = yp - dist * surface[n].
ny;
77 z_int = zp - dist * surface[n].
nz;
79 double den = (z2-z3)*(y1-y3)-(y2-y3)*(z1-z3);
81 l1 = ((y2-y3)*(z3-z_int)-(z2-z3)*(y3-y_int)) / den;
82 l2 = ((z1-z3)*(y3-y_int)-(y1-y3)*(z3-z_int)) / den;
84 if ((l1 > -eps) && (l2 > -eps) && (l3 > -eps)) is_it_in = 1;
85 }
else if (
absolute(surface[n].ny) > eps) {
86 double den = (x2-x3)*(z1-z3)-(z2-z3)*(x1-x3);
88 l1 = ((z2-z3)*(x3-x_int)-(x2-x3)*(z3-z_int)) / den;
89 l2 = ((x1-x3)*(z3-z_int)-(z1-z3)*(x3-x_int)) / den;
91 if ((l1 > -eps) && (l2 > -eps) && (l3 > -eps)) is_it_in = 1;
93 double den = (y2-y3)*(x1-x3)-(x2-x3)*(y1-y3);
95 l1 = ((x2-x3)*(y3-y_int)-(y2-y3)*(x3-x_int)) / den;
96 l2 = ((y1-y3)*(x3-x_int)-(x1-x3)*(y3-y_int)) / den;
98 if ((l1 > -eps) && (l2 > -eps) && (l3 > -eps)) is_it_in = 1;
107 for (n = 0; n < nf; n++) {
108 double dist = surface[n].
nx*(xp-surface[n].
x1)
109 + surface[n].ny*(yp-surface[n].y1)
110 + surface[n].
nz*(zp-surface[n].
z1);
111 if (dist > eps)
continue;
122 fprintf(stderr,
"Error in IBNearestFacetNormal(): no nearest normal found for boundary node (%d,%d,%d) ",i,j,k);
123 fprintf(stderr,
"on rank %d.\n",mpi->
rank);
125 }
else boundary[dg].
face = &surface[n_min];
Structure defining an immersed boundary node.
Structure containing variables for immersed boundary implementation.
Structure defining a body.
Structure defining a facet.
Structures and function definitions for immersed boundaries.
MPI related function definitions.
#define _GetCoordinate_(dir, i, dim, ghosts, x, coord)
Contains function definitions for common mathematical functions.
int IBNearestFacetNormal(void *, void *, double *, double, int *, int)
Some basic definitions and macros.
Structure of MPI-related variables.