Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
removeBCs.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 !! removeBCs_meff
58 !!
59 !! FUNCTION
60 !! This subroutine removes rows and collumns from the effective
61 !! mass matrix that are associated with perscribed boundary
62 !! conditions. The new effective mass matrix is then put into
63 !! the global variables in comp_row_global.
64 !!
65 !! INPUTS
66 !! ndim -- The size of one dimension of the global Meff matrix
67 !! nrows -- The number of rows assigned to this processor
68 !! nnz -- The number of nonzeros in section of the Meff matrix on this processor
69 !! nstart -- The global index of the first row assigned to this processor
70 !! rp1 -- The row mapping vector
71 !! cval -- The collumn mapping vector
72 !! aval -- The nonzero value vector
73 !!
74 !! OUTPUTS
75 !! newnrows -- The number of rows assigned to this proc after BCs have been removed
76 !! newnstart -- The global index of the first row assigned to this proc after BCs have been removed
77 !! newndim -- The size of the global Meff matrix after BCs have been removed
78 !!
79 !! USES
80 !! none
81 !!
82 !!****
83 
84 SUBROUTINE removebcs_meff(ndim,nrows,nnz,nstart,rp1,cval,aval,newnrows,newnstart,newndim,global)
85 
87  USE comp_row_global
88  USE implicit_global
89  USE precision
91 
92  IMPLICIT NONE
93 
94  include 'mpif.h'
95 
96  TYPE(rocfrac_global) :: global
97 
98  INTEGER :: i, j, m, counter1, counter2, counter3, counter4, counter5
99 
100  INTEGER :: ndim, nnz, nstart, nrows
101  REAL(kind=wp), DIMENSION(nnz) :: aval
102  INTEGER, DIMENSION(nnz) :: cval
103  INTEGER, DIMENSION(nrows+1) :: rp1
104 
105  INTEGER :: numdisp ! Local number of displacement BCs
106  INTEGER, ALLOCATABLE, DIMENSION(:) :: dispbc ! Local displacement BCs
107  INTEGER, ALLOCATABLE, DIMENSION(:) :: tempintv
108  INTEGER :: newnrows
109  INTEGER :: newnstart
110  INTEGER :: newndim
111 
112 
113  ! Count the number of displacement BCs locally
114  numdisp = 0
115  DO i = 1, global%NumNp
116  IF (nodeproc(i) == myid) THEN
117  DO j = 1, 3
118  IF(node_flag(i,j) == 8) THEN ! Imposed constant nodal displacement
119  numdisp = numdisp + 1
120  ENDIF
121  ENDDO
122  ENDIF
123  ENDDO
124  !print*,myid,' number of local disp BCs = ',numdisp
125 
126  ! Sum the local disp BCs, then broadcast to all procs
127  CALL mpi_barrier(rocstar_communicator,ierr)
128  CALL mpi_reduce(numdisp, gnumdisp, 1, mpi_integer, mpi_sum, 0 , rocstar_communicator, ierr)
129  CALL mpi_bcast(gnumdisp, 1, mpi_integer, 0, rocstar_communicator, ierr)
130  newndim = 3*gnumnp - gnumdisp
131  !print*,myid,' number of global disp BCs = ',gnumdisp
132 
133  ! Figure out which DOF have displacements perscribed
134  IF(numdisp > 0) THEN
135  ALLOCATE(dispbc(1:numdisp))
136  dispbc(:) = 0
137  counter2 = 0
138  DO m = 1, gnumnp
139  DO i = 1, global%NumNp
140  IF (local2global(i) == m) THEN
141  IF (nodeproc(i) == myid) THEN
142  DO j = 1, 3
143  IF(node_flag(i,j) == 8) THEN ! Imposed constant nodal displacement
144  counter2 = counter2 + 1
145  dispbc(counter2) = 3*m - 3 + j
146  ENDIF
147  ENDDO
148  ENDIF
149  ENDIF
150  ENDDO
151  ENDDO
152  ENDIF
153  !print*,myid,' local disp bcs = ',dispbc(:)
154 
155  ! Have each proc in turn broadcast its number of displacement BCs to the other procs
156  ALLOCATE(numdispproc(1:nprocs))
157  numdispproc(:) = 0
158  numdispproc(myid+1) = numdisp
159  DO i = 1, nprocs
160  CALL mpi_bcast(numdispproc(i), 1, mpi_integer, i-1, rocstar_communicator, ierr)
161  ENDDO
162  newnstart = nstart
163  DO i = 1, myid
164  newnstart = newnstart - numdispproc(i)
165  ENDDO
166  !print*,myid,' number of disp bcs on other procs = ',numdispproc(:)
167 
168  ! Have each proc in turn broadcast the numbers of its displacement BCs
169  ALLOCATE(gdispbc(1:gnumdisp))
170  gdispbc(:) = 0
171  counter1 = 0
172  DO i = 1, nprocs
173  IF (numdispproc(i) > 0) THEN
174  ALLOCATE(tempintv(1:numdispproc(i)))
175  tempintv(:) = 0
176  if (i-1 == myid) tempintv(:) = dispbc(:)
177  CALL mpi_bcast(tempintv(1), numdispproc(i), mpi_integer, i-1, rocstar_communicator, ierr)
178  DO j = 1, numdispproc(i)
179  counter1 = counter1 + 1
180  gdispbc(counter1) = tempintv(j)
181  ENDDO
182  DEALLOCATE(tempintv)
183  ENDIF
184  ENDDO
185  !print*,myid,' global disp bcs = ',gdispbc(:)
186 
187 
188 
189  ! Count nonzeros in new matrix
190  nnz_temp = 0
191  counter2 = 0
192  DO i = 1, nrows
193  DO j = rp1(i)+1, rp1(i+1)
194  counter2 = counter2 + 1
195  counter1 = 0
196  DO m = 1, gnumdisp
197  IF((gdispbc(m) == i + nstart - 1).OR.(gdispbc(m) == cval(counter2)+1)) THEN
198  counter1 = 1
199  ENDIF
200  ENDDO
201  !if(counter1==1) print*,myid,' non-zero removed at ',i+nstart-1,cval(counter2)+1
202  IF(counter1 == 0) nnz_temp = nnz_temp + 1
203  ENDDO
204  ENDDO
205 
206  ! Count rows in new matrix
207  newnrows = 0
208  counter2 = 0
209  DO i = 1, nrows
210  counter1 = 0
211  DO m = 1, gnumdisp
212  IF(gdispbc(m) == i + nstart - 1) THEN
213  counter1 = 1
214  ENDIF
215  ENDDO
216  !if(counter1==1) print*,myid,' row removed at ',i+nstart-1
217  IF(counter1 == 0) newnrows = newnrows + 1
218  ENDDO
219 
220  ! Allocate variables for new matrix
221  ALLOCATE(rp_temp(1:newnrows+1))
222  ALLOCATE(cval_temp(1:nnz_temp))
223  ALLOCATE(aval_temp(1:nnz_temp))
224 
225  ! Construct new matrix
226  counter2 = 0
227  counter3 = 0
228  counter4 = 0
229  rp_temp(1) = 0
230  DO i = 1, nrows
231  DO j = rp1(i)+1, rp1(i+1)
232  counter2 = counter2 + 1
233  counter1 = 0
234  counter5 = 0
235  DO m = 1, gnumdisp
236  IF(gdispbc(m) < cval(counter2)+1) THEN
237  counter5 = counter5 + 1
238  ENDIF
239  IF((gdispbc(m) == i + nstart - 1).OR.(gdispbc(m) == cval(counter2)+1)) THEN
240  counter1 = 1
241  ENDIF
242  ENDDO
243  IF(counter1 == 0) THEN
244  counter3 = counter3 + 1
245  aval_temp(counter3) = aval(counter2)
246  cval_temp(counter3) = cval(counter2) - counter5
247  ENDIF
248  ENDDO
249  counter1 = 0
250  DO m = 1, gnumdisp
251  IF(gdispbc(m) == i + nstart - 1) THEN
252  counter1 = 1
253  ENDIF
254  ENDDO
255  IF(counter1 == 0) THEN
256  counter4 = counter4 + 1
257  rp_temp(counter4+1) = counter3
258  ENDIF
259  ENDDO
260 
261 
262 END SUBROUTINE removebcs_meff
263 
264 
265 
266 
267 
268 
269 
270 
271 
272 
273 
274 
275 
276 
277 
278 
279 
280 !!****
281 !!
282 !! NAME
283 !! removeBCs_pbar
284 !!
285 !! FUNCTION
286 !! This subroutine removes values from the load vector
287 !! that are associated with perscribed boundary
288 !! conditions.
289 !!
290 !! INPUTS
291 !! ndim -- The size of one dimension of the global Meff matrix
292 !! nstart -- The global index of the first row assigned to this processor
293 !! pbar -- The part of the global load vector that is assigned to this processor
294 !! newndim -- The size of the global Meff matrix after BCs have been removed
295 !!
296 !! OUTPUTS
297 !! newpbar -- The part of the global load vector that is assigned to this processor after BCs have been removed
298 !!
299 !! USES
300 !! none
301 !!
302 !!****
303 
304 SUBROUTINE removebcs_pbar(nstart,ndim,pbar,newndim,newpbar)
305 
306  USE removebcs_global
307  USE comp_row_global
308  USE implicit_global
309  USE precision
310 
311  IMPLICIT NONE
312 
313  include 'mpif.h'
314 
315  INTEGER :: i, m, counter1, counter2
316 
317  INTEGER :: ndim, newndim, nstart
318  REAL(kind=wp), DIMENSION(ndim) :: pbar
319  REAL(kind=wp), DIMENSION(newndim) :: newpbar
320 
321 
322  ! Construct new vector
323  counter2 = 0
324  DO i = 1, ndim
325  counter1 = 0
326  DO m = 1, gnumdisp
327  IF(gdispbc(m) == i + nstart - 1) THEN
328  counter1 = 1
329  ENDIF
330  ENDDO
331  IF(counter1 == 0) THEN
332  counter2 = counter2 + 1
333  newpbar(counter2) = pbar(i)
334  ENDIF
335  ENDDO
336 
337 
338 END SUBROUTINE removebcs_pbar
339 
340 
341 
342 
343 
344 
345 
346 
347 
348 !!****
349 !!
350 !! NAME
351 !! removeBCs_newa
352 !!
353 !! FUNCTION
354 !! This subroutine takes the acceleration vector that
355 !! does not include boundary conditions and expands it
356 !! back into the acceleration vector with rows associated
357 !! with boundary conditions in it.
358 !!
359 !! INPUTS
360 !! ndim -- The size of one dimension of the global Meff matrix
361 !! nstart -- The global index of the first row assigned to this processor
362 !! newa -- The part of the global acceleration vector assigned to this proc without rows associated with boundary conditions
363 !! newndim -- The size of the global Meff matrix after BCs have been removed
364 !!
365 !! OUTPUTS
366 !! a -- The part of the global acceleration vector assigned to this proc with rows associated with boundary conditions
367 !!
368 !! USES
369 !! none
370 !!
371 !!****
372 
373 SUBROUTINE removebcs_newa(nstart,ndim,a,newndim,newa)
374 
375  USE removebcs_global
376  USE comp_row_global
377  USE implicit_global
378  USE precision
379 
380  IMPLICIT NONE
381 
382  include 'mpif.h'
383 
384  INTEGER :: i, m, counter1, counter2, counter3
385 
386  INTEGER :: ndim, newndim, nstart
387  REAL(kind=wp), DIMENSION(ndim) :: a
388  REAL(kind=wp), DIMENSION(newndim) :: newa
389 
390 
391  ! Construct new vector
392  counter2 = 0
393  DO i = 1, newndim
394  counter3 = 0
395  DO m = 1, gnumdisp
396  IF((gdispbc(m) <= i + counter3 + nstart - 1).AND.(gdispbc(m) >= nstart)) THEN
397  counter3 = counter3 + 1
398  ENDIF
399  ENDDO
400  a(i+counter3) = newa(i)
401  !if(myid==2) print*,myid,i,counter3,i+counter3
402  ENDDO
403 
404 
405 END SUBROUTINE removebcs_newa
406 
FT m(int i, int j) const
subroutine removebcs_newa(nstart, ndim, a, newndim, newa)
Definition: removeBCs.f90:373
subroutine removebcs_meff(ndim, nrows, nnz, nstart, rp1, cval, aval, newnrows, newnstart, newndim, global)
Definition: removeBCs.f90:84
blockLoc i
Definition: read.cpp:79
subroutine removebcs_pbar(nstart, ndim, pbar, newndim, newpbar)
Definition: removeBCs.f90:304
j indices j
Definition: Indexing.h:6
RT a() const
Definition: Line_2.h:140