Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UpdateMassMatrix.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 SUBROUTINE updatemassmatrix(glb)
54 
55 !!****f* Rocfrac/Rocfrac/Source/UpdateMassMatrix.f90
56 !!
57 !! NAME
58 !! UpdateMassMatrix
59 !!
60 !! FUNCTION
61 !! Updates the mass matrix due to change in undeformed
62 !! configuration. Calls the appropriate mass matrix subroutine
63 !! and handles the parallel communication.
64 !!
65 !! INPUTS
66 !! glb -- global variables
67 !!
68 !! USES
69 !! ROCSTAR_RocFrac, V3D4_MASS, V3D4N_MASS, V3D10_MASS, V3D8_MASS
70 !!
71 !!****
72 
73  USE rocstar_rocfrac
74 
75  IMPLICIT NONE
76  include 'mpif.h'
77 
78  TYPE(rocfrac_global) :: glb
79 
80  REAL*8, ALLOCATABLE, DIMENSION(:) :: buf
81 
82  INTEGER :: j, j1, k , k1
83  INTEGER :: ierr
84  INTEGER :: totnumndcomm3
85  INTEGER :: elemstart, elemend
86 
87 
88  glb%xmass(:) = 0.d0
89 
90  IF(glb%HeatTransSoln) glb%CapctInv(:) = 0.d0
91 ! glb%TotalMassSolidp = 0.d0
92 ! glb%TotalGeomVolp = 0.d0
93 
94  IF(glb%iElType.EQ.4)THEN
95 
96  IF(.NOT.(glb%NdBasedEl))THEN
97 
98  elemstart = 1
99  DO j = 1, glb%NumMatVol
100  elemend = glb%NumElPartBndryMat(j) + elemstart - 1
101  CALL v3d4_mass(glb%MeshCoor,glb%ElConnVol,glb%MatIdVol,glb%rho,glb%xmass, &
102  glb%NumNP,glb%NumElVol,glb%NumMatVol,elemstart,elemend)
103 
104  IF(glb%HeatTransSoln) CALL v3d4_capacitance(glb%MeshCoor,glb%ElConnVol,glb%MatIdVol,glb%rho,glb%Cp,glb%CapctInv, &
105  glb%NumNP,glb%NumElVol,glb%NumMatVol,elemstart,elemend)
106 
107  elemstart = glb%NumElVolMat(j) + elemstart
108  ENDDO
109 
110  ELSE IF(glb%NdBasedEl)THEN
111 ! CALL VolNodal(glb%MeshCoor,glb%ElConnVol,glb%MatIdVol, &
112 ! glb%NumNP,glb%NumElVol,glb%NumMatVol,1,glb%NumElVol,glb%TotalMassSolidp, &
113 ! glb%NumElNeigh,glb%ElConnNd,glb%AlphaR,glb%VolUndfmd)
114 
115  CALL v3d4n_mass( &
116  glb%MeshCoor,&
117  glb%ElConnVol,&
118  glb%MatIdVol,&
119  glb%rho, &
120  glb%xmass, &
121  glb%NumNP,glb%NumElVol,glb%NumMatVol,1,glb%NumElVol,glb%TotalMassSolidp, &
122  glb%NumElNeigh,glb%ElConnNd,glb%AlphaR,glb%VolUndfmd)
123 
124  ENDIF
125 
126  ELSE IF(glb%iElType.EQ.10)THEN
127  elemstart = 1
128  DO j = 1, glb%NumMatVol
129  elemend = glb%NumElPartBndryMat(j) + elemstart - 1
130  CALL v3d10_mass(glb%MeshCoor,glb%ElConnVol,glb%MatIdVol,glb%rho,glb%xmass, &
131  glb%NumNP,glb%NumElVol,glb%NumMatVol,elemstart,elemend,glb%TotalMassSolidp)
132  IF(glb%HeatTransSoln) CALL v3d10_capacitance(glb%MeshCoor,glb%ElConnVol,glb%MatIdVol,glb%rho,glb%Cp,glb%CapctInv, &
133  glb%NumNP,glb%NumElVol,glb%NumMatVol,elemstart,elemend)
134 
135  elemstart = glb%NumElVolMat(j) + elemstart
136  ENDDO
137 
138  ELSE IF(glb%iElType.EQ.8)THEN
139  elemstart = 1
140  DO j = 1, glb%NumMatVol
141  elemend = glb%NumElPartBndryMat(j) + elemstart - 1
142  CALL v3d8_mass(glb%MeshCoor,glb%ElConnVol,glb%MatIdVol,glb%rho,glb%xmass, &
143  glb%NumNP,glb%NumElVol,glb%NumMatVol,elemstart,elemend)
144  elemstart = glb%NumElVolMat(j) + elemstart
145  ENDDO
146  ENDIF
147 
148  IF(.NOT.(glb%HeatTransSoln))THEN
149 !
150 !----- FORM THE BUFFER CONTAINING COMMUNICATED MASS MATRIX NODAL VALUES
151 !
152  totnumndcomm3 = glb%TotNumNdComm/3
153  ALLOCATE(buf(1:totnumndcomm3))
154  k1 = 1
155  DO j1 = 1, glb%TotNumNeighProcs
156  k = glb%NeighProcList(j1)
157  DO j = 1, glb%NumNdComm(j1)
158  buf(k1) = glb%xmass( glb%NdCommList(j1)%NdId(j) )
159  k1 = k1 + 1
160  ENDDO
161  ENDDO
162 !
163 !-MPI- RECEIVE THE RECIPRICAL MASS MATRIX DIAGONAL FROM THE NEIGHBORS
164 !
165  DO j1 = 1, glb%TotNumNeighProcs
166  k = glb%NeighProcList(j1)+1
167  CALL mpi_irecv(glb%RecvDataFrm(k)%rcvbuf(1),glb%NumNdComm(j1), &
168  mpi_double_precision,k-1,10,glb%MPI_COMM_ROCFRAC,glb%ReqRcv(j1),ierr)
169  ENDDO
170 !
171 !-MPI- SEND THE RECIPRICAL MASS MATRIX DIAGONAL TO THE NEIGHBORS
172 !
173  k1 = 1
174  DO j1 = 1, glb%TotNumNeighProcs
175  k = glb%NeighProcList(j1)
176  CALL mpi_isend(buf(k1),glb%NumNdComm(j1), &
177  mpi_double_precision,k,10,glb%MPI_COMM_ROCFRAC,glb%ReqSnd(j1),ierr)
178  k1 = k1 + glb%NumNdComm(j1)
179  ENDDO
180 
181  ELSE ! Pass the heat transfer capacitance to neighboring processors
182 
183 !
184 !----- FORM THE BUFFER CONTAINING COMMUNICATED MASS MATRIX NODAL VALUES
185 !
186  totnumndcomm3 = ( glb%TotNumNdComm/3 )*2
187  ALLOCATE(buf(1:totnumndcomm3))
188  k1 = 1
189  DO j1 = 1, glb%TotNumNeighProcs
190  k = glb%NeighProcList(j1)
191  DO j = 1, glb%NumNdComm(j1)
192  buf(k1) = glb%xmass( glb%NdCommList(j1)%NdId(j) )
193  buf(k1+1) = glb%CapctInv( glb%NdCommList(j1)%NdId(j) )
194  k1 = k1 + 2
195  ENDDO
196  ENDDO
197 
198 
199 !
200 !-MPI- RECEIVE THE RECIPRICAL MASS MATRIX DIAGONAL FROM THE NEIGHBORS
201 !
202  DO j1 = 1, glb%TotNumNeighProcs
203  k = glb%NeighProcList(j1)+1
204  CALL mpi_irecv(glb%RecvDataFrm(k)%rcvbuf(1),glb%NumNdComm(j1)*2, &
205  mpi_double_precision,k-1,10,glb%MPI_COMM_ROCFRAC,glb%ReqRcv(j1),ierr)
206  ENDDO
207 !
208 !-MPI- SEND THE RECIPRICAL MASS MATRIX DIAGONAL TO THE NEIGHBORS
209 !
210  k1 = 1
211  DO j1 = 1, glb%TotNumNeighProcs
212  k = glb%NeighProcList(j1)
213  CALL mpi_isend(buf(k1),glb%NumNdComm(j1)*2, &
214  mpi_double_precision,k,10,glb%MPI_COMM_ROCFRAC,glb%ReqSnd(j1),ierr)
215  k1 = k1 + glb%NumNdComm(j1)*2
216  ENDDO
217 
218  ENDIF
219 
220 !
221 !----- CALCULATE THE INTERIOR SUBMESH'S RECIPRICAL MASS MATRIX DIAGONAL
222 !
223 
224  IF(glb%iElType.EQ.4)THEN
225  IF(glb%iSolnType(1).LT.10)THEN
226  elemend = 0
227  DO j = 1, glb%NumMatVol
228  elemstart = elemend + glb%NumElPartBndryMat(j) + 1
229  elemend = glb%NumElVolMat(j) + elemend
230  CALL v3d4_mass(glb%MeshCoor,glb%ElConnVol,glb%MatIdVol,glb%rho,glb%xmass, &
231  glb%NumNP,glb%NumElVol,glb%NumMatVol,elemstart,elemend)
232 
233  IF(glb%HeatTransSoln) CALL v3d4_capacitance(glb%MeshCoor,glb%ElConnVol,glb%MatIdVol,glb%rho,glb%Cp,glb%CapctInv, &
234  glb%NumNP,glb%NumElVol,glb%NumMatVol,elemstart,elemend)
235  ENDDO
236  ENDIF
237  ELSE IF(glb%iElType.EQ.10)THEN
238  elemend = 0
239  DO j = 1, glb%NumMatVol
240  elemstart = elemend + glb%NumElPartBndryMat(j) + 1
241  elemend = glb%NumElVolMat(j) + elemend
242  CALL v3d10_mass(glb%MeshCoor,glb%ElConnVol,glb%MatIdVol,glb%rho,glb%xmass, &
243  glb%NumNP,glb%NumElVol,glb%NumMatVol,elemstart,elemend,glb%TotalMassSolidp)
244 
245  IF(glb%HeatTransSoln) CALL v3d10_capacitance(glb%MeshCoor,glb%ElConnVol,glb%MatIdVol,glb%rho,glb%Cp,glb%CapctInv, &
246  glb%NumNP,glb%NumElVol,glb%NumMatVol,elemstart,elemend)
247 
248  ENDDO
249 
250  ELSE IF(glb%iElType.EQ.8)THEN
251  elemend = 0
252  DO j = 1, glb%NumMatVol
253  elemstart = elemend + glb%NumElPartBndryMat(j) + 1
254  elemend = glb%NumElVolMat(j) + elemend
255  CALL v3d8_mass(glb%MeshCoor,glb%ElConnVol,glb%MatIdVol,glb%rho,glb%xmass, &
256  glb%NumNP,glb%NumElVol,glb%NumMatVol,elemstart,elemend)
257  ENDDO
258 
259 
260  ENDIF
261 !
262 !-MPI- WAIT FOR THE RECIPRICAL MASS MATRIX DIAGONAL COMMUNICATION
263 ! TO COMPLETE
264 !
265 
266 
267  IF(glb%TotNumNeighProcs.GT.0)THEN
268  CALL mpi_waitall(glb%TotNumNeighProcs,glb%ReqRcv,glb%StatRcv,ierr)
269  CALL mpi_waitall(glb%TotNumNeighProcs,glb%ReqSnd,glb%StatSnd,ierr)
270  ENDIF
271  DEALLOCATE(buf)
272 !
273 !----- ADD NEIGHBOR'S CONTRIBUTION TO THE RECIPRICAL MASS
274 ! MATRIX DIAGONAL
275 !
276 
277 
278  IF(.NOT.(glb%HeatTransSoln))THEN
279  DO j1 = 1, glb%TotNumNeighProcs
280  k = glb%NeighProcList(j1)+1
281  DO j = 1, glb%NumNdComm(j1)
282  k1 = glb%NdCommList(j1)%NdId(j)
283  glb%xmass(k1) = glb%xmass(k1) + glb%RecvDataFrm(k)%rcvbuf(j)
284  ENDDO
285  ENDDO
286 
287  ELSE
288 
289  DO j1 = 1, glb%TotNumNeighProcs
290  k = glb%NeighProcList(j1)+1
291  DO j = 1, glb%NumNdComm(j1)
292  k1 = glb%NdCommList(j1)%NdId(j)
293  glb%xmass(k1) = glb%xmass(k1) + glb%RecvDataFrm(k)%rcvbuf(j*2-1)
294  glb%CapctInv(k1) = glb%CapctInv(k1) + glb%RecvDataFrm(k)%rcvbuf(j*2)
295  ENDDO
296  ENDDO
297 
298  ENDIF
299  glb%xmass(:) = 1.d0/glb%xmass(:)
300 
301  IF(glb%HeatTransSoln) glb%CapctInv(:) = 1./glb%CapctInv(:)
302 
303 
304  IF(glb%iSolnType(1).GE.10)THEN
305 
306  ALLOCATE(buf(1:totnumndcomm3))
307  k1 = 1
308  DO j1 = 1, glb%TotNumNeighProcs
309  k = glb%NeighProcList(j1)
310  DO j = 1, glb%NumNdComm(j1)
311  buf(k1) = glb%VolUndfmd( glb%NdCommList(j1)%NdId(j) )
312  k1 = k1 + 1
313  ENDDO
314  ENDDO
315 !
316 !-MPI- RECEIVE THE RECIPRICAL MASS MATRIX DIAGONAL FROM THE NEIGHBORS
317 !
318  DO j1 = 1, glb%TotNumNeighProcs
319  k = glb%NeighProcList(j1)+1
320  CALL mpi_irecv(glb%RecvDataFrm(k)%rcvbuf(1),glb%NumNdComm(j1), &
321  mpi_double_precision,k-1,10,glb%MPI_COMM_ROCFRAC,glb%ReqRcv(j1),ierr)
322  ENDDO
323 !
324 !-MPI- SEND THE RECIPRICAL MASS MATRIX DIAGONAL TO THE NEIGHBORS
325 !
326  k1 = 1
327  DO j1 = 1, glb%TotNumNeighProcs
328  k = glb%NeighProcList(j1)
329  CALL mpi_isend(buf(k1),glb%NumNdComm(j1), &
330  mpi_double_precision,k,10,glb%MPI_COMM_ROCFRAC,glb%ReqSnd(j1),ierr)
331  k1 = k1 + glb%NumNdComm(j1)
332  ENDDO
333 !
334 !-MPI- WAIT FOR THE RECIPRICAL MASS MATRIX DIAGONAL COMMUNICATION
335 ! TO COMPLETE
336 !
337  IF(glb%TotNumNeighProcs.GT.0)THEN
338  CALL mpi_waitall(glb%TotNumNeighProcs,glb%ReqRcv,glb%StatRcv,ierr)
339  CALL mpi_waitall(glb%TotNumNeighProcs,glb%ReqSnd,glb%StatSnd,ierr)
340  ENDIF
341  DEALLOCATE(buf)
342 !
343 !----- ADD NEIGHBOR'S CONTRIBUTION TO THE RECIPRICAL MASS
344 ! MATRIX DIAGONAL
345 !
346  DO j1 = 1, glb%TotNumNeighProcs
347  k = glb%NeighProcList(j1)+1
348  DO j = 1, glb%NumNdComm(j1)
349  k1 = glb%NdCommList(j1)%NdId(j)
350  glb%VolUndfmd(k1) = glb%VolUndfmd(k1) + glb%RecvDataFrm(k)%rcvbuf(j)
351  ENDDO
352  ENDDO
353  ENDIF
354 
355  RETURN
356 END SUBROUTINE updatemassmatrix
357 
subroutine v3d4_mass(coor, lmcstet, matcstet, rho, xm, numnp, numcstet, numat_vol, nstart, nend)
Definition: v3d4_mass.f90:53
j indices k indices k
Definition: Indexing.h:6
subroutine v3d8_mass(coor, nodes, MatType, rho, xm, NumNP, NumEl, NumMat, nstart, nend)
Definition: v3d8_mass.f90:53
subroutine v3d10_capacitance(coor, lmcstet, matcstet, Rho, Cp, Capct, numnp, numcstet, numat_vol, nstart, nend)
subroutine v3d10_mass(coor, lmcstet, matcstet, rho, xm, numnp, numcstet, numat_vol, nstart, nend, TotalMass)
Definition: v3d10_mass.f90:53
subroutine v3d4_capacitance(coor, lmcstet, matcstet, Rho, Cp, Capct, numnp, numcstet, numat_vol, nstart, nend)
subroutine updatemassmatrix(glb)
j indices j
Definition: Indexing.h:6
subroutine v3d4n_mass(coor, lmcstet, matcstet, rho, xm, numnp, numcstet, numat_vol, nstart, nend, TotalMass, NumElNeigh, ElConn, Alpha, Vhat)
Definition: v3d4n_mass.f90:53