Debian Codegraph @

packages/seacas/applications/explore/exp_invcon.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 C=======================================================================
7 SUBROUTINE INVCON (ia, NELBLK, IDELB, NUMELB, NUMLNK, LINK, NUMNP,
8 * ICON, ICSCR, NODIND, lisnp, nout, mapn, mape, domapn, domape,
9 $ DOBLK, DOELE, ebtype)
10 C=======================================================================
11
12 C --Parameters:
13 C -- NELBLK - IN - the number of element blocks
14 C -- NUMEL - IN - the number of elements in all blocks
15 C -- NUMELB - IN - the number of elements for each block
16 C -- NUMLNK - IN - the number of nodes per element for each block
17 C -- LINK - IN - the connectivity array
18
19 include 'exodusII.inc'
20 include 'exp_dbase.blk'
21
22 INTEGER IA(*)
23 INTEGER IDELB(*)
24 INTEGER NUMELB(*)
25 INTEGER NUMLNK(*)
26 INTEGER LINK(*)
27 INTEGER ICON(NELBLK,*)
28 INTEGER ICSCR(2,NELBLK)
29 INTEGER NODIND(2,NUMNP)
30 INTEGER LISNP(0:*)
31 INTEGER MAPN(*)
32 INTEGER MAPE(*)
33 LOGICAL DOMAPN
34 LOGICAL DOMAPE
35 LOGICAL FIRST, DOBLK, DOELE
36 CHARACTER*(MXSTLN) EBTYPE(*)
37 DATA FIRST /.TRUE./
38 SAVE index, ndcon
39
40 if (first) then
41 first = .false.
42 call iniint (numnp*nelblk, 0, icon)
43 call iniint (2*numnp, 0, nodind)
44
45 ISLNK = 1
46 DO IELB = 1, NELBLK
47 if (ebtype(ielb) .eq. 'nsided' .or.
48 * ebtype(ielb) .eq. 'NSIDED') THEN
49 CALL invcn1 (IELB, 1, NUMLNK(IELB),
50 & LINK(ISLNK), icon, nelblk)
51 ISLNK = ISLNK + NUMLNK(IELB)
52 ELSE
53 CALL invcn1 (IELB, NUMELB(IELB), NUMLNK(IELB),
54 & LINK(ISLNK), icon, nelblk)
55 ISLNK = ISLNK + NUMLNK(IELB) * NUMELB(IELB)
56 END IF
57 end do
58
59 C ... Build up a node index map so we can store the inverse node
60 C -element connectivity in a linear array.
61 index = 1
62 do i = 1, numnp
63 isum = 0
64 do j=1, nelblk
65 isum = isum + icon(j,i)
66 end do
67 nodind(1,i) = index
68 nodind(2,i) = 0
69 index = index + isum
70 end do
71 call mdrsrv('NODCON', ndcon, index)
72 ISLNK = 1
73 IELST = 0
74 DO IELB = 1, NELBLK
75 if (ebtype(ielb) .eq. 'nsided' .or.
76 * ebtype(ielb) .eq. 'NSIDED') THEN
77 call mdrsrv('NNPE', nnpe, numelb(ielb))
78 CALL EXGECPP(NDB, EXEBLK, IDELB(ielb), ia(nnpe), IERR)
79 call invcn2n(IELST, numelb(ielb), ia(nnpe),
80 & LINK(ISLNK), nodind, numnp, ia(ndcon))
81 call mddel('NNPE')
82 ISLNK = ISLNK + NUMLNK(IELB)
83 IELST = IELST + NUMELB(IELB)
84 ELSE
85 call invcn2(IELST, NUMELB(IELB), NUMLNK(IELB),
86 & LINK(ISLNK), nodind, numnp, ia(ndcon))
87 ISLNK = ISLNK + NUMLNK(IELB) * NUMELB(IELB)
88 IELST = IELST + NUMELB(IELB)
89 END IF
90 end do
91
92 if (domape) then
93 do i = 0, index-1
94 ia(ndcon+i) = mape(ia(ndcon+i))
95 end do
96 end if
97 end if
98
99 C=======================================================================
100 C ... OUTPUT
101 C=======================================================================
102
103 if (nout .gt. 0) then
104 if (domapn) write (nout, 10005) 'Node'
105 else
106 if (domapn) write (*, 10005) 'Node'
107 end if
108
109 if (nout .gt. 0) then
110 if (domape) write (nout, 10005) 'Element'
111 else
112 if (domape) write (*, 10005) 'Element'
113 end if
114
115 C ... Node/Block inverse connectivity
116 if (doblk) then
117 if (nout .gt. 0) then
118 WRITE (nout, 10000)
119 else
120 WRITE (*, 10000)
121 end if
122 do i = 1, lisnp(0)
123 INP = LISNP(I)
124
125 C ... Get nonzero blocks for this node.
126 icnt = 0
127 do j=1, nelblk
128 if (icon(j,inp) .gt. 0) then
129 icnt = icnt + 1
130 icscr(1,icnt) = idelb(j)
131 icscr(2,icnt) = icon(j,inp)
132 end if
133 end do
134
135 if (domapn) then
136 id = mapn(inp)
137 else
138 id = inp
139 end if
140 IF (NOUT .GT. 0) THEN
141 WRITE (NOUT, 10020) ID, (icscr(1,j), icscr(2,j),j=1,icnt)
142 ELSE
143 WRITE (*, 10020) ID, (icscr(1,j), icscr(2,j),j=1,icnt)
144 END IF
145 end do
146 end if
147
148 C ... Node/Element inverse connectivity
149 if (doele) then
150 if (nout .gt. 0) then
151 WRITE (nout, 10010)
152 else
153 WRITE (*, 10010)
154 end if
155 do i = 1, lisnp(0)
156 INP = LISNP(I)
157
158 ibeg = ndcon + nodind(1,inp) - 2
159 icnt = nodind(2,inp)
160 if (domapn) then
161 id = mapn(inp)
162 else
163 id = inp
164 end if
165 IF (NOUT .GT. 0) THEN
166 WRITE (NOUT, 10030) ID, (ia(ibeg+k), k=1,icnt)
167 ELSE
168 WRITE (*, 10030) ID, (ia(ibeg+k), k=1,icnt)
169 END IF
170 end do
171 end if
172
173 10000 FORMAT (/,1x, 'Inverse Node-Block Connectivity:',/,
174 * ' Output is: Block ID:# times in this block')
175 10010 FORMAT (/,1x, 'Inverse Node-Element Connectivity:',/,
176 * ' Output is: id of elements connected to node')
177 10005 FORMAT (1X, A,' ids are Global')
178 10020 FORMAT (1X, 'Node', I12,2X, 5 (1X, i10,':',i2.2), :, /,
179 & (17X, 5(1X, i10,':',i2.2)))
180 10030 FORMAT (1X, 'Node', I12,':',2X, 8 (1X, i10), :, /,
181 & (17X, 8(1X, i10)))
182 RETURN
183 END
184
185 subroutine invcn1(ielb, numelb, numlnk, link, icon, nelblk)
186
187 integer link(numlnk,*)
188 integer icon(nelblk,*)
189
190 do i=1, numelb
191 do j = 1, numlnk
192 node = link(j,i)
193 icon(ielb,node) = icon(ielb,node) + 1
194 end do
195 end do
196 return
197 end
198
199 subroutine invcn2(ielst, numelb, numlnk, link,
200 $ nodind, numnp, nodcon)
201 integer link(numlnk,*)
202 integer nodind(2,numnp)
203 integer nodcon(*)
204
205 do i=1, numelb
206 do j = 1, numlnk
207 node = link(j,i)
208 index = nodind(1,node)
209 icnt = nodind(2,node)
210 nodcon(index+icnt) = ielst+i
211 nodind(2,node) = nodind(2,node) + 1
212 end do
213 end do
214 return
215 end
216
217 subroutine invcn2n(ielst, numelb, nnpe, link,
218 $ nodind, numnp, nodcon)
219 integer nnpe(*), link(*)
220 integer nodind(2,numnp)
221 integer nodcon(*)
222
223 ind = 0
224 do i=1, numelb
225 numlnk = nnpe(i)
226 do j = 1, numlnk
227 node = link(ind + j)
228 index = nodind(1,node)
229 icnt = nodind(2,node)
230 nodcon(index+icnt) = ielst+i
231 nodind(2,node) = nodind(2,node) + 1
232 end do
233 ind = ind + numlnk
234 end do
235 return
236 end