Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PERI_coCprSlowTermsFlo.F90
Go to the documentation of this file.
1 ! *********************************************************************
2 ! * Rocstar Simulation Suite *
3 ! * Copyright@2015, Illinois Rocstar LLC. All rights reserved. *
4 ! * *
5 ! * Illinois Rocstar LLC *
6 ! * Champaign, IL *
7 ! * www.illinoisrocstar.com *
8 ! * sales@illinoisrocstar.com *
9 ! * *
10 ! * License: See LICENSE file in top level of distribution package or *
11 ! * http://opensource.org/licenses/NCSA *
12 ! *********************************************************************
13 ! *********************************************************************
14 ! * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *
15 ! * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *
16 ! * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *
17 ! * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR *
18 ! * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
19 ! * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
20 ! * Arising FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
21 ! * USE OR OTHER DEALINGS WITH THE SOFTWARE. *
22 ! *********************************************************************
23 !******************************************************************************
24 !
25 ! Purpose: compute additional terms to NS due to CPR formulations
26 !
27 ! Description: all variables in slow terms are averaged over i,k plane.
28 !
29 ! Input: region = data of current region.
30 !
31 ! Output: region%levels%mixt%rhs = CPR slow terms added to the residual.
32 !
33 ! Notes: This routine contents MPI global SUM which does not account for
34 ! summation over regions in same processor. Therefore nProcAlloc should
35 ! be equal to nRegions.
36 !
37 !******************************************************************************
38 !
39 ! $Id: PERI_coCprSlowTermsFlo.F90,v 1.3 2008/12/06 08:44:37 mtcampbe Exp $
40 !
41 ! Copyright: (c) 2001 by the University of Illinois
42 !
43 !******************************************************************************
44 
45 SUBROUTINE peri_cocprslowterms( region )
46 
47  USE moddatatypes
48  USE moddatastruct, ONLY : t_region
51  USE moderror
52  USE modmpi
53  USE modparameters
55  IMPLICIT NONE
56 
57 #include "Indexing.h"
58 
59 ! ... parameters
60  TYPE(t_region) :: region
61 
62 ! ... loop variables
63  INTEGER :: i, j, k, l
64 
65 ! ... local variables
66  CHARACTER(CHRLEN) :: rcsidentstring
67 
68  INTEGER :: ipcbeg, ipcend, jpcbeg, jpcend, kpcbeg, kpcend
69  INTEGER :: ilev, icoff, ijcoff, ijkc0, nvar, ipc, jpc, kpc
70  INTEGER :: indcp, indmol
71 
72  REAL(RFREAL), POINTER :: cv(:,:), dv(:,:), gv(:,:), rhs(:,:), vol(:)
73  REAL(RFREAL), POINTER :: cprvar(:,:), varsend(:,:), varrecv(:,:)
74  REAL(RFREAL), ALLOCATABLE :: rgas(:), cpgas(:)
75  REAL(RFREAL) :: voleps, aversize, sndaversize, rcvaversize, ravgrho
76  REAL(RFREAL) :: denumer, denomin, delta, rdelta, gamma, gammin, gagmin
77  REAL(RFREAL) :: rho, ruc, ren, uve, vve, wve, tmp, prs, rprim, uprim, vprim
78  REAL(RFREAL) :: wprim, tprim, pprim, ugrad, vgrad, wgrad, tgrad, pgrad
79  REAL(RFREAL) :: refmeanpgrad, fcont, fmomx, fmomy, fmomz, frhoe
80 
81 !******************************************************************************
82 
83  rcsidentstring = '$RCSfile: PERI_coCprSlowTermsFlo.F90,v $ $Revision: 1.3 $'
84 
85  CALL registerfunction( region%global,'PERI_CoCprSlowTerms',&
86  'PERI_coCprSlowTermsFlo.F90' )
87 
88 ! get dimensions, pointers and parameters -------------------------------------
89 
90  ilev = region%currLevel
91 
92  CALL rflo_getdimensphys( region,ilev,ipcbeg,ipcend, &
93  jpcbeg,jpcend,kpcbeg,kpcend )
94  CALL rflo_getcelloffset( region,ilev,icoff,ijcoff )
95 
96  cv => region%levels(ilev)%mixt%cv
97  dv => region%levels(ilev)%mixt%dv
98  gv => region%levels(ilev)%mixt%gv
99  rhs => region%levels(ilev)%mixt%rhs
100  vol => region%levels(ilev)%grid%vol
101  cprvar => region%levels(ilev)%peri%cprVar
102  varsend=> region%levels(ilev)%peri%varSend
103  varrecv=> region%levels(ilev)%peri%varRecv
104 
105  ipc = ipcend-ipcbeg+1
106  jpc = jpcend-jpcbeg+1
107  kpc = kpcend-kpcbeg+1
108  aversize = dble(ipc*kpc)
109 
110  indcp = region%levels(ilev)%mixt%indCp
111  indmol = region%levels(ilev)%mixt%indMol
112  nvar = region%periInput%nVar
113 
114  refmeanpgrad = region%periInput%meanPgrad
115  delta = region%global%refLength
116  rdelta = 1._rfreal/delta
117 
118 ! allocate temporary space
119 
120  ALLOCATE( rgas(jpcbeg:jpcend), cpgas(jpcbeg:jpcend) )
121 
122 ! x-z plane averaged variables
123 
124  DO j=jpcbeg,jpcend
125  cprvar(1:nvar,j) = 0._rfreal
126  rgas(j) = 0._rfreal
127  cpgas(j) = 0._rfreal
128  DO k=kpcbeg,kpcend
129  DO i=ipcbeg,ipcend
130  ijkc0 = indijk(i ,j ,k ,icoff,ijcoff)
131 
132  cprvar(cpr_rho,j) = cprvar(cpr_rho,j) + cv(cv_mixt_dens,ijkc0)
133  cprvar(cpr_ruc,j) = cprvar(cpr_ruc,j) + cv(cv_mixt_xmom,ijkc0)
134  cprvar(cpr_rvc,j) = cprvar(cpr_rvc,j) + cv(cv_mixt_ymom,ijkc0)
135  cprvar(cpr_uve,j) = cprvar(cpr_uve,j) + dv(dv_mixt_uvel,ijkc0)
136  cprvar(cpr_vve,j) = cprvar(cpr_vve,j) + dv(dv_mixt_vvel,ijkc0)
137  cprvar(cpr_tmp,j) = cprvar(cpr_tmp,j) + dv(dv_mixt_temp,ijkc0)
138  cprvar(cpr_prs,j) = cprvar(cpr_prs,j) + dv(dv_mixt_pres,ijkc0)
139 
140  rgas(j) = rgas(j) + mixtperf_r_m( gv(gv_mixt_mol,ijkc0*indmol) )
141  cpgas(j)= cpgas(j)+ gv(gv_mixt_cp,ijkc0*indcp)
142  ENDDO
143  ENDDO
144  ENDDO
145 
146 #ifdef MPI
147  DO j = jpcbeg, jpcend
148  DO l = 1,nvar
149  varsend(j-jpcbeg+1,l) = cprvar(l,j)
150  END DO
151  varsend(j-jpcbeg+1,nvar+1) = rgas(j)
152  varsend(j-jpcbeg+1,nvar+2) = cpgas(j)
153  END DO
154  CALL mpi_barrier( region%global%mpiComm, region%global%mpierr )
155  DO l = 1, nvar+gas_nvar
156  CALL mpi_allreduce( varsend(1,l),varrecv(1,l),jpc,mpi_double_precision, &
157  mpi_sum,region%global%mpiComm, region%global%mpierr )
158  END DO
159  DO j = jpcbeg, jpcend
160  DO l = 1,nvar
161  cprvar(l,j) = varrecv(j-jpcbeg+1,l)
162  END DO
163  rgas(j) = varrecv(j-jpcbeg+1,nvar+1)
164  cpgas(j) = varrecv(j-jpcbeg+1,nvar+2)
165  END DO
166 
167  sndaversize = aversize
168  CALL mpi_allreduce( sndaversize,rcvaversize,1, mpi_double_precision, &
169  mpi_sum,region%global%mpiComm,region%global%mpierr )
170  aversize = rcvaversize
171 #endif
172 
173  DO j = jpcbeg,jpcend
174  DO l = 1,nvar
175  cprvar(l,j) = cprvar(l,j)/aversize
176  ENDDO
177  rgas(j) = rgas(j)/aversize
178  cpgas(j)= cpgas(j)/aversize
179 
180  gamma = mixtperf_g_cpr( cpgas(j),rgas(j) )
181  gagmin = gamma/(gamma - 1_rfreal)
182 
183  ravgrho = 1._rfreal/cprvar(cpr_rho,j)
184  denumer = gagmin*refmeanpgrad + (cprvar(cpr_ruc,j)**2 + &
185  cprvar(cpr_rvc,j)**2)*rdelta*ravgrho
186  denomin = gagmin*cprvar(cpr_prs,j)*ravgrho + &
187  (cprvar(cpr_ruc,j)**2+cprvar(cpr_rvc,j)**2)*ravgrho**2
188  cprvar(cpr_dor,j) = denumer/denomin
189  cprvar(cpr_dou,j) = (cprvar(cpr_ruc,j)*rdelta-cprvar(cpr_uve,j)* &
190  cprvar(cpr_dor,j))*ravgrho
191  cprvar(cpr_dov,j) = -cprvar(cpr_vve,j)*ravgrho*cprvar(cpr_dor,j)
192  cprvar(cpr_dot,j) = (refmeanpgrad/rgas(j)-cprvar(cpr_tmp,j)* &
193  cprvar(cpr_dor,j))*ravgrho
194  ENDDO
195 
196  DO k = kpcbeg, kpcend
197  DO j = jpcbeg, jpcend
198  DO i = ipcbeg, ipcend
199  ijkc0 = indijk(i ,j ,k ,icoff,ijcoff)
200 
201  rho = cv(cv_mixt_dens,ijkc0)
202  ruc = cv(cv_mixt_xmom,ijkc0)
203  ren = cv(cv_mixt_ener,ijkc0)
204  uve = dv(dv_mixt_uvel,ijkc0)
205  vve = dv(dv_mixt_vvel,ijkc0)
206  wve = dv(dv_mixt_wvel,ijkc0)
207  tmp = dv(dv_mixt_temp,ijkc0)
208  prs = dv(dv_mixt_pres,ijkc0)
209 
210  rprim = rho - cprvar(cpr_rho,j)
211  uprim = uve - cprvar(cpr_uve,j)
212  vprim = vve - cprvar(cpr_vve,j)
213  wprim = wve
214  tprim = tmp - cprvar(cpr_tmp,j)
215  pprim = prs - cprvar(cpr_prs,j)
216 
217  ugrad = uprim*rdelta + cprvar(cpr_dou,j)
218  vgrad = vprim*rdelta + cprvar(cpr_dov,j)
219  wgrad = wprim*rdelta
220  tgrad = tprim*rdelta + cprvar(cpr_dot,j)
221  pgrad = pprim*rdelta + refmeanpgrad
222 
223  fcont = (cprvar(cpr_ruc,j)+cprvar(cpr_rho,j)*uprim+cprvar(cpr_uve,j)* &
224  rprim)*rdelta + uprim*cprvar(cpr_dor,j) + rprim*cprvar(cpr_dou,j)
225  fmomx = uve*fcont + ruc*ugrad + pgrad
226  fmomy = vve*fcont + ruc*vgrad
227  fmomz = wve*fcont + ruc*wgrad
228  gamma = mixtperf_g_cpr( cpgas(j),rgas(j) )
229  gammin= gamma-1._rfreal
230  frhoe = ren/rho*fcont + ruc*(uve*ugrad+vve*vgrad+wve*wgrad+rgas(j)/ &
231  gammin*tgrad) + prs*ugrad +uve*pgrad
232 
233  voleps= vol(ijkc0)*region%periInput%cprEpsilon
234  rhs(cv_mixt_dens,ijkc0) = rhs(cv_mixt_dens,ijkc0) + voleps*fcont
235  rhs(cv_mixt_xmom,ijkc0) = rhs(cv_mixt_xmom,ijkc0) + voleps*fmomx
236  rhs(cv_mixt_ymom,ijkc0) = rhs(cv_mixt_ymom,ijkc0) + voleps*fmomy
237  rhs(cv_mixt_zmom,ijkc0) = rhs(cv_mixt_zmom,ijkc0) + voleps*fmomz
238  rhs(cv_mixt_ener,ijkc0) = rhs(cv_mixt_ener,ijkc0) + voleps*frhoe
239 !=======================================
240 ! fCont = cprVar(CPR_RUC,j)*rdelta
241 ! fMomX = cprVar(CPR_UVE,j)*fCont
242 ! fMomY = cprVar(CPR_VVE,j)*fCont
243 ! fMomZ = 0._RFREAL
244 ! fRhoE = ren/rho*fCont + ruc*(uve*uGrad+vve*vGrad+wve*wGrad+rgas(j)/ &
245 ! gammin*tGrad) + prs*uGrad +uve*pGrad
246 ! rhs(CV_MIXT_DENS,ijkC0) = rhs(CV_MIXT_DENS,ijkC0) + volEps*fCont
247 ! rhs(CV_MIXT_XMOM,ijkC0) = rhs(CV_MIXT_XMOM,ijkC0) + volEps* &
248 ! (fMomX + ruc*uve*rdelta + refMeanPgrad)
249 ! rhs(CV_MIXT_YMOM,ijkC0) = rhs(CV_MIXT_YMOM,ijkC0) + volEps*ruc*vve*rdelta
250 ! rhs(CV_MIXT_ZMOM,ijkC0) = rhs(CV_MIXT_ZMOM,ijkC0) + volEps*ruc*wve*rdelta
251 ! rhs(CV_MIXT_ENER,ijkC0) = rhs(CV_MIXT_ENER,ijkC0) + volEps* &
252 ! (ren/rho+prs)*uve*rdelta
253 !========================================
254  ENDDO
255  ENDDO
256  ENDDO
257 
258 ! deallocate temporary workspace
259 
260  DEALLOCATE( rgas, cpgas )
261 
262 ! finalize --------------------------------------------------------------------
263 
264  CALL deregisterfunction( region%global )
265 
266 END SUBROUTINE peri_cocprslowterms
267 
268 !******************************************************************************
269 !
270 ! RCS Revision history:
271 !
272 ! $Log: PERI_coCprSlowTermsFlo.F90,v $
273 ! Revision 1.3 2008/12/06 08:44:37 mtcampbe
274 ! Updated license.
275 !
276 ! Revision 1.2 2008/11/19 22:17:49 mtcampbe
277 ! Added Illinois Open Source License/Copyright
278 !
279 ! Revision 1.1 2004/06/08 23:56:56 wasistho
280 ! changed nomenclature
281 !
282 ! Revision 1.2 2003/05/15 02:57:05 jblazek
283 ! Inlined index function.
284 !
285 ! Revision 1.1.1.1 2003/03/29 03:36:30 wasistho
286 ! install ROCPERI
287 !
288 !
289 !******************************************************************************
290 
291 
292 
293 
294 
295 
296 
subroutine peri_cocprslowterms(region)
real(rfreal) function mixtperf_r_m(M)
Definition: MixtPerf_R.F90:54
j indices k indices k
Definition: Indexing.h:6
NT rhs
**********************************************************************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 kpcbeg
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
**********************************************************************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 jpcbeg
**********************************************************************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 ipcend
**********************************************************************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 ipcbeg
blockLoc i
Definition: read.cpp:79
subroutine rflo_getcelloffset(region, iLev, iCellOffset, ijCellOffset)
RT delta(int i) const
Definition: Direction_2.h:159
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 jpcend
subroutine deregisterfunction(global)
Definition: ModError.F90:469
real(rfreal) function mixtperf_g_cpr(Cp, R)
Definition: MixtPerf_G.F90:39
subroutine rflo_getdimensphys(region, iLev, ipcbeg, ipcend, jpcbeg, jpcend, kpcbeg, kpcend)