Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GlbThermCap.f90
Go to the documentation of this file.
1 !!****
2 !!
3 !! NAME
4 !! GlbThermCap
5 !!
6 !! FUNCTION
7 !! This subroutine constructs the global consistent capacitance matrix,
8 !! then puts it into CRS format. The matrix information is stored in
9 !! global variables: rp_c, aval_c, cval_c, nnz_c, nrows_ktc, nstart_ktc
10 !!
11 !! INPUTS
12 !! none
13 !!
14 !! OUTPUTS
15 !! none
16 !!
17 !! USES
18 !! none
19 !!
20 !!****
21 
22 SUBROUTINE glbthermcap(global)
23 
24  USE implicit_global
25  USE comp_row_global
27 
28  IMPLICIT NONE
29 
30  include 'mpif.h'
31 
32  TYPE(rocfrac_global) :: global
33 
34  INTEGER :: i, j, m, p, inode, jnode, counter
35 
36  REAL(kind=wp) :: tempcval
37  INTEGER, ALLOCATABLE, DIMENSION(:) :: amounttoreceive, amounttosend
38 
39  REAL(kind=wp), ALLOCATABLE, DIMENSION(:) :: bufsnd
40 
41  ! ... Gauss point coordinates
42  REAL(kind=wp), DIMENSION(1:3,1:8) :: ri = reshape( &
43  (/-0.577350269189626,-0.577350269189626,-0.577350269189626, &
44  0.577350269189626,-0.577350269189626,-0.577350269189626, &
45  0.577350269189626, 0.577350269189626,-0.577350269189626, &
46  -0.577350269189626, 0.577350269189626,-0.577350269189626, &
47  -0.577350269189626,-0.577350269189626, 0.577350269189626, &
48  0.577350269189626,-0.577350269189626, 0.577350269189626, &
49  0.577350269189626, 0.577350269189626, 0.577350269189626, &
50  -0.577350269189626, 0.577350269189626, 0.577350269189626/),(/3,8/) )
51 
52 
53 
54  ! ... Construct the global capacitance matrix
55  IF(myid == 0) print*,'CONSTRUCTING THE CAPACITANCE MATRIX'
56  CALL mpi_barrier(rocstar_communicator,ierr)
57 
58  IF ( myid == 0) print*,'RocTherm, GlbThermCap :: before LocThermCap'
59 
60  ! ... Construct the capacitance matrix as a consistent matrix
61  CALL locthermcap_v3d8(global%NumElVol,global%NumNp,global%NumMatVol,global%MeshCoor,global%ElConnVol,global%MatIdVol,ri,global%rho,global%Cp,global%ElConnVol)
62 
63  IF(myid == 0) print*,'FINISHED CONSTRUCTING THE CAPACITANCE MATRIX'
64  CALL mpi_barrier(rocstar_communicator,ierr)
65 
66 
67  ! ... number of non-zeros and CRS vectors ' '_temp computed by LocThermCap_v3d8
68  nnz_c = nnz_temp
69  ALLOCATE(cval_c(1:nnz_c))
70  ALLOCATE(aval_c(1:nnz_c))
71  ALLOCATE(rp_c(1:gnumnp+1))
72  rp_c = rp_temp
73  cval_c = cval_temp
74  aval_c = aval_temp
75  DEALLOCATE(rp_temp)
76  DEALLOCATE(cval_temp)
77  DEALLOCATE(aval_temp)
78 
79 
80  IF(myid == 0) print*,'COMMUNICATING CAPACITANCE MATRIX TO ALL PROCESSES'
81 
82  ! ... Communicate mass to the other procs
83  ! ... boundary nodes on this process are communicated to the processes
84  ! ... to which they are assigned
85  IF (nprocs > 1) THEN
86  CALL mpi_barrier(rocstar_communicator,ierr)
87  ! ... initialize request and status variables for MPI sends and receives
88  ALLOCATE(req_rcv(1:nprocs))
89  ALLOCATE(req_snd(1:nprocs))
90  ALLOCATE(stat_snd(1:mpi_status_size,1:nprocs))
91  ALLOCATE(stat_rcv(1:mpi_status_size,1:nprocs))
92  DO i = 1, nprocs
93  req_rcv(i) = 0
94  req_snd(i) = 0
95  DO j = 1, mpi_status_size
96  stat_rcv(1,i) = 0
97  stat_snd(j,i) = 0
98  ENDDO
99  ENDDO
100 
101  ! ... number of nodes each process will send to this process
102  ! ... (nodes owned by this process but in the partition of other processes)
103  ALLOCATE(amounttoreceive(1:numcommprocsfrom1))
104  DO i = 1, numcommprocsfrom1
105  CALL mpi_irecv(amounttoreceive(i),1, &
106  mpi_integer,commprocsfrom1(i),10,rocstar_communicator, &
107  req_rcv(i),ierr)
108  ENDDO
109 print*,'RocTherm, GlbCap :: after MPI_IRECV',myid
110  ! ... number of nodes each process will be sent from this process
111  ! ... (nodes owned by other processes but in the partition of this one)
112  ALLOCATE(amounttosend(1:numcommprocs1))
113  DO i = 1, numcommprocs1
114  counter = 0
115  ! ... loop through the nodes going to be sent to process i
116  DO j = 1, numcommnodes1(i)
117  ! ... inode is the global node number corresponding to the jth node going to process i
118  ! ... from this process
119  inode = local2global(commnodes1(i,j))
120  DO jnode = 1, gnumnp
121  tempcval = 0.0
122  ! ... return the value (tempCval) stored in CRS at explicit matrix
123  ! ... location (inode, jnode)
124  CALL comp_row_getval(gnumnp,gnumnp,nnz_c,1,rp_c,cval_c,aval_c, &
125  inode,jnode,tempcval)
126 
127 
128 
129  ! ... if there is a value at this node, then add 1 to the ammount to send
130  ! ... to process i.
131  IF (tempcval /= 0.0) THEN
132  counter = counter + 1
133  ENDIF
134  ENDDO
135  ENDDO
136 
137  ! ... amount to send process i is the sum of all non-zeros in the loop above
138  amounttosend(i) = counter
139 
140  CALL mpi_send(amounttosend(i),1,mpi_integer, &
141  commprocs1(i),10,rocstar_communicator,ierr)
142  ENDDO
143 
144  CALL mpi_waitall(nprocs,req_rcv,stat_rcv,ierr)
145 
146 
147  ! ... Communicate parts of the capcitance matrix to other procs
148 
149  ! ... receive information from other processes
150  ! ... (nodes owned by this process but in the partition of other processes)
151  CALL mpi_barrier(rocstar_communicator,ierr)
152  ALLOCATE(frmproc(1:numcommprocsfrom1))
153  DO i = 1, numcommprocsfrom1
154  ALLOCATE(frmproc(i)%rcvbuf(1:3*amounttoreceive(i)))
155  CALL mpi_irecv(frmproc(i)%rcvbuf(1),3*amounttoreceive(i), &
156  mpi_double_precision,commprocsfrom1(i),10,rocstar_communicator, &
157  req_rcv(i),ierr)
158  ENDDO
159 
160  ! ... send information to other processes
161  ! ... (nodes owned by other processes but in the partition of this one)
162  DO i = 1, numcommprocs1
163  ALLOCATE(bufsnd(3*amounttosend(i)))
164  bufsnd(:) = 0.0
165  counter = 0
166  ! ... loop through the nodes going to be sent to process i
167  DO j = 1, numcommnodes1(i)
168  ! ... inode is the global node number corresponding to the jth node going to process i
169  ! ... from this process
170  inode = local2global(commnodes1(i,j))
171  DO jnode = 1, gnumnp
172  tempcval = 0.0
173  ! ... return the value (tempCval) stored in CRS at explicit matrix
174  ! ... location (inode, jnode)
175  CALL comp_row_getval(gnumnp,gnumnp,nnz_c,1,rp_c,cval_c,aval_c, &
176  inode,jnode,tempcval)
177 
178  ! ... if there is a value at this node, put it in the location '3*counter'
179  ! ... (preceeded by the row and column locations (fortran)) in the buffer to
180  ! ... be sent to process i.
181  IF (tempcval /= 0.0) THEN
182  counter = counter + 1
183  bufsnd(3*counter-2) = inode
184  bufsnd(3*counter-1) = jnode
185  bufsnd(3*counter) = tempcval
186  ENDIF
187  ENDDO
188  ENDDO
189 
190  CALL mpi_send(bufsnd,3*amounttosend(i),mpi_double_precision, &
191  commprocs1(i),10,rocstar_communicator,ierr)
192 
193  DEALLOCATE(bufsnd)
194  ENDDO
195 
196  CALL mpi_waitall(nprocs,req_rcv,stat_rcv,ierr)
197 
198  DEALLOCATE(req_rcv)
199  DEALLOCATE(req_snd)
200  DEALLOCATE(stat_snd)
201  DEALLOCATE(stat_rcv)
202  ENDIF
203 
204  IF(myid == 0) print*,'FINISHED COMMUNICATING CAPACITANCE MATRIX TO ALL PROCESSES'
205 
206  ! ... add values from other processes into this processes capacitance matrix
207  IF (nprocs > 1) THEN
208  DO i = 1, numcommprocsfrom1
209  DO j = 1, amounttoreceive(i)
210  CALL comp_row_addval(gnumnp,gnumnp,nnz_c,1,rp_c,cval_c,aval_c, &
211  int(frmproc(i)%rcvbuf(3*j-2)),int(frmproc(i)%rcvbuf(3*j-1)),frmproc(i)%rcvbuf(3*j))
212 
213  ! ... if after the addition, the number of non-zeroes has changed
214  ! ... reallocate the aval and cval vectors to accomodate
215  IF (nnz_temp /= nnz_c) THEN
216  DEALLOCATE(cval_c,aval_c)
217  ALLOCATE(cval_c(nnz_temp),aval_c(nnz_temp))
218  nnz_c = nnz_temp
219  rp_c = rp_temp
220  cval_c = cval_temp
221  ENDIF
222  aval_c = aval_temp
223  DEALLOCATE(rp_temp,cval_temp,aval_temp)
224  ENDDO
225  ENDDO
226  DEALLOCATE(frmproc)
227  DEALLOCATE(amounttoreceive)
228  DEALLOCATE(amounttosend)
229  ENDIF
230 
231  ! ... Resize the matrix to the size needed on this proc
232  CALL comp_row_resize(gnumnp,gnumnp,nnz_c,1,rp_c,cval_c,aval_c,nstart_ktc,nrows_ktc)
233  DEALLOCATE(rp_c,cval_c,aval_c)
234  ALLOCATE(rp_c(1:nrows_ktc+1))
235  ALLOCATE(cval_c(1:nnz_temp))
236  ALLOCATE(aval_c(1:nnz_temp))
237  nnz_c = nnz_temp
238  rp_c = rp_temp
239  cval_c = cval_temp
240  aval_c = aval_temp
241  DEALLOCATE(rp_temp,cval_temp,aval_temp)
242 
243 
244 END SUBROUTINE glbthermcap
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 glbthermcap(global)
Definition: GlbThermCap.f90:22
subroutine locthermcap_v3d8(NumEl, NumNP, NumMat, coor, nodes, MatType, ri, rho, cap, ElConnVol)
subroutine comp_row_getval(ndim, nrows, nnz, nstart, rp, cval, aval, ipos, jpos, val)
subroutine comp_row_resize(ndim, nrows, nnz, nstart, rp, cval, aval, newnstart, newnrows)
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)