| 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 movnd2(numnp, ndim, x, y, vnorm, |
| 9 |
* neessm, nnessm, ltnesm, toler, delmax, index, vector, gap) |
| 10 |
C======================================================================= |
| 11 |
|
| 12 |
REAL X(*), Y(*), VNORM(3,*) |
| 13 |
DIMENSION LTNESM(2,*) |
| 14 |
integer index(*) |
| 15 |
REAL VECTOR(2) |
| 16 |
|
| 17 |
dmax = 0.0 |
| 18 |
dmin = 1.0e15 |
| 19 |
match = 0 |
| 20 |
|
| 21 |
do 130 inod = 1, numnp |
| 22 |
pmin = 1.0e38 |
| 23 |
if (vnorm(1,inod) .ne. 0.0 .or. vnorm(2,inod) .ne. 0.0) then |
| 24 |
|
| 25 |
X0 = X(inod) |
| 26 |
Y0 = Y(inod) |
| 27 |
|
| 28 |
AI = VNORM(1, inod) |
| 29 |
BJ = VNORM(2, inod) |
| 30 |
C ... Node movement (delta) = (xnew-X0)**2 + (ynew-Y0)**2 |
| 31 |
C = (x0+t*ai-x0)**2 + (y0+t*bj-y0)**2 |
| 32 |
C = t**2 * (ai**2 + bj**2) |
| 33 |
C Want delta < delmax ==> t**2 * (ai**2 + bj**2) < delmax**2 |
| 34 |
C ==> t**2 < delmax**2 / (ai**2 + bj**2) = tmax |
| 35 |
|
| 36 |
tmax = delmax**2 / (ai**2 + bj**2) |
| 37 |
|
| 38 |
do 110 iseg = 1, neessm |
| 39 |
XI = x(LTNESM(1,ISEG)) |
| 40 |
YI = y(LTNESM(1,ISEG)) |
| 41 |
|
| 42 |
XJ = x(LTNESM(2,ISEG)) |
| 43 |
YJ = y(LTNESM(2,ISEG)) |
| 44 |
|
| 45 |
C ... If denom == 0, then node normal is parallel to plane |
| 46 |
denom = (yj-yi)*ai - (xj-xi)*bj |
| 47 |
if (denom .ne. 0.0) then |
| 48 |
T = ((xj-xi)*(y0-yi) - (yj-yi)*(x0-xi))/denom |
| 49 |
S = ( ai *(y0-yi) - bj *(x0-xi))/denom |
| 50 |
|
| 51 |
if (t .ge. 0.0 .and. t**2 .le. tmax .and. |
| 52 |
* 0.0-toler .le. S .and. S .le. 1.0+toler) then |
| 53 |
C ... If we made it this far, then the intersection point is inside the |
| 54 |
C face. Save the minimum distance found so far. |
| 55 |
delta = t**2 * (ai**2 + bj**2) |
| 56 |
dmin = min(delta, dmin) |
| 57 |
dmax = max(delta, dmax) |
| 58 |
match = match + 1 |
| 59 |
|
| 60 |
go to 120 |
| 61 |
else |
| 62 |
C ... The node is outside the tolerance, |
| 63 |
C for this face/node combination. Save the minimum for all face/node comb |
| 64 |
if (S .lt. 0.0) then |
| 65 |
S = -S |
| 66 |
else if (S .gt. 1.0) then |
| 67 |
S = S - 1.0 |
| 68 |
endif |
| 69 |
|
| 70 |
pmin = min(S, pmin) |
| 71 |
end if |
| 72 |
end if |
| 73 |
110 continue |
| 74 |
end if |
| 75 |
120 continue |
| 76 |
130 continue |
| 77 |
|
| 78 |
C ... Update the node positions based on the minimum distance found |
| 79 |
C and the specified vector. |
| 80 |
if (match .gt. 0) then |
| 81 |
dmin = dmin - gap |
| 82 |
AI = vector(1) |
| 83 |
BJ = vector(2) |
| 84 |
|
| 85 |
do 140 inod=1, numnp |
| 86 |
if (index(inod) .eq. 1) then |
| 87 |
X0 = X(inod) |
| 88 |
Y0 = Y(inod) |
| 89 |
|
| 90 |
C ... Update the nodes position (Currently, assumes in vector direction) |
| 91 |
X(inod) = X0 + dmin * AI |
| 92 |
Y(inod) = Y0 + dmin * BJ |
| 93 |
end if |
| 94 |
140 continue |
| 95 |
write (*, 10020) dmin |
| 96 |
else |
| 97 |
write (*,*) 'No node movement.' |
| 98 |
end if |
| 99 |
|
| 100 |
10020 format(/,'Node movement = ',1pe11.4) |
| 101 |
return |
| 102 |
end |