Debian Codegraph @

packages/seacas/applications/grepos/gp_matxyz.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 MATXYZ (NDIM,
9 & NUMNP, XN, YN, ZN, IX, IXNP, NMATCH, TOLER)
10 C=======================================================================
11
12 C --*** MATXYZ *** (GREPOS) Find matching nodes
13 C --
14 C --MATXYZ matches nodes in the database by comparing
15 C --the coordinates. Since some slack is needed in the equality check,
16 C --the comparison may not work for all meshes.
17 C --The nodes to be matched may be limited to nodes in two
18 C -- nodal point sets. (NOT IMPLEMENTED)
19 C --
20 C --Parameters:
21 C -- NDIM - IN - the number of coordinates per node
22 C -- NUMNP - IN - the number of nodes in the database
23 C -- XN, YN, ZN - IN - the coordinates in the database
24 C -- IX - SCRATCH - size = NUMNP
25 C -- NMATCH - OUT - the number of matching nodes
26 C -- TOLER - IN - the tolerance used for matching
27
28 REAL XN(*), YN(*), ZN(*)
29 INTEGER IX(*)
30 INTEGER IXNP(*)
31
32 CHARACTER*80 STRING
33
34 IF (TOLER .LT. 0.0) THEN
35 RETURN
36 END IF
37
38 nmatch = 0
39
40 time0 = 0.0
41 time1 = 0.0
42 time2 = 0.0
43
44 CALL MINMAX (NUMNP, XN, XMIN, XMAX)
45 CALL MINMAX (NUMNP, YN, YMIN, YMAX)
46 IF (NDIM .GE. 3) THEN
47 CALL MINMAX (NUMNP, ZN, ZMIN, ZMAX)
48 END IF
49
50 DELTAX = XMAX - XMIN
51 DELTAY = YMAX - YMIN
52 DELTAZ = ZMAX - ZMIN
53
54 XMIN = XMIN - TOLER
55 XMAX = XMAX + TOLER
56 YMIN = YMIN - TOLER
57 YMAX = YMAX + TOLER
58 ZMIN = ZMIN - TOLER
59 ZMAX = ZMAX + TOLER
60
61 C --Index the nodes
62
63 IN1 = 0
64 IF (NDIM .LT. 3) Z3D = 0.0
65 DO 120 INP = 1, NUMNP
66 IX(INP) = INP
67 IXNP(INP) = INP
68 120 CONTINUE
69
70 C --Find all matching nodes by comparing coordinates of nodes in overlap area
71
72 DELMAX = MAX(DELTAX, DELTAY, DELTAZ)
73
74 imat = 0
75 call excpus(time0)
76 if (DELMAX .EQ. DELTAX) THEN
77 imat = 1
78 call indexn(xn, 1, 1, ix, numnp, .FALSE.)
79 call prterr('CMDSPEC', 'Entering Sorting Phase, Sort on X')
80 else if (delmax .eq. deltay) then
81 imat = 2
82 call indexn(yn, 1, 1, ix, numnp, .FALSE.)
83 call prterr('CMDSPEC', 'Entering Sorting Phase, Sort on Y')
84 else if (ndim .ge. 3 .and. delmax .eq. deltaz) then
85 imat = 3
86 call indexn(zn, 1, 1, ix, numnp, .FALSE.)
87 call prterr('CMDSPEC', 'Entering Sorting Phase, Sort on Z')
88 end if
89 call prterr('CMDSPEC', 'Entering Comparison Phase')
90
91 IN1 = NUMNP
92 IN2 = NUMNP
93
94 CALL EXCPUS(time1)
95 DISMIN = 1.0E38
96 DISMAX = -1.0E38
97 NCOMP = 0
98 nout = 0
99 WRITE (*,'(A)') ' '
100 WRITE (*,'(A)') ' '
101
102 IF (NDIM .LT. 3) Z3D = 0.0
103 IF (NDIM .LT. 3) Z = 0.0
104 IN1SV = IN1
105 IN2SV = IN2
106 DO 170 I1 = 1, IN1SV
107 I2BEG = I1+1
108 INP1 = IX(I1)
109 X = XN(INP1)
110 Y = YN(INP1)
111 IF (NDIM .GE. 3) Z = ZN(INP1)
112 DMIN = 1.0E38
113 NDMIN = 0
114
115 I2BEGS = I2BEG
116 DO 160 I2 = I2BEGS, IN2SV
117 NCOMP = NCOMP + 1
118 nout = nout + 1
119 IF ( nout .ge. 10000000) THEN
120 CMPX = 1.0 * (IN1SV - I1) * IN2 + (IN2 - I2)
121 WRITE (*, 10020) NCOMP, CMPX, NMATCH
122 nout = 0
123 END IF
124 INP2 = IX(I2)
125 IF (NDIM .GE. 3) Z3D = ZN(INP2)
126
127 if ((imat .eq. 1 .and. (x-toler .gt. xn(inp2))) .or.
128 * (imat .eq. 2 .and. (y-toler .gt. yn(inp2))) .or.
129 * (imat .eq. 3 .and. (z-toler .gt. z3d))) i2beg = i2
130
131 C ... Since we are sorted on coordinate X|Y|Z,
132 C if set 2 X|Y|Z greater than set 1 X|Y|Z+toler, go to next X1|Y1|Z1 coord.
133 if ((imat .eq. 1 .and. xn(inp2)-toler .gt. x) .or.
134 * (imat .eq. 2 .and. yn(inp2)-toler .gt. y) .or.
135 * (imat .eq. 3 .and. z3d -toler .gt. z)) goto 165
136
137 DIS = MAX (ABS (XN(INP2) - X), ABS(YN(INP2) - Y),
138 * ABS (Z3D - Z) )
139 IF (DIS .EQ. 0.0) THEN
140 DISMAX = MAX(DISMAX, DIS)
141 NMATCH = NMATCH + 1
142 if (inp1 .lt. inp2) then
143 IXNP(INP2) = -INP1
144 else
145 IXNP(INP1) = -INP2
146 end if
147 ELSE IF (DIS .LE. TOLER) THEN
148 IF (DIS .LT. DMIN) THEN
149 DMIN = DIS
150 NDMIN = I2
151 END IF
152 ELSE
153 DISMIN = MIN(DISMIN, DIS)
154 END IF
155 160 CONTINUE
156 165 CONTINUE
157 IF (DMIN .LE. TOLER) THEN
158 DISMAX = MAX(DISMAX, DMIN)
159 NMATCH = NMATCH + 1
160 INP2 = IX(NDMIN)
161 if (inp1 .lt. inp2) then
162 IXNP(INP2) = -INP1
163 else
164 IXNP(INP1) = -INP2
165 end if
166 END IF
167 170 CONTINUE
168
169 CALL EXCPUS(time2)
170
171 WRITE (*, 10050) NCOMP, NMATCH
172 WRITE (*, 10021) TOLER
173 IF (DISMAX .GT. -1.0E37) THEN
174 WRITE (*, 10025) DISMAX
175 END IF
176 IF (DISMIN .LT. 1.0E37) THEN
177 WRITE (*, 10030) DISMIN
178 END IF
179
180 WRITE (STRING, 10000) NMATCH
181 CALL SQZSTR (STRING, LSTR)
182 WRITE (*, 10010) STRING(:LSTR)
183
184 if (ncomp .gt. 0) then
185 if ((time2 - time1) .ne. 0.0) then
186 Write (*, 10055) Time2-Time1, NCOMP/(time2-time1)
187 else
188 write (*, 10060) Time2-Time1
189 end if
190 end if
191
192 RETURN
193 10000 FORMAT (I8, ' nodes matched')
194 10010 FORMAT (/, 4X, A)
195 10020 FORMAT (' Comparisons = ',T20,I10,T32,1pE10.3,T47,
196 * ' Matches = ', I8)
197 10050 FORMAT (' Comparisons = ',T20,I10,T47,' Matches = ',I8)
198 10021 FORMAT (/,' Tolerance used for matching = ',T50,1PE10.3)
199 10025 FORMAT (' Maximum distance between matched nodes = ',T50,
200 * 1PE10.3)
201 10030 FORMAT (' Minimum distance between nonmatched nodes = ',T50,
202 * 1PE10.3)
203 10055 FORMAT (' Cpu Time = ',1PE10.3, ', comparison/sec = ',1PE10.3)
204 10060 FORMAT (' Cpu Time = ',1PE10.3, ', comparison/sec = Infinite')
205 END