Debian Codegraph @

packages/seacas/applications/grepos/gp_snpnd2.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 snpnd2(numnp, ndim, x, y, vnorm,
9 * neessm, nnessm, ltnesm, toler, delmax)
10 C=======================================================================
11
12 REAL X(*), Y(*), VNORM(3,*)
13 DIMENSION LTNESM(2,*)
14
15 REAL SAVEIT(2)
16 LOGICAL FOUND
17
18 C ... Quiet the compiler...
19 saveit(1) = 0.0
20 saveit(2) = 0.0
21
22 glotol = 0.0
23 notmat = 0
24 matin = 0
25 mattol = 0
26 numnod = 0
27 dmax = 0.0
28 svdel = 0.0
29
30 do 130 inod = 1, numnp
31 pmin = 1.0e38
32 svmax = -1.0e38
33 found = .false.
34 if (vnorm(1,inod) .ne. 0.0 .or. vnorm(2,inod) .ne. 0.0) then
35
36 numnod = numnod + 1
37
38 X0 = X(inod)
39 Y0 = Y(inod)
40
41 AI = VNORM(1, inod)
42 BJ = VNORM(2, inod)
43 C ... Node movement (delta) = (xnew-X0)**2 + (ynew-Y0)**2
44 C = (x0+t*ai-x0)**2 + (y0+t*bj-y0)**2
45 C = t**2 * (ai**2 + bj**2)
46 C Want delta < delmax ==> t**2 * (ai**2 + bj**2) < delmax**2
47 C ==> t**2 < delmax**2 / (ai**2 + bj**2) = tmax
48
49 tmax = delmax**2 / (ai**2 + bj**2)
50
51 do 110 iseg = 1, neessm
52 XI = x(LTNESM(1,ISEG))
53 YI = y(LTNESM(1,ISEG))
54
55 XJ = x(LTNESM(2,ISEG))
56 YJ = y(LTNESM(2,ISEG))
57
58 C ... If denom == 0, then node normal is parallel to plane
59 denom = (yj-yi)*ai - (xj-xi)*bj
60 if (denom .ne. 0.0) then
61 T = ((xj-xi)*(y0-yi) - (yj-yi)*(x0-xi))/denom
62 S = ( ai *(y0-yi) - bj *(x0-xi))/denom
63
64 if (t**2 .le. tmax .and.
65 * 0.0 .le. S .and. S .le. 1.0) then
66 C ... If we made it this far, then the intersection point is inside the
67 C face. Move the node to the intersection point and get the next node
68 X(INOD) = X0 + T * AI
69 Y(INOD) = Y0 + T * BJ
70
71 delta = t**2 * (ai**2 + bj**2)
72 dmax = max(delta, dmax)
73 matin = matin + 1
74
75 go to 120
76 else if (t**2 .le. tmax .and.
77 * 0.0-toler .le. S .and. S .le. 1.0+toler) then
78 C ... If we made it this far, then the intersection point is outside the
79 C face, but inside the tolerance range.
80 C Save the intersection point in case no intersections within the
81 C face are found.
82 if (S .gt. 1.0) S = 1.0 - S
83 C ... -toler < S < 0.0
84 if (toler .gt. svmax) then
85 found = .TRUE.
86 svmax = toler
87 svdel = t**2 * (ai**2 + bj**2)
88 SAVEIT(1) = X0 + T * AI
89 SAVEIT(2) = Y0 + T * BJ
90 end if
91 else
92 C ... The node is outside the tolerance,
93 C for this face/node combination. Save the minimum for all face/node comb
94 if (S .lt. 0.0) then
95 S = -S
96 else if (S .gt. 1.0) then
97 S = S - 1.0
98 endif
99
100 pmin = min(S, pmin)
101 end if
102 end if
103 110 continue
104 if (found) then
105 x(inod) = saveit(1)
106 y(inod) = saveit(2)
107 dmax = max(svdel, dmax)
108 mattol = mattol + 1
109 else
110 write (*,10000) inod, pmin
111 glotol = Max(glotol, pmin)
112 notmat = notmat + 1
113 end if
114 end if
115 120 continue
116 130 continue
117
118 if (notmat .gt. 0) then
119 write (*,10010) notmat, glotol
120 end if
121 write (*, 10020) sqrt(dmax), numnod, matin, mattol
122 10000 format('WARNING - No matching face found for node ',i9,/,
123 * ' Tolerance must be at least ',1pe11.4,
124 * ' to detect a match.')
125 10010 format(/,'WARNING - ',I9,' nodes were not matched.',/,
126 * 'Set tolerance greater than ',1pe11.4,' to match all nodes.')
127 10020 format(/,'Maximum node movement = ',1pe11.4,
128 * /,'Number of unique slave nodes = ',I9,
129 * /,'Number of exact matches = ',I9,
130 * /,'Number of toleranced matches = ',I9 )
131 return
132 end