Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RFLU_ModRoeFlux.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: Collection of Roe flux routines.
26 !
27 ! Description: None.
28 !
29 ! Notes: None.
30 !
31 ! ******************************************************************************
32 !
33 ! $Id: RFLU_ModRoeFlux.F90,v 1.10 2008/12/06 08:44:24 mtcampbe Exp $
34 !
35 ! Copyright: (c) 2005-2006 by the University of Illinois
36 !
37 ! ******************************************************************************
38 
40 
41  USE moddatatypes
42  USE modglobal, ONLY: t_global
43  USE modparameters
44  USE moderror
45  USE moddatastruct, ONLY: t_region
46  USE modbndpatch, ONLY: t_patch
47  USE modgrid, ONLY: t_grid
48  USE modmpi
49 
51 
52  USE rflu_modnscbc
53 
54  IMPLICIT NONE
55 
56  PRIVATE
57  PUBLIC :: rflu_roe_computeflux, &
66 
67 ! ******************************************************************************
68 ! Declarations and definitions
69 ! ******************************************************************************
70 
71  CHARACTER(CHRLEN) :: &
72  RCSIdentString = '$RCSfile: RFLU_ModRoeFlux.F90,v $ $Revision: 1.10 $'
73 
74 ! ******************************************************************************
75 ! Routines
76 ! ******************************************************************************
77 
78  CONTAINS
79 
80 
81 
82 
83 
84 
85 
86 
87 ! ******************************************************************************
88 !
89 ! Purpose: Wrapper function for Roe flux functions.
90 !
91 ! Description: None.
92 !
93 ! Input:
94 ! pRegion Pointer to region data
95 ! fluxPart Part of flux (central or dissipation)
96 !
97 ! Output: None.
98 !
99 ! Notes: None.
100 !
101 ! ******************************************************************************
102 
103 SUBROUTINE rflu_roe_computeflux(pRegion,fluxPart)
104 
105  IMPLICIT NONE
106 
107 ! ******************************************************************************
108 ! Definitions and declarations
109 ! ******************************************************************************
110 
111 ! ==============================================================================
112 ! Arguments
113 ! ==============================================================================
114 
115  INTEGER, INTENT(IN) :: fluxpart
116  TYPE(t_region), POINTER :: pregion
117 
118 ! ==============================================================================
119 ! Locals
120 ! ==============================================================================
121 
122  TYPE(t_global), POINTER :: global
123 
124 ! ******************************************************************************
125 ! Start
126 ! ******************************************************************************
127 
128  global => pregion%global
129 
130  CALL registerfunction(global,'RFLU_ROE_ComputeFlux',&
131  'RFLU_ModRoeFlux.F90')
132 
133 ! ******************************************************************************
134 ! Call flux functions
135 ! ******************************************************************************
136 
137  SELECT CASE ( global%flowType )
138 
139 ! ==============================================================================
140 ! Unsteady flow
141 ! ==============================================================================
142 
143  CASE ( flow_unsteady )
144  SELECT CASE ( pregion%mixtInput%gasModel )
145 
146 ! ------------------------------------------------------------------------------
147 ! Thermally and calorically perfect gas
148 ! ------------------------------------------------------------------------------
149 
150  CASE ( gas_model_tcperf )
151  SELECT CASE ( pregion%mixtInput%spaceOrder )
152  CASE ( discr_order_1 )
153  CALL rflu_roe_computeflux1_tcp(pregion)
154  CASE ( discr_order_2 )
155  CALL rflu_roe_computeflux2_tcp(pregion)
156  CASE default
157  CALL errorstop(global,err_reached_default,__line__)
158  END SELECT ! pRegion%mixtInput%spaceOrder
159 
160 ! ------------------------------------------------------------------------------
161 ! Mixture of gas, vapor, and liquid
162 ! ------------------------------------------------------------------------------
163 
164  CASE ( gas_model_mixt_gasliq )
165  SELECT CASE ( pregion%mixtInput%spaceOrder )
166  CASE ( discr_order_1 )
167  CALL rflu_roe_computeflux1_gl(pregion)
168  CASE ( discr_order_2 )
169  CALL rflu_roe_computeflux2_gl(pregion)
170  CASE default
171  CALL errorstop(global,err_reached_default,__line__)
172  END SELECT ! pRegion%mixtInput%spaceOrder
173 
174 ! ------------------------------------------------------------------------------
175 ! Default
176 ! ------------------------------------------------------------------------------
177 
178  CASE default
179  CALL errorstop(global,err_reached_default,__line__)
180  END SELECT ! pRegion%mixtInput%gasModel
181 
182 ! ==============================================================================
183 ! Steady flow. NOTE for explicit solver, distinguish between central and
184 ! dissipative parts of flux.
185 ! ==============================================================================
186 
187  CASE ( flow_steady )
188  SELECT CASE ( global%solverType )
189 
190 ! ------------------------------------------------------------------------------
191 ! Explicit solver
192 ! ------------------------------------------------------------------------------
193 
194  CASE ( solv_explicit )
195  SELECT CASE ( fluxpart )
196 
197 ! --------- Central part of flux -----------------------------------------------
198 
199  CASE ( flux_part_central )
200  SELECT CASE ( pregion%mixtInput%gasModel )
201  CASE ( gas_model_tcperf )
202  SELECT CASE ( pregion%mixtInput%spaceOrder )
203  CASE ( discr_order_1 )
204  CALL rflu_roe_computefluxc1(pregion)
205  CASE ( discr_order_2 )
206  CALL rflu_roe_computefluxc2_tcp(pregion)
207  CASE default
208  CALL errorstop(global,err_reached_default,__line__)
209  END SELECT ! pRegion%mixtInput%spaceOrder
210  CASE default
211  CALL errorstop(global,err_reached_default,__line__)
212  END SELECT ! pRegion%mixtInput%gasModel
213 
214 ! --------- Dissipative part of flux -------------------------------------------
215 
216  CASE ( flux_part_dissip )
217  SELECT CASE ( pregion%mixtInput%gasModel )
218  CASE ( gas_model_tcperf )
219  SELECT CASE ( pregion%mixtInput%spaceOrder )
220  CASE ( discr_order_1 )
221  CALL rflu_roe_computefluxd1_tcp(pregion)
222  CASE ( discr_order_2 )
223  CALL rflu_roe_computefluxd2_tcp(pregion)
224  CASE default
225  CALL errorstop(global,err_reached_default,__line__)
226  END SELECT ! pRegion%mixtInput%spaceOrder
227  CASE default
228  CALL errorstop(global,err_reached_default,__line__)
229  END SELECT ! pRegion%mixtInput%gasModel
230 
231 ! --------- Default ------------------------------------------------------------
232 
233  CASE default
234  CALL errorstop(global,err_reached_default,__line__)
235  END SELECT ! fluxPart
236 
237 ! ------------------------------------------------------------------------------
238 ! Implicit solver. NOTE compute entire flux.
239 ! ------------------------------------------------------------------------------
240 
241  CASE ( solv_implicit_nk )
242  SELECT CASE ( pregion%mixtInput%gasModel )
243  CASE ( gas_model_tcperf )
244  SELECT CASE ( pregion%mixtInput%spaceOrder )
245  CASE ( discr_order_1 )
246  CALL rflu_roe_computeflux1_tcp(pregion)
247  CASE ( discr_order_2 )
248  CALL rflu_roe_computeflux2_tcp(pregion)
249  CASE default
250  CALL errorstop(global,err_reached_default,__line__)
251  END SELECT ! pRegion%mixtInput%spaceOrder
252  CASE default
253  CALL errorstop(global,err_reached_default,__line__)
254  END SELECT ! pRegion%mixtInput%gasModel
255 
256 ! ------------------------------------------------------------------------------
257 ! Default
258 ! ------------------------------------------------------------------------------
259 
260  CASE default
261  CALL errorstop(global,err_reached_default,__line__)
262  END SELECT ! global%solverType
263  CASE default
264  CALL errorstop(global,err_reached_default,__line__)
265  END SELECT ! global%flowType
266 
267 ! ******************************************************************************
268 ! End
269 ! ******************************************************************************
270 
271  CALL deregisterfunction(global)
272 
273 END SUBROUTINE rflu_roe_computeflux
274 
275 
276 
277 
278 
279 
280 
281 
282 ! ******************************************************************************
283 !
284 ! Purpose: Compute central convective fluxes using first-order accurate
285 ! accurate approximation by average of variables.
286 !
287 ! Description: None.
288 !
289 ! Input:
290 ! pRegion Pointer to region
291 !
292 ! Output: None.
293 !
294 ! Notes: None.
295 !
296 ! ******************************************************************************
297 
298 SUBROUTINE rflu_roe_computefluxc1(pRegion)
299 
301 
302  IMPLICIT NONE
303 
304 ! ******************************************************************************
305 ! Definitions and declarations
306 ! ******************************************************************************
307 
308 ! ==============================================================================
309 ! Arguments
310 ! ==============================================================================
311 
312  TYPE(t_region), POINTER :: pregion
313 
314 ! ==============================================================================
315 ! Locals
316 ! ==============================================================================
317 
318  INTEGER :: c1,c2,ifg,indgs,ipatch
319  REAL(RFREAL) :: el,er,fs,irl,irr,nm,nx,ny,nz,ql,qr,rl,rr,ul,ur,vl,vr,wl,wr, &
320  pl,pr
321  REAL(RFREAL) :: flx(5)
322  REAL(RFREAL), DIMENSION(:,:), POINTER :: pcv,pdv,prhs
323  TYPE(t_global), POINTER :: global
324  TYPE(t_grid), POINTER :: pgrid
325  TYPE(t_patch), POINTER :: ppatch
326 
327 ! ******************************************************************************
328 ! Start
329 ! ******************************************************************************
330 
331  global => pregion%global
332 
333  CALL registerfunction(global,'RFLU_ROE_ComputeFluxC1',&
334  'RFLU_ModRoeFlux.F90')
335 
336 #ifdef ROCPROF
337  CALL fprofiler_begins("RFLU::ROE_ComputeFluxC1")
338 #endif
339 
340 ! ******************************************************************************
341 ! Set dimensions and pointers
342 ! ******************************************************************************
343 
344  pgrid => pregion%grid
345 
346  indgs = pgrid%indGs
347 
348  pcv => pregion%mixt%cv
349  pdv => pregion%mixt%dv
350 
351  prhs => pregion%mixt%rhs
352 
353 ! ******************************************************************************
354 ! Compute fluxes through interior faces
355 ! ******************************************************************************
356 
357  DO ifg = 1,pgrid%nFaces
358  c1 = pgrid%f2c(1,ifg)
359  c2 = pgrid%f2c(2,ifg)
360 
361 ! ==============================================================================
362 ! Get face geometry and grid speed
363 ! ==============================================================================
364 
365  nx = pgrid%fn(xcoord,ifg)
366  ny = pgrid%fn(ycoord,ifg)
367  nz = pgrid%fn(zcoord,ifg)
368  nm = pgrid%fn(xyzmag,ifg)
369 
370  fs = pgrid%gs(indgs*ifg)
371 
372 ! ==============================================================================
373 ! Compute left and right states
374 ! ==============================================================================
375 
376 ! ------------------------------------------------------------------------------
377 ! Left state
378 ! ------------------------------------------------------------------------------
379 
380  rl = pcv(cv_mixt_dens,c1)
381  irl = 1.0_rfreal/rl
382 
383  ul = pcv(cv_mixt_xmom,c1)*irl
384  vl = pcv(cv_mixt_ymom,c1)*irl
385  wl = pcv(cv_mixt_zmom,c1)*irl
386  el = pcv(cv_mixt_ener,c1)*irl
387  pl = pdv(dv_mixt_pres,c1)
388 
389  ql = ul*nx + vl*ny + wl*nz - fs
390 
391 ! ------------------------------------------------------------------------------
392 ! Right state
393 ! ------------------------------------------------------------------------------
394 
395  rr = pcv(cv_mixt_dens,c2)
396  irr = 1.0_rfreal/rr
397 
398  ur = pcv(cv_mixt_xmom,c2)*irr
399  vr = pcv(cv_mixt_ymom,c2)*irr
400  wr = pcv(cv_mixt_zmom,c2)*irr
401  er = pcv(cv_mixt_ener,c2)*irr
402  pr = pdv(dv_mixt_pres,c2)
403 
404  qr = ur*nx + vr*ny + wr*nz - fs
405 
406 ! ==============================================================================
407 ! Compute fluxes
408 ! ==============================================================================
409 
410  flx(1) = 0.5_rfreal*(ql* rl + qr* rr )*nm
411  flx(2) = 0.5_rfreal*(ql* rl*ul + pl*nx + qr* rr*ur + pr*nx)*nm
412  flx(3) = 0.5_rfreal*(ql* rl*vl + pl*ny + qr* rr*vr + pr*ny)*nm
413  flx(4) = 0.5_rfreal*(ql* rl*wl + pl*nz + qr* rr*wr + pr*nz)*nm
414  flx(5) = 0.5_rfreal*(ql*(rl*el + pl) + pl*fs + qr*(rr*er + pr) + pr*fs)*nm
415 
416 ! ==============================================================================
417 ! Accumulate into residual
418 ! ==============================================================================
419 
420  prhs(cv_mixt_dens,c1) = prhs(cv_mixt_dens,c1) + flx(1)
421  prhs(cv_mixt_xmom,c1) = prhs(cv_mixt_xmom,c1) + flx(2)
422  prhs(cv_mixt_ymom,c1) = prhs(cv_mixt_ymom,c1) + flx(3)
423  prhs(cv_mixt_zmom,c1) = prhs(cv_mixt_zmom,c1) + flx(4)
424  prhs(cv_mixt_ener,c1) = prhs(cv_mixt_ener,c1) + flx(5)
425 
426  prhs(cv_mixt_dens,c2) = prhs(cv_mixt_dens,c2) - flx(1)
427  prhs(cv_mixt_xmom,c2) = prhs(cv_mixt_xmom,c2) - flx(2)
428  prhs(cv_mixt_ymom,c2) = prhs(cv_mixt_ymom,c2) - flx(3)
429  prhs(cv_mixt_zmom,c2) = prhs(cv_mixt_zmom,c2) - flx(4)
430  prhs(cv_mixt_ener,c2) = prhs(cv_mixt_ener,c2) - flx(5)
431  END DO ! ifg
432 
433 ! ******************************************************************************
434 ! Compute fluxes through boundary faces
435 ! ******************************************************************************
436 
437  DO ipatch = 1,pregion%grid%nPatches
438  ppatch => pregion%patches(ipatch)
439 
440  IF ( ppatch%bcKind == bc_kind_nscbc ) THEN
441  CALL rflu_nscbc_compfirstpatchflux(pregion,ppatch)
442  ELSE
443  CALL rflu_centralfirstpatch(pregion,ppatch)
444  END IF ! pPatch%bcKind
445  END DO ! iPatch
446 
447 ! ******************************************************************************
448 ! End
449 ! ******************************************************************************
450 
451 #ifdef ROCPROF
452  CALL fprofiler_ends("RFLU::ROE_ComputeFluxC1")
453 #endif
454 
455  CALL deregisterfunction(global)
456 
457 END SUBROUTINE rflu_roe_computefluxc1
458 
459 
460 
461 
462 
463 
464 
465 
466 
467 
468 ! ******************************************************************************
469 !
470 ! Purpose: Compute central convective fluxes using second-order accurate
471 ! accurate approximation by average of variables for thermally and
472 ! calorically perfect gas.
473 !
474 ! Description: None.
475 !
476 ! Input:
477 ! pRegion Pointer to region
478 !
479 ! Output: None.
480 !
481 ! Notes:
482 ! 1. Assumes ideal gas and constant Cp and R! This assumption is necessary
483 ! because need to compute face states from reconstructed variables.
484 !
485 ! ******************************************************************************
486 
487 SUBROUTINE rflu_roe_computefluxc2_tcp(pRegion)
488 
489  USE modinterfaces, ONLY: mixtperf_eo_dgpuvw, &
492 
493  IMPLICIT NONE
494 
495 ! ******************************************************************************
496 ! Declarations and definitions
497 ! ******************************************************************************
498 
499 ! ==============================================================================
500 ! Arguments
501 ! ==============================================================================
502 
503  TYPE(t_region), POINTER :: pregion
504 
505 ! ==============================================================================
506 ! Locals
507 ! ==============================================================================
508 
509  INTEGER :: c1,c2,ifg,indgs,ipatch
510  REAL(RFREAL) :: dx,dy,dz,el,er,fs,g,irl,irr,nm,nx,ny,nz,ql,qr,rl,rr,ul,ur, &
511  vl,vr,wl,wr,pl,pr,xc,yc,zc
512  REAL(RFREAL) :: flx(5)
513  REAL(RFREAL), DIMENSION(:,:), POINTER :: pcv,pdv,pgv,prhs
514  REAL(RFREAL), DIMENSION(:,:,:), POINTER :: pgc
515  TYPE(t_global), POINTER :: global
516  TYPE(t_grid), POINTER :: pgrid
517  TYPE(t_patch), POINTER :: ppatch
518 
519 ! ******************************************************************************
520 ! Start
521 ! ******************************************************************************
522 
523  global => pregion%global
524 
525  CALL registerfunction(global,'RFLU_ROE_ComputeFluxC2_TCP',&
526  'RFLU_ModRoeFlux.F90')
527 
528 #ifdef ROCPROF
529  CALL fprofiler_begins("RFLU::ROE_ComputeFluxC2_TCP")
530 #endif
531 
532 ! ******************************************************************************
533 ! Set dimensions and pointers
534 ! ******************************************************************************
535 
536  pgrid => pregion%grid
537 
538  indgs = pgrid%indGs
539 
540  pcv => pregion%mixt%cv
541  pdv => pregion%mixt%dv
542 
543  pgc => pregion%mixt%gradCell
544  prhs => pregion%mixt%rhs
545 
546 ! ******************************************************************************
547 ! Define constants
548 ! ******************************************************************************
549 
550  g = global%refGamma
551 
552 ! ******************************************************************************
553 ! Compute fluxes through interior faces
554 ! ******************************************************************************
555 
556  DO ifg = 1,pgrid%nFaces
557  c1 = pgrid%f2c(1,ifg)
558  c2 = pgrid%f2c(2,ifg)
559 
560 ! ==============================================================================
561 ! Get face geometry and grid speed
562 ! ==============================================================================
563 
564  nx = pgrid%fn(xcoord,ifg)
565  ny = pgrid%fn(ycoord,ifg)
566  nz = pgrid%fn(zcoord,ifg)
567  nm = pgrid%fn(xyzmag,ifg)
568 
569  xc = pgrid%fc(xcoord,ifg)
570  yc = pgrid%fc(ycoord,ifg)
571  zc = pgrid%fc(zcoord,ifg)
572 
573  fs = pgrid%gs(indgs*ifg)
574 
575 ! ==============================================================================
576 ! Compute left and right states
577 ! ==============================================================================
578 
579 ! ------------------------------------------------------------------------------
580 ! Left state
581 ! ------------------------------------------------------------------------------
582 
583  rl = pcv(cv_mixt_dens,c1)
584  irl = 1.0_rfreal/rl
585 
586  ul = pcv(cv_mixt_xmom,c1)*irl
587  vl = pcv(cv_mixt_ymom,c1)*irl
588  wl = pcv(cv_mixt_zmom,c1)*irl
589  pl = pdv(dv_mixt_pres,c1)
590 
591  dx = xc - pgrid%cofg(xcoord,c1)
592  dy = yc - pgrid%cofg(ycoord,c1)
593  dz = zc - pgrid%cofg(zcoord,c1)
594 
595  rl = rl + pgc(xcoord,grc_mixt_dens,c1)*dx &
596  + pgc(ycoord,grc_mixt_dens,c1)*dy &
597  + pgc(zcoord,grc_mixt_dens,c1)*dz
598  ul = ul + pgc(xcoord,grc_mixt_xvel,c1)*dx &
599  + pgc(ycoord,grc_mixt_xvel,c1)*dy &
600  + pgc(zcoord,grc_mixt_xvel,c1)*dz
601  vl = vl + pgc(xcoord,grc_mixt_yvel,c1)*dx &
602  + pgc(ycoord,grc_mixt_yvel,c1)*dy &
603  + pgc(zcoord,grc_mixt_yvel,c1)*dz
604  wl = wl + pgc(xcoord,grc_mixt_zvel,c1)*dx &
605  + pgc(ycoord,grc_mixt_zvel,c1)*dy &
606  + pgc(zcoord,grc_mixt_zvel,c1)*dz
607  pl = pl + pgc(xcoord,grc_mixt_pres,c1)*dx &
608  + pgc(ycoord,grc_mixt_pres,c1)*dy &
609  + pgc(zcoord,grc_mixt_pres,c1)*dz
610 
611  el = mixtperf_eo_dgpuvw(rl,g,pl,ul,vl,wl)
612  ql = ul*nx + vl*ny + wl*nz - fs
613 
614 ! ------------------------------------------------------------------------------
615 ! Right state
616 ! ------------------------------------------------------------------------------
617 
618  rr = pcv(cv_mixt_dens,c2)
619  irr = 1.0_rfreal/rr
620 
621  ur = pcv(cv_mixt_xmom,c2)*irr
622  vr = pcv(cv_mixt_ymom,c2)*irr
623  wr = pcv(cv_mixt_zmom,c2)*irr
624  pr = pdv(dv_mixt_pres,c2)
625 
626  dx = xc - pgrid%cofg(xcoord,c2)
627  dy = yc - pgrid%cofg(ycoord,c2)
628  dz = zc - pgrid%cofg(zcoord,c2)
629 
630  rr = rr + pgc(xcoord,grc_mixt_dens,c2)*dx &
631  + pgc(ycoord,grc_mixt_dens,c2)*dy &
632  + pgc(zcoord,grc_mixt_dens,c2)*dz
633  ur = ur + pgc(xcoord,grc_mixt_xvel,c2)*dx &
634  + pgc(ycoord,grc_mixt_xvel,c2)*dy &
635  + pgc(zcoord,grc_mixt_xvel,c2)*dz
636  vr = vr + pgc(xcoord,grc_mixt_yvel,c2)*dx &
637  + pgc(ycoord,grc_mixt_yvel,c2)*dy &
638  + pgc(zcoord,grc_mixt_yvel,c2)*dz
639  wr = wr + pgc(xcoord,grc_mixt_zvel,c2)*dx &
640  + pgc(ycoord,grc_mixt_zvel,c2)*dy &
641  + pgc(zcoord,grc_mixt_zvel,c2)*dz
642  pr = pr + pgc(xcoord,grc_mixt_pres,c2)*dx &
643  + pgc(ycoord,grc_mixt_pres,c2)*dy &
644  + pgc(zcoord,grc_mixt_pres,c2)*dz
645 
646  er = mixtperf_eo_dgpuvw(rr,g,pr,ur,vr,wr)
647  qr = ur*nx + vr*ny + wr*nz - fs
648 
649 ! ==============================================================================
650 ! Compute fluxes
651 ! ==============================================================================
652 
653  flx(1) = 0.5_rfreal*(ql* rl + qr* rr )*nm
654  flx(2) = 0.5_rfreal*(ql* rl*ul + pl*nx + qr* rr*ur + pr*nx)*nm
655  flx(3) = 0.5_rfreal*(ql* rl*vl + pl*ny + qr* rr*vr + pr*ny)*nm
656  flx(4) = 0.5_rfreal*(ql* rl*wl + pl*nz + qr* rr*wr + pr*nz)*nm
657  flx(5) = 0.5_rfreal*(ql*(rl*el + pl) + pl*fs + qr*(rr*er + pr) + pr*fs)*nm
658 
659 ! ==============================================================================
660 ! Accumulate into residual
661 ! ==============================================================================
662 
663  prhs(cv_mixt_dens,c1) = prhs(cv_mixt_dens,c1) + flx(1)
664  prhs(cv_mixt_xmom,c1) = prhs(cv_mixt_xmom,c1) + flx(2)
665  prhs(cv_mixt_ymom,c1) = prhs(cv_mixt_ymom,c1) + flx(3)
666  prhs(cv_mixt_zmom,c1) = prhs(cv_mixt_zmom,c1) + flx(4)
667  prhs(cv_mixt_ener,c1) = prhs(cv_mixt_ener,c1) + flx(5)
668 
669  prhs(cv_mixt_dens,c2) = prhs(cv_mixt_dens,c2) - flx(1)
670  prhs(cv_mixt_xmom,c2) = prhs(cv_mixt_xmom,c2) - flx(2)
671  prhs(cv_mixt_ymom,c2) = prhs(cv_mixt_ymom,c2) - flx(3)
672  prhs(cv_mixt_zmom,c2) = prhs(cv_mixt_zmom,c2) - flx(4)
673  prhs(cv_mixt_ener,c2) = prhs(cv_mixt_ener,c2) - flx(5)
674  END DO ! ifg
675 
676 ! ******************************************************************************
677 ! Compute fluxes through boundary faces
678 ! ******************************************************************************
679 
680  DO ipatch = 1,pregion%grid%nPatches
681  ppatch => pregion%patches(ipatch)
682 
683  IF ( ppatch%bcKind == bc_kind_nscbc ) THEN
684  SELECT CASE ( ppatch%spaceOrder )
685  CASE ( 1 )
686  CALL rflu_nscbc_compfirstpatchflux(pregion,ppatch)
687  CASE ( 2 )
688  CALL rflu_nscbc_compsecondpatchflux(pregion,ppatch)
689  CASE default
690  CALL errorstop(global,err_reached_default,__line__)
691  END SELECT ! pPatch%spaceOrder
692  ELSE
693  SELECT CASE ( ppatch%spaceOrder )
694  CASE ( 1 )
695  CALL rflu_centralfirstpatch(pregion,ppatch)
696  CASE ( 2 )
697  CALL rflu_centralsecondpatch(pregion,ppatch)
698  CASE default
699  CALL errorstop(global,err_reached_default,__line__)
700  END SELECT ! pPatch%spaceOrder
701  END IF ! pPatch%bcKind
702  END DO ! iPatch
703 
704 ! ******************************************************************************
705 ! End
706 ! ******************************************************************************
707 
708 #ifdef ROCPROF
709  CALL fprofiler_ends("RFLU::ROE_ComputeFluxC2_TCP")
710 #endif
711 
712  CALL deregisterfunction(global)
713 
714 END SUBROUTINE rflu_roe_computefluxc2_tcp
715 
716 
717 
718 
719 
720 
721 
722 ! ******************************************************************************
723 !
724 ! Purpose: Compute dissipative fluxes using first-order accurate Roe scheme
725 ! for thermally and calorically perfect gas.
726 !
727 ! Description: None.
728 !
729 ! Input:
730 ! pRegion Pointer to region
731 !
732 ! Output: None.
733 !
734 ! Notes: None.
735 !
736 ! ******************************************************************************
737 
738 SUBROUTINE rflu_roe_computefluxd1_tcp(pRegion)
739 
740  USE modinterfaces, ONLY: mixtperf_c_ghovm2, &
742 
743  IMPLICIT NONE
744 
745 ! ******************************************************************************
746 ! Definitions and declarations
747 ! ******************************************************************************
748 
749 ! ==============================================================================
750 ! Arguments
751 ! ==============================================================================
752 
753  TYPE(t_region), POINTER :: pregion
754 
755 ! ==============================================================================
756 ! Locals
757 ! ==============================================================================
758 
759  INTEGER :: c1,c2,ifg,indgs
760  REAL(RFREAL) :: ah,betrk,cp,dissfact,dp,dq,dr,du,de,dv1,dv2,dv5,dw,efc, &
761  epsentr,fs,g,hh,hl,hr,irl,irr,l1,l2,l5,nm,nx,ny,nz,pl, &
762  pr,qh,ql,qr,rl,rh,rr,sh,term,tl,tr,t1,t2,t3,t5,ul,uh,ur, &
763  vl,vh,vr,wl,wh,wr,wt
764  REAL(RFREAL) :: flx(5)
765  REAL(RFREAL), DIMENSION(:,:), POINTER :: pcv,pdiss,pdv
766  TYPE(t_global), POINTER :: global
767  TYPE(t_grid), POINTER :: pgrid
768 
769 ! ******************************************************************************
770 ! Start
771 ! ******************************************************************************
772 
773  global => pregion%global
774 
775  CALL registerfunction(global,'RFLU_ROE_ComputeFluxD1_TCP',&
776  'RFLU_ModRoeFlux.F90')
777 
778 #ifdef ROCPROF
779  CALL fprofiler_begins("RFLU::ROE_ComputeFluxD1_TCP")
780 #endif
781 
782 ! ******************************************************************************
783 ! Set dimensions and pointers
784 ! ******************************************************************************
785 
786  pgrid => pregion%grid
787 
788  indgs = pgrid%indGs
789 
790  pcv => pregion%mixt%cv
791  pdv => pregion%mixt%dv
792 
793  pdiss => pregion%mixt%diss
794 
795 ! ******************************************************************************
796 ! Define constants
797 ! ******************************************************************************
798 
799  cp = global%refCp
800  g = global%refGamma
801 
802  epsentr = pregion%mixtInput%epsentr
803  betrk = pregion%mixtInput%betrk(pregion%irkStep)
804  dissfact = pregion%mixtInput%dissFact
805  term = 0.5_rfreal*betrk*dissfact
806 
807 ! ******************************************************************************
808 ! Compute fluxes through interior faces
809 ! ******************************************************************************
810 
811  DO ifg = 1,pgrid%nFaces
812  c1 = pgrid%f2c(1,ifg)
813  c2 = pgrid%f2c(2,ifg)
814 
815 ! ==============================================================================
816 ! Get face geometry and grid speed
817 ! ==============================================================================
818 
819  nx = pgrid%fn(xcoord,ifg)
820  ny = pgrid%fn(ycoord,ifg)
821  nz = pgrid%fn(zcoord,ifg)
822  nm = pgrid%fn(xyzmag,ifg)
823 
824  fs = pgrid%gs(indgs*ifg)
825 
826 ! ==============================================================================
827 ! Compute left and right states
828 ! ==============================================================================
829 
830 ! ------------------------------------------------------------------------------
831 ! Left state
832 ! ------------------------------------------------------------------------------
833 
834  rl = pcv(cv_mixt_dens,c1)
835  irl = 1.0_rfreal/rl
836  ul = pcv(cv_mixt_xmom,c1)*irl
837  vl = pcv(cv_mixt_ymom,c1)*irl
838  wl = pcv(cv_mixt_zmom,c1)*irl
839  pl = pdv(dv_mixt_pres,c1)
840  tl = pdv(dv_mixt_temp,c1)
841 
842  hl = mixtperf_ho_cptuvw(cp,tl,ul,vl,wl)
843 
844 ! ------------------------------------------------------------------------------
845 ! Right state
846 ! ------------------------------------------------------------------------------
847 
848  rr = pcv(cv_mixt_dens,c2)
849  irr = 1.0_rfreal/rr
850  ur = pcv(cv_mixt_xmom,c2)*irr
851  vr = pcv(cv_mixt_ymom,c2)*irr
852  wr = pcv(cv_mixt_zmom,c2)*irr
853  pr = pdv(dv_mixt_pres,c2)
854  tr = pdv(dv_mixt_temp,c2)
855 
856  hr = mixtperf_ho_cptuvw(cp,tr,ur,vr,wr)
857 
858 ! ==============================================================================
859 ! Compute Roe-averaged face variables (h for hat)
860 ! ==============================================================================
861 
862  rh = sqrt(rl*rr)
863  wt = rl/(rl + rh)
864 
865  uh = wt*ul + (1.0_rfreal-wt)*ur
866  vh = wt*vl + (1.0_rfreal-wt)*vr
867  wh = wt*wl + (1.0_rfreal-wt)*wr
868  hh = wt*hl + (1.0_rfreal-wt)*hr
869 
870  qh = uh*nx + vh*ny + wh*nz - fs
871  sh = 0.5_rfreal*(uh*uh + vh*vh + wh*wh)
872 
873  ah = mixtperf_c_ghovm2(g,hh,2.0_rfreal*sh) ! NOTE factor of 2
874 
875 ! ==============================================================================
876 ! Compute eigenvalues
877 ! ==============================================================================
878 
879  l1 = abs(qh - ah)
880  l2 = abs(qh )
881  l5 = abs(qh + ah)
882 
883 ! ==============================================================================
884 ! Compute entropy fix
885 ! ==============================================================================
886 
887  efc = epsentr*l5
888  l1 = entropyfixhartenhyman(l1,efc)
889  l2 = entropyfixhartenhyman(l2,efc)
890  l5 = entropyfixhartenhyman(l5,efc)
891 
892 ! ==============================================================================
893 ! Compute wavestrengths
894 ! ==============================================================================
895 
896  dr = rr - rl
897  du = ur - ul
898  de = vr - vl ! use de to denote dv because dv is already used
899  dw = wr - wl
900  dp = pr - pl
901  dq = du*nx + de*ny + dw*nz ! Note: no gs contribution
902 
903  dv1 = (dp - rh*ah*dq)/(2.0_rfreal*ah*ah)
904  dv5 = (dp + rh*ah*dq)/(2.0_rfreal*ah*ah)
905  dv2 = dr - dp/(ah*ah)
906 
907  t1 = l1*dv1
908  t2 = l2*dv2
909  t3 = l2*rh
910  t5 = l5*dv5
911 
912 ! ==============================================================================
913 ! Compute fluxes
914 ! ==============================================================================
915 
916  flx(1) = term*(t1 + t2 + t5 )*nm
917  flx(2) = term*(t1*(uh-nx*ah) + t2*uh + t3*(du-nx*dq) + t5*(uh+nx*ah))*nm
918  flx(3) = term*(t1*(vh-ny*ah) + t2*vh + t3*(de-ny*dq) + t5*(vh+ny*ah))*nm
919  flx(4) = term*(t1*(wh-nz*ah) + t2*wh + t3*(dw-nz*dq) + t5*(wh+nz*ah))*nm
920  flx(5) = term*(t1*(hh-qh*ah) + t2*sh + t3*(uh*du+vh*de+wh*dw-qh*dq) + t5*(hh+qh*ah))*nm
921 
922 ! ==============================================================================
923 ! Accumulate into residual
924 ! ==============================================================================
925 
926  pdiss(cv_mixt_dens,c1) = pdiss(cv_mixt_dens,c1) + flx(1)
927  pdiss(cv_mixt_xmom,c1) = pdiss(cv_mixt_xmom,c1) + flx(2)
928  pdiss(cv_mixt_ymom,c1) = pdiss(cv_mixt_ymom,c1) + flx(3)
929  pdiss(cv_mixt_zmom,c1) = pdiss(cv_mixt_zmom,c1) + flx(4)
930  pdiss(cv_mixt_ener,c1) = pdiss(cv_mixt_ener,c1) + flx(5)
931 
932  pdiss(cv_mixt_dens,c2) = pdiss(cv_mixt_dens,c2) - flx(1)
933  pdiss(cv_mixt_xmom,c2) = pdiss(cv_mixt_xmom,c2) - flx(2)
934  pdiss(cv_mixt_ymom,c2) = pdiss(cv_mixt_ymom,c2) - flx(3)
935  pdiss(cv_mixt_zmom,c2) = pdiss(cv_mixt_zmom,c2) - flx(4)
936  pdiss(cv_mixt_ener,c2) = pdiss(cv_mixt_ener,c2) - flx(5)
937  END DO ! ifg
938 
939 ! ******************************************************************************
940 ! End
941 ! ******************************************************************************
942 
943 #ifdef ROCPROF
944  CALL fprofiler_ends("RFLU::ROE_ComputeFluxD1_TCP")
945 #endif
946 
947  CALL deregisterfunction(global)
948 
949 END SUBROUTINE rflu_roe_computefluxd1_tcp
950 
951 
952 
953 
954 
955 
956 
957 
958 ! ******************************************************************************
959 !
960 ! Purpose: Compute dissipative fluxes using second-order accurate Roe scheme
961 ! for thermally and calorically perfect gas.
962 !
963 ! Description: None.
964 !
965 ! Input:
966 ! pRegion Pointer to region
967 !
968 ! Output: None.
969 !
970 ! Notes:
971 ! 1. Assumes ideal gas and constant Cp and R!
972 !
973 ! ******************************************************************************
974 
975 SUBROUTINE rflu_roe_computefluxd2_tcp(pRegion)
976 
977  USE modinterfaces, ONLY: mixtperf_c_ghovm2, &
979  mixtperf_r_cpg, &
981 
982  IMPLICIT NONE
983 
984 ! ******************************************************************************
985 ! Declarations and definitions
986 ! ******************************************************************************
987 
988 ! ==============================================================================
989 ! Arguments
990 ! ==============================================================================
991 
992  TYPE(t_region), POINTER :: pregion
993 
994 ! ==============================================================================
995 ! Locals
996 ! ==============================================================================
997 
998  INTEGER :: c1,c2,ifg,indgs
999  REAL(RFREAL) :: ah,betrk,cp,de,dissfact,dp,dq,dr,du,dv1,dv2,dv5,dw,dx, &
1000  dy,dz,efc,epsentr,fs,g,gc,hh,hl,hr,irl,irr,l1,l2,l5,nm,nx, &
1001  ny,nz,pl,pr,qh,ql,qr,rl,rh,rr,sh,term,tl,tr,t1,t2,t3, &
1002  t5,ul,uh,ur,vl,vh,vr,wl,wh,wr,wt,xc,yc,zc
1003  REAL(RFREAL) :: flx(5)
1004  REAL(RFREAL), DIMENSION(:,:), POINTER :: pcv,pdiss,pdv
1005  REAL(RFREAL), DIMENSION(:,:,:), POINTER :: pgc
1006  TYPE(t_global), POINTER :: global
1007  TYPE(t_grid), POINTER :: pgrid
1008 
1009 ! ******************************************************************************
1010 ! Start
1011 ! ******************************************************************************
1012 
1013  global => pregion%global
1014 
1015  CALL registerfunction(global,'RFLU_ROE_ComputeFluxD2_TCP',&
1016  'RFLU_ModRoeFlux.F90')
1017 
1018 #ifdef ROCPROF
1019  CALL fprofiler_begins("RFLU::ROE_ComputeFluxD2_TCP")
1020 #endif
1021 
1022 ! ******************************************************************************
1023 ! Set dimensions and pointers
1024 ! ******************************************************************************
1025 
1026  pgrid => pregion%grid
1027 
1028  indgs = pgrid%indGs
1029 
1030  pcv => pregion%mixt%cv
1031  pdv => pregion%mixt%dv
1032 
1033  pgc => pregion%mixt%gradCell
1034  pdiss => pregion%mixt%diss
1035 
1036 ! ******************************************************************************
1037 ! Define constants
1038 ! ******************************************************************************
1039 
1040  cp = global%refCp
1041  g = global%refGamma
1042  gc = mixtperf_r_cpg(cp,g)
1043 
1044  epsentr = pregion%mixtInput%epsentr
1045  betrk = pregion%mixtInput%betrk(pregion%irkStep)
1046  dissfact = pregion%mixtInput%dissFact
1047  term = 0.5_rfreal*betrk*dissfact
1048 
1049 ! ******************************************************************************
1050 ! Compute fluxes through interior faces
1051 ! ******************************************************************************
1052 
1053  DO ifg = 1,pgrid%nFaces
1054  c1 = pgrid%f2c(1,ifg)
1055  c2 = pgrid%f2c(2,ifg)
1056 
1057 ! ==============================================================================
1058 ! Get face geometry and grid speed
1059 ! ==============================================================================
1060 
1061  nx = pgrid%fn(xcoord,ifg)
1062  ny = pgrid%fn(ycoord,ifg)
1063  nz = pgrid%fn(zcoord,ifg)
1064  nm = pgrid%fn(xyzmag,ifg)
1065 
1066  xc = pgrid%fc(xcoord,ifg)
1067  yc = pgrid%fc(ycoord,ifg)
1068  zc = pgrid%fc(zcoord,ifg)
1069 
1070  fs = pgrid%gs(indgs*ifg)
1071 
1072 ! ==============================================================================
1073 ! Compute left and right states
1074 ! ==============================================================================
1075 
1076 ! ------------------------------------------------------------------------------
1077 ! Left state
1078 ! ------------------------------------------------------------------------------
1079 
1080  rl = pcv(cv_mixt_dens,c1)
1081  irl = 1.0_rfreal/rl
1082 
1083  ul = pcv(cv_mixt_xmom,c1)*irl
1084  vl = pcv(cv_mixt_ymom,c1)*irl
1085  wl = pcv(cv_mixt_zmom,c1)*irl
1086  pl = pdv(dv_mixt_pres,c1)
1087 
1088  dx = xc - pgrid%cofg(xcoord,c1)
1089  dy = yc - pgrid%cofg(ycoord,c1)
1090  dz = zc - pgrid%cofg(zcoord,c1)
1091 
1092  rl = rl + pgc(xcoord,grc_mixt_dens,c1)*dx &
1093  + pgc(ycoord,grc_mixt_dens,c1)*dy &
1094  + pgc(zcoord,grc_mixt_dens,c1)*dz
1095  ul = ul + pgc(xcoord,grc_mixt_xvel,c1)*dx &
1096  + pgc(ycoord,grc_mixt_xvel,c1)*dy &
1097  + pgc(zcoord,grc_mixt_xvel,c1)*dz
1098  vl = vl + pgc(xcoord,grc_mixt_yvel,c1)*dx &
1099  + pgc(ycoord,grc_mixt_yvel,c1)*dy &
1100  + pgc(zcoord,grc_mixt_yvel,c1)*dz
1101  wl = wl + pgc(xcoord,grc_mixt_zvel,c1)*dx &
1102  + pgc(ycoord,grc_mixt_zvel,c1)*dy &
1103  + pgc(zcoord,grc_mixt_zvel,c1)*dz
1104  pl = pl + pgc(xcoord,grc_mixt_pres,c1)*dx &
1105  + pgc(ycoord,grc_mixt_pres,c1)*dy &
1106  + pgc(zcoord,grc_mixt_pres,c1)*dz
1107 
1108  tl = mixtperf_t_dpr(rl,pl,gc)
1109  hl = mixtperf_ho_cptuvw(cp,tl,ul,vl,wl)
1110 
1111 ! ------------------------------------------------------------------------------
1112 ! Right state
1113 ! ------------------------------------------------------------------------------
1114 
1115  rr = pcv(cv_mixt_dens,c2)
1116  irr = 1.0_rfreal/rr
1117  ur = pcv(cv_mixt_xmom,c2)*irr
1118  vr = pcv(cv_mixt_ymom,c2)*irr
1119  wr = pcv(cv_mixt_zmom,c2)*irr
1120  pr = pdv(dv_mixt_pres,c2)
1121 
1122  dx = xc - pgrid%cofg(xcoord,c2)
1123  dy = yc - pgrid%cofg(ycoord,c2)
1124  dz = zc - pgrid%cofg(zcoord,c2)
1125 
1126  rr = rr + pgc(xcoord,grc_mixt_dens,c2)*dx &
1127  + pgc(ycoord,grc_mixt_dens,c2)*dy &
1128  + pgc(zcoord,grc_mixt_dens,c2)*dz
1129  ur = ur + pgc(xcoord,grc_mixt_xvel,c2)*dx &
1130  + pgc(ycoord,grc_mixt_xvel,c2)*dy &
1131  + pgc(zcoord,grc_mixt_xvel,c2)*dz
1132  vr = vr + pgc(xcoord,grc_mixt_yvel,c2)*dx &
1133  + pgc(ycoord,grc_mixt_yvel,c2)*dy &
1134  + pgc(zcoord,grc_mixt_yvel,c2)*dz
1135  wr = wr + pgc(xcoord,grc_mixt_zvel,c2)*dx &
1136  + pgc(ycoord,grc_mixt_zvel,c2)*dy &
1137  + pgc(zcoord,grc_mixt_zvel,c2)*dz
1138  pr = pr + pgc(xcoord,grc_mixt_pres,c2)*dx &
1139  + pgc(ycoord,grc_mixt_pres,c2)*dy &
1140  + pgc(zcoord,grc_mixt_pres,c2)*dz
1141 
1142  tr = mixtperf_t_dpr(rr,pr,gc)
1143  hr = mixtperf_ho_cptuvw(cp,tr,ur,vr,wr)
1144 
1145 ! ==============================================================================
1146 ! Compute Roe-averaged face variables (h for hat)
1147 ! ==============================================================================
1148 
1149  rh = sqrt(rl*rr)
1150  wt = rl/(rl + rh)
1151 
1152  uh = wt*ul + (1.0_rfreal-wt)*ur
1153  vh = wt*vl + (1.0_rfreal-wt)*vr
1154  wh = wt*wl + (1.0_rfreal-wt)*wr
1155  hh = wt*hl + (1.0_rfreal-wt)*hr
1156 
1157  qh = uh*nx + vh*ny + wh*nz - fs
1158  sh = 0.5_rfreal*(uh*uh + vh*vh + wh*wh)
1159 
1160  ah = mixtperf_c_ghovm2(g,hh,2.0_rfreal*sh) ! NOTE factor of 2
1161 
1162 ! ==============================================================================
1163 ! Compute eigenvalues
1164 ! ==============================================================================
1165 
1166  l1 = abs(qh - ah)
1167  l2 = abs(qh )
1168  l5 = abs(qh + ah)
1169 
1170 ! ==============================================================================
1171 ! Compute entropy fix
1172 ! ==============================================================================
1173 
1174  efc = epsentr*l5
1175  l1 = entropyfixhartenhyman(l1,efc)
1176  l2 = entropyfixhartenhyman(l2,efc)
1177  l5 = entropyfixhartenhyman(l5,efc)
1178 
1179 ! ==============================================================================
1180 ! Compute wavestrengths
1181 ! ==============================================================================
1182 
1183  dr = rr - rl
1184  du = ur - ul
1185  de = vr - vl ! use de to denote dv because dv is already used
1186  dw = wr - wl
1187  dp = pr - pl
1188  dq = du*nx + de*ny + dw*nz ! Note: no gs contribution
1189 
1190  dv1 = (dp - rh*ah*dq)/(2.0_rfreal*ah*ah)
1191  dv5 = (dp + rh*ah*dq)/(2.0_rfreal*ah*ah)
1192  dv2 = dr - dp/(ah*ah)
1193 
1194  t1 = l1*dv1
1195  t2 = l2*dv2
1196  t3 = l2*rh
1197  t5 = l5*dv5
1198 
1199 ! ==============================================================================
1200 ! Compute fluxes
1201 ! ==============================================================================
1202 
1203  flx(1) = term*(t1 + t2 + t5 )*nm
1204  flx(2) = term*(t1*(uh-nx*ah) + t2*uh + t3*(du-nx*dq) + t5*(uh+nx*ah))*nm
1205  flx(3) = term*(t1*(vh-ny*ah) + t2*vh + t3*(de-ny*dq) + t5*(vh+ny*ah))*nm
1206  flx(4) = term*(t1*(wh-nz*ah) + t2*wh + t3*(dw-nz*dq) + t5*(wh+nz*ah))*nm
1207  flx(5) = term*(t1*(hh-qh*ah) + t2*sh + t3*(uh*du+vh*de+wh*dw-qh*dq) + t5*(hh+qh*ah))*nm
1208 
1209 ! ==============================================================================
1210 ! Accumulate into residual
1211 ! ==============================================================================
1212 
1213  pdiss(cv_mixt_dens,c1) = pdiss(cv_mixt_dens,c1) + flx(1)
1214  pdiss(cv_mixt_xmom,c1) = pdiss(cv_mixt_xmom,c1) + flx(2)
1215  pdiss(cv_mixt_ymom,c1) = pdiss(cv_mixt_ymom,c1) + flx(3)
1216  pdiss(cv_mixt_zmom,c1) = pdiss(cv_mixt_zmom,c1) + flx(4)
1217  pdiss(cv_mixt_ener,c1) = pdiss(cv_mixt_ener,c1) + flx(5)
1218 
1219  pdiss(cv_mixt_dens,c2) = pdiss(cv_mixt_dens,c2) - flx(1)
1220  pdiss(cv_mixt_xmom,c2) = pdiss(cv_mixt_xmom,c2) - flx(2)
1221  pdiss(cv_mixt_ymom,c2) = pdiss(cv_mixt_ymom,c2) - flx(3)
1222  pdiss(cv_mixt_zmom,c2) = pdiss(cv_mixt_zmom,c2) - flx(4)
1223  pdiss(cv_mixt_ener,c2) = pdiss(cv_mixt_ener,c2) - flx(5)
1224  END DO ! ifg
1225 
1226 ! ******************************************************************************
1227 ! End
1228 ! ******************************************************************************
1229 
1230 #ifdef ROCPROF
1231  CALL fprofiler_ends("RFLU::ROE_ComputeFluxD2_TCP")
1232 #endif
1233 
1234  CALL deregisterfunction(global)
1235 
1236 END SUBROUTINE rflu_roe_computefluxd2_tcp
1237 
1238 
1239 
1240 
1241 
1242 
1243 
1244 
1245 
1246 
1247 ! ******************************************************************************
1248 !
1249 ! Purpose: Compute convective fluxes using first-order accurate Roe scheme for
1250 ! multiphase flow.
1251 !
1252 ! Description: None.
1253 !
1254 ! Input:
1255 ! pRegion Pointer to region
1256 !
1257 ! Output: None.
1258 !
1259 ! Notes: None.
1260 !
1261 ! ******************************************************************************
1262 
1263 SUBROUTINE rflu_roe_computeflux1_gl(pRegion)
1264 
1265  USE modinterfaces, ONLY: mixtgasliq_c, &
1266  mixtliq_c2_bp, &
1268  mixtperf_c2_grt, &
1269  mixtperf_cv_cpr, &
1270  mixtperf_d_prt, &
1271  mixtperf_r_cpg, &
1272  mixtperf_r_m, &
1274 
1275  IMPLICIT NONE
1276 
1277 ! ******************************************************************************
1278 ! Definitions and declarations
1279 ! ******************************************************************************
1280 
1281 ! ==============================================================================
1282 ! Arguments
1283 ! ==============================================================================
1284 
1285  TYPE(t_region), POINTER :: pregion
1286 
1287 ! ==============================================================================
1288 ! Locals
1289 ! ==============================================================================
1290 
1291  INTEGER :: c1,c2,ifg,indgs,indmf,ipatch
1292  REAL(RFREAL) :: bgh2,blh2,bp,bt,bvh2,cmh,cml,cmr,cvg,cvl,cvv,cgh2,clh2, &
1293  cvh2,cvm,dissfact,de,dp,dq,dr,dtemp,du,dv1,dv2,dv3,dv4, &
1294  dv5,dvfg,dvfv,dw,efc,egh,el,elh,epsentr,er,evh,factor1, &
1295  factor2,factor4,factor5,fdv1,fdv2,fdv3,fs,fxn1,fxn2, &
1296  fxn3,fxn4,fxn5,fxn6,invc2p,invc2pb,irl,irr,l1,l2,l3,l4, &
1297  l5,nm,nx,ny,nz,ph,pl,po,pr,qh,ql,qr,ra11,ra12x,ra12y, &
1298  ra12z,ra13,ra14,ra15,ra21,ra22x,ra22y,ra22z,ra23,ra24, &
1299  ra25,ra31,ra32x,ra32y,ra32z,ra33,ra34,ra35,ra41,ra42x, &
1300  ra42y,ra42z,ra43,ra44,ra45,ra51,ra52x,ra52y,ra52z,ra53, &
1301  ra54,ra55,rgh,rgl,rgr,rh,rl,rlh,ro,rr,rvh,rvl,rvr, &
1302  rygl,rygr,ryvl,ryvr,rg,rv,sh,t1,t2,t3,t4,t5,t6,th,tl, &
1303  to,tr,uh,ul,ur,vfgh,vfgl,vfgr,vflh,vfvh,vfvl,vfvr,vh, &
1304  vl,vr,wh,wl,wr,wt
1305  REAL(RFREAL) :: flxconv(5),flxdiss(5)
1306  REAL(RFREAL), DIMENSION(:), POINTER :: pmf
1307  REAL(RFREAL), DIMENSION(:,:), POINTER :: fn,pcvmixt,pcvspec,pdvmixt,prhs
1308  TYPE(t_global), POINTER :: global
1309  TYPE(t_patch), POINTER :: ppatch
1310  TYPE(t_grid), POINTER :: pgrid
1311 
1312 ! ******************************************************************************
1313 ! Start
1314 ! ******************************************************************************
1315 
1316  global => pregion%global
1317 
1318  CALL registerfunction(global,'RFLU_ROE_ComputeFlux1_GL',&
1319  'RFLU_ModRoeFlux.F90')
1320 
1321 ! ******************************************************************************
1322 ! Set dimensions and pointers
1323 ! ******************************************************************************
1324 
1325  pgrid => pregion%grid
1326 
1327  indgs = pregion%grid%indGs
1328  indmf = pregion%mixtInput%indMfMixt
1329  epsentr = pregion%mixtInput%epsentr
1330  dissfact = pregion%mixtInput%dissFact
1331 
1332  pcvmixt => pregion%mixt%cv
1333  pdvmixt => pregion%mixt%dv
1334  pcvspec => pregion%spec%cv
1335 
1336  pmf => pregion%mixt%mfMixt
1337  prhs => pregion%mixt%rhs
1338 
1339 ! ******************************************************************************
1340 ! Define constants
1341 ! ******************************************************************************
1342 
1343  ro = global%refDensityLiq
1344  po = global%refPressLiq
1345  to = global%refTempLiq
1346  bp = global%refBetaPLiq
1347  bt = global%refBetaTLiq
1348  cvl = global%refCvLiq
1349 
1350  rg = mixtperf_r_m(pregion%specInput%specType(1)%pMaterial%molw)
1351  cvg = mixtperf_cv_cpr(pregion%specInput%specType(1)%pMaterial%spht,rg)
1352 
1353  rv = mixtperf_r_m(pregion%specInput%specType(2)%pMaterial%molw)
1354  cvv = mixtperf_cv_cpr(pregion%specInput%specType(2)%pMaterial%spht,rv)
1355 
1356 ! ******************************************************************************
1357 ! Compute fluxes through interior faces
1358 ! ******************************************************************************
1359 
1360  DO ifg = 1,pgrid%nFaces
1361  c1 = pgrid%f2c(1,ifg)
1362  c2 = pgrid%f2c(2,ifg)
1363 
1364 ! ==============================================================================
1365 ! Get face geometry and grid speed
1366 ! ==============================================================================
1367 
1368  nx = pgrid%fn(xcoord,ifg)
1369  ny = pgrid%fn(ycoord,ifg)
1370  nz = pgrid%fn(zcoord,ifg)
1371  nm = pgrid%fn(xyzmag,ifg)
1372 
1373  fs = pgrid%gs(indgs*ifg)
1374 
1375 ! ==============================================================================
1376 ! Compute left and right states
1377 ! ==============================================================================
1378 
1379 ! ------------------------------------------------------------------------------
1380 ! Left state
1381 ! ------------------------------------------------------------------------------
1382 
1383  rl = pcvmixt(cv_mixt_dens,c1)
1384  irl = 1.0_rfreal/rl
1385 
1386  ul = pcvmixt(cv_mixt_xmom,c1)*irl
1387  vl = pcvmixt(cv_mixt_ymom,c1)*irl
1388  wl = pcvmixt(cv_mixt_zmom,c1)*irl
1389  el = pcvmixt(cv_mixt_ener,c1)*irl
1390  pl = pdvmixt(dv_mixt_pres,c1)
1391  tl = pdvmixt(dv_mixt_temp,c1)
1392  cml = pdvmixt(dv_mixt_soun,c1)
1393 
1394  rygl = pcvspec(1,c1)
1395  ryvl = pcvspec(2,c1)
1396  rvl = mixtperf_d_prt(pl,rv,tl)
1397  rgl = mixtperf_d_prt(pl,rg,tl)
1398  vfvl = ryvl/rvl
1399  vfgl = rygl/rgl
1400 
1401  ql = ul*nx + vl*ny + wl*nz - fs
1402 
1403 ! ------------------------------------------------------------------------------
1404 ! Right state
1405 ! ------------------------------------------------------------------------------
1406 
1407  rr = pcvmixt(cv_mixt_dens,c2)
1408  irr = 1.0_rfreal/rr
1409 
1410  ur = pcvmixt(cv_mixt_xmom,c2)*irr
1411  vr = pcvmixt(cv_mixt_ymom,c2)*irr
1412  wr = pcvmixt(cv_mixt_zmom,c2)*irr
1413  er = pcvmixt(cv_mixt_ener,c2)*irr
1414  pr = pdvmixt(dv_mixt_pres,c2)
1415  tr = pdvmixt(dv_mixt_temp,c2)
1416  cmr = pdvmixt(dv_mixt_soun,c2)
1417 
1418  rygr = pcvspec(1,c2)
1419  ryvr = pcvspec(2,c2)
1420  rvr = mixtperf_d_prt(pr,rv,tr)
1421  rgr = mixtperf_d_prt(pr,rg,tr)
1422  vfvr = ryvr/rvr
1423  vfgr = rygr/rgr
1424 
1425  qr = ur*nx + vr*ny + wr*nz - fs
1426 
1427 ! ==============================================================================
1428 ! Compute Roe-averaged face variables (h for hat)
1429 ! ==============================================================================
1430 
1431  rh = sqrt(rl*rr)
1432  wt = rl/(rl + rh)
1433  uh = wt*ul + (1.0_rfreal-wt)*ur
1434  vh = wt*vl + (1.0_rfreal-wt)*vr
1435  wh = wt*wl + (1.0_rfreal-wt)*wr
1436  ph = wt*pl + (1.0_rfreal-wt)*pr
1437  th = wt*tl + (1.0_rfreal-wt)*tr
1438 
1439  vfgh = wt*vfgl + (1.0_rfreal-wt)*vfgr
1440  vfvh = wt*vfvl + (1.0_rfreal-wt)*vfvr
1441  vflh = 1.0_rfreal - vfvh - vfgh
1442 
1443  qh = uh*nx + vh*ny + wh*nz - fs
1444  sh = 0.5_rfreal*(uh*uh + vh*vh + wh*wh)
1445 
1446  elh = cvl*th + sh
1447  evh = cvv*th + sh
1448  egh = cvg*th + sh
1449 
1450  clh2 = mixtliq_c2_bp(bp)
1451  cvh2 = mixtperf_c2_grt(1.0_rfreal,rv,th)
1452  cgh2 = mixtperf_c2_grt(1.0_rfreal,rg,th)
1453 
1454  rlh = mixtliq_d_dobpppobttto(ro,bp,bt,ph,po,th,to)
1455  rvh = mixtperf_d_prt(ph,rv,th)
1456  rgh = mixtperf_d_prt(ph,rg,th)
1457 
1458  blh2 = -bt/bp
1459  bvh2 = rvh*rv
1460  bgh2 = rgh*rg
1461 
1462  cvm = (rlh*vflh*cvl + rvh*vfvh*cvv + rgh*vfgh*cvg)/rh
1463 
1464  cmh = mixtgasliq_c(cvm,rh,ph,rlh,rvh,rgh,vflh,vfvh,vfgh,clh2,cvh2,cgh2, &
1465  blh2,bvh2,bgh2)
1466 
1467 ! ==============================================================================
1468 ! Compute eigenvalues
1469 ! ==============================================================================
1470 
1471  l1 = abs(qh )
1472  l2 = abs(qh )
1473  l3 = abs(qh )
1474  l4 = abs(qh - cmh)
1475  l5 = abs(qh + cmh)
1476 
1477 ! ==============================================================================
1478 ! Compute entropy fix
1479 ! ==============================================================================
1480 
1481  efc = epsentr*l5
1482  l1 = entropyfixhartenhyman(l1,efc)
1483  l2 = entropyfixhartenhyman(l2,efc)
1484  l3 = entropyfixhartenhyman(l3,efc)
1485  l4 = entropyfixhartenhyman(l4,efc)
1486  l5 = entropyfixhartenhyman(l5,efc)
1487 
1488 ! ==============================================================================
1489 ! Compute wavestrengths
1490 ! ==============================================================================
1491 
1492  dr = rr - rl
1493  du = ur - ul
1494  de = vr - vl
1495  dw = wr - wl
1496  dq = du*nx + de*ny + dw*nz ! Note: no gs contribution
1497  dp = pr - pl
1498  dtemp = tr - tl
1499  dvfv = vfvr - vfvl
1500  dvfg = vfgr - vfgl
1501 
1502  fdv1 = ph/(rh*cmh*cmh*rh*cvm*th)
1503  fdv2 = (vfgh*(rgh*cgh2 - rh*cmh*cmh &
1504  + (bgh2*ph)/(rh*cvm)))/(rgh*cgh2*rh*cmh*cmh)
1505  fdv3 = (vfvh*(rvh*cvh2 - rh*cmh*cmh &
1506  + (bvh2*ph)/(rh*cvm)))/(rvh*cvh2*rh*cmh*cmh)
1507 
1508  dv1 = (dtemp/th) - (dp*fdv1)
1509  dv2 = dvfg - dp*fdv2
1510  dv3 = dvfv - dp*fdv3
1511  dv4 = -dq/cmh + dp/(rh*cmh*cmh)
1512  dv5 = dq/cmh + dp/(rh*cmh*cmh)
1513 
1514  invc2p = vflh/clh2 + vfgh/cgh2 + vfvh/cvh2
1515  invc2pb = (blh2*vflh)/clh2 + (bgh2*vfgh)/cgh2 &
1516  + (bvh2*vfvh)/cvh2
1517 
1518  ra11 = -th*invc2pb
1519  ra12x = -th*invc2pb*uh
1520  ra12y = -th*invc2pb*vh
1521  ra12z = -th*invc2pb*wh
1522  ra13 = rlh*vflh*cvl*th + bt*cvl*th*th*vflh - th*invc2pb*sh
1523  ra14 = -(bgh2*vfgh*th)/cgh2
1524  ra15 = -(bvh2*vfvh*th)/cvh2
1525 
1526  ra21 = rgh - rlh
1527  ra22x = (rgh - rlh)*uh
1528  ra22y = (rgh - rlh)*vh
1529  ra22z = (rgh - rlh)*wh
1530  ra23 = rgh*egh - rlh*elh
1531  ra24 = rgh
1532  ra25 = 0.0_rfreal
1533 
1534  ra31 = rvh - rlh
1535  ra32x = (rvh - rlh)*uh
1536  ra32y = (rvh - rlh)*vh
1537  ra32z = (rvh - rlh)*wh
1538  ra33 = rvh*evh - rlh*elh
1539  ra34 = 0.0_rfreal
1540  ra35 = rvh
1541 
1542  fxn1 = ((rgh - rlh)*vfgh*(rgh*cgh2 - rh*cmh*cmh &
1543  + (bgh2*ph)/(rh*cvm)))/(2.0_rfreal*rgh*cgh2)
1544  fxn2 = ((rvh - rlh)*vfvh*(rvh*cvh2 - rh*cmh*cmh &
1545  + (bvh2*ph)/(rh*cvm)))/(2.0_rfreal*rvh*cvh2)
1546  factor1 = 0.5_rfreal*rh*cmh*cmh*invc2p &
1547  - (ph*invc2pb)/(2.0_rfreal*rh*cvm) + fxn1 + fxn2
1548 
1549  fxn3 = 0.5_rfreal*rh*cmh*cmh*((elh*vflh)/clh2 &
1550  + (egh*vfgh)/cgh2 + (evh*vfvh)/cvh2)
1551  fxn4 = (ph*(rlh*vflh*cvl + bt*cvl*th*vflh &
1552  - (sh*invc2pb)))/(2.0_rfreal*rh*cvm)
1553  fxn5 = ((rgh*egh - rlh*elh)*vfgh*(rgh*cgh2 - rh*cmh*cmh &
1554  + (bgh2*ph)/(rh*cvm)))/(2.0_rfreal*rgh*cgh2)
1555  fxn6 = ((rvh*evh - rlh*elh)*vfvh*(rvh*cvh2 - rh*cmh*cmh &
1556  + (bvh2*ph)/(rh*cvm)))/(2.0_rfreal*rvh*cvh2)
1557  factor2 = fxn3 + fxn4 + fxn5 + fxn6
1558 
1559  factor4 = 0.5_rfreal*rgh*vfgh
1560  factor5 = 0.5_rfreal*rvh*vfvh
1561 
1562  ra41 = factor1
1563  ra42x = factor1*uh - 0.5_rfreal*rh*cmh*nx
1564  ra42y = factor1*vh - 0.5_rfreal*rh*cmh*ny
1565  ra42z = factor1*wh - 0.5_rfreal*rh*cmh*nz
1566  ra43 = factor2 - 0.5_rfreal*rh*cmh*qh
1567  ra44 = factor4
1568  ra45 = factor5
1569 
1570  ra51 = factor1
1571  ra52x = factor1*uh + 0.5_rfreal*rh*cmh*nx
1572  ra52y = factor1*vh + 0.5_rfreal*rh*cmh*ny
1573  ra52z = factor1*wh + 0.5_rfreal*rh*cmh*nz
1574  ra53 = factor2 + 0.5_rfreal*rh*cmh*qh
1575  ra54 = factor4
1576  ra55 = factor5
1577 
1578  t1 = l1*dv1
1579  t2 = l2*dv2
1580  t3 = l3*dv3
1581  t4 = l4*dv4
1582  t5 = l5*dv5
1583  t6 = l1*rh
1584 
1585 ! ==============================================================================
1586 ! Compute fluxes
1587 ! ==============================================================================
1588 
1589 ! ------------------------------------------------------------------------------
1590 ! Central part
1591 ! ------------------------------------------------------------------------------
1592 
1593  flxconv(1) = 0.5_rfreal*(ql*rl + qr*rr )*nm
1594  flxconv(2) = 0.5_rfreal*(ql*rl*ul + pl*nx + qr*rr*ur + pr*nx)*nm
1595  flxconv(3) = 0.5_rfreal*(ql*rl*vl + pl*ny + qr*rr*vr + pr*ny)*nm
1596  flxconv(4) = 0.5_rfreal*(ql*rl*wl + pl*nz + qr*rr*wr + pr*nz)*nm
1597  flxconv(5) = 0.5_rfreal*(ql*(rl*el + pl) + pl*fs + qr*(rr*er + pr) &
1598  + pr*fs)*nm
1599 
1600 ! ------------------------------------------------------------------------------
1601 ! Dissipative part
1602 ! ------------------------------------------------------------------------------
1603 
1604  flxdiss(1) = 0.5_rfreal*dissfact*(ra11*t1 + ra21*t2 + ra31*t3 &
1605  + ra41*t4 + ra51*t5)*nm
1606  flxdiss(2) = 0.5_rfreal*dissfact*(ra12x*t1 + ra22x*t2 + ra32x*t3 &
1607  + ra42x*t4 + ra52x*t5 + t6*(du-nx*dq))*nm
1608  flxdiss(3) = 0.5_rfreal*dissfact*(ra12y*t1 + ra22y*t2 + ra32y*t3 &
1609  + ra42y*t4 + ra52y*t5 + t6*(de-ny*dq))*nm
1610  flxdiss(4) = 0.5_rfreal*dissfact*(ra12z*t1 + ra22z*t2 + ra32z*t3 &
1611  + ra42z*t4 + ra52z*t5 + t6*(dw-nz*dq))*nm
1612  flxdiss(5) = 0.5_rfreal*dissfact*(ra13*t1 + ra23*t2 + ra33*t3 &
1613  + ra43*t4 + ra53*t5 &
1614  + t6*(uh*du+vh*de+wh*dw-qh*dq))*nm
1615 
1616 ! ==============================================================================
1617 ! Store mass flux
1618 ! ==============================================================================
1619 
1620  pmf(indmf*ifg) = flxconv(1) - flxdiss(1)
1621 
1622 ! ==============================================================================
1623 ! Accumulate into residual
1624 ! ==============================================================================
1625 
1626  prhs(cv_mixt_dens,c1) = prhs(cv_mixt_dens,c1) + (flxconv(1) - flxdiss(1))
1627  prhs(cv_mixt_xmom,c1) = prhs(cv_mixt_xmom,c1) + (flxconv(2) - flxdiss(2))
1628  prhs(cv_mixt_ymom,c1) = prhs(cv_mixt_ymom,c1) + (flxconv(3) - flxdiss(3))
1629  prhs(cv_mixt_zmom,c1) = prhs(cv_mixt_zmom,c1) + (flxconv(4) - flxdiss(4))
1630  prhs(cv_mixt_ener,c1) = prhs(cv_mixt_ener,c1) + (flxconv(5) - flxdiss(5))
1631 
1632  prhs(cv_mixt_dens,c2) = prhs(cv_mixt_dens,c2) - (flxconv(1) - flxdiss(1))
1633  prhs(cv_mixt_xmom,c2) = prhs(cv_mixt_xmom,c2) - (flxconv(2) - flxdiss(2))
1634  prhs(cv_mixt_ymom,c2) = prhs(cv_mixt_ymom,c2) - (flxconv(3) - flxdiss(3))
1635  prhs(cv_mixt_zmom,c2) = prhs(cv_mixt_zmom,c2) - (flxconv(4) - flxdiss(4))
1636  prhs(cv_mixt_ener,c2) = prhs(cv_mixt_ener,c2) - (flxconv(5) - flxdiss(5))
1637  END DO ! ifg
1638 
1639 ! ******************************************************************************
1640 ! Compute fluxes through boundary faces
1641 ! ******************************************************************************
1642 
1643  DO ipatch = 1,pregion%grid%nPatches
1644  ppatch => pregion%patches(ipatch)
1645 
1646  CALL rflu_centralfirstpatch_gl(pregion,ppatch)
1647  END DO ! iPatch
1648 
1649 ! ******************************************************************************
1650 ! End
1651 ! ******************************************************************************
1652 
1653  CALL deregisterfunction(global)
1654 
1655 END SUBROUTINE rflu_roe_computeflux1_gl
1656 
1657 
1658 
1659 
1660 
1661 
1662 
1663 
1664 ! ******************************************************************************
1665 !
1666 ! Purpose: Compute convective fluxes using first-order accurate Roe scheme
1667 ! for calorically and thermally perfect gas.
1668 !
1669 ! Description: None.
1670 !
1671 ! Input:
1672 ! pRegion Pointer to region
1673 !
1674 ! Output: None.
1675 !
1676 ! Notes: None.
1677 !
1678 ! ******************************************************************************
1679 
1680 SUBROUTINE rflu_roe_computeflux1_tcp(pRegion)
1681 
1682  USE modinterfaces, ONLY: mixtperf_c_ghovm2, &
1685 
1686  IMPLICIT NONE
1687 
1688 ! ******************************************************************************
1689 ! Definitions and declarations
1690 ! ******************************************************************************
1691 
1692 ! ==============================================================================
1693 ! Arguments
1694 ! ==============================================================================
1695 
1696  TYPE(t_region), POINTER :: pregion
1697 
1698 ! ==============================================================================
1699 ! Locals
1700 ! ==============================================================================
1701 
1702  INTEGER :: c1,c2,ifg,indgs,indmf,indsd,ipatch
1703  REAL(RFREAL) :: ah,cp,dissfact,dp,dq,dr,du,de,dv1,dv2,dv5,dw,efc, &
1704  epsentr,fs,g,hh,hl,hr,irl,irr,l1,l2,l5,nm,nx,ny,nz,pl, &
1705  pr,qh,ql,qr,rl,rh,rr,sh,term,tl,tr,t1,t2,t3,t5,ul,uh,ur,vl, &
1706  vh,vr,wl,wh,wr,wt
1707  REAL(RFREAL) :: flxconv(5),flxdiss(5)
1708  REAL(RFREAL), DIMENSION(:), POINTER :: pmf
1709  REAL(RFREAL), DIMENSION(:,:), POINTER :: pcv,pdv,pgv,prhs,psd
1710  TYPE(t_global), POINTER :: global
1711  TYPE(t_grid), POINTER :: pgrid
1712  TYPE(t_patch), POINTER :: ppatch
1713 
1714 ! ******************************************************************************
1715 ! Start
1716 ! ******************************************************************************
1717 
1718  global => pregion%global
1719 
1720  CALL registerfunction(global,'RFLU_ROE_ComputeFlux1_TCP',&
1721  'RFLU_ModRoeFlux.F90')
1722 
1723 #ifdef ROCPROF
1724  CALL fprofiler_begins("RFLU::ROE_ComputeFlux1_TCP")
1725 #endif
1726 
1727 ! ******************************************************************************
1728 ! Set dimensions and pointers
1729 ! ******************************************************************************
1730 
1731  pgrid => pregion%grid
1732 
1733  indgs = pregion%grid%indGs
1734  indmf = pregion%mixtInput%indMfMixt
1735  indsd = pregion%mixtInput%indSd
1736  epsentr = pregion%mixtInput%epsentr
1737  dissfact = pregion%mixtInput%dissFact
1738 
1739  pcv => pregion%mixt%cv
1740  pdv => pregion%mixt%dv
1741 
1742  pmf => pregion%mixt%mfMixt
1743  prhs => pregion%mixt%rhs
1744  psd => pregion%mixt%sd
1745 
1746 ! ******************************************************************************
1747 ! Define constants
1748 ! ******************************************************************************
1749 
1750  cp = global%refCp
1751  g = global%refGamma
1752 
1753 ! ******************************************************************************
1754 ! Compute fluxes through interior faces
1755 ! ******************************************************************************
1756 
1757  DO ifg = 1,pgrid%nFaces
1758  c1 = pgrid%f2c(1,ifg)
1759  c2 = pgrid%f2c(2,ifg)
1760 
1761 ! ==============================================================================
1762 ! Get face geometry and grid speed
1763 ! ==============================================================================
1764 
1765  nx = pgrid%fn(xcoord,ifg)
1766  ny = pgrid%fn(ycoord,ifg)
1767  nz = pgrid%fn(zcoord,ifg)
1768  nm = pgrid%fn(xyzmag,ifg)
1769 
1770  fs = pgrid%gs(indgs*ifg)
1771 
1772 ! ==============================================================================
1773 ! Compute left and right states
1774 ! ==============================================================================
1775 
1776 ! ------------------------------------------------------------------------------
1777 ! Left state
1778 ! ------------------------------------------------------------------------------
1779 
1780  rl = pcv(cv_mixt_dens,c1)
1781  irl = 1.0_rfreal/rl
1782 
1783  ul = pcv(cv_mixt_xmom,c1)*irl
1784  vl = pcv(cv_mixt_ymom,c1)*irl
1785  wl = pcv(cv_mixt_zmom,c1)*irl
1786  pl = pdv(dv_mixt_pres,c1)
1787  tl = pdv(dv_mixt_temp,c1)
1788 
1789  hl = mixtperf_ho_cptuvw(cp,tl,ul,vl,wl)
1790 
1791  ql = ul*nx + vl*ny + wl*nz - fs
1792 
1793 ! ------------------------------------------------------------------------------
1794 ! Right state
1795 ! ------------------------------------------------------------------------------
1796 
1797  rr = pcv(cv_mixt_dens,c2)
1798  irr = 1.0_rfreal/rr
1799 
1800  ur = pcv(cv_mixt_xmom,c2)*irr
1801  vr = pcv(cv_mixt_ymom,c2)*irr
1802  wr = pcv(cv_mixt_zmom,c2)*irr
1803  pr = pdv(dv_mixt_pres,c2)
1804  tr = pdv(dv_mixt_temp,c2)
1805 
1806  hr = mixtperf_ho_cptuvw(cp,tr,ur,vr,wr)
1807 
1808  qr = ur*nx + vr*ny + wr*nz - fs
1809 
1810 ! ==============================================================================
1811 ! Compute Roe-averaged face variables (h for hat)
1812 ! ==============================================================================
1813 
1814  rh = sqrt(rl*rr)
1815  wt = rl/(rl + rh)
1816 
1817  uh = wt*ul + (1.0_rfreal-wt)*ur
1818  vh = wt*vl + (1.0_rfreal-wt)*vr
1819  wh = wt*wl + (1.0_rfreal-wt)*wr
1820  hh = wt*hl + (1.0_rfreal-wt)*hr
1821 
1822  qh = uh*nx + vh*ny + wh*nz - fs
1823  sh = 0.5_rfreal*(uh*uh + vh*vh + wh*wh)
1824 
1825  ah = mixtperf_c_ghovm2(g,hh,2.0_rfreal*sh) ! NOTE factor of 2
1826 
1827 ! ==============================================================================
1828 ! Compute eigenvalues
1829 ! ==============================================================================
1830 
1831  l1 = abs(qh - ah)
1832  l2 = abs(qh )
1833  l5 = abs(qh + ah)
1834 
1835 ! ==============================================================================
1836 ! Compute entropy fix
1837 ! ==============================================================================
1838 
1839  efc = epsentr*l5
1840  l1 = entropyfixhartenhyman(l1,efc)
1841  l2 = entropyfixhartenhyman(l2,efc)
1842  l5 = entropyfixhartenhyman(l5,efc)
1843 
1844 ! ==============================================================================
1845 ! Compute wavestrengths
1846 ! ==============================================================================
1847 
1848  dr = rr - rl
1849  du = ur - ul
1850  de = vr - vl ! use de to denote dv because dv is already used
1851  dw = wr - wl
1852  dp = pr - pl
1853  dq = du*nx + de*ny + dw*nz ! Note: no gs contribution
1854 
1855  dv1 = (dp - rh*ah*dq)/(2.0_rfreal*ah*ah)
1856  dv5 = (dp + rh*ah*dq)/(2.0_rfreal*ah*ah)
1857  dv2 = dr - dp/(ah*ah)
1858 
1859  t1 = l1*dv1
1860  t2 = l2*dv2
1861  t3 = l2*rh
1862  t5 = l5*dv5
1863 
1864 ! ==============================================================================
1865 ! Compute fluxes
1866 ! ==============================================================================
1867 
1868 ! ------------------------------------------------------------------------------
1869 ! Central part
1870 ! ------------------------------------------------------------------------------
1871 
1872  flxconv(1) = 0.5_rfreal*(ql*rl + qr*rr )*nm
1873  flxconv(2) = 0.5_rfreal*(ql*rl*ul + pl*nx + qr*rr*ur + pr*nx)*nm
1874  flxconv(3) = 0.5_rfreal*(ql*rl*vl + pl*ny + qr*rr*vr + pr*ny)*nm
1875  flxconv(4) = 0.5_rfreal*(ql*rl*wl + pl*nz + qr*rr*wr + pr*nz)*nm
1876  flxconv(5) = 0.5_rfreal*(ql*rl*hl + pl*fs + qr*rr*hr + pr*fs)*nm
1877 
1878 ! ------------------------------------------------------------------------------
1879 ! Dissipative part
1880 ! ------------------------------------------------------------------------------
1881 
1882  flxdiss(1) = 0.5_rfreal*dissfact*(t1 + t2 + t5 )*nm
1883  flxdiss(2) = 0.5_rfreal*dissfact*(t1*(uh-nx*ah) + t2*uh + t3*(du-nx*dq) + t5*(uh+nx*ah))*nm
1884  flxdiss(3) = 0.5_rfreal*dissfact*(t1*(vh-ny*ah) + t2*vh + t3*(de-ny*dq) + t5*(vh+ny*ah))*nm
1885  flxdiss(4) = 0.5_rfreal*dissfact*(t1*(wh-nz*ah) + t2*wh + t3*(dw-nz*dq) + t5*(wh+nz*ah))*nm
1886  flxdiss(5) = 0.5_rfreal*dissfact*(t1*(hh-qh*ah) + t2*sh + t3*(uh*du+vh*de+wh*dw-qh*dq) + t5*(hh+qh*ah))*nm
1887 
1888 ! ==============================================================================
1889 ! Store mass flux
1890 ! ==============================================================================
1891 
1892  pmf(indmf*ifg) = flxconv(1) - flxdiss(1)
1893 
1894 ! ==============================================================================
1895 ! Accumulate into residual
1896 ! ==============================================================================
1897 
1898  prhs(cv_mixt_dens,c1) = prhs(cv_mixt_dens,c1) + (flxconv(1) - flxdiss(1))
1899  prhs(cv_mixt_xmom,c1) = prhs(cv_mixt_xmom,c1) + (flxconv(2) - flxdiss(2))
1900  prhs(cv_mixt_ymom,c1) = prhs(cv_mixt_ymom,c1) + (flxconv(3) - flxdiss(3))
1901  prhs(cv_mixt_zmom,c1) = prhs(cv_mixt_zmom,c1) + (flxconv(4) - flxdiss(4))
1902  prhs(cv_mixt_ener,c1) = prhs(cv_mixt_ener,c1) + (flxconv(5) - flxdiss(5))
1903 
1904  prhs(cv_mixt_dens,c2) = prhs(cv_mixt_dens,c2) - (flxconv(1) - flxdiss(1))
1905  prhs(cv_mixt_xmom,c2) = prhs(cv_mixt_xmom,c2) - (flxconv(2) - flxdiss(2))
1906  prhs(cv_mixt_ymom,c2) = prhs(cv_mixt_ymom,c2) - (flxconv(3) - flxdiss(3))
1907  prhs(cv_mixt_zmom,c2) = prhs(cv_mixt_zmom,c2) - (flxconv(4) - flxdiss(4))
1908  prhs(cv_mixt_ener,c2) = prhs(cv_mixt_ener,c2) - (flxconv(5) - flxdiss(5))
1909 
1910 ! ==============================================================================
1911 ! Accumulate into substantial derivative
1912 ! ==============================================================================
1913 
1914  psd(sd_xmom,c1*indsd) = psd(sd_xmom,c1*indsd) + uh*pmf(indmf*ifg)
1915  psd(sd_ymom,c1*indsd) = psd(sd_ymom,c1*indsd) + vh*pmf(indmf*ifg)
1916  psd(sd_zmom,c1*indsd) = psd(sd_zmom,c1*indsd) + wh*pmf(indmf*ifg)
1917 
1918  psd(sd_xmom,c2*indsd) = psd(sd_xmom,c2*indsd) - uh*pmf(indmf*ifg)
1919  psd(sd_ymom,c2*indsd) = psd(sd_ymom,c2*indsd) - vh*pmf(indmf*ifg)
1920  psd(sd_zmom,c2*indsd) = psd(sd_zmom,c2*indsd) - wh*pmf(indmf*ifg)
1921  END DO ! ifg
1922 
1923 ! ******************************************************************************
1924 ! Compute fluxes through boundary faces
1925 ! ******************************************************************************
1926 
1927  DO ipatch = 1,pregion%grid%nPatches
1928  ppatch => pregion%patches(ipatch)
1929 
1930  IF ( ppatch%bcKind == bc_kind_nscbc ) THEN
1931  CALL rflu_nscbc_compfirstpatchflux(pregion,ppatch)
1932  ELSE
1933  CALL rflu_centralfirstpatch(pregion,ppatch)
1934  END IF ! pPatch%bcKind
1935  END DO ! iPatch
1936 
1937 ! ******************************************************************************
1938 ! End
1939 ! ******************************************************************************
1940 
1941 #ifdef ROCPROF
1942  CALL fprofiler_ends("RFLU::ROE_ComputeFlux1_TCP")
1943 #endif
1944 
1945  CALL deregisterfunction(global)
1946 
1947 END SUBROUTINE rflu_roe_computeflux1_tcp
1948 
1949 
1950 
1951 
1952 
1953 
1954 
1955 
1956 
1957 ! ******************************************************************************
1958 !
1959 ! Purpose: Compute convective fluxes using second-order accurate Roe scheme for
1960 ! multiphase flow.
1961 !
1962 ! Description: None.
1963 !
1964 ! Input:
1965 ! pRegion Pointer to region
1966 !
1967 ! Output: None.
1968 !
1969 ! Notes: None.
1970 !
1971 ! ******************************************************************************
1972 
1973 SUBROUTINE rflu_roe_computeflux2_gl(pRegion)
1974 
1975  USE modinterfaces, ONLY: mixtgasliq_c, &
1976  mixtliq_c2_bp, &
1978  mixtperf_c2_grt, &
1979  mixtperf_cv_cpr, &
1980  mixtperf_d_prt, &
1981  mixtperf_r_cpg, &
1982  mixtperf_r_m, &
1985 
1986  IMPLICIT NONE
1987 
1988 ! ******************************************************************************
1989 ! Definitions and declarations
1990 ! ******************************************************************************
1991 
1992 ! ==============================================================================
1993 ! Arguments
1994 ! ==============================================================================
1995 
1996  TYPE(t_region), POINTER :: pregion
1997 
1998 ! ==============================================================================
1999 ! Locals
2000 ! ==============================================================================
2001 
2002  INTEGER :: c1,c2,ifg,indgs,indmf,ipatch
2003  REAL(RFREAL) :: bgh2,bgl2,bgr2,blh2,bll2,blr2,bp,bt,bvh2,bvl2,bvr2,cmh, &
2004  cml,cmr,cvg,cvl,cvv,cgh2,cgl2,cgr2,clh2,cll2,clr2,cvh2, &
2005  cvl2,cvr2,cvm,dissfact,de,dp,dq,dr,dtemp,du,dv1,dv2,dv3, &
2006  dv4,dv5,dvfg,dvfv,dw,dx,dy,dz,efc,egh,el,elh,epsentr,er, &
2007  evh,factor1,factor2,factor4,factor5,fdv1,fdv2,fdv3,fs, &
2008  fxn1,fxn2,fxn3,fxn4,fxn5,fxn6,invc2p,invc2pb,irl,irr,l1, &
2009  l2,l3,l4,l5,nm,nx,ny,nz,ph,pl,po,pr,qh,ql,qr,ra11,ra12x, &
2010  ra12y,ra12z,ra13,ra14,ra15,ra21,ra22x,ra22y,ra22z,ra23, &
2011  ra24,ra25,ra31,ra32x,ra32y,ra32z,ra33,ra34,ra35,ra41, &
2012  ra42x,ra42y,ra42z,ra43,ra44,ra45,ra51,ra52x,ra52y,ra52z, &
2013  ra53,ra54,ra55,rel,rer,rgh,rgl,rgr,rh,rl,rlh,rll,rlr,ro, &
2014  rr,rvh,rvl,rvr,rygl,rygr,ryvl,ryvr,rg,rv,sh,t1,t2,t3,t4, &
2015  t5,t6,th,tl,to,tr,uh,ul,ur,vfgh,vfgl,vfgr,vflh,vfll,vflr, &
2016  vfvh,vfvl,vfvr,vh,vl,vr,vl2,vr2,ygl,ygr,yll,ylr,yvl,yvr, &
2017  wh,wl,wr,wt,xc,yc,zc
2018  REAL(RFREAL) :: flxconv(5),flxdiss(5)
2019  REAL(RFREAL), DIMENSION(:), POINTER :: pmf
2020  REAL(RFREAL), DIMENSION(:,:), POINTER :: pcvmixt,pcvspec,pdvmixt,prhs
2021  REAL(RFREAL), DIMENSION(:,:,:), POINTER :: pgradmixt,pgradspec
2022  TYPE(t_global), POINTER :: global
2023  TYPE(t_grid), POINTER :: pgrid
2024  TYPE(t_patch), POINTER :: ppatch
2025 
2026 ! ******************************************************************************
2027 ! Start
2028 ! ******************************************************************************
2029 
2030  global => pregion%global
2031 
2032  CALL registerfunction(global,'RFLU_ROE_ComputeFlux2_GL',&
2033  'RFLU_ModRoeFlux.F90')
2034 
2035 ! ******************************************************************************
2036 ! Set dimensions and pointers
2037 ! ******************************************************************************
2038 
2039  pgrid => pregion%grid
2040 
2041  indgs = pregion%grid%indGs
2042  indmf = pregion%mixtInput%indMfMixt
2043  epsentr = pregion%mixtInput%epsentr
2044  dissfact = pregion%mixtInput%dissFact
2045 
2046  pcvmixt => pregion%mixt%cv
2047  pdvmixt => pregion%mixt%dv
2048  pcvspec => pregion%spec%cv
2049 
2050  pgradmixt => pregion%mixt%gradCell
2051  pgradspec => pregion%spec%gradCell
2052 
2053  pmf => pregion%mixt%mfMixt
2054  prhs => pregion%mixt%rhs
2055 
2056 ! ******************************************************************************
2057 ! Define constants
2058 ! ******************************************************************************
2059 
2060  ro = global%refDensityLiq
2061  po = global%refPressLiq
2062  to = global%refTempLiq
2063  bp = global%refBetaPLiq
2064  bt = global%refBetaTLiq
2065  cvl = global%refCvLiq
2066 
2067  rg = mixtperf_r_m(pregion%specInput%specType(1)%pMaterial%molw)
2068  cvg = mixtperf_cv_cpr(pregion%specInput%specType(1)%pMaterial%spht,rg)
2069 
2070  rv = mixtperf_r_m(pregion%specInput%specType(2)%pMaterial%molw)
2071  cvv = mixtperf_cv_cpr(pregion%specInput%specType(2)%pMaterial%spht,rv)
2072 
2073 ! ******************************************************************************
2074 ! Compute fluxes through interior faces
2075 ! ******************************************************************************
2076 
2077  DO ifg = 1,pgrid%nFaces
2078  c1 = pgrid%f2c(1,ifg)
2079  c2 = pgrid%f2c(2,ifg)
2080 
2081 ! ==============================================================================
2082 ! Get face geometry and grid speed
2083 ! ==============================================================================
2084 
2085  nx = pgrid%fn(xcoord,ifg)
2086  ny = pgrid%fn(ycoord,ifg)
2087  nz = pgrid%fn(zcoord,ifg)
2088  nm = pgrid%fn(xyzmag,ifg)
2089 
2090  xc = pgrid%fc(xcoord,ifg)
2091  yc = pgrid%fc(ycoord,ifg)
2092  zc = pgrid%fc(zcoord,ifg)
2093 
2094  fs = pgrid%gs(indgs*ifg)
2095 
2096 ! ==============================================================================
2097 ! Compute left and right states
2098 ! ==============================================================================
2099 
2100 ! -----------------------------------------------------------------------------
2101 ! Left state
2102 ! -----------------------------------------------------------------------------
2103 
2104  rl = pcvmixt(cv_mixt_dens,c1)
2105  irl = 1.0_rfreal/rl
2106 
2107  ul = pcvmixt(cv_mixt_xmom,c1)*irl
2108  vl = pcvmixt(cv_mixt_ymom,c1)*irl
2109  wl = pcvmixt(cv_mixt_zmom,c1)*irl
2110  pl = pdvmixt(dv_mixt_pres,c1)
2111  tl = pdvmixt(dv_mixt_temp,c1)
2112 
2113  ygl = pcvspec(1,c1)*irl
2114  yvl = pcvspec(2,c1)*irl
2115 
2116  dx = xc - pgrid%cofg(xcoord,c1)
2117  dy = yc - pgrid%cofg(ycoord,c1)
2118  dz = zc - pgrid%cofg(zcoord,c1)
2119 
2120  pl = pl + pgradmixt(xcoord,grc_mixt_pres,c1)*dx &
2121  + pgradmixt(ycoord,grc_mixt_pres,c1)*dy &
2122  + pgradmixt(zcoord,grc_mixt_pres,c1)*dz
2123  ul = ul + pgradmixt(xcoord,grc_mixt_xvel,c1)*dx &
2124  + pgradmixt(ycoord,grc_mixt_xvel,c1)*dy &
2125  + pgradmixt(zcoord,grc_mixt_xvel,c1)*dz
2126  vl = vl + pgradmixt(xcoord,grc_mixt_yvel,c1)*dx &
2127  + pgradmixt(ycoord,grc_mixt_yvel,c1)*dy &
2128  + pgradmixt(zcoord,grc_mixt_yvel,c1)*dz
2129  wl = wl + pgradmixt(xcoord,grc_mixt_zvel,c1)*dx &
2130  + pgradmixt(ycoord,grc_mixt_zvel,c1)*dy &
2131  + pgradmixt(zcoord,grc_mixt_zvel,c1)*dz
2132  tl = tl + pgradmixt(xcoord,grc_mixt_temp,c1)*dx &
2133  + pgradmixt(ycoord,grc_mixt_temp,c1)*dy &
2134  + pgradmixt(zcoord,grc_mixt_temp,c1)*dz
2135 
2136  ygl = ygl + pgradspec(xcoord,1,c1)*dx &
2137  + pgradspec(ycoord,1,c1)*dy &
2138  + pgradspec(zcoord,1,c1)*dz
2139  yvl = yvl + pgradspec(xcoord,2,c1)*dx &
2140  + pgradspec(ycoord,2,c1)*dy &
2141  + pgradspec(zcoord,2,c1)*dz
2142 
2143  yll = 1.0_rfreal - ygl - yvl
2144 
2145  vl2 = ul*ul + vl*vl + wl*wl
2146  ql = ul*nx + vl*ny + wl*nz - fs
2147 
2148  rll = mixtliq_d_dobpppobttto(ro,bp,bt,pl,po,tl,to)
2149  rvl = mixtperf_d_prt(pl,rv,tl)
2150  rgl = mixtperf_d_prt(pl,rg,tl)
2151  rl = 1.0_rfreal/(yll/rll + yvl/rvl + ygl/rgl)
2152 
2153  vfgl = rl*ygl/rgl
2154  vfvl = rl*yvl/rvl
2155  vfll = 1.0_rfreal - vfgl - vfvl
2156 
2157  rel = (rll*vfll*cvl + rgl*vfgl*cvg + rvl*vfvl*cvv)*tl + 0.5_rfreal*rl*vl2
2158  el = rel/rl
2159 
2160  cll2 = mixtliq_c2_bp(bp)
2161  cvl2 = mixtperf_c2_grt(1.0_rfreal,rv,tl)
2162  cgl2 = mixtperf_c2_grt(1.0_rfreal,rg,tl)
2163 
2164  bll2 = -bt/bp
2165  bvl2 = rvl*rv
2166  bgl2 = rgl*rg
2167 
2168  cvm = (rll*vfll*cvl + rvl*vfvl*cvv + rgl*vfgl*cvg)/rl
2169 
2170  cml = mixtgasliq_c(cvm,rl,pl,rll,rvl,rgl,vfll,vfvl,vfgl,cll2,cvl2,cgl2, &
2171  bll2,bvl2,bgl2)
2172 
2173 !----------------------------------------------------------------------------
2174 ! Right state
2175 ! -----------------------------------------------------------------------------
2176 
2177  rr = pcvmixt(cv_mixt_dens,c2)
2178  irr = 1.0_rfreal/rr
2179 
2180  ur = pcvmixt(cv_mixt_xmom,c2)*irr
2181  vr = pcvmixt(cv_mixt_ymom,c2)*irr
2182  wr = pcvmixt(cv_mixt_zmom,c2)*irr
2183  pr = pdvmixt(dv_mixt_pres,c2)
2184  tr = pdvmixt(dv_mixt_temp,c2)
2185 
2186  ygr = pcvspec(1,c2)*irr
2187  yvr = pcvspec(2,c2)*irr
2188 
2189  dx = xc - pgrid%cofg(xcoord,c2)
2190  dy = yc - pgrid%cofg(ycoord,c2)
2191  dz = zc - pgrid%cofg(zcoord,c2)
2192 
2193  pr = pr + pgradmixt(xcoord,grc_mixt_pres,c2)*dx &
2194  + pgradmixt(ycoord,grc_mixt_pres,c2)*dy &
2195  + pgradmixt(zcoord,grc_mixt_pres,c2)*dz
2196  ur = ur + pgradmixt(xcoord,grc_mixt_xvel,c2)*dx &
2197  + pgradmixt(ycoord,grc_mixt_xvel,c2)*dy &
2198  + pgradmixt(zcoord,grc_mixt_xvel,c2)*dz
2199  vr = vr + pgradmixt(xcoord,grc_mixt_yvel,c2)*dx &
2200  + pgradmixt(ycoord,grc_mixt_yvel,c2)*dy &
2201  + pgradmixt(zcoord,grc_mixt_yvel,c2)*dz
2202  wr = wr + pgradmixt(xcoord,grc_mixt_zvel,c2)*dx &
2203  + pgradmixt(ycoord,grc_mixt_zvel,c2)*dy &
2204  + pgradmixt(zcoord,grc_mixt_zvel,c2)*dz
2205  tr = tr + pgradmixt(xcoord,grc_mixt_temp,c2)*dx &
2206  + pgradmixt(ycoord,grc_mixt_temp,c2)*dy &
2207  + pgradmixt(zcoord,grc_mixt_temp,c2)*dz
2208 
2209  ygr = ygr + pgradspec(xcoord,1,c2)*dx &
2210  + pgradspec(ycoord,1,c2)*dy &
2211  + pgradspec(zcoord,1,c2)*dz
2212  yvr = yvr + pgradspec(xcoord,2,c2)*dx &
2213  + pgradspec(ycoord,2,c2)*dy &
2214  + pgradspec(zcoord,2,c2)*dz
2215 
2216  ylr = 1.0_rfreal - ygr - yvr
2217 
2218  vr2 = ur*ur + vr*vr + wr*wr
2219  qr = ur*nx + vr*ny + wr*nz - fs
2220 
2221  rlr = mixtliq_d_dobpppobttto(ro,bp,bt,pr,po,tr,to)
2222  rvr = mixtperf_d_prt(pr,rv,tr)
2223  rgr = mixtperf_d_prt(pr,rg,tr)
2224  rr = 1.0_rfreal/(ylr/rlr + yvr/rvr + ygr/rgr)
2225 
2226  vfgr = rr*ygr/rgr
2227  vfvr = rr*yvr/rvr
2228  vflr = 1.0_rfreal - vfgr - vfvr
2229 
2230  rer = (rlr*vflr*cvl + rgr*vfgr*cvg + rvr*vfvr*cvv)*tr + 0.5_rfreal*rr*vr2
2231  er = rer/rr
2232 
2233  clr2 = mixtliq_c2_bp(bp)
2234  cvr2 = mixtperf_c2_grt(1.0_rfreal,rv,tr)
2235  cgr2 = mixtperf_c2_grt(1.0_rfreal,rg,tr)
2236 
2237  blr2 = -bt/bp
2238  bvr2 = rvr*rv
2239  bgr2 = rgr*rg
2240 
2241  cvm = (rlr*vflr*cvl + rvr*vfvr*cvv + rgr*vfgr*cvg)/rr
2242 
2243  cmr = mixtgasliq_c(cvm,rr,pr,rlr,rvr,rgr,vflr,vfvr,vfgr,clr2,cvr2,cgr2, &
2244  blr2,bvr2,bgr2)
2245 
2246 ! ==============================================================================
2247 ! Compute Roe-averaged face variables (h for hat)
2248 ! ==============================================================================
2249 
2250  rh = sqrt(rl*rr)
2251  wt = rl/(rl + rh)
2252  uh = wt*ul + (1.0_rfreal-wt)*ur
2253  vh = wt*vl + (1.0_rfreal-wt)*vr
2254  wh = wt*wl + (1.0_rfreal-wt)*wr
2255  ph = wt*pl + (1.0_rfreal-wt)*pr
2256  th = wt*tl + (1.0_rfreal-wt)*tr
2257 
2258  vfgh = wt*vfgl + (1.0_rfreal-wt)*vfgr
2259  vfvh = wt*vfvl + (1.0_rfreal-wt)*vfvr
2260  vflh = 1.0_rfreal - vfvh - vfgh
2261 
2262  qh = uh*nx + vh*ny + wh*nz - fs
2263  sh = 0.5_rfreal*(uh*uh + vh*vh + wh*wh)
2264 
2265  elh = cvl*th + sh
2266  evh = cvv*th + sh
2267  egh = cvg*th + sh
2268 
2269  clh2 = mixtliq_c2_bp(bp)
2270  cvh2 = mixtperf_c2_grt(1.0_rfreal,rv,th)
2271  cgh2 = mixtperf_c2_grt(1.0_rfreal,rg,th)
2272 
2273  rlh = mixtliq_d_dobpppobttto(ro,bp,bt,ph,po,th,to)
2274  rvh = mixtperf_d_prt(ph,rv,th)
2275  rgh = mixtperf_d_prt(ph,rg,th)
2276 
2277  blh2 = -bt/bp
2278  bvh2 = rvh*rv
2279  bgh2 = rgh*rg
2280 
2281  cvm = (rlh*vflh*cvl + rvh*vfvh*cvv + rgh*vfgh*cvg)/rh
2282 
2283  cmh = mixtgasliq_c(cvm,rh,ph,rlh,rvh,rgh,vflh,vfvh,vfgh,clh2,cvh2,cgh2, &
2284  blh2,bvh2,bgh2)
2285 
2286 ! ==============================================================================
2287 ! Compute eigenvalues
2288 ! ==============================================================================
2289 
2290  l1 = abs(qh )
2291  l2 = abs(qh )
2292  l3 = abs(qh )
2293  l4 = abs(qh - cmh)
2294  l5 = abs(qh + cmh)
2295 
2296 ! ==============================================================================
2297 ! Compute entropy fix
2298 ! ==============================================================================
2299 
2300  efc = epsentr*l5
2301  l1 = entropyfixhartenhyman(l1,efc)
2302  l2 = entropyfixhartenhyman(l2,efc)
2303  l3 = entropyfixhartenhyman(l3,efc)
2304  l4 = entropyfixhartenhyman(l4,efc)
2305  l5 = entropyfixhartenhyman(l5,efc)
2306 
2307 ! ==============================================================================
2308 ! Compute wavestrengths
2309 ! ==============================================================================
2310 
2311  dr = rr - rl
2312  du = ur - ul
2313  de = vr - vl
2314  dw = wr - wl
2315  dq = du*nx + de*ny + dw*nz ! Note: no gs contribution
2316  dp = pr - pl
2317  dtemp = tr - tl
2318  dvfv = vfvr - vfvl
2319  dvfg = vfgr - vfgl
2320 
2321  fdv1 = ph/(rh*cmh*cmh*rh*cvm*th)
2322  fdv2 = (vfgh*(rgh*cgh2 - rh*cmh*cmh &
2323  + (bgh2*ph)/(rh*cvm)))/(rgh*cgh2*rh*cmh*cmh)
2324  fdv3 = (vfvh*(rvh*cvh2 - rh*cmh*cmh &
2325  + (bvh2*ph)/(rh*cvm)))/(rvh*cvh2*rh*cmh*cmh)
2326 
2327  dv1 = (dtemp/th) - (dp*fdv1)
2328  dv2 = dvfg - dp*fdv2
2329  dv3 = dvfv - dp*fdv3
2330  dv4 = -dq/cmh + dp/(rh*cmh*cmh)
2331  dv5 = dq/cmh + dp/(rh*cmh*cmh)
2332 
2333  invc2p = vflh/clh2 + vfgh/cgh2 + vfvh/cvh2
2334  invc2pb = (blh2*vflh)/clh2 + (bgh2*vfgh)/cgh2 &
2335  + (bvh2*vfvh)/cvh2
2336 
2337  ra11 = -th*invc2pb
2338  ra12x = -th*invc2pb*uh
2339  ra12y = -th*invc2pb*vh
2340  ra12z = -th*invc2pb*wh
2341  ra13 = rlh*vflh*cvl*th + bt*cvl*th*th*vflh - th*invc2pb*sh
2342  ra14 = -(bgh2*vfgh*th)/cgh2
2343  ra15 = -(bvh2*vfvh*th)/cvh2
2344 
2345  ra21 = rgh - rlh
2346  ra22x = (rgh - rlh)*uh
2347  ra22y = (rgh - rlh)*vh
2348  ra22z = (rgh - rlh)*wh
2349  ra23 = rgh*egh - rlh*elh
2350  ra24 = rgh
2351  ra25 = 0.0_rfreal
2352 
2353  ra31 = rvh - rlh
2354  ra32x = (rvh - rlh)*uh
2355  ra32y = (rvh - rlh)*vh
2356  ra32z = (rvh - rlh)*wh
2357  ra33 = rvh*evh - rlh*elh
2358  ra34 = 0.0_rfreal
2359  ra35 = rvh
2360 
2361  fxn1 = ((rgh - rlh)*vfgh*(rgh*cgh2 - rh*cmh*cmh &
2362  + (bgh2*ph)/(rh*cvm)))/(2.0_rfreal*rgh*cgh2)
2363  fxn2 = ((rvh - rlh)*vfvh*(rvh*cvh2 - rh*cmh*cmh &
2364  + (bvh2*ph)/(rh*cvm)))/(2.0_rfreal*rvh*cvh2)
2365  factor1 = 0.5_rfreal*rh*cmh*cmh*invc2p &
2366  - (ph*invc2pb)/(2.0_rfreal*rh*cvm) + fxn1 + fxn2
2367 
2368  fxn3 = 0.5_rfreal*rh*cmh*cmh*((elh*vflh)/clh2 &
2369  + (egh*vfgh)/cgh2 + (evh*vfvh)/cvh2)
2370  fxn4 = (ph*(rlh*vflh*cvl + bt*cvl*th*vflh &
2371  - (sh*invc2pb)))/(2.0_rfreal*rh*cvm)
2372  fxn5 = ((rgh*egh - rlh*elh)*vfgh*(rgh*cgh2 - rh*cmh*cmh &
2373  + (bgh2*ph)/(rh*cvm)))/(2.0_rfreal*rgh*cgh2)
2374  fxn6 = ((rvh*evh - rlh*elh)*vfvh*(rvh*cvh2 - rh*cmh*cmh &
2375  + (bvh2*ph)/(rh*cvm)))/(2.0_rfreal*rvh*cvh2)
2376  factor2 = fxn3 + fxn4 + fxn5 + fxn6
2377 
2378  factor4 = 0.5_rfreal*rgh*vfgh
2379  factor5 = 0.5_rfreal*rvh*vfvh
2380 
2381  ra41 = factor1
2382  ra42x = factor1*uh - 0.5_rfreal*rh*cmh*nx
2383  ra42y = factor1*vh - 0.5_rfreal*rh*cmh*ny
2384  ra42z = factor1*wh - 0.5_rfreal*rh*cmh*nz
2385  ra43 = factor2 - 0.5_rfreal*rh*cmh*qh
2386  ra44 = factor4
2387  ra45 = factor5
2388 
2389  ra51 = factor1
2390  ra52x = factor1*uh + 0.5_rfreal*rh*cmh*nx
2391  ra52y = factor1*vh + 0.5_rfreal*rh*cmh*ny
2392  ra52z = factor1*wh + 0.5_rfreal*rh*cmh*nz
2393  ra53 = factor2 + 0.5_rfreal*rh*cmh*qh
2394  ra54 = factor4
2395  ra55 = factor5
2396 
2397  t1 = l1*dv1
2398  t2 = l2*dv2
2399  t3 = l3*dv3
2400  t4 = l4*dv4
2401  t5 = l5*dv5
2402  t6 = l1*rh
2403 
2404 ! ==============================================================================
2405 ! Compute fluxes
2406 ! ==============================================================================
2407 
2408 ! ------------------------------------------------------------------------------
2409 ! Central part
2410 ! ------------------------------------------------------------------------------
2411 
2412  flxconv(1) = 0.5_rfreal*(ql*rl + qr*rr )*nm
2413  flxconv(2) = 0.5_rfreal*(ql*rl*ul + pl*nx + qr*rr*ur + pr*nx)*nm
2414  flxconv(3) = 0.5_rfreal*(ql*rl*vl + pl*ny + qr*rr*vr + pr*ny)*nm
2415  flxconv(4) = 0.5_rfreal*(ql*rl*wl + pl*nz + qr*rr*wr + pr*nz)*nm
2416  flxconv(5) = 0.5_rfreal*(ql*(rl*el + pl) + pl*fs + qr*(rr*er + pr) &
2417  + pr*fs)*nm
2418 
2419 ! ------------------------------------------------------------------------------
2420 ! Dissipative part
2421 ! ------------------------------------------------------------------------------
2422 
2423  flxdiss(1) = 0.5_rfreal*dissfact*(ra11*t1 + ra21*t2 + ra31*t3 &
2424  + ra41*t4 + ra51*t5)*nm
2425  flxdiss(2) = 0.5_rfreal*dissfact*(ra12x*t1 + ra22x*t2 + ra32x*t3 &
2426  + ra42x*t4 + ra52x*t5 + t6*(du-nx*dq))*nm
2427  flxdiss(3) = 0.5_rfreal*dissfact*(ra12y*t1 + ra22y*t2 + ra32y*t3 &
2428  + ra42y*t4 + ra52y*t5 + t6*(de-ny*dq))*nm
2429  flxdiss(4) = 0.5_rfreal*dissfact*(ra12z*t1 + ra22z*t2 + ra32z*t3 &
2430  + ra42z*t4 + ra52z*t5 + t6*(dw-nz*dq))*nm
2431  flxdiss(5) = 0.5_rfreal*dissfact*(ra13*t1 + ra23*t2 + ra33*t3 &
2432  + ra43*t4 + ra53*t5 &
2433  + t6*(uh*du+vh*de+wh*dw-qh*dq))*nm
2434 
2435 ! ==============================================================================
2436 ! Store mass flux
2437 ! ==============================================================================
2438 
2439  pmf(indmf*ifg) = flxconv(1) - flxdiss(1)
2440 
2441 ! ==============================================================================
2442 ! Accumulate into residual
2443 ! ==============================================================================
2444 
2445  prhs(cv_mixt_dens,c1) = prhs(cv_mixt_dens,c1) + (flxconv(1) - flxdiss(1))
2446  prhs(cv_mixt_xmom,c1) = prhs(cv_mixt_xmom,c1) + (flxconv(2) - flxdiss(2))
2447  prhs(cv_mixt_ymom,c1) = prhs(cv_mixt_ymom,c1) + (flxconv(3) - flxdiss(3))
2448  prhs(cv_mixt_zmom,c1) = prhs(cv_mixt_zmom,c1) + (flxconv(4) - flxdiss(4))
2449  prhs(cv_mixt_ener,c1) = prhs(cv_mixt_ener,c1) + (flxconv(5) - flxdiss(5))
2450 
2451  prhs(cv_mixt_dens,c2) = prhs(cv_mixt_dens,c2) - (flxconv(1) - flxdiss(1))
2452  prhs(cv_mixt_xmom,c2) = prhs(cv_mixt_xmom,c2) - (flxconv(2) - flxdiss(2))
2453  prhs(cv_mixt_ymom,c2) = prhs(cv_mixt_ymom,c2) - (flxconv(3) - flxdiss(3))
2454  prhs(cv_mixt_zmom,c2) = prhs(cv_mixt_zmom,c2) - (flxconv(4) - flxdiss(4))
2455  prhs(cv_mixt_ener,c2) = prhs(cv_mixt_ener,c2) - (flxconv(5) - flxdiss(5))
2456  END DO ! ifg
2457 
2458 ! ******************************************************************************
2459 ! Compute fluxes through boundary faces
2460 ! ******************************************************************************
2461 
2462  DO ipatch = 1,pregion%grid%nPatches
2463  ppatch => pregion%patches(ipatch)
2464 
2465  IF ( ppatch%bcKind == bc_kind_nscbc ) THEN
2466  SELECT CASE ( ppatch%spaceOrder )
2467  CASE ( 1 )
2468  CALL rflu_nscbc_compfirstpatchflux(pregion,ppatch)
2469  CASE ( 2 )
2470  CALL rflu_nscbc_compsecondpatchflux(pregion,ppatch)
2471  CASE default
2472  CALL errorstop(global,err_reached_default,__line__)
2473  END SELECT ! pPatch%spaceOrder
2474  ELSE
2475  SELECT CASE ( ppatch%spaceOrder )
2476  CASE ( 1 )
2477  CALL rflu_centralfirstpatch_gl(pregion,ppatch)
2478  CASE ( 2 )
2479  CALL rflu_centralsecondpatch_gl(pregion,ppatch)
2480  CASE default
2481  CALL errorstop(global,err_reached_default,__line__)
2482  END SELECT ! pPatch%spaceOrder
2483  END IF ! pPatch%bcKind
2484  END DO ! iPatch
2485 
2486 ! ******************************************************************************
2487 ! End
2488 ! ******************************************************************************
2489 
2490  CALL deregisterfunction(global)
2491 
2492 END SUBROUTINE rflu_roe_computeflux2_gl
2493 
2494 
2495 
2496 
2497 
2498 
2499 
2500 
2501 
2502 
2503 ! ******************************************************************************
2504 !
2505 ! Purpose: Compute convective fluxes using second-order accurate Roe scheme
2506 ! for calorically and thermally perfect gas.
2507 !
2508 ! Description: None.
2509 !
2510 ! Input:
2511 ! pRegion Pointer to region
2512 !
2513 ! Output: None.
2514 !
2515 ! Notes: None.
2516 !
2517 ! ******************************************************************************
2518 
2519 SUBROUTINE rflu_roe_computeflux2_tcp(pRegion)
2520 
2521  USE modinterfaces, ONLY: mixtperf_c_ghovm2, &
2523  mixtperf_r_cpg, &
2524  mixtperf_t_dpr, &
2527 
2528  IMPLICIT NONE
2529 
2530 ! ******************************************************************************
2531 ! Definitions and declarations
2532 ! ******************************************************************************
2533 
2534 ! ==============================================================================
2535 ! Arguments
2536 ! ==============================================================================
2537 
2538  TYPE(t_region), POINTER :: pregion
2539 
2540 ! ==============================================================================
2541 ! Locals
2542 ! ==============================================================================
2543 
2544  INTEGER :: c1,c2,ifg,indgs,indmf,indsd,ipatch
2545  REAL(RFREAL) :: ah,cp,de,dissfact,dp,dq,dr,du,dv1,dv2,dv5,dw,dx,dy,dz, &
2546  efc,epsentr,fs,g,gc,hh,hl,hr,irl,irr,l1,l2,l5,nm,nx,ny,nz, &
2547  pl,pr,qh,ql,qr,rl,rh,rr,sh,term,tl,tr,t1,t2,t3,t5,ul, &
2548  uh,ur,vl,vh,vr,wl,wh,wr,wt,xc,yc,zc
2549  REAL(RFREAL) :: flxconv(5),flxdiss(5)
2550  REAL(RFREAL), DIMENSION(:), POINTER :: pmf
2551  REAL(RFREAL), DIMENSION(:,:), POINTER :: pcv,pdv,prhs,psd
2552  REAL(RFREAL), DIMENSION(:,:,:), POINTER :: pgc
2553  TYPE(t_global), POINTER :: global
2554  TYPE(t_grid), POINTER :: pgrid
2555  TYPE(t_patch), POINTER :: ppatch
2556 
2557 ! ******************************************************************************
2558 ! Start
2559 ! ******************************************************************************
2560 
2561  global => pregion%global
2562 
2563  CALL registerfunction(global,'RFLU_ROE_ComputeFlux2_TCP',&
2564  'RFLU_ModRoeFlux.F90')
2565 
2566 #ifdef ROCPROF
2567  CALL fprofiler_begins("RFLU::ROE_ComputeFlux2_TCP")
2568 #endif
2569 
2570 ! ******************************************************************************
2571 ! Set dimensions and pointers
2572 ! ******************************************************************************
2573 
2574  pgrid => pregion%grid
2575 
2576  indgs = pregion%grid%indGs
2577  indmf = pregion%mixtInput%indMfMixt
2578  indsd = pregion%mixtInput%indSd
2579  epsentr = pregion%mixtInput%epsentr
2580  dissfact = pregion%mixtInput%dissFact
2581 
2582  pcv => pregion%mixt%cv
2583  pdv => pregion%mixt%dv
2584 
2585  pgc => pregion%mixt%gradCell
2586  pmf => pregion%mixt%mfMixt
2587  prhs => pregion%mixt%rhs
2588  psd => pregion%mixt%sd
2589 
2590 ! ******************************************************************************
2591 ! Define constants
2592 ! ******************************************************************************
2593 
2594  cp = global%refCp
2595  g = global%refGamma
2596  gc = mixtperf_r_cpg(cp,g)
2597 
2598 ! ******************************************************************************
2599 ! Compute fluxes through interior faces
2600 ! ******************************************************************************
2601 
2602  DO ifg = 1,pgrid%nFaces
2603  c1 = pgrid%f2c(1,ifg)
2604  c2 = pgrid%f2c(2,ifg)
2605 
2606 ! ==============================================================================
2607 ! Get face geometry and grid speed
2608 ! ==============================================================================
2609 
2610  nx = pgrid%fn(xcoord,ifg)
2611  ny = pgrid%fn(ycoord,ifg)
2612  nz = pgrid%fn(zcoord,ifg)
2613  nm = pgrid%fn(xyzmag,ifg)
2614 
2615  xc = pgrid%fc(xcoord,ifg)
2616  yc = pgrid%fc(ycoord,ifg)
2617  zc = pgrid%fc(zcoord,ifg)
2618 
2619  fs = pgrid%gs(indgs*ifg)
2620 
2621 ! ==============================================================================
2622 ! Compute left and right states
2623 ! ==============================================================================
2624 
2625 ! ------------------------------------------------------------------------------
2626 ! Left state
2627 ! ------------------------------------------------------------------------------
2628 
2629  rl = pcv(cv_mixt_dens,c1)
2630  irl = 1.0_rfreal/rl
2631 
2632  ul = pcv(cv_mixt_xmom,c1)*irl
2633  vl = pcv(cv_mixt_ymom,c1)*irl
2634  wl = pcv(cv_mixt_zmom,c1)*irl
2635  pl = pdv(dv_mixt_pres,c1)
2636 
2637  dx = xc - pgrid%cofg(xcoord,c1)
2638  dy = yc - pgrid%cofg(ycoord,c1)
2639  dz = zc - pgrid%cofg(zcoord,c1)
2640 
2641  rl = rl + pgc(xcoord,grc_mixt_dens,c1)*dx &
2642  + pgc(ycoord,grc_mixt_dens,c1)*dy &
2643  + pgc(zcoord,grc_mixt_dens,c1)*dz
2644  ul = ul + pgc(xcoord,grc_mixt_xvel,c1)*dx &
2645  + pgc(ycoord,grc_mixt_xvel,c1)*dy &
2646  + pgc(zcoord,grc_mixt_xvel,c1)*dz
2647  vl = vl + pgc(xcoord,grc_mixt_yvel,c1)*dx &
2648  + pgc(ycoord,grc_mixt_yvel,c1)*dy &
2649  + pgc(zcoord,grc_mixt_yvel,c1)*dz
2650  wl = wl + pgc(xcoord,grc_mixt_zvel,c1)*dx &
2651  + pgc(ycoord,grc_mixt_zvel,c1)*dy &
2652  + pgc(zcoord,grc_mixt_zvel,c1)*dz
2653  pl = pl + pgc(xcoord,grc_mixt_pres,c1)*dx &
2654  + pgc(ycoord,grc_mixt_pres,c1)*dy &
2655  + pgc(zcoord,grc_mixt_pres,c1)*dz
2656 
2657  tl = mixtperf_t_dpr(rl,pl,gc)
2658  hl = mixtperf_ho_cptuvw(cp,tl,ul,vl,wl)
2659 
2660  ql = ul*nx + vl*ny + wl*nz - fs
2661 
2662 ! ------------------------------------------------------------------------------
2663 ! Right state
2664 ! ------------------------------------------------------------------------------
2665 
2666  rr = pcv(cv_mixt_dens,c2)
2667  irr = 1.0_rfreal/rr
2668 
2669  ur = pcv(cv_mixt_xmom,c2)*irr
2670  vr = pcv(cv_mixt_ymom,c2)*irr
2671  wr = pcv(cv_mixt_zmom,c2)*irr
2672  pr = pdv(dv_mixt_pres,c2)
2673 
2674  dx = xc - pgrid%cofg(xcoord,c2)
2675  dy = yc - pgrid%cofg(ycoord,c2)
2676  dz = zc - pgrid%cofg(zcoord,c2)
2677 
2678  rr = rr + pgc(xcoord,grc_mixt_dens,c2)*dx &
2679  + pgc(ycoord,grc_mixt_dens,c2)*dy &
2680  + pgc(zcoord,grc_mixt_dens,c2)*dz
2681  ur = ur + pgc(xcoord,grc_mixt_xvel,c2)*dx &
2682  + pgc(ycoord,grc_mixt_xvel,c2)*dy &
2683  + pgc(zcoord,grc_mixt_xvel,c2)*dz
2684  vr = vr + pgc(xcoord,grc_mixt_yvel,c2)*dx &
2685  + pgc(ycoord,grc_mixt_yvel,c2)*dy &
2686  + pgc(zcoord,grc_mixt_yvel,c2)*dz
2687  wr = wr + pgc(xcoord,grc_mixt_zvel,c2)*dx &
2688  + pgc(ycoord,grc_mixt_zvel,c2)*dy &
2689  + pgc(zcoord,grc_mixt_zvel,c2)*dz
2690  pr = pr + pgc(xcoord,grc_mixt_pres,c2)*dx &
2691  + pgc(ycoord,grc_mixt_pres,c2)*dy &
2692  + pgc(zcoord,grc_mixt_pres,c2)*dz
2693 
2694  tr = mixtperf_t_dpr(rr,pr,gc)
2695  hr = mixtperf_ho_cptuvw(cp,tr,ur,vr,wr)
2696 
2697  qr = ur*nx + vr*ny + wr*nz - fs
2698 
2699 ! ==============================================================================
2700 ! Compute Roe-averaged face variables (h for hat)
2701 ! ==============================================================================
2702 
2703  rh = sqrt(rl*rr)
2704  wt = rl/(rl + rh)
2705 
2706  uh = wt*ul + (1.0_rfreal-wt)*ur
2707  vh = wt*vl + (1.0_rfreal-wt)*vr
2708  wh = wt*wl + (1.0_rfreal-wt)*wr
2709  hh = wt*hl + (1.0_rfreal-wt)*hr
2710 
2711  qh = uh*nx + vh*ny + wh*nz - fs
2712  sh = 0.5_rfreal*(uh*uh + vh*vh + wh*wh)
2713 
2714  ah = mixtperf_c_ghovm2(g,hh,2.0_rfreal*sh) ! NOTE factor of 2
2715 
2716 ! ==============================================================================
2717 ! Compute eigenvalues
2718 ! ==============================================================================
2719 
2720  l1 = abs(qh - ah)
2721  l2 = abs(qh )
2722  l5 = abs(qh + ah)
2723 
2724 ! ==============================================================================
2725 ! Compute entropy fix
2726 ! ==============================================================================
2727 
2728  efc = epsentr*l5
2729  l1 = entropyfixhartenhyman(l1,efc)
2730  l2 = entropyfixhartenhyman(l2,efc)
2731  l5 = entropyfixhartenhyman(l5,efc)
2732 
2733 ! ==============================================================================
2734 ! Compute wavestrengths
2735 ! ==============================================================================
2736 
2737  dr = rr - rl
2738  du = ur - ul
2739  de = vr - vl ! use de to denote dv because dv is already used
2740  dw = wr - wl
2741  dp = pr - pl
2742  dq = du*nx + de*ny + dw*nz ! Note: no gs contribution
2743 
2744  dv1 = (dp - rh*ah*dq)/(2.0_rfreal*ah*ah)
2745  dv5 = (dp + rh*ah*dq)/(2.0_rfreal*ah*ah)
2746  dv2 = dr - dp/(ah*ah)
2747 
2748  t1 = l1*dv1
2749  t2 = l2*dv2
2750  t3 = l2*rh
2751  t5 = l5*dv5
2752 
2753 ! =============================================================================
2754 ! Compute fluxes
2755 ! =============================================================================
2756 
2757 ! ------------------------------------------------------------------------------
2758 ! Central part
2759 ! ------------------------------------------------------------------------------
2760 
2761  flxconv(1) = 0.5_rfreal*(ql*rl + qr*rr )*nm
2762  flxconv(2) = 0.5_rfreal*(ql*rl*ul + pl*nx + qr*rr*ur + pr*nx)*nm
2763  flxconv(3) = 0.5_rfreal*(ql*rl*vl + pl*ny + qr*rr*vr + pr*ny)*nm
2764  flxconv(4) = 0.5_rfreal*(ql*rl*wl + pl*nz + qr*rr*wr + pr*nz)*nm
2765  flxconv(5) = 0.5_rfreal*(ql*rl*hl + pl*fs + qr*rr*hr + pr*fs)*nm
2766 
2767 ! ------------------------------------------------------------------------------
2768 ! Dissipative part
2769 ! ------------------------------------------------------------------------------
2770 
2771  flxdiss(1) = 0.5_rfreal*dissfact*(t1 + t2 + t5 )*nm
2772  flxdiss(2) = 0.5_rfreal*dissfact*(t1*(uh-nx*ah) + t2*uh + t3*(du-nx*dq) + t5*(uh+nx*ah))*nm
2773  flxdiss(3) = 0.5_rfreal*dissfact*(t1*(vh-ny*ah) + t2*vh + t3*(de-ny*dq) + t5*(vh+ny*ah))*nm
2774  flxdiss(4) = 0.5_rfreal*dissfact*(t1*(wh-nz*ah) + t2*wh + t3*(dw-nz*dq) + t5*(wh+nz*ah))*nm
2775  flxdiss(5) = 0.5_rfreal*dissfact*(t1*(hh-qh*ah) + t2*sh + t3*(uh*du+vh*de+wh*dw-qh*dq) + t5*(hh+qh*ah))*nm
2776 
2777 ! =============================================================================
2778 ! Store mass flux
2779 ! =============================================================================
2780 
2781  pmf(indmf*ifg) = flxconv(1) - flxdiss(1)
2782 
2783 ! ==============================================================================
2784 ! Accumulate into residual
2785 ! ==============================================================================
2786 
2787  prhs(cv_mixt_dens,c1) = prhs(cv_mixt_dens,c1) + (flxconv(1) - flxdiss(1))
2788  prhs(cv_mixt_xmom,c1) = prhs(cv_mixt_xmom,c1) + (flxconv(2) - flxdiss(2))
2789  prhs(cv_mixt_ymom,c1) = prhs(cv_mixt_ymom,c1) + (flxconv(3) - flxdiss(3))
2790  prhs(cv_mixt_zmom,c1) = prhs(cv_mixt_zmom,c1) + (flxconv(4) - flxdiss(4))
2791  prhs(cv_mixt_ener,c1) = prhs(cv_mixt_ener,c1) + (flxconv(5) - flxdiss(5))
2792 
2793  prhs(cv_mixt_dens,c2) = prhs(cv_mixt_dens,c2) - (flxconv(1) - flxdiss(1))
2794  prhs(cv_mixt_xmom,c2) = prhs(cv_mixt_xmom,c2) - (flxconv(2) - flxdiss(2))
2795  prhs(cv_mixt_ymom,c2) = prhs(cv_mixt_ymom,c2) - (flxconv(3) - flxdiss(3))
2796  prhs(cv_mixt_zmom,c2) = prhs(cv_mixt_zmom,c2) - (flxconv(4) - flxdiss(4))
2797  prhs(cv_mixt_ener,c2) = prhs(cv_mixt_ener,c2) - (flxconv(5) - flxdiss(5))
2798 
2799 ! ==============================================================================
2800 ! Accumulate into substantial derivative
2801 ! ==============================================================================
2802 
2803  psd(sd_xmom,c1*indsd) = psd(sd_xmom,c1*indsd) + uh*pmf(indmf*ifg)
2804  psd(sd_ymom,c1*indsd) = psd(sd_ymom,c1*indsd) + vh*pmf(indmf*ifg)
2805  psd(sd_zmom,c1*indsd) = psd(sd_zmom,c1*indsd) + wh*pmf(indmf*ifg)
2806 
2807  psd(sd_xmom,c2*indsd) = psd(sd_xmom,c2*indsd) - uh*pmf(indmf*ifg)
2808  psd(sd_ymom,c2*indsd) = psd(sd_ymom,c2*indsd) - vh*pmf(indmf*ifg)
2809  psd(sd_zmom,c2*indsd) = psd(sd_zmom,c2*indsd) - wh*pmf(indmf*ifg)
2810  END DO ! ifg
2811 
2812 ! ******************************************************************************
2813 ! Compute fluxes through boundary faces
2814 ! ******************************************************************************
2815 
2816  DO ipatch = 1,pregion%grid%nPatches
2817  ppatch => pregion%patches(ipatch)
2818 
2819  IF ( ppatch%bcKind == bc_kind_nscbc ) THEN
2820  SELECT CASE ( ppatch%spaceOrder )
2821  CASE ( 1 )
2822  CALL rflu_nscbc_compfirstpatchflux(pregion,ppatch)
2823  CASE ( 2 )
2824  CALL rflu_nscbc_compsecondpatchflux(pregion,ppatch)
2825  CASE default
2826  CALL errorstop(global,err_reached_default,__line__)
2827  END SELECT ! pPatch%spaceOrder
2828  ELSE
2829  SELECT CASE ( ppatch%spaceOrder )
2830  CASE ( 1 )
2831  CALL rflu_centralfirstpatch(pregion,ppatch)
2832  CASE ( 2 )
2833  CALL rflu_centralsecondpatch(pregion,ppatch)
2834  CASE default
2835  CALL errorstop(global,err_reached_default,__line__)
2836  END SELECT ! pPatch%spaceOrder
2837  END IF ! pPatch%bcKind
2838  END DO ! iPatch
2839 
2840 ! ******************************************************************************
2841 ! End
2842 ! ******************************************************************************
2843 
2844 #ifdef ROCPROF
2845  CALL fprofiler_ends("RFLU::ROE_ComputeFlux2_TCP")
2846 #endif
2847 
2848  CALL deregisterfunction(global)
2849 
2850 END SUBROUTINE rflu_roe_computeflux2_tcp
2851 
2852 
2853 
2854 
2855 
2856 
2857 
2858 
2859 ! ******************************************************************************
2860 ! End
2861 ! ******************************************************************************
2862 
2863 END MODULE rflu_modroeflux
2864 
2865 ! ******************************************************************************
2866 !
2867 ! RCS Revision history:
2868 !
2869 ! $Log: RFLU_ModRoeFlux.F90,v $
2870 ! Revision 1.10 2008/12/06 08:44:24 mtcampbe
2871 ! Updated license.
2872 !
2873 ! Revision 1.9 2008/11/19 22:17:35 mtcampbe
2874 ! Added Illinois Open Source License/Copyright
2875 !
2876 ! Revision 1.8 2006/08/19 15:39:18 mparmar
2877 ! Added computation of boundary flux using boundary variables
2878 !
2879 ! Revision 1.7 2006/05/03 17:55:42 haselbac
2880 ! Bug fix: Missing pGrid def in RFLU_ROE_ComputeFlux2_TCP
2881 !
2882 ! Revision 1.6 2006/05/01 21:00:47 haselbac
2883 ! Rewrite for consistency and cleanliness
2884 !
2885 ! Revision 1.5 2006/04/15 16:58:42 haselbac
2886 ! Added capability of running 1st order boundary fluxes with 2nd order volume fluxes
2887 !
2888 ! Revision 1.4 2006/04/07 15:19:20 haselbac
2889 ! Removed tabs
2890 !
2891 ! Revision 1.3 2006/03/26 20:22:09 haselbac
2892 ! Added support for GL model
2893 !
2894 ! Revision 1.2 2005/07/07 22:45:01 haselbac
2895 ! Added profiling calls
2896 !
2897 ! Revision 1.1 2005/05/16 20:36:29 haselbac
2898 ! Initial revision
2899 !
2900 ! ******************************************************************************
2901 
2902 
2903 
2904 
2905 
2906 
2907 
2908 
2909 
2910 
2911 
2912 
2913 
2914 
2915 
2916 
2917 
subroutine, public rflu_roe_computeflux2_gl(pRegion)
subroutine rflu_centralsecondpatch(pRegion, pPatch)
real(rfreal) function mixtperf_r_m(M)
Definition: MixtPerf_R.F90:54
NT dx
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
real(rfreal) function mixtperf_d_prt(P, R, T)
Definition: MixtPerf_D.F90:71
subroutine, public rflu_roe_computeflux(pRegion, fluxPart)
double sqrt(double d)
Definition: double.h:73
real(rfreal) function mixtperf_c_ghovm2(G, Ho, Vm2)
Definition: MixtPerf_C.F90:71
real(rfreal) function mixtperf_r_cpg(Cp, G)
Definition: MixtPerf_R.F90:39
real(rfreal) function, public entropyfixhartenhyman(l, d)
subroutine rflu_centralsecondpatch_gl(pRegion, pPatch)
subroutine rflu_centralfirstpatch_gl(pRegion, pPatch)
real(rfreal) function mixtperf_c2_grt(G, R, T)
Definition: MixtPerf_C.F90:101
real(rfreal) function mixtperf_ho_cptuvw(Cp, T, U, V, W)
Definition: MixtPerf_H.F90:39
real(rfreal) function mixtliq_c2_bp(Bp)
Definition: MixtLiq_C.F90:54
subroutine, public rflu_roe_computefluxc1(pRegion)
real(rfreal) function mixtperf_t_dpr(D, P, R)
Definition: MixtPerf_T.F90:85
subroutine, public rflu_nscbc_compsecondpatchflux(pRegion, pPatch)
subroutine, public rflu_roe_computeflux2_tcp(pRegion)
RT dz() const
Definition: Direction_3.h:133
real(rfreal) function mixtliq_d_dobpppobttto(Dz, Bp, Bt, P, Po, T, To)
Definition: MixtLiq_D.F90:40
real(rfreal) function mixtgasliq_c(Cvm, D, P, Dl, Dv, Dg, VFl, VFv, VFg, Cl2, Cv2, Cg2, Bl2, Bv2, Bg2)
NT dy
subroutine, public rflu_roe_computeflux1_gl(pRegion)
real(rfreal) function mixtperf_eo_dgpuvw(D, G, P, U, V, W)
Definition: MixtPerf_E.F90:40
subroutine rflu_centralfirstpatch(pRegion, pPatch)
subroutine errorstop(global, errorCode, errorLine, addMessage)
Definition: ModError.F90:483
subroutine, public rflu_roe_computefluxd1_tcp(pRegion)
subroutine deregisterfunction(global)
Definition: ModError.F90:469
subroutine, public rflu_nscbc_compfirstpatchflux(pRegion, pPatch)
real(rfreal) function mixtperf_cv_cpr(Cp, R)
Definition: MixtPerf_Cv.F90:39
subroutine, public rflu_roe_computefluxd2_tcp(pRegion)
subroutine, public rflu_roe_computeflux1_tcp(pRegion)
subroutine, public rflu_roe_computefluxc2_tcp(pRegion)
unsigned char g() const
Definition: Color.h:69