Debian Codegraph @

packages/seacas/applications/grepos/gp_movnod.f

raw
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 movnod(numnp, ndim, x, y, z,
9 * vnorm, neesss, nnesss, ltness,
10 * plane, neessm, nnessm, ltnesm,
11 * toler, delmax, index, vector, gap)
12 C=======================================================================
13
14 REAL X(*), Y(*), Z(*), VNORM(3,*), PLANE(4,*)
15 DIMENSION LTNESS(4,*), LTNESM(4,*)
16 INTEGER INDEX(*)
17 REAL VECTOR(3)
18 LOGICAL FOUND
19
20 REAL PI(3)
21
22 dmax = 0.0
23 dmin = 1.0e15
24 delmx2 = delmax**2
25 match = 0
26
27 do 130 inod = 1, numnp
28 found = .FALSE.
29 smin = 1.0e15
30 smax = 0.0
31 armax = -1.0e38
32 if (vnorm(1,inod) .ne. 0.0 .or. vnorm(2,inod) .ne. 0.0 .or.
33 * vnorm(3,inod) .ne. 0.0) then
34
35 X0 = X(inod)
36 Y0 = Y(inod)
37 Z0 = Z(inod)
38
39 AI = VNORM(1, inod)
40 BJ = VNORM(2, inod)
41 CK = VNORM(3, inod)
42
43 do 110 ifac = 1, neessm
44 A = plane(1,ifac)
45 B = plane(2,ifac)
46 C = plane(3,ifac)
47 D = plane(4,ifac)
48
49 C ... If denom == 0, then node normal is parallel to plane
50 DENOM = A*AI + B*BJ + C*CK
51 if (denom .ne. 0.0) then
52 T = -(A*X0 + B*Y0 + C*Z0 - D) / DENOM
53
54 C ... Intersection point
55 PI(1) = X0 + T * AI
56 PI(2) = Y0 + T * BJ
57 PI(3) = Z0 + T * CK
58
59 if (t .lt. 0.0) go to 100
60 dx = abs(x(inod)-pi(1))
61 if (dx .gt. delmax) go to 100
62 dy = abs(y(inod)-pi(2))
63 if (dy .gt. delmax) go to 100
64 dz = abs(z(inod)-pi(3))
65 if (dz .gt. delmax) go to 100
66
67 delta2 = dx**2 + dy**2 + dz**2
68 if (delta2 .le. delmx2) then
69 C ... See if intersection point is inside face.
70 XI = X(LTNESM(1,IFAC))
71 YI = Y(LTNESM(1,IFAC))
72 ZI = Z(LTNESM(1,IFAC))
73
74 XJ = X(LTNESM(2,IFAC))
75 YJ = Y(LTNESM(2,IFAC))
76 ZJ = Z(LTNESM(2,IFAC))
77
78 XK = X(LTNESM(3,IFAC))
79 YK = Y(LTNESM(3,IFAC))
80 ZK = Z(LTNESM(3,IFAC))
81
82 XL = X(LTNESM(4,IFAC))
83 YL = Y(LTNESM(4,IFAC))
84 ZL = Z(LTNESM(4,IFAC))
85
86 area1 = trarea(xi, yi, zi, xj, yj, zj,
87 * pi(1), pi(2), pi(3),
88 * plane(1,ifac))
89
90 area2 = trarea(xj, yj, zj, xk, yk, zk,
91 * pi(1), pi(2), pi(3),
92 * plane(1,ifac))
93
94 area3 = trarea(xk, yk, zk, xl, yl, zl,
95 * pi(1), pi(2), pi(3),
96 * plane(1,ifac))
97
98 area4 = trarea(xl, yl, zl, xi, yi, zi,
99 * pi(1), pi(2), pi(3),
100 * plane(1,ifac))
101
102 if (area1 .ge. 0.0 .and. area2 .ge. 0.0 .and.
103 * area3 .ge. 0.0 .and. area4 .ge. 0.0) then
104 C ... If we made it this far, then the intersection point is inside the
105 C face. Save the minimum distance found so far.
106 dmin = min(delta2, dmin)
107 dmax = max(delta2, dmax)
108 match = match + 1
109
110 go to 120
111 else if (area1 .ge. -toler .and. area2 .ge. -toler .and.
112 * area3 .ge. -toler .and. area4 .ge. -toler) then
113 C ... If we made it this far, then the intersection point is outside the
114 C face, but inside the toler. Save the minimum distance found so far.
115 found = .true.
116 smin = min(delta2, smin)
117 smax = max(delta2, smax)
118 else
119 C ... The node is outside the tolerance, find the most negative of the area*
120 C for this face/node combination. Save the maximum (closest to zero)
121 C for all face/node combinations.
122 armin = MIN(area1, area2, area3, area4)
123 armax = MAX(armin, armax)
124 end if
125 end if
126 end if
127 100 continue
128 110 continue
129 if (found) then
130 C ... The node did not intersect any face, but it did find one within
131 C the tolerance. Use the closest one
132 dmin = smin
133 end if
134 end if
135 120 continue
136 130 continue
137
138 C ... Update the node positions based on the minimum distance found
139 C and the specified vector.
140 if (match .gt. 0) then
141 AI = vector(1)
142 BJ = vector(2)
143 CK = vector(3)
144
145 dmin = sqrt(dmin)
146 dmin = dmin - gap
147
148 do 140 inod=1, numnp
149 if (index(inod) .eq. 1) then
150 X0 = X(inod)
151 Y0 = Y(inod)
152 Z0 = Z(inod)
153
154 C ... Update the nodes position (Currently, assumes in vector direction)
155 X(inod) = X0 + dmin * AI
156 Y(inod) = Y0 + dmin * BJ
157 Z(inod) = Z0 + dmin * CK
158 end if
159 140 continue
160 write (*, 10020) dmin
161 else
162 write (*,*) 'No node movement.'
163 end if
164
165 10020 format(/,'Node movement = ',1pe11.4)
166 return
167 end