| 1 |
C Copyright(C) 1999-2020 National Technology & Engineering Solutions |
| 2 |
C of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with |
| 3 |
C NTESS, the U.S. Government retains certain rights in this software. |
| 4 |
C |
| 5 |
C See packages/seacas/LICENSE for details |
| 6 |
|
| 7 |
C======================================================================= |
| 8 |
subroutine snpnod(numnp, ndim, x, y, z, |
| 9 |
* vnorm, neesss, nnesss, ltness, |
| 10 |
* plane, neessm, nnessm, ltnesm, |
| 11 |
* toler, delmax) |
| 12 |
C======================================================================= |
| 13 |
|
| 14 |
REAL X(*), Y(*), Z(*), VNORM(3,*), PLANE(4,*) |
| 15 |
DIMENSION LTNESS(4,*), LTNESM(4,*) |
| 16 |
|
| 17 |
REAL PI(3) |
| 18 |
REAL SAVEIT(3) |
| 19 |
LOGICAL FOUND |
| 20 |
|
| 21 |
glotol = 0.0 |
| 22 |
notmat = 0 |
| 23 |
matin = 0 |
| 24 |
mattol = 0 |
| 25 |
numnod = 0 |
| 26 |
dmax = 0.0 |
| 27 |
delmx2 = delmax**2 |
| 28 |
svdel = 0.0 |
| 29 |
saveit(1) = 0.0 |
| 30 |
saveit(2) = 0.0 |
| 31 |
saveit(3) = 0.0 |
| 32 |
|
| 33 |
do 130 inod = 1, numnp |
| 34 |
armax = -1.0e38 |
| 35 |
svmax = -1.0e38 |
| 36 |
found = .false. |
| 37 |
if (vnorm(1,inod) .ne. 0.0 .or. vnorm(2,inod) .ne. 0.0 .or. |
| 38 |
* vnorm(3,inod) .ne. 0.0) then |
| 39 |
|
| 40 |
numnod = numnod + 1 |
| 41 |
|
| 42 |
X0 = X(inod) |
| 43 |
Y0 = Y(inod) |
| 44 |
Z0 = Z(inod) |
| 45 |
|
| 46 |
AI = VNORM(1, inod) |
| 47 |
BJ = VNORM(2, inod) |
| 48 |
CK = VNORM(3, inod) |
| 49 |
|
| 50 |
do 110 ifac = 1, neessm |
| 51 |
A = plane(1,ifac) |
| 52 |
B = plane(2,ifac) |
| 53 |
C = plane(3,ifac) |
| 54 |
D = plane(4,ifac) |
| 55 |
|
| 56 |
C ... If denom == 0, then node normal is parallel to plane |
| 57 |
DENOM = A*AI + B*BJ + C*CK |
| 58 |
if (denom .ne. 0.0) then |
| 59 |
T = -(A*X0 + B*Y0 + C*Z0 - D) / DENOM |
| 60 |
|
| 61 |
C ... Intersection point |
| 62 |
PI(1) = X0 + T * AI |
| 63 |
PI(2) = Y0 + T * BJ |
| 64 |
PI(3) = Z0 + T * CK |
| 65 |
|
| 66 |
dx = abs(x(inod)-pi(1)) |
| 67 |
if (dx .gt. delmax) go to 100 |
| 68 |
dy = abs(y(inod)-pi(2)) |
| 69 |
if (dy .gt. delmax) go to 100 |
| 70 |
dz = abs(z(inod)-pi(3)) |
| 71 |
if (dz .gt. delmax) go to 100 |
| 72 |
|
| 73 |
delta2 = dx**2 + dy**2 + dz**2 |
| 74 |
if (delta2 .le. delmx2) then |
| 75 |
C ... See if intersection point is inside face. |
| 76 |
XI = X(LTNESM(1,IFAC)) |
| 77 |
YI = Y(LTNESM(1,IFAC)) |
| 78 |
ZI = Z(LTNESM(1,IFAC)) |
| 79 |
|
| 80 |
XJ = X(LTNESM(2,IFAC)) |
| 81 |
YJ = Y(LTNESM(2,IFAC)) |
| 82 |
ZJ = Z(LTNESM(2,IFAC)) |
| 83 |
|
| 84 |
XK = X(LTNESM(3,IFAC)) |
| 85 |
YK = Y(LTNESM(3,IFAC)) |
| 86 |
ZK = Z(LTNESM(3,IFAC)) |
| 87 |
|
| 88 |
XL = X(LTNESM(4,IFAC)) |
| 89 |
YL = Y(LTNESM(4,IFAC)) |
| 90 |
ZL = Z(LTNESM(4,IFAC)) |
| 91 |
|
| 92 |
area1 = trarea(xi, yi, zi, xj, yj, zj, |
| 93 |
* pi(1), pi(2), pi(3), |
| 94 |
* plane(1,ifac)) |
| 95 |
|
| 96 |
area2 = trarea(xj, yj, zj, xk, yk, zk, |
| 97 |
* pi(1), pi(2), pi(3), |
| 98 |
* plane(1,ifac)) |
| 99 |
|
| 100 |
area3 = trarea(xk, yk, zk, xl, yl, zl, |
| 101 |
* pi(1), pi(2), pi(3), |
| 102 |
* plane(1,ifac)) |
| 103 |
|
| 104 |
area4 = trarea(xl, yl, zl, xi, yi, zi, |
| 105 |
* pi(1), pi(2), pi(3), |
| 106 |
* plane(1,ifac)) |
| 107 |
|
| 108 |
if (area1 .ge. 0.0 .and. area2 .ge. 0.0 .and. |
| 109 |
* area3 .ge. 0.0 .and. area4 .ge. 0.0) then |
| 110 |
C ... If we made it this far, then the intersection point is inside the |
| 111 |
C face. Move the node to the intersection point and get the next node |
| 112 |
X(INOD) = PI(1) |
| 113 |
Y(INOD) = PI(2) |
| 114 |
Z(INOD) = PI(3) |
| 115 |
|
| 116 |
dmax = max(delta2, dmax) |
| 117 |
matin = matin + 1 |
| 118 |
|
| 119 |
go to 120 |
| 120 |
else if (area1 .ge. -toler .and. area2 .ge. -toler .and. |
| 121 |
* area3 .ge. -toler .and. area4 .ge. -toler) then |
| 122 |
C ... If we made it this far, then the intersection point is slightly |
| 123 |
C outside the face, but is within tolerance. Save this intersection |
| 124 |
C point in case no intersections within the face are found. |
| 125 |
|
| 126 |
C ... Want largest negative |
| 127 |
armin = MIN(area1, area2, area3, area4) |
| 128 |
|
| 129 |
C ... NOTE: armin < 0, want closest to zero. |
| 130 |
if (armin .gt. svmax) then |
| 131 |
found = .TRUE. |
| 132 |
svmax = armin |
| 133 |
svdel = delta2 |
| 134 |
SAVEIT(1) = PI(1) |
| 135 |
SAVEIT(2) = PI(2) |
| 136 |
SAVEIT(3) = PI(3) |
| 137 |
end if |
| 138 |
else |
| 139 |
C ... The node is outside the tolerance, find the most negative of the area* |
| 140 |
C for this face/node combination. Save the maximum (closest to zero) |
| 141 |
C for all face/node combinations. |
| 142 |
armin = MIN(area1, area2, area3, area4) |
| 143 |
armax = MAX(armin, armax) |
| 144 |
end if |
| 145 |
end if |
| 146 |
end if |
| 147 |
100 continue |
| 148 |
110 continue |
| 149 |
if (found) then |
| 150 |
x(inod) = saveit(1) |
| 151 |
y(inod) = saveit(2) |
| 152 |
z(inod) = saveit(3) |
| 153 |
dmax = max(svdel, dmax) |
| 154 |
mattol = mattol + 1 |
| 155 |
else |
| 156 |
write (*,10000) inod, -armax |
| 157 |
glotol = MAX(glotol, -armax) |
| 158 |
notmat = notmat + 1 |
| 159 |
end if |
| 160 |
end if |
| 161 |
120 continue |
| 162 |
130 continue |
| 163 |
|
| 164 |
if (notmat .gt. 0) then |
| 165 |
write (*,10010) notmat, glotol |
| 166 |
end if |
| 167 |
write (*, 10020) sqrt(dmax), numnod, matin, mattol |
| 168 |
10000 format('WARNING - No matching face found for node ',i9,/, |
| 169 |
* ' Tolerance must be at least ',1pe11.4, |
| 170 |
* ' to detect a match.') |
| 171 |
10010 format(/,'WARNING - ',I9,' nodes were not matched.',/, |
| 172 |
* 'Set tolerance greater than ',1pe11.4,' to match all nodes.') |
| 173 |
10020 format(/,'Maximum node movement = ',1pe11.4, |
| 174 |
* /,'Number of unique slave nodes = ',I9, |
| 175 |
* /,'Number of exact matches = ',I9, |
| 176 |
* /,'Number of toleranced matches = ',I9 ) |
| 177 |
return |
| 178 |
end |
| 179 |
|
| 180 |
real function trarea(A1, A2, A3, B1, B2, B3, C1, C2, C3, |
| 181 |
* RNORM) |
| 182 |
real sum(3), rnorm(3) |
| 183 |
|
| 184 |
sum(1) = A2*B3 - A3*B2 |
| 185 |
sum(2) = A3*B1 - A1*B3 |
| 186 |
sum(3) = A1*B2 - A2*B1 |
| 187 |
|
| 188 |
sum(1) = sum(1) + B2*C3 - B3*C2 |
| 189 |
sum(2) = sum(2) + B3*C1 - B1*C3 |
| 190 |
sum(3) = sum(3) + B1*C2 - B2*C1 |
| 191 |
|
| 192 |
sum(1) = sum(1) + C2*A3 - C3*A2 |
| 193 |
sum(2) = sum(2) + C3*A1 - C1*A3 |
| 194 |
sum(3) = sum(3) + C1*A2 - C2*A1 |
| 195 |
|
| 196 |
trarea = sum(1)*rnorm(1) + sum(2)*rnorm(2) + sum(3)*rnorm(3) |
| 197 |
return |
| 198 |
end |