Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
implicit_v3d8_mass_consistent.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 !! implicit_v3d8_mass_consistent
58 !!
59 !! FUNCTION
60 !! This subroutine constructs the global mass matrix as a
61 !! consistent matrix. The resulting matrix is put into
62 !! the variables in comp_row_global.
63 !!
64 !! INPUTS
65 !! NumEl -- The number of elements that this processor knows about
66 !! NumNp -- The number of nodes that this processor knows about
67 !! NumMat -- The global number of materials in the structure
68 !! coor -- The coordinates of each of the nodes
69 !! nodes -- The connectivity table
70 !! MatType -- Mapping of material types to elements
71 !! ri -- Gauss point positions within an element
72 !! rho -- Density of the materials
73 !! ElConnVol -- The connectivity table (redundant)
74 !!
75 !! OUTPUTS
76 !! none
77 !!
78 !! USES
79 !! none
80 !!
81 !!****
82 
83 SUBROUTINE implicit_v3d8_mass_consistent( NumEl, NumNP, NumMat, &
84  coor, nodes, mattype, ri, rho ,elconnvol )
85 
86  USE precision
87  USE implicit_global
88  USE comp_row_global
89 
90  IMPLICIT NONE
91 
92  ! Input variables
93  INTEGER :: numel, numnp, nummat
94  INTEGER, DIMENSION(1:NumEl) :: mattype
95  INTEGER, DIMENSION(1:8,1:NumEl) :: nodes
96  REAL(KIND=wp), DIMENSION(1:3,1:NumNP) :: coor
97  REAL(KIND=wp), DIMENSION(1:3,1:8) :: ri
98  REAL(KIND=wp), DIMENSION(1:NumMat) :: rho
99  INTEGER, DIMENSION(1:8,1:NumEl) :: elconnvol
100 
101  ! Internal variables
102  REAL(kind=wp), DIMENSION(1:8) :: n
103  REAL(kind=wp), DIMENSION(1:8,1:3) :: dn
104  REAL(kind=wp), DIMENSION(1:8,1:8) :: ntn
105  INTEGER :: igpt
106  INTEGER :: ngpts = 8
107  INTEGER :: ielem
108  INTEGER :: imat
109  INTEGER :: i, j
110  INTEGER :: dof1, dof2, gdof1, gdof2, ldof1, ldof2
111  REAL(kind=wp) :: tempval
112  INTEGER :: nnzold
113  REAL(kind=wp) :: element_volume
114  REAL(kind=wp), DIMENSION(1:3,1:3) :: jac, jacinv
115  REAL(kind=wp) :: detj
116  LOGICAL :: error
117  INTEGER :: n1,n2,n3,n4,n5,n6,n7,n8
118  REAL(kind=wp),DIMENSION(1:3,1:8) :: coord
119 
120  ! Output variables
121  INTEGER, ALLOCATABLE, DIMENSION(:) :: rp, cval
122  REAL(KIND=wp), ALLOCATABLE, DIMENSION(:) :: aval
123  INTEGER :: nnz
124 
125  ! Initialize the output variables
126  ALLOCATE(rp(1:3*gnumnp+1))
127  ALLOCATE(cval(1:1))
128  ALLOCATE(aval(1:1))
129  nnz = 1
130  rp(1) = 0
131  rp(2:3*gnumnp+1) = 1
132  cval(1) = 0
133  aval(1) = 0.0
134 
135  ! Loop through the elements
136  DO ielem = 1, numel
137 
138  ! Node positions
139  n1 = nodes(1,ielem)
140  n2 = nodes(2,ielem)
141  n3 = nodes(3,ielem)
142  n4 = nodes(4,ielem)
143  n5 = nodes(5,ielem)
144  n6 = nodes(6,ielem)
145  n7 = nodes(7,ielem)
146  n8 = nodes(8,ielem)
147  coord(1,1) = coor(1,n1)
148  coord(2,1) = coor(2,n1)
149  coord(3,1) = coor(3,n1)
150  coord(1,2) = coor(1,n2)
151  coord(2,2) = coor(2,n2)
152  coord(3,2) = coor(3,n2)
153  coord(1,3) = coor(1,n3)
154  coord(2,3) = coor(2,n3)
155  coord(3,3) = coor(3,n3)
156  coord(1,4) = coor(1,n4)
157  coord(2,4) = coor(2,n4)
158  coord(3,4) = coor(3,n4)
159  coord(1,5) = coor(1,n5)
160  coord(2,5) = coor(2,n5)
161  coord(3,5) = coor(3,n5)
162  coord(1,6) = coor(1,n6)
163  coord(2,6) = coor(2,n6)
164  coord(3,6) = coor(3,n6)
165  coord(1,7) = coor(1,n7)
166  coord(2,7) = coor(2,n7)
167  coord(3,7) = coor(3,n7)
168  coord(1,8) = coor(1,n8)
169  coord(2,8) = coor(2,n8)
170  coord(3,8) = coor(3,n8)
171 
172  ! Find which material this element is made of
173  imat = mattype(ielem)
174 
175  ! Initialize stuff
176  ntn(:,:) = 0.0
177  element_volume = 0.0
178 
179  ! Loop throught the gauss points in this element
180  DO igpt = 1, ngpts
181 
182  ! Find the shape functions
183  n(:) = 0.0
184  dn(:,:) = 0.0
185  CALL get_shape(ri,n,dn,igpt)
186 
187  ! Find the volume of the element
188  jac(1:3,1:3) = 0.0
189  jacinv(1:3,1:3) = 0.0
190  CALL get_jacobien(coord,3,8,dn,jac,jacinv,detj,error)
191  element_volume = element_volume + detj ! * w
192 
193  ! Integrate and assemble into NtN
194  DO i = 1, 8
195  DO j = 1, 8
196  ntn(i,j) = ntn(i,j) + rho(imat)*n(i)*n(j)*detj ! * w
197  ENDDO
198  ENDDO
199 
200  ENDDO
201 
202  ! Put these parts of the mass matrix into the global mass matrix
203  DO dof1 = 1, 3 ! dof1 loop
204  DO i = 1, 8 ! node1 loop
205  gdof1 = 3 * local2global(elconnvol(i,ielem)) - 3 + dof1
206  ldof1 = i
207  DO j = 1, 8 ! node2 loop
208  ldof2 = j
209  gdof2 = 3 * local2global(elconnvol(j,ielem)) - 3 + dof1
210 
211  ! Make sure the matrix is exactly symmetric
212  IF ( ldof1 <= ldof2 ) THEN
213  tempval = ntn(ldof1,ldof2)
214  ELSE
215  tempval = ntn(ldof2,ldof1)
216  ENDIF
217 
218  IF ( tempval == 0.0 ) THEN
219  print*,'ZERO DETECTED IN LOCAL MASS MATRIX!',gdof1,gdof2,myid
220  END IF
221 
222  ! Add the value to the global matrix
223  nnzold = nnz
224  CALL comp_row_addval(3*gnumnp,3*gnumnp,nnz,1,rp,cval,aval,gdof1,gdof2,tempval)
225  nnz = nnz_temp
226  IF (nnzold /= nnz) THEN
227  DEALLOCATE(cval)
228  DEALLOCATE(aval)
229  ALLOCATE(cval(1:nnz))
230  ALLOCATE(aval(1:nnz))
231  rp = rp_temp
232  cval = cval_temp
233  ENDIF
234  aval = aval_temp
235  DEALLOCATE(rp_temp)
236  DEALLOCATE(cval_temp)
237  DEALLOCATE(aval_temp)
238 
239  ENDDO
240  ENDDO
241  ENDDO
242 
243  ENDDO
244 
245  ! Put the output variables into global variables
246  nnz_temp = nnz
247  ALLOCATE(rp_temp(1:3*gnumnp+1))
248  ALLOCATE(cval_temp(1:nnz_temp))
249  ALLOCATE(aval_temp(1:nnz_temp))
250  rp_temp = rp
251  cval_temp = cval
252  aval_temp = aval
253  DEALLOCATE(rp)
254  DEALLOCATE(cval)
255  DEALLOCATE(aval)
256 
257 
258 END SUBROUTINE implicit_v3d8_mass_consistent
259 
int coord[NPANE][NROW *NCOL][3]
Definition: blastest.C:86
subroutine get_jacobien(coords, mcrd, nnode, dn, jac, jacinv, detj, error)
Definition: v3d8_me.f90:1003
blockLoc i
Definition: read.cpp:79
const NT & n
virtual std::ostream & print(std::ostream &os) const
j indices j
Definition: Indexing.h:6
subroutine implicit_v3d8_mass_consistent(NumEl, NumNP, NumMat, coor, nodes, MatType, ri, rho, ElConnVol)
subroutine get_shape(r, n, dn, igpt)
Definition: v3d8_me.f90:846
subroutine comp_row_addval(ndim, nrows, nnz, nstart, rp, cval, aval, ipos, jpos, val)