Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RFLU_ScalarSecond.F90
Go to the documentation of this file.
1 ! *********************************************************************
2 ! * Rocstar Simulation Suite *
3 ! * Copyright@2015, Illinois Rocstar LLC. All rights reserved. *
4 ! * *
5 ! * Illinois Rocstar LLC *
6 ! * Champaign, IL *
7 ! * www.illinoisrocstar.com *
8 ! * sales@illinoisrocstar.com *
9 ! * *
10 ! * License: See LICENSE file in top level of distribution package or *
11 ! * http://opensource.org/licenses/NCSA *
12 ! *********************************************************************
13 ! *********************************************************************
14 ! * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *
15 ! * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *
16 ! * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *
17 ! * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR *
18 ! * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
19 ! * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
20 ! * Arising FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
21 ! * USE OR OTHER DEALINGS WITH THE SOFTWARE. *
22 ! *********************************************************************
23 !******************************************************************************
24 !
25 ! Purpose: Compute second-order accurate discretization of scalar inviscid flux.
26 !
27 ! Description: None.
28 !
29 ! Input:
30 ! pRegion Pointer to region data
31 ! nVarScal Number of scalar variables
32 ! cvScal Conserved scalar variables
33 ! gradCellScal Cell gradients of scalar variables
34 ! resScal Residual due to central scalar fluxes
35 !
36 ! Output: None.
37 !
38 ! Notes: None.
39 !
40 !******************************************************************************
41 !
42 ! $Id: RFLU_ScalarSecond.F90,v 1.4 2008/12/06 08:44:13 mtcampbe Exp $
43 !
44 ! Copyright: (c) 2004 by the University of Illinois
45 !
46 !******************************************************************************
47 
48 SUBROUTINE rflu_scalarsecond(pRegion,nVarScal,cvScal,gradCellScal,resScal)
49 
50  USE moddatatypes
51  USE modglobal, ONLY: t_global
52  USE moddatastruct, ONLY: t_region
53  USE modgrid, ONLY: t_grid
54  USE moderror
55  USE modparameters
56 
57  IMPLICIT NONE
58 
59 ! *****************************************************************************
60 ! Definitions and declarations
61 ! *****************************************************************************
62 
63 ! =============================================================================
64 ! Arguments
65 ! =============================================================================
66 
67  INTEGER, INTENT(IN) :: nvarscal
68  REAL(RFREAL), DIMENSION(:,:), INTENT(IN) :: cvscal
69  REAL(RFREAL), DIMENSION(:,:), INTENT(INOUT) :: resscal
70  REAL(RFREAL), DIMENSION(:,:,:), INTENT(IN) :: gradcellscal
71  TYPE(t_region), POINTER :: pregion
72 
73 ! =============================================================================
74 ! Locals
75 ! =============================================================================
76 
77  CHARACTER(CHRLEN) :: rcsidentstring
78  INTEGER :: c1,c2,ifc,ivarscal
79  REAL(RFREAL) :: dx1,dx2,dy1,dy2,dz1,dz2,flx,mf,mfn,mfp,sl,sr,xc,yc,zc
80  REAL(RFREAL), DIMENSION(:), POINTER :: pmf
81  TYPE(t_global), POINTER :: global
82  TYPE(t_grid), POINTER :: pgrid
83 
84 ! *****************************************************************************
85 ! Start
86 ! *****************************************************************************
87 
88  rcsidentstring = '$RCSfile: RFLU_ScalarSecond.F90,v $ $Revision: 1.4 $'
89 
90  global => pregion%global
91 
92  CALL registerfunction(global,'RFLU_ScalarSecond',&
93  'RFLU_ScalarSecond.F90')
94 
95 ! *****************************************************************************
96 ! Checks: Defensive coding, should never occur
97 ! *****************************************************************************
98 
99  IF ( pregion%mixtInput%indMfMixt /= 1 ) THEN
100  CALL errorstop(global,err_indmfmixt_invalid,__line__)
101  END IF ! pRegion%mixtInput%indMfMixt
102 
103 ! *****************************************************************************
104 ! Set dimensions and pointers
105 ! *****************************************************************************
106 
107  pgrid => pregion%grid
108  pmf => pregion%mixt%mfMixt
109 
110 ! *****************************************************************************
111 ! Compute fluxes
112 ! *****************************************************************************
113 
114  DO ifc = 1,pgrid%nFaces
115  c1 = pgrid%f2c(1,ifc)
116  c2 = pgrid%f2c(2,ifc)
117 
118 ! =============================================================================
119 ! Get face geometry and relative position vectors
120 ! =============================================================================
121 
122  xc = pgrid%fc(xcoord,ifc)
123  yc = pgrid%fc(ycoord,ifc)
124  zc = pgrid%fc(zcoord,ifc)
125 
126  dx1 = xc - pgrid%cofg(xcoord,c1)
127  dy1 = yc - pgrid%cofg(ycoord,c1)
128  dz1 = zc - pgrid%cofg(zcoord,c1)
129 
130  dx2 = xc - pgrid%cofg(xcoord,c2)
131  dy2 = yc - pgrid%cofg(ycoord,c2)
132  dz2 = zc - pgrid%cofg(zcoord,c2)
133 
134 ! =============================================================================
135 ! Get mass flux
136 ! =============================================================================
137 
138  mf = pmf(ifc)
139  mfp = max(mf,0.0_rfreal)
140  mfn = min(mf,0.0_rfreal)
141 
142 ! =============================================================================
143 ! Compute flux and accumulate into residual
144 ! =============================================================================
145 
146  DO ivarscal = 1,nvarscal
147  sl = cvscal(ivarscal,c1)
148  sr = cvscal(ivarscal,c2)
149 
150  sl = sl + gradcellscal(xcoord,ivarscal,c1)*dx1 &
151  + gradcellscal(ycoord,ivarscal,c1)*dy1 &
152  + gradcellscal(zcoord,ivarscal,c1)*dz1
153 
154  sr = sr + gradcellscal(xcoord,ivarscal,c2)*dx2 &
155  + gradcellscal(ycoord,ivarscal,c2)*dy2 &
156  + gradcellscal(zcoord,ivarscal,c2)*dz2
157 
158  flx = mfp*sl + mfn*sr
159 
160  resscal(ivarscal,c1) = resscal(ivarscal,c1) + flx
161  resscal(ivarscal,c2) = resscal(ivarscal,c2) - flx
162  END DO ! iVarScal
163  END DO ! ifc
164 
165 ! *****************************************************************************
166 ! End
167 ! *****************************************************************************
168 
169  CALL deregisterfunction(global)
170 
171 END SUBROUTINE rflu_scalarsecond
172 
173 !******************************************************************************
174 !
175 ! RCS Revision history:
176 !
177 ! $Log: RFLU_ScalarSecond.F90,v $
178 ! Revision 1.4 2008/12/06 08:44:13 mtcampbe
179 ! Updated license.
180 !
181 ! Revision 1.3 2008/11/19 22:17:26 mtcampbe
182 ! Added Illinois Open Source License/Copyright
183 !
184 ! Revision 1.2 2006/04/07 15:19:16 haselbac
185 ! Removed tabs
186 !
187 ! Revision 1.1 2004/01/29 22:56:12 haselbac
188 ! Initial revision
189 !
190 !******************************************************************************
191 
192 
193 
194 
195 
196 
197 
Vector_n max(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:354
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
Vector_n min(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:346
subroutine errorstop(global, errorCode, errorLine, addMessage)
Definition: ModError.F90:483
subroutine rflu_scalarsecond(pRegion, nVarScal, cvScal, gradCellScal, resScal)
subroutine deregisterfunction(global)
Definition: ModError.F90:469