Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
get_fint.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 !! get_fint
58 !!
59 !! FUNCTION
60 !! This subroutine constructs the internal force vector for this
61 !! processor by multiplying its part of the stiffness matrix by
62 !! the global displacment vector.
63 !!
64 !! INPUTS
65 !! ndim -- The size of one dimension of the global stiffness matrix
66 !! nrows -- The number of rows that are assigned to this processor
67 !! nnz -- The number of nonzeros in this processor's part of the stiffness matrix
68 !! nstart -- The global index of the first row assigned to this processor
69 !! rp_k -- The row mapping vector
70 !! cval_k -- The collumn mapping vector
71 !! aval_k -- The nonzero values in this processor's part of the stiffness matrix
72 !! dispin -- The part of the global displacement vector thats assigned to this processor
73 !!
74 !! OUTPUTS
75 !! fint -- The part of the global internal force vector thats assigned to this processor
76 !!
77 !! USES
78 !! MPI
79 !!
80 !!****
81 
82 SUBROUTINE get_fint(ndim,nrows,nnz,nstart,rp_k,cval_k,aval_k,dispin,fint)
83 
84  USE precision
85  USE implicit_global
87 
88  IMPLICIT NONE
89 
90  include 'mpif.h'
91 
92  ! Input variables
93  INTEGER :: ndim, nrows, nnz, nstart
94  INTEGER, DIMENSION(nrows+1) :: rp_k
95  INTEGER, DIMENSION(nnz) :: cval_k
96  REAL(kind=wp), DIMENSION(nnz) :: aval_k
97  REAL(kind=wp), DIMENSION(nrows) :: dispin
98 
99  ! Output variables
100  REAL(kind=wp), DIMENSION(nrows) :: fint
101 
102  ! Internal variables
103  REAL(kind=wp), DIMENSION(ndim) :: disptemp
104  INTEGER, ALLOCATABLE, DIMENSION(:) :: numdispfrom
105  REAL(kind=wp), ALLOCATABLE, DIMENSION(:) :: bufsnd
106  INTEGER :: i, j, k, m, counter1, counter2
107  REAL(kind=wp) :: tempval
108  INTEGER, ALLOCATABLE, DIMENSION(:) :: req_rcv, req_snd
109  INTEGER, ALLOCATABLE, DIMENSION(:,:) :: stat_rcv, stat_snd
110 
111  !
112  ! Communicate how many pieces of disp to send to each other proc
113  !
114 
115  IF (nprocs > 1) THEN
116 
117  CALL mpi_barrier(rocstar_communicator,ierr)
118  ALLOCATE(req_rcv(1:nprocs))
119  ALLOCATE(req_snd(1:nprocs))
120  ALLOCATE(stat_snd(1:mpi_status_size,1:nprocs))
121  ALLOCATE(stat_rcv(1:mpi_status_size,1:nprocs))
122  ALLOCATE(numdispfrom(1:nprocs))
123  DO i = 1, nprocs
124  req_rcv(i) = 0
125  req_snd(i) = 0
126  DO j = 1, mpi_status_size
127  stat_rcv(j,i) = 0
128  stat_snd(j,i) = 0
129  ENDDO
130  ENDDO
131  DO i = 1, nprocs
132  IF (i-1 /= myid) THEN
133  CALL mpi_irecv(numdispfrom(i),1, &
134  mpi_integer,i-1,10,rocstar_communicator, &
135  req_rcv(i),ierr)
136  ENDIF
137  ENDDO
138  DO i = 1, nprocs
139  IF (i-1 /= myid) THEN
140  !CALL MPI_ISEND(nrows,1,MPI_INTEGER, &
141  ! i-1,10,ROCSTAR_COMMUNICATOR,req_snd(i),ierr)
142  CALL mpi_send(nrows,1,mpi_integer, &
143  i-1,10,rocstar_communicator,ierr)
144  ENDIF
145  ENDDO
146  CALL mpi_waitall(nprocs,req_rcv,stat_rcv,ierr)
147  !CALL MPI_WAITALL(nprocs,req_snd,stat_snd,ierr)
148  DEALLOCATE(req_rcv)
149  DEALLOCATE(req_snd)
150  DEALLOCATE(stat_snd)
151  DEALLOCATE(stat_rcv)
152 
153 
154 
155  !
156  ! Communicate displacement to all the other procs
157  !
158 
159  CALL mpi_barrier(rocstar_communicator,ierr)
160  ALLOCATE(req_rcv(1:nprocs))
161  ALLOCATE(req_snd(1:nprocs))
162  ALLOCATE(stat_snd(1:mpi_status_size,1:nprocs))
163  ALLOCATE(stat_rcv(1:mpi_status_size,1:nprocs))
164  DO i = 1, nprocs
165  req_rcv(i) = 0
166  req_snd(i) = 0
167  DO j = 1, mpi_status_size
168  stat_rcv(j,i) = 0
169  stat_snd(j,i) = 0
170  ENDDO
171  ENDDO
172  ALLOCATE(frmproc(1:nprocs))
173  DO i = 1, nprocs
174  IF (i-1 /= myid) THEN
175  ALLOCATE(frmproc(i)%rcvbuf(1:4*int(numdispfrom(i)/3)))
176  CALL mpi_irecv(frmproc(i)%rcvbuf(1),4*int(numdispfrom(i)/3), &
177  mpi_double_precision,i-1,10,rocstar_communicator, &
178  req_rcv(i),ierr)
179  ENDIF
180  ENDDO
181  DO i = 1, nprocs
182  IF (i-1 /= myid) THEN
183  ALLOCATE(bufsnd(1:4*lnumnp))
184  counter1 = 0
185  DO j = 1, gnumnp
186  IF ((global2local(j) /= -1) .AND. (nodeproc(global2local(j)) == myid)) THEN
187  counter1 = counter1 + 1
188  bufsnd(4*counter1-3) = j
189  bufsnd(4*counter1-2) = dispin(3*counter1-2)
190  bufsnd(4*counter1-1) = dispin(3*counter1-1)
191  bufsnd(4*counter1) = dispin(3*counter1)
192  ENDIF
193  ENDDO
194  !CALL MPI_ISEND(bufsnd,4*INT(nrows/3),MPI_DOUBLE_PRECISION, &
195  ! i-1,10,ROCSTAR_COMMUNICATOR,req_snd(i),ierr)
196  CALL mpi_send(bufsnd,4*int(nrows/3),mpi_double_precision, &
197  i-1,10,rocstar_communicator,ierr)
198  DEALLOCATE(bufsnd)
199  ENDIF
200  ENDDO
201  !CALL MPI_WAITALL(NumCommProcsFrom2,req_rcv,stat_rcv,ierr)
202  !CALL MPI_WAITALL(NumCommProcs2,req_snd,stat_snd,ierr)
203  CALL mpi_waitall(nprocs,req_rcv,stat_rcv,ierr)
204  !CALL MPI_WAITALL(nprocs,req_snd,stat_snd,ierr)
205  DEALLOCATE(req_rcv)
206  DEALLOCATE(req_snd)
207  DEALLOCATE(stat_snd)
208  DEALLOCATE(stat_rcv)
209 
210  ENDIF
211 
212  ! Create a global displacement vector
213  DO i = 1, gnumnp
214  IF ((global2local(i) /= -1) .AND. (nodeproc(global2local(i)) == myid)) THEN
215  disptemp( 3*i - 2 ) = dispin( 3*(i - (nstart-1)/3)-2 )
216  disptemp( 3*i - 1 ) = dispin( 3*(i - (nstart-1)/3)-1 )
217  disptemp( 3*i ) = dispin( 3*(i - (nstart-1)/3) )
218  ELSE
219  DO j = 1, nprocs
220  IF (j-1 /= myid) THEN
221  DO m = 1, int(numdispfrom(j)/3)
222  IF (int(frmproc(j)%rcvbuf(4*m-3)) == i) THEN
223  disptemp( 3*i - 2 ) = frmproc(j)%rcvbuf(4*m-2)
224  disptemp( 3*i - 1 ) = frmproc(j)%rcvbuf(4*m-1)
225  disptemp( 3*i ) = frmproc(j)%rcvbuf(4*m)
226  ENDIF
227  ENDDO
228  ENDIF
229  ENDDO
230  ENDIF
231  ENDDO
232  IF (nprocs > 1) DEALLOCATE(frmproc)
233 
234 
235  !
236  ! Multiply the K matrix by the displacement to find fint
237  !
238  CALL comp_row_vecmult(3*gnumnp,nrows,nnz,nstart,rp_k,cval_k,aval_k,disptemp,fint)
239 
240 
241 
242 END SUBROUTINE get_fint
243 
FT m(int i, int j) const
j indices k indices k
Definition: Indexing.h:6
subroutine comp_row_vecmult(gndim, nrows1, nnz1, nstart1, rp1, cval1, aval1, vec, ans)
blockLoc i
Definition: read.cpp:79
subroutine get_fint(ndim, nrows, nnz, nstart, rp_k, cval_k, aval_k, dispin, fint)
Definition: get_fint.f90:82
j indices j
Definition: Indexing.h:6