Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RFLU_TimeStepInviscid.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: Calculate max. allowable local/global time step in the case
26 ! of inviscid flow.
27 !
28 ! Description: None.
29 !
30 ! Input:
31 ! pRegion Pointer to region
32 !
33 ! Output: None.
34 !
35 ! Notes: None.
36 !
37 ! ******************************************************************************
38 !
39 ! $Id: RFLU_TimeStepInviscid.F90,v 1.23 2008/12/06 08:44:30 mtcampbe Exp $
40 !
41 ! Copyright: (c) 2002-2005 by the University of Illinois
42 !
43 ! ******************************************************************************
44 
45 SUBROUTINE rflu_timestepinviscid(pRegion)
46 
47  USE moddatatypes
48  USE moddatastruct, ONLY: t_region
49  USE modglobal, ONLY: t_global
50  USE modgrid, ONLY: t_grid
51  USE modbndpatch, ONLY: t_patch
52  USE moderror
53  USE modparameters
54 
57 
58  USE modinterfaces, ONLY: mixtperf_c_grt, &
59  mixtperf_g_cpr, &
61 
62 #ifdef PETSC
64 #endif
65 
66  IMPLICIT NONE
67 
68 ! ******************************************************************************
69 ! Declarations and definitions
70 ! ******************************************************************************
71 
72 ! ==============================================================================
73 ! Arguments
74 ! ==============================================================================
75 
76  TYPE(t_region), POINTER :: pregion
77 
78 ! ==============================================================================
79 ! Locals
80 ! ==============================================================================
81 
82  CHARACTER(CHRLEN) :: rcsidentstring
83  INTEGER :: c1,c2,distrib,gasmodel,icg,ifg,ifl,indcp,indgs,indmol,ipatch
84  INTEGER :: dtminloc(1)
85  REAL(RFREAL) :: as,a1,a2,cp,dtmin,dtscale,dummyrealout,fs,fsu,gam,hl,ir1, &
86  ir2,minj,mm,nm,nx,ny,nz,pl,pr,rgas,rl,rr,rur,rvr,rwr,srad, &
87  tinj,uinj,ul,u1,u2,vc,vinj,vl,vm2,v1,v2,winj,wl,w1,w2
88  REAL(RFREAL), DIMENSION(:,:), POINTER :: pcv,pdv,pgv,pvals
89  TYPE(t_global), POINTER :: global
90  TYPE(t_grid), POINTER :: pgrid
91  TYPE(t_patch), POINTER :: ppatch
92 
93 ! ******************************************************************************
94 ! Start
95 ! ******************************************************************************
96 
97  rcsidentstring = '$RCSfile: RFLU_TimeStepInviscid.F90,v $ $Revision: 1.23 $'
98 
99  global => pregion%global
100 
101  CALL registerfunction(global,'RFLU_TimeStepInviscid',&
102  'RFLU_TimeStepInviscid.F90')
103 
104 ! ******************************************************************************
105 ! Get dimensions and pointers
106 ! ******************************************************************************
107 
108  pgrid => pregion%grid
109 
110  indcp = pregion%mixtInput%indCp
111  indmol = pregion%mixtInput%indMol
112  gasmodel = pregion%mixtInput%gasModel
113 
114  pcv => pregion%mixt%cv
115  pdv => pregion%mixt%dv
116  pgv => pregion%mixt%gv
117 
118  indgs = pgrid%indGs
119 
120 ! ******************************************************************************
121 ! Initialize time step
122 ! ******************************************************************************
123 
124  DO icg = 1,pgrid%nCellsTot ! Explicit loop to avoid Frost problem
125  pregion%dt(icg) = 0.0_rfreal
126  END DO ! icg
127 
128 ! ******************************************************************************
129 ! Local time step
130 ! ******************************************************************************
131 
132 ! ==============================================================================
133 ! Interior faces
134 ! ==============================================================================
135 
136  DO ifg = 1,pregion%grid%nFaces
137 
138  c1 = pgrid%f2c(1,ifg)
139  c2 = pgrid%f2c(2,ifg)
140 
141  nx = pgrid%fn(xcoord,ifg)
142  ny = pgrid%fn(ycoord,ifg)
143  nz = pgrid%fn(zcoord,ifg)
144  nm = pgrid%fn(xyzmag,ifg)
145 
146  fs = pgrid%gs(indgs*ifg)
147  fsu = rflu_descalegridspeed(pregion,fs)
148 
149  ir1 = 1.0_rfreal/pcv(cv_mixt_dens,c1)
150  ir2 = 1.0_rfreal/pcv(cv_mixt_dens,c2)
151 
152  u1 = pcv(cv_mixt_xmom,c1)*ir1
153  v1 = pcv(cv_mixt_ymom,c1)*ir1
154  w1 = pcv(cv_mixt_zmom,c1)*ir1
155  a1 = pdv(dv_mixt_soun,c1)
156 
157  u2 = pcv(cv_mixt_xmom,c2)*ir2
158  v2 = pcv(cv_mixt_ymom,c2)*ir2
159  w2 = pcv(cv_mixt_zmom,c2)*ir2
160  a2 = pdv(dv_mixt_soun,c2)
161 
162  vc = 0.5_rfreal*((u1+u2)*nx + (v1+v2)*ny + (w1+w2)*nz)
163  as = 0.5_rfreal*(a1+a2)
164 
165  srad = (abs(vc - fsu) + as)*nm
166 
167  pregion%dt(c1) = pregion%dt(c1) + srad
168  pregion%dt(c2) = pregion%dt(c2) + srad
169  END DO ! ifg
170 
171 ! ==============================================================================
172 ! Boundary faces
173 ! ==============================================================================
174 
175  DO ipatch = 1,pgrid%nPatches
176 
177  ppatch => pregion%patches(ipatch)
178 
179  SELECT CASE ( ppatch%bcType )
180 
181 ! ------------------------------------------------------------------------------
182 ! Injection boundary
183 ! ------------------------------------------------------------------------------
184 
185  CASE ( bc_injection:bc_injection+bc_range )
186  pvals => ppatch%mixt%vals
187 
188  distrib = ppatch%mixt%distrib
189 
190  DO ifl = 1,ppatch%nBFaces
191  c1 = ppatch%bf2c(ifl)
192 
193  nx = ppatch%fn(xcoord,ifl)
194  ny = ppatch%fn(ycoord,ifl)
195  nz = ppatch%fn(zcoord,ifl)
196  nm = ppatch%fn(xyzmag,ifl)
197 
198  fs = ppatch%gs(indgs*ifl)
199  fsu = rflu_descalegridspeed(pregion,fs)
200 
201  pl = pdv(dv_mixt_pres,c1)
202 
203  minj = pvals(bcdat_inject_mfrate,distrib*ifl)
204 
205  IF ( minj > 0.0_rfreal ) THEN ! Surface burning
206  tinj = pvals(bcdat_inject_temp,distrib*ifl)
207 
208  IF ( gasmodel == gas_model_tcperf ) THEN
209  cp = pgv(gv_mixt_cp ,indcp *c1)
210  mm = pgv(gv_mixt_mol,indmol*c1)
211 
212  CALL rflu_setrindstateinjectperf(cp,mm,nx,ny,nz,minj,tinj,pl, &
213  fsu,rl,ul,vl,wl,hl)
214 
215  vc = ul*nx + vl*ny + wl*nz
216  rgas = mixtperf_r_m(mm)
217  gam = mixtperf_g_cpr(cp,rgas)
218  a1 = mixtperf_c_grt(gam,rgas,tinj)
219  ELSE ! Defensive programming
220  CALL errorstop(global,err_reached_default,__line__)
221  END IF ! gasModel
222  ELSE ! Surface NOT burning
223  vc = fsu
224  a1 = pdv(dv_mixt_soun,c1)
225  END IF ! minj
226 
227  pregion%dt(c1) = pregion%dt(c1) + (abs(vc - fsu) + a1)*nm
228  END DO ! ifl
229 
230 ! ------------------------------------------------------------------------------
231 ! All other boundaries
232 ! ------------------------------------------------------------------------------
233 
234  CASE default
235  DO ifl = 1,ppatch%nBFaces
236  c1 = ppatch%bf2c(ifl)
237 
238  nx = ppatch%fn(xcoord,ifl)
239  ny = ppatch%fn(ycoord,ifl)
240  nz = ppatch%fn(zcoord,ifl)
241  nm = ppatch%fn(xyzmag,ifl)
242 
243  fs = ppatch%gs(indgs*ifl)
244  fsu = rflu_descalegridspeed(pregion,fs)
245 
246  ir1 = 1.0_rfreal/pcv(cv_mixt_dens,c1)
247 
248  u1 = pcv(cv_mixt_xmom,c1)*ir1
249  v1 = pcv(cv_mixt_ymom,c1)*ir1
250  w1 = pcv(cv_mixt_zmom,c1)*ir1
251  a1 = pdv(dv_mixt_soun,c1)
252 
253  vc = u1*nx + v1*ny + w1*nz
254 
255  pregion%dt(c1) = pregion%dt(c1) + (abs(vc - fsu) + a1)*nm
256  END DO ! ifl
257  END SELECT ! pPatch%bcType
258  END DO ! iPatch
259 
260 ! ******************************************************************************
261 ! Finalize computation of local time step. NOTE set time step in dummy cells
262 ! to crazy value, that way code will blow up immediately should it be used by
263 ! accident.
264 ! ******************************************************************************
265 
266  DO icg = 1,pgrid%nCells
267  pregion%dt(icg) = pgrid%vol(icg)/pregion%dt(icg)
268  END DO ! icg
269 
270  DO icg = pgrid%nCells+1,pgrid%nCellsTot
271  pregion%dt(icg) = REAL(ABS(CRAZY_VALUE_INT),kind=rfreal)
272  END DO ! icg
273 
274 ! ******************************************************************************
275 ! For Newton-Krylov solvers, ramp the timestep
276 ! ******************************************************************************
277 
278  IF ( global%solverType == solv_implicit_nk ) THEN
279  dtscale = 1.0
280 #ifdef PETSC
281  CALL rflu_petsc_getdtscale(global,dtscale)
282 #endif
283  DO icg = 1,pgrid%nCells
284  pregion%dt(icg) = dtscale*pregion%dt(icg)
285  ENDDO ! icg
286  END IF ! global%solverType
287 
288 ! ******************************************************************************
289 ! For unsteady flows, determine minimum step
290 ! ******************************************************************************
291 
292  IF ( global%flowType == flow_unsteady ) THEN
293  dtmin = minval(pregion%dt(1:pgrid%nCells))
294  dtminloc = minloc(pregion%dt(1:pgrid%nCells))
295 
296  pregion%dtMin = dtmin
297  pregion%dtMinLoc = dtminloc(1)
298  END IF ! global%flowType
299 
300 ! ******************************************************************************
301 ! Finalize
302 ! ******************************************************************************
303 
304  CALL deregisterfunction(global)
305 
306 END SUBROUTINE rflu_timestepinviscid
307 
308 ! ******************************************************************************
309 !
310 ! RCS Revision history:
311 !
312 ! $Log: RFLU_TimeStepInviscid.F90,v $
313 ! Revision 1.23 2008/12/06 08:44:30 mtcampbe
314 ! Updated license.
315 !
316 ! Revision 1.22 2008/11/19 22:17:43 mtcampbe
317 ! Added Illinois Open Source License/Copyright
318 !
319 ! Revision 1.21 2006/08/19 15:40:00 mparmar
320 ! Renamed patch variables
321 !
322 ! Revision 1.20 2006/04/07 15:19:22 haselbac
323 ! Removed tabs
324 !
325 ! Revision 1.19 2006/02/08 21:34:46 hdewey2
326 ! Set dtScale so not undefined when running implicit solver wo PETSC
327 !
328 ! Revision 1.18 2005/11/14 17:00:58 haselbac
329 ! Removed DEBUG statement
330 !
331 ! Revision 1.17 2005/10/31 21:09:37 haselbac
332 ! Changed specModel and SPEC_MODEL_NONE
333 !
334 ! Revision 1.16 2005/09/23 14:56:01 haselbac
335 ! Bug fix: Missing ifdef PETSC
336 !
337 ! Revision 1.15 2005/09/22 17:12:33 hdewey2
338 ! Changed implicit timestep ramping to call RFLU_PETSC_GetDtScale to get the
339 ! timestep scaling.
340 !
341 ! Revision 1.14 2005/08/17 20:28:24 hdewey2
342 ! Added timestep ramping for the implicit Newton-Krylov solver
343 !
344 ! Revision 1.13 2004/10/19 19:29:26 haselbac
345 ! Now receive pRegion, partial rewrite, cosmetics
346 !
347 ! Revision 1.12 2004/01/11 02:17:34 jiao
348 ! Eliminated some redundant trailing spaces that made some lines too long.
349 ! This changed was necessary to compile with NAG F90 compiler.
350 !
351 ! Revision 1.11 2003/10/15 02:43:57 haselbac
352 ! Added code to determine location of minimum dt
353 !
354 ! Revision 1.10 2003/09/04 20:19:37 haselbac
355 ! Removed temporary fix for Rocburn problem in GENx
356 !
357 ! Revision 1.9 2003/08/22 20:31:56 haselbac
358 ! Added temporary fix for ignition problems
359 !
360 ! Revision 1.8 2003/04/18 20:00:09 haselbac
361 ! Clean-up, added explicit initialization (prevent Frost-problem)
362 !
363 ! Revision 1.7 2003/03/15 18:58:15 haselbac
364 ! Clean-up, cosmetics
365 !
366 ! Revision 1.6 2003/01/28 14:50:06 haselbac
367 ! Use parameters in fn
368 !
369 ! Revision 1.5 2002/11/27 20:27:45 haselbac
370 ! Proper contribution from injecting boundaries
371 !
372 ! Revision 1.4 2002/11/08 21:34:49 haselbac
373 ! Fixed bug in use of grid speed
374 !
375 ! Revision 1.3 2002/09/09 15:51:56 haselbac
376 ! global and mixtInput under regions, add grid speeds
377 !
378 ! Revision 1.2 2002/07/25 18:29:48 haselbac
379 ! Bug fix, bug only shows for cases with dummy cells
380 !
381 ! Revision 1.1 2002/05/04 17:02:00 haselbac
382 ! Initial revision
383 !
384 ! ******************************************************************************
385 
386 
387 
388 
389 
390 
391 
subroutine, public rflu_setrindstateinjectperf(cpGas, mmGas, nx, ny, nz, mInj, tInj, pl, fs, rl, ul, vl, wl, Hl)
real(rfreal) function mixtperf_r_m(M)
Definition: MixtPerf_R.F90:54
subroutine rflu_timestepinviscid(pRegion)
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
real(rfreal) function, public rflu_descalegridspeed(pRegion, fs)
subroutine, public rflu_petsc_getdtscale(global, dtscale)
real(rfreal) function mixtperf_c_grt(G, R, T)
Definition: MixtPerf_C.F90:86
subroutine errorstop(global, errorCode, errorLine, addMessage)
Definition: ModError.F90:483
subroutine deregisterfunction(global)
Definition: ModError.F90:469
real(rfreal) function mixtperf_g_cpr(Cp, R)
Definition: MixtPerf_G.F90:39