Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LocThermStiff_v3d8.f90
Go to the documentation of this file.
1 
2 !!****
3 !!
4 !! NAME
5 !! LocThermStiff_v3d8
6 !!
7 !! FUNCTION
8 !! This subroutine constructs the process local thermal stiffness
9 !! matrix for volumetric stess 8 node, 3d elements. The resulting
10 !! matrix is put into the variables aval_kt, cval_kt and rp_kt
11 !! in comp_row_global.
12 !!
13 !! INPUTS
14 !! coor -- Coordinates of the nodes
15 !! ElConnVol -- The connectivity table
16 !! dmat -- Material stiffness matrix
17 !! numnp -- Number of nodes
18 !! NumEl -- Number of elements
19 !! MatType -- Mapping of materials to elements
20 !! NumMatType -- Total number of materials
21 !!
22 !! OUTPUTS
23 !! none
24 !!
25 !! USES
26 !! none
27 !!
28 !!****
29 
30 SUBROUTINE locthermstiff_v3d8(coor,ElConnVol,dmat, &
31  numnp,numel,mattype,nummattype)
32 
33 
34  USE comp_row_global
35  USE implicit_global
36  USE precision
37 
38  IMPLICIT NONE
39 
40  ! ... number of node points that this process knows of
41  INTEGER :: numnp
42  ! ... number of elements that this process knows of
43  INTEGER :: numel
44  ! ... number of materials in the model
45  INTEGER :: nummattype
46  ! ... coordinate array
47  REAL*8, DIMENSION(1:3,1:numnp) :: coor
48  ! ... connectivity table for Brick
49  INTEGER, DIMENSION(1:8,1:NumEl) :: elconnvol
50  INTEGER, DIMENSION(1:NumEl) :: mattype
51 
52  ! ... Local variables
53  ! ... node numbers
54  INTEGER :: n1,n2,n3,n4,n5,n6,n7,n8
55  ! ... coordinate array
56  REAL*8, DIMENSION(1:3,1:8) :: coord
57 
58  REAL*8 :: element_volume
59  ! ... element index, material index, Gauss point index
60  INTEGER :: ielem, imat, igpt
61  ! ... shape function, derivatives, jacobian and products
62  REAL*8 :: n(8), dn(8,3), jac(3,3), jacinv(3,3), nkn(8,8), dmat(3,3),bmat(8,3)
63 
64  ! ... Gauss point coordinates
65  REAL*8, DIMENSION(1:3,1:8) :: ri = reshape( &
66  (/-0.577350269189626,-0.577350269189626,-0.577350269189626, &
67  0.577350269189626,-0.577350269189626,-0.577350269189626, &
68  0.577350269189626, 0.577350269189626,-0.577350269189626, &
69  -0.577350269189626, 0.577350269189626,-0.577350269189626, &
70  -0.577350269189626,-0.577350269189626, 0.577350269189626, &
71  0.577350269189626,-0.577350269189626, 0.577350269189626, &
72  0.577350269189626, 0.577350269189626, 0.577350269189626, &
73  -0.577350269189626, 0.577350269189626, 0.577350269189626/),(/3,8/) )
74 
75  ! ... determinant of the jacobian
76  REAL*8 :: detj
77  LOGICAL :: error, debug
78  INTEGER,parameter :: ngpts = 8
79  INTEGER :: i,k,j,l
80 
81  INTEGER :: m
82  INTEGER :: dof1, dof2
83  INTEGER :: counter
84  REAL(kind=wp) :: tempval
85 
86  ! ... Initialize the K matrix
87  ! ... find number of non-zeros in the process local thermal stiffness matrix
88  CALL ktnumnnz(numnp,numel,elconnvol,nnz_kt)
89  ALLOCATE(rp_kt(1:gnumnp+1))
90  ALLOCATE(cval_kt(1:nnz_kt))
91  ALLOCATE(aval_kt(1:nnz_kt))
92  rp_kt(:) = 0
93  cval_kt(:) = 0
94  aval_kt(:) = 0.0
95 
96  ! ... fill the cval_kt and rp_kt vectors
97  CALL ktinitcrs(numnp,numel,elconnvol,nnz_kt,rp_kt,cval_kt,aval_kt)
98 
99 
100  ! ... Loop through the elements
101  DO ielem = 1, numel
102 
103  ! ... Node positions
104  n1 = elconnvol(1,ielem)
105  n2 = elconnvol(2,ielem)
106  n3 = elconnvol(3,ielem)
107  n4 = elconnvol(4,ielem)
108  n5 = elconnvol(5,ielem)
109  n6 = elconnvol(6,ielem)
110  n7 = elconnvol(7,ielem)
111  n8 = elconnvol(8,ielem)
112 
113  ! ... x,y,z coordinates of node n#.
114  ! ... local node 1
115  coord(1,1) = coor(1,n1)
116  coord(2,1) = coor(2,n1)
117  coord(3,1) = coor(3,n1)
118  ! ... local node 2
119  coord(1,2) = coor(1,n2)
120  coord(2,2) = coor(2,n2)
121  coord(3,2) = coor(3,n2)
122  ! ... local node 3
123  coord(1,3) = coor(1,n3)
124  coord(2,3) = coor(2,n3)
125  coord(3,3) = coor(3,n3)
126  ! ... local node 4
127  coord(1,4) = coor(1,n4)
128  coord(2,4) = coor(2,n4)
129  coord(3,4) = coor(3,n4)
130  ! ... local node 5
131  coord(1,5) = coor(1,n5)
132  coord(2,5) = coor(2,n5)
133  coord(3,5) = coor(3,n5)
134  ! ... local node 6
135  coord(1,6) = coor(1,n6)
136  coord(2,6) = coor(2,n6)
137  coord(3,6) = coor(3,n6)
138  ! ... local node 7
139  coord(1,7) = coor(1,n7)
140  coord(2,7) = coor(2,n7)
141  coord(3,7) = coor(3,n7)
142  ! ... local node 8
143  coord(1,8) = coor(1,n8)
144  coord(2,8) = coor(2,n8)
145  coord(3,8) = coor(3,n8)
146 
147  ! ... Find which material this element is made of
148  imat = mattype(ielem)
149 
150  ! ... Initialize stuff
151  nkn(:,:) = 0.0
152  element_volume = 0.0
153 
154  ! ... Loop throught the gauss points in this element
155  DO igpt = 1, 8
156 
157  ! ... Find the shape functions N and the derivative dN
158  ! ... at gauss point = igpt
159  n(:) = 0.0
160  dn(:,:) = 0.0
161  CALL get_shape(ri,n,dn,igpt)
162 
163  ! ... Find the volume of the element
164  jac(1:3,1:3) = 0.0
165  jacinv(1:3,1:3) = 0.0
166  detj = 0
167 
168  CALL get_jacobien(coord,3,8,dn,jac,jacinv,detj,error)
169  element_volume = element_volume + detj ! * w
170 
171 
172  bmat(:,:) = 0.0
173  do i =1,8
174  bmat(i,:) = matmul(dn(i,:),jacinv)
175  enddo
176 
177 
178  ! ... Integrate and assemble into NkN
179  DO i = 1, 8
180  DO j = 1, 8
181  DO k = 1, 3
182  ! ... conductivity tensor 3x3
183  DO l = 1,3
184  nkn(i,j) = nkn(i,j) + dmat(k,l) * bmat(i,k) * bmat(j,k) *detj ! * w
185 
186 
187  ENDDO
188  ENDDO
189  ENDDO
190  ENDDO
191 
192  ENDDO
193 
194 
195 
196 
197  !**************************************************************
198  ! Assemble local K (i.e. matrix) into Global stiffness matrix
199  !**************************************************************
200  ! ... Loop over the first node
201  DO i = 1, 8
202  ! ... Find the corresponding global node
203  dof1 = local2global(elconnvol(i,ielem))
204 
205  ! ... Loop over second node
206  DO j = 1, 8
207 
208  ! ... Find the corresponding global node
209  dof2 = local2global(elconnvol(j,ielem))
210 
211  ! Make sure the matrix is exactly symmetric by using only values in the upper triangle of NkN
212  IF ( i <= j ) THEN
213  tempval = nkn(i,j)
214  ELSE
215  tempval = nkn(j,i)
216  ENDIF
217 
218  ! ... Place the nonzeros into the K matrix
219  IF (tempval /= 0.0) THEN
220  counter = 0
221  DO m = rp_kt(dof1)+1, rp_kt(dof1+1)
222  IF (cval_kt(m) == dof2-1) THEN
223  aval_kt(m) = aval_kt(m) + tempval
224 
225  counter = 1
226  ENDIF
227 
228  ENDDO
229  if(counter==0) print*,'WARNING: Unable to add value to K matrix at (',dof1,',',dof2,') on processor ',myid,rp_kt(dof1)+1,rp_kt(dof1+1)
230  ELSE
231  print*,myid,'ZERO DETECTED IN LOCAL STIFFNESS MATRIX!',dof1,dof2
232  END IF
233 
234  ENDDO
235  ENDDO
236  ENDDO
237 
238  ! ... the arrays are stored in global temporary arrays because pointers of unknown
239  ! ... size can't be passed as arguments
240  ALLOCATE(rp_temp(1:gnumnp+1),cval_temp(1:nnz_kt),aval_temp(1:nnz_kt))
241  nnz_temp = nnz_kt
242  rp_temp = rp_kt
243  cval_temp = cval_kt
244  aval_temp = aval_kt
245 
246  DEALLOCATE(rp_kt,cval_kt,aval_kt)
247 
248 END SUBROUTINE locthermstiff_v3d8
249 
250 
FT m(int i, int j) const
j indices k indices k
Definition: Indexing.h:6
subroutine ktnumnnz(NumNp, NumEl, ElConnVol, nnz)
Definition: KtInitCRS.f90:26
int coord[NPANE][NROW *NCOL][3]
Definition: blastest.C:86
subroutine ktinitcrs(NumNp, NumEl, ElConnVol, nnz, rp, cval, aval)
Definition: KtInitCRS.f90:146
subroutine locthermstiff_v3d8(coor, ElConnVol, dmat, numnp, NumEL, MatType, NumMatType)
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
bool debug(bool s=true)
Definition: GEM.H:193
subroutine get_shape(r, n, dn, igpt)
Definition: v3d8_me.f90:846