Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GlbThermStiff.f90
Go to the documentation of this file.
1 !!****
2 !!
3 !! NAME
4 !! GlbThermStiff
5 !!
6 !! FUNCTION
7 !! This subroutine constructs the global thermal stiffness matrix,
8 !! in CRS format. The matrix information is stored in global
9 !! variables: rp_kt, aval_kt, cval_kt, nnz_kt, nrows_ktc, nstart_ktc
10 !!
11 !! INPUTS
12 !! none
13 !!
14 !! OUTPUTS
15 !! none
16 !!
17 !! USES
18 !! none
19 !!
20 !!****
21 
22 SUBROUTINE glbthermstiff(global)
23 
24  USE implicit_global
25  USE comp_row_global
27 
28  IMPLICIT NONE
29 
30  include 'mpif.h'
31 
32  TYPE int_buf
33  INTEGER, DIMENSION(:), POINTER :: rcvbuf
34  END TYPE int_buf
35 
36  TYPE(rocfrac_global) :: global
37  INTEGER :: i, j, m, p, inode, jnode, counter
38  REAL(kind=wp) :: tempkval
39 
40  INTEGER, ALLOCATABLE, DIMENSION(:) :: amounttoreceive, amounttosend
41  REAL(kind=wp), ALLOCATABLE, DIMENSION(:) :: bufsnd
42 
43 
44 
45 
46  IF(myid==0) print*,'CONSTRUCTING THE THERMAL STIFFNESS MATRIX'
47 
48  ! ... Construct the process local thermal stiffness matrix
49  CALL locthermstiff_v3d8(global%MeshCoor, global%ElConnVol, global%dmat(1,:,:), global%NumNp, &
50  global%NumElVol, global%MatIdVol, global%NumMatVol)
51 
52 
53  ALLOCATE(rp_kt(1:gnumnp+1))
54  ALLOCATE(cval_kt(1:nnz_temp))
55  ALLOCATE(aval_kt(1:nnz_temp))
56  nnz_kt = nnz_temp
57  rp_kt = rp_temp
58  cval_kt = cval_temp
59  aval_kt = aval_temp
60  DEALLOCATE(rp_temp,cval_temp,aval_temp)
61 
62 
63  IF(myid==0) print*,'COMMUNICATING THE THERMAL STIFFNESS MATRIX TO OTHER PROCS'
64 
65  ! ... Communicate stiffness to the other processes
66  ! ... boundary nodes on this process are communicated to the processes
67  ! ... to which they are assigned
68  IF (nprocs > 1) THEN
69  CALL mpi_barrier(rocstar_communicator,ierr)
70  ! ... initialize request and status variables for MPI sends and receives
71  ALLOCATE(req_rcv(1:nprocs))
72  ALLOCATE(req_snd(1:nprocs))
73  ALLOCATE(stat_snd(1:mpi_status_size,1:nprocs))
74  ALLOCATE(stat_rcv(1:mpi_status_size,1:nprocs))
75  DO i = 1, nprocs
76  req_rcv(i) = 0
77  req_snd(i) = 0
78  DO j = 1, mpi_status_size
79  stat_rcv(1,i) = 0
80  stat_snd(j,i) = 0
81  ENDDO
82  ENDDO
83 
84  ! ... number of nodes each process will send to this process
85  ! ... (nodes owned by this process but in the partition of other processes)
86  ALLOCATE(amounttoreceive(1:numcommprocsfrom1))
87  DO i = 1, numcommprocsfrom1
88  CALL mpi_irecv(amounttoreceive(i),1, &
89  mpi_integer,commprocsfrom1(i),10,rocstar_communicator, &
90  req_rcv(i),ierr)
91  ENDDO
92 
93  ! ... number of nodes each process will be sent from this process
94  ! ... (nodes owned by other processes but in the partition of this one)
95  ALLOCATE(amounttosend(1:numcommprocs1))
96  DO i = 1, numcommprocs1
97  counter = 0
98  ! ... loop through the nodes going to be sent to process i
99  DO j = 1, numcommnodes1(i)
100  ! ... inode is the global node number corresponding to the jth node going to process i
101  ! ... from this process
102  inode = local2global(commnodes1(i,j))
103  DO jnode = 1, gnumnp
104  tempkval = 0.0
105  ! ... return the value (tempKval) stored in CRS at explicit matrix
106  ! ... location (inode, jnode)
107  CALL comp_row_getval(gnumnp,gnumnp,nnz_kt,1,rp_kt,cval_kt,aval_kt, &
108  inode,jnode,tempkval)
109  ! ... if there is a value at this node, then add 1 to the amount to send
110  ! ... to process i.
111 
112 
113  IF (tempkval /= 0.0) THEN
114 
115  counter = counter + 1
116  ENDIF
117  ENDDO
118  ENDDO
119 
120  ! ... amount to send process i is the sum of all non-zeros in the loop above
121  amounttosend(i) = counter
122 
123  CALL mpi_send(amounttosend(i),1,mpi_integer, &
124  commprocs1(i),10,rocstar_communicator,ierr)
125  ENDDO
126 
127  CALL mpi_waitall(nprocs,req_rcv,stat_rcv,ierr)
128 
129 
130  ! ... Communicate parts of the thermal stiffness matrix to other processes
131 
132  ! ... receive information from other processes
133  ! ... (nodes owned by this process but in the partition of other processes)
134  CALL mpi_barrier(rocstar_communicator,ierr)
135  ALLOCATE(frmproc(1:numcommprocsfrom1))
136  DO i = 1, numcommprocsfrom1
137  ALLOCATE(frmproc(i)%rcvbuf(1:3*amounttoreceive(i)))
138  CALL mpi_irecv(frmproc(i)%rcvbuf(1),3*amounttoreceive(i), &
139  mpi_double_precision,commprocsfrom1(i),10,rocstar_communicator, &
140  req_rcv(i),ierr)
141  ENDDO
142 
143  ! ... send information to other processes
144  ! ... (nodes owned by other processes but in the partition of this one)
145  DO i = 1, numcommprocs1
146  ALLOCATE(bufsnd(3*amounttosend(i)))
147  bufsnd(:) = 0.0
148  counter = 0
149  ! ... loop through the nodes going to be sent to process i
150  DO j = 1, numcommnodes1(i)
151  ! ... inode is the global node number corresponding to the jth node going to process i
152  ! ... from this process
153  inode = local2global(commnodes1(i,j))
154  DO jnode = 1, gnumnp
155  tempkval = 0.0
156  ! ... return the value (tempKval) stored in CRS at explicit matrix
157  ! ... location (inode, jnode)
158  CALL comp_row_getval(gnumnp,gnumnp,nnz_kt,1,rp_kt,cval_kt,aval_kt, &
159  inode,jnode,tempkval)
160 
161  ! ... if there is a value at this node, put it in the location '3*counter'
162  ! ... (preceeded by the row and column locations (fortran)) in the buffer to
163  ! ... be sent to process i.
164  IF (tempkval /= 0.0) THEN
165  counter = counter + 1
166  bufsnd(3*counter-2) = inode
167  bufsnd(3*counter-1) = jnode
168  bufsnd(3*counter) = tempkval
169 
170  ENDIF
171  ENDDO
172  ENDDO
173 
174  CALL mpi_send(bufsnd,3*amounttosend(i),mpi_double_precision, &
175  commprocs1(i),10,rocstar_communicator,ierr)
176 
177  DEALLOCATE(bufsnd)
178  ENDDO
179 
180  CALL mpi_waitall(nprocs,req_rcv,stat_rcv,ierr)
181 
182  DEALLOCATE(req_rcv)
183  DEALLOCATE(req_snd)
184  DEALLOCATE(stat_snd)
185  DEALLOCATE(stat_rcv)
186  ENDIF
187 
188  IF(myid == 0) print*,'FINISHED COMMUNICATING THERMAL STIFFNESS MATRIX TO ALL PROCESSES'
189 
190  ! ... add values from other processes into this processes thermal stiffness matrix
191  IF (nprocs > 1) THEN
192  DO i = 1, numcommprocsfrom1
193  DO j = 1, amounttoreceive(i)
194 
195  CALL comp_row_addval(gnumnp,gnumnp,nnz_kt,1,rp_kt,cval_kt,aval_kt, &
196  int(frmproc(i)%rcvbuf(3*j-2)),int(frmproc(i)%rcvbuf(3*j-1)),frmproc(i)%rcvbuf(3*j))
197 
198  ! ... if after the addition, the number of non-zeroes has changed
199  ! ... reallocate the aval and cval vectors to accomodate
200  IF (nnz_temp /= nnz_kt) THEN
201  DEALLOCATE(cval_kt,aval_kt)
202  ALLOCATE(cval_kt(nnz_temp),aval_kt(nnz_temp))
203  nnz_kt = nnz_temp
204  rp_kt = rp_temp
205  cval_kt = cval_temp
206  ENDIF
207  aval_kt = aval_temp
208  DEALLOCATE(rp_temp,cval_temp,aval_temp)
209  ENDDO
210  ENDDO
211 
212  DEALLOCATE(frmproc)
213  DEALLOCATE(amounttoreceive)
214  DEALLOCATE(amounttosend)
215  ENDIF
216 
217  ! ... Resize the matrix to the size needed on this proc
218  CALL comp_row_resize(gnumnp,gnumnp,nnz_kt,1,rp_kt,cval_kt,aval_kt,nstart_ktc,lnumnp)
219  DEALLOCATE(rp_kt,cval_kt,aval_kt)
220  ALLOCATE(rp_kt(1:lnumnp+1))
221  ALLOCATE(cval_kt(1:nnz_temp))
222  ALLOCATE(aval_kt(1:nnz_temp))
223  nnz_kt = nnz_temp
224  rp_kt = rp_temp
225  cval_kt = cval_temp
226  aval_kt = aval_temp
227  DEALLOCATE(rp_temp,cval_temp,aval_temp)
228 
229 
230 END SUBROUTINE glbthermstiff
FT m(int i, int j) const
**********************************************************************Rocstar Simulation Suite Illinois Rocstar LLC All rights reserved ****Illinois Rocstar LLC IL **www illinoisrocstar com **sales illinoisrocstar com WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **Arising OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE **********************************************************************INTERFACE SUBROUTINE inode
subroutine comp_row_getval(ndim, nrows, nnz, nstart, rp, cval, aval, ipos, jpos, val)
subroutine locthermstiff_v3d8(coor, ElConnVol, dmat, numnp, NumEL, MatType, NumMatType)
subroutine comp_row_resize(ndim, nrows, nnz, nstart, rp, cval, aval, newnstart, newnrows)
subroutine glbthermstiff(global)
blockLoc i
Definition: read.cpp:79
virtual std::ostream & print(std::ostream &os) const
j indices j
Definition: Indexing.h:6
**********************************************************************Rocstar Simulation Suite Illinois Rocstar LLC All rights reserved ****Illinois Rocstar LLC IL **www illinoisrocstar com **sales illinoisrocstar com WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **Arising OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE **********************************************************************INTERFACE SUBROUTINE jnode
subroutine comp_row_addval(ndim, nrows, nnz, nstart, rp, cval, aval, ipos, jpos, val)