Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
initK.f90
Go to the documentation of this file.
1 !*********************************************************************
2 !* Illinois Open Source License *
3 !* *
4 !* University of Illinois/NCSA *
5 !* Open Source License *
6 !* *
7 !* Copyright@2008, University of Illinois. All rights reserved. *
8 !* *
9 !* Developed by: *
10 !* *
11 !* Center for Simulation of Advanced Rockets *
12 !* *
13 !* University of Illinois *
14 !* *
15 !* www.csar.uiuc.edu *
16 !* *
17 !* Permission is hereby granted, free of charge, to any person *
18 !* obtaining a copy of this software and associated documentation *
19 !* files (the "Software"), to deal with the Software without *
20 !* restriction, including without limitation the rights to use, *
21 !* copy, modify, merge, publish, distribute, sublicense, and/or *
22 !* sell copies of the Software, and to permit persons to whom the *
23 !* Software is furnished to do so, subject to the following *
24 !* conditions: *
25 !* *
26 !* *
27 !* @ Redistributions of source code must retain the above copyright *
28 !* notice, this list of conditions and the following disclaimers. *
29 !* *
30 !* @ Redistributions in binary form must reproduce the above *
31 !* copyright notice, this list of conditions and the following *
32 !* disclaimers in the documentation and/or other materials *
33 !* provided with the distribution. *
34 !* *
35 !* @ Neither the names of the Center for Simulation of Advanced *
36 !* Rockets, the University of Illinois, nor the names of its *
37 !* contributors may be used to endorse or promote products derived *
38 !* from this Software without specific prior written permission. *
39 !* *
40 !* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *
41 !* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *
42 !* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *
43 !* NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR *
44 !* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
45 !* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
46 !* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
47 !* USE OR OTHER DEALINGS WITH THE SOFTWARE. *
48 !*********************************************************************
49 !* Please acknowledge The University of Illinois Center for *
50 !* Simulation of Advanced Rockets in works and publications *
51 !* resulting from this software or its derivatives. *
52 !*********************************************************************
53 
54 !!****
55 !!
56 !! NAME
57 !! numKnnz
58 !!
59 !! FUNCTION
60 !! This subroutine uses the node numbering combined with
61 !! the connectivity table in order to calculate the number
62 !! of nonzero entries in the stiffness matrix due only to
63 !! the elements and nodes on this processor.
64 !!
65 !! INPUTS
66 !! NumNp -- Total number of nodes that this proc knows about
67 !! NumEl -- Total number of elements that this proc knows about
68 !! ElConnVol -- Connectivity table
69 !!
70 !! OUTPUTS
71 !! nnz -- The number of nonzeros in the K matrix
72 !!
73 !! USES
74 !! none
75 !!
76 !!****
77 
78 SUBROUTINE numknnz(NumNp,NumEl,ElConnVol,nnz)
79 
80  USE precision
81  USE implicit_global
82 
83  IMPLICIT NONE
84 
85  ! Input variables
86  INTEGER :: numnp, numel
87  INTEGER :: elconnvol(1:8,1:numel)
88 
89  ! Output variables
90  INTEGER :: nnz
91 
92  ! Internal variables
93  INTEGER :: i, j, k, m, n, counter
94  INTEGER :: innz(1:56), jnnz(1:26)
95 
96 
97 !
98 ! Count the nonzeros that should be in the K matrix
99 !
100 
101  ! Loop through nodes counting off-diagonal blocks of nonzeros
102  nnz = 0
103  DO i = 1, numnp
104 
105  ! Initialize connectivity variables
106  innz(:) = -1
107  jnnz(:) = -1
108 
109  ! Construct nodal connectivity vector
110  DO j = 1, numel
111  DO k = 1, 8
112  IF (elconnvol(k,j) == i) THEN
113  DO m = 1, 8
114  IF (k /= m) THEN
115  DO n = 1, 56
116  IF (innz(n) == -1) THEN
117  innz(n) = elconnvol(m,j)
118  EXIT
119  ENDIF
120  ENDDO
121  ENDIF
122  ENDDO
123  ENDIF
124  ENDDO
125  ENDDO
126 
127  ! Eliminate duplicates from nodal connectivity vector
128  DO j = 1, 56
129  IF (innz(j) /= -1) THEN
130  DO k = 1, 26
131  IF (jnnz(k) /= -1) THEN
132  IF (jnnz(k) == innz(j)) THEN
133  EXIT
134  ENDIF
135  ELSE
136  jnnz(k) = innz(j)
137  nnz = nnz + 1
138  EXIT
139  ENDIF
140  ENDDO
141  ENDIF
142  ENDDO
143 
144  ENDDO
145 
146  ! Take into account the blocks on the diagonal
147  nnz = nnz + numnp
148 
149  ! Convert number of blocks to number of nonzeros
150  nnz = 9*nnz ! since 3 dof
151 
152 
153 END SUBROUTINE numknnz
154 
155 
156 
157 
158 
159 
160 
161 
162 
163 
164 
165 
166 
167 !!****
168 !!
169 !! NAME
170 !! initK
171 !!
172 !! FUNCTION
173 !! This subroutine uses the node numbering combined with
174 !! the connectivity table and number of nonzeros in the K
175 !! matrix to assemble the pre-allocated compressed row
176 !! storage arrays. It does this by putting a definite
177 !! (not assumed) zero at each point that can contain a
178 !! nonzero value. The actual values in the K matrix are
179 !! added in the v3d8_me_K subroutine.
180 !!
181 !! INPUTS
182 !! NumNp -- Total number of nodes that this proc knows about
183 !! NumEl -- Total number of elements that this proc knows about
184 !! ElConnVol -- Connectivity table
185 !! nnz -- The number of nonzeros in the K matrix
186 !!
187 !! OUTPUTS
188 !! rp -- The row mapping vector
189 !! cval -- The collumn mapping vector
190 !! aval -- The value vector (which will be returned as all zeros)
191 !!
192 !! USES
193 !! none
194 !!
195 !!****
196 
197 SUBROUTINE initk(NumNp,NumEl,ElConnVol,nnz,rp,cval,aval)
198 
199 
200  USE precision
201  USE implicit_global
202 
203  IMPLICIT NONE
204 
205  include 'mpif.h'
206 
207  ! Input variables
208  INTEGER :: numnp, numel
209  INTEGER :: elconnvol(1:8,1:numel)
210  INTEGER :: nnz
211 
212  ! Output variables
213  INTEGER :: rp(1:3*gnumnp+1)
214  INTEGER :: cval(1:nnz)
215  INTEGER :: aval(1:nnz)
216 
217  ! Internal variables
218  INTEGER :: i, j, k, m, n, counter, ii
219  INTEGER :: innz(1:56), jnnz(1:27)
220 
221 
222  ! Initialize CRS variables
223  aval(:) = 0.0
224  cval(:) = -1
225  rp(:) = -1
226  rp(1) = 0
227 
228  ! Loop through nodes
229  counter = 0
230  DO i = 1, gnumnp
231 
232  ! If this node is on this processor
233  IF (global2local(i) /= -1) THEN
234 
235  ii = global2local(i)
236 
237  ! Initialize connectivity variables
238  innz(:) = -1
239  jnnz(:) = -1
240 
241  ! Make sure diagonal terms are included
242  jnnz(27) = ii
243 
244  ! Construct nodal connectivity vector
245  DO j = 1, numel
246  DO k = 1, 8
247  IF (elconnvol(k,j) == ii) THEN
248  DO m = 1, 8
249  IF (k /= m) THEN
250  DO n = 1, 56
251  IF (innz(n) == -1) THEN
252  innz(n) = elconnvol(m,j)
253  EXIT
254  ENDIF
255  ENDDO
256  ENDIF
257  ENDDO
258  ENDIF
259  ENDDO
260  ENDDO
261 
262  ! Eliminate duplicates from nodal connectivity vector
263  DO j = 1, 56
264  IF (innz(j) /= -1) THEN
265  DO k = 1, 26
266  IF (jnnz(k) /= -1) THEN
267  IF (jnnz(k) == innz(j)) THEN
268  EXIT
269  ENDIF
270  ELSE
271  jnnz(k) = innz(j)
272  EXIT
273  ENDIF
274  ENDDO
275  ENDIF
276  ENDDO
277 
278  ! Loop through rows with same nonzero blocks
279  DO j = 1, 3
280 
281  ! Construct cval
282  DO n = 1, gnumnp
283  DO k = 1, 27
284  IF(jnnz(k) /= -1) THEN
285  m = local2global(jnnz(k))
286  IF (m == n) THEN
287  counter = counter + 3
288  cval(counter-2) = 3*m-3
289  cval(counter-1) = 3*m-2
290  cval(counter) = 3*m-1
291  ENDIF
292  ENDIF
293  ENDDO
294  ENDDO
295 
296  ! Construct rp
297  rp(3*i+j-2) = counter
298 
299  ENDDO
300 
301  ! If this node is not on this processor
302  ELSE
303 
304  DO j = 1, 3
305  rp(3*i+j-2) = rp(3*i+j-3)
306  ENDDO
307 
308  ENDIF
309 
310 
311 
312  ENDDO
313 
314 
315 END SUBROUTINE initk
316 
subroutine numknnz(NumNp, NumEl, ElConnVol, nnz)
Definition: initK.f90:78
FT m(int i, int j) const
j indices k indices k
Definition: Indexing.h:6
subroutine initk(NumNp, NumEl, ElConnVol, nnz, rp, cval, aval)
Definition: initK.f90:197
blockLoc i
Definition: read.cpp:79
const NT & n
j indices j
Definition: Indexing.h:6