Debian Codegraph @

packages/seacas/applications/blot/fndpth.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 FNDPTH (NODVAR, LENE, NLNKE, LINKE, XNE, YNE, ZNE,
9 & NPINFO, MAXNE, NNENUM, NENUM)
10 C=======================================================================
11
12 C --*** FNDPTH *** (SPLOT) Find path between nodes/elements
13 C -- Written by Amy Gilkey - revised 10/29/87
14 C --
15 C --FNDPTH finds a path between nodes or elements. The nodes
16 C --or elements selected are the connected nodes/elements closest to the
17 C --straight line between the end points. "Connected" nodes are in
18 C --the same element; "connected" elements share at lease one node.
19 C --
20 C --Parameters:
21 C -- NODVAR - IN - true if nodal versus element plot
22 C -- LENE - IN - the cumulative element counts by element block
23 C -- NLNKE - IN - the number of nodes per element
24 C -- LINKE - IN - the element connectivity
25 C -- XNE, YNE, ZNE - IN - the coordinates of the nodes (if nodes)
26 C -- or element centroids (if elements)
27 C -- NPINFO - IN/OUT - optimization information
28 C -- MAXNE - IN - the number of nodes or elements
29 C -- NNENUM - IN/OUT - the number of selected node/element numbers
30 C -- NENUM - IN/OUT - the selected node/element numbers
31 C --
32 C --Common Variables:
33 C -- Uses NDIM of /DBNUMS/
34
35 include 'dbnums.blk'
36
37 LOGICAL NODVAR
38 INTEGER LENE(0:NELBLK), LINKE(*)
39 INTEGER NLNKE(NELBLK)
40 REAL XNE(*), YNE(*), ZNE(*)
41 INTEGER NPINFO(2,*)
42 INTEGER NENUM(*)
43
44 INTEGER NECONN(-1:50)
45 LOGICAL FIRST
46 SAVE FIRST
47
48 DATA FIRST / .TRUE. /
49
50 IF (FIRST) THEN
51 FIRST = .FALSE.
52
53 C --Calculate the starting and ending element which contains each node
54
55 CALL INIINT (2*NUMNP, 0, NPINFO)
56 DO 130 IELB = 1, NELBLK
57 IXL0 = IDBLNK (IELB, 0, LENE, NLNKE) - 1
58 DO 120 IEL = LENE(IELB-1)+1, LENE(IELB)
59 IF (LINKE(IXL0+1) .EQ. 0) GOTO 110
60 DO 100 K = 1, NLNKE(IELB)
61 N = LINKE(IXL0+K)
62 IF (NPINFO(1,N) .EQ. 0) NPINFO(1,N) = IEL
63 NPINFO(2,N) = IEL
64 100 CONTINUE
65 110 CONTINUE
66 IXL0 = IXL0 + NLNKE(IELB)
67 120 CONTINUE
68 130 CONTINUE
69 END IF
70
71 IF (NNENUM .LT. 2) THEN
72 CALL PRTERR ('CMDERR',
73 & 'Path must be defined by at least two points')
74 GOTO 220
75 END IF
76
77 C --Save the path defining points at the end of the list
78
79 IXEND = MAXNE + 1
80 DO 140 I = NNENUM, 1, -1
81 IXEND = IXEND-1
82 NENUM(IXEND) = NENUM(I)
83 140 CONTINUE
84
85 ILAST = 0
86 NNENUM = 1
87 IEND = NENUM(IXEND)
88 DO 210 IXEND = IXEND+1, MAXNE
89 ISTART = IEND
90 IEND = NENUM(IXEND)
91
92 C --Calculate the vector components of start-to-end vector
93
94 UX = XNE(IEND) - XNE(ISTART)
95 UY = YNE(IEND) - YNE(ISTART)
96 IF (NDIM .EQ. 3) UZ = ZNE(IEND) - ZNE(ISTART)
97 IF (NDIM .EQ. 3) THEN
98 VECLEN = SQRT (UX*UX + UY*UY + UZ*UZ)
99 ELSE
100 VECLEN = SQRT (UX*UX + UY*UY)
101 END IF
102 IF (VECLEN .LE. 0.0) THEN
103 CALL PRTERR ('CMDERR',
104 & 'Start point is equal to end point')
105 GOTO 220
106 END IF
107 UX = UX / VECLEN
108 UY = UY / VECLEN
109 IF (NDIM .EQ. 3) UZ = UZ / VECLEN
110
111 SLAST = 0.0
112 ITHIS = ISTART
113
114 150 CONTINUE
115 IF (ITHIS .NE. IEND) THEN
116 IF (NNENUM .GE. IXEND) THEN
117 CALL PRTERR ('CMDERR',
118 & 'Too many node/element numbers selected')
119 GOTO 220
120 END IF
121 NNENUM = NNENUM + 1
122
123 C --Find all nodes/elements connected to current node/element,
124 C --except last node/element
125
126 NCONN = 0
127 IF (NODVAR) THEN
128 NECONN(0) = ILAST
129 DO 170 IEL = NPINFO(1,ITHIS), NPINFO(2,ITHIS)
130 IELB = 0
131 IXL0 = IDBLNK (IELB, IEL, LENE, NLNKE) - 1
132 IL = LOCINT (ITHIS, NLNKE(IELB), LINKE(IXL0+1))
133 IF (IL .GT. 0) THEN
134 DO 160 K = 1, NLNKE(IELB)
135 IF (LINKE(IXL0+K) .EQ. ITHIS) GOTO 160
136 IF (LOCINT (LINKE(IXL0+K), NCONN+1, NECONN(0))
137 & .LE. 0) THEN
138 NCONN = NCONN + 1
139 NECONN(NCONN) = LINKE(IXL0+K)
140 END IF
141 160 CONTINUE
142 END IF
143 170 CONTINUE
144 ELSE
145 NECONN(-1) = ITHIS
146 NECONN(0) = ILAST
147 ITELB = 0
148 IXT0 = IDBLNK (ITELB, ITHIS, LENE, NLNKE) - 1
149 DO 190 ILINK = 1, NLNKE(ITELB)
150 INE = LINKE(IXT0+ILINK)
151 DO 180 IEL = NPINFO(1,INE), NPINFO(2,INE)
152 IELB = 0
153 IXL0 = IDBLNK (IELB, IEL, LENE, NLNKE) - 1
154 IL = LOCINT (INE, NLNKE(IELB), LINKE(IXL0+1))
155 IF (IL .GT. 0) THEN
156 IF (LOCINT (IEL, NCONN+2, NECONN(-1)) .LE. 0)
157 & THEN
158 NCONN = NCONN + 1
159 NECONN(NCONN) = IEL
160 END IF
161 END IF
162 180 CONTINUE
163 190 CONTINUE
164 END IF
165
166 C --Find the node/element with the smallest distance to the
167 C --start-to-end vector (DL) that moves toward the end point
168 C --(SLAST is distance from start point to where vector from
169 C --the last point to start-to-end vector intersect)
170
171 ILAST = ITHIS
172 DLMIN = 2 * VECLEN
173 DO 200 IX = 1, NCONN
174 INE = NECONN(IX)
175 XD = XNE(INE) - XNE(ISTART)
176 YD = YNE(INE) - YNE(ISTART)
177 IF (NDIM .EQ. 3) ZD = ZNE(INE) - ZNE(ISTART)
178 IF (NDIM .EQ. 3) THEN
179 S = UX*XD + UY*YD + UZ*ZD
180 ELSE
181 S = UX*XD + UY*YD
182 END IF
183 IF (S .GT. SLAST) THEN
184 IF (NDIM .EQ. 3) THEN
185 DL = XD*XD + YD*YD + ZD*ZD - S*S
186 ELSE
187 DL = XD*XD + YD*YD - S*S
188 END IF
189 IF (DL .LT. DLMIN) THEN
190 ITHIS = INE
191 SMIN = S
192 DLMIN = DL
193 END IF
194 END IF
195 200 CONTINUE
196
197 C --Assign best node/element to list
198
199 IF (ILAST .EQ. ITHIS) THEN
200 NENUM(NNENUM) = IEND
201 CALL PRTERR ('CMDERR',
202 & 'No path found from start to end')
203 GOTO 220
204 END IF
205 SLAST = SMIN
206 NENUM(NNENUM) = ITHIS
207 GOTO 150
208 END IF
209 210 CONTINUE
210
211 220 CONTINUE
212 RETURN
213 END