Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SPEC_EqEulCorr.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 Equilibrium Eulerian correction to species mass fluxes and
26 ! overall mass flux for interior faces.
27 !
28 ! Description: None.
29 !
30 ! Input:
31 ! pRegion Pointer to data of current region
32 ! iSpec Index of species
33 !
34 ! Output: None.
35 !
36 ! Notes:
37 ! 1. By passing iSpec, rather than looping over all iSpec inside the face
38 ! loop, this routine is optimized for the case of a few Eq Eul species
39 ! among many non Eq Eul (e.g., gas species).
40 !
41 ! ******************************************************************************
42 !
43 ! $Id: SPEC_EqEulCorr.F90,v 1.8 2008/12/06 08:44:40 mtcampbe Exp $
44 !
45 ! Copyright: (c) 2004-2005 by the University of Illinois
46 !
47 ! ******************************************************************************
48 
49 SUBROUTINE spec_eqeulcorr(pRegion,iSpec)
50 
51  USE moddatatypes
52  USE moderror
53  USE modparameters
54  USE modglobal, ONLY: t_global
55  USE modgrid, ONLY: t_grid
56  USE modbndpatch, ONLY: t_patch
57  USE moddatastruct, ONLY: t_region
58  USE modspecies, ONLY: t_spec_type
59 
61 
63 
64  IMPLICIT NONE
65 
66 ! ******************************************************************************
67 ! Definitions and declarations
68 ! ******************************************************************************
69 
70 ! ==============================================================================
71 ! Arguments
72 ! ==============================================================================
73 
74  INTEGER, INTENT(IN) :: ispec
75  TYPE(t_region), POINTER :: pregion
76 
77 ! ==============================================================================
78 ! Locals
79 ! ==============================================================================
80 
81  CHARACTER(CHRLEN) :: rcsidentstring
82  INTEGER :: c1,c2,ifl,ipatch,ispeceev
83  REAL(RFREAL) :: eo1,eo2,flx,idens,ir1,ir2,nx,ny,nz,nm,phi1,phi2,p1,p2,ry, &
84  ry1,ry2,r1,r2,taucoef,term,ts1,ts2,ug,ug1,ug2,us,us1,us2, &
85  vg,vg1,vg2,vs,vs1,vs2,wg,wg1,wg2,ws,ws1,ws2
86  REAL(RFREAL), DIMENSION(:,:), POINTER :: pcvmixt,pcvspec,pdvmixt,psd, &
87  rhsmixt,rhsspec
88  REAL(RFREAL), DIMENSION(:,:,:), POINTER :: peev
89  TYPE(t_global), POINTER :: global
90  TYPE(t_grid), POINTER :: pgrid
91  TYPE(t_patch), POINTER :: ppatch
92  TYPE(t_spec_type), POINTER :: pspectype
93 
94 ! ******************************************************************************
95 ! Start
96 ! ******************************************************************************
97 
98  rcsidentstring = '$RCSfile: SPEC_EqEulCorr.F90,v $ $Revision: 1.8 $'
99 
100  global => pregion%global
101 
102  CALL registerfunction(global,'SPEC_EqEulCorr',&
103  'SPEC_EqEulCorr.F90')
104 
105 ! ******************************************************************************
106 ! Set dimensions and pointers
107 ! ******************************************************************************
108 
109  pgrid => pregion%grid
110  psd => pregion%mixt%sd
111  pcvmixt => pregion%mixt%cv
112  pcvspec => pregion%spec%cv
113  pdvmixt => pregion%mixt%cv
114  rhsmixt => pregion%mixt%rhs
115  rhsspec => pregion%spec%rhs
116  peev => pregion%spec%eev
117 
118  pspectype => pregion%specInput%specType(ispec)
119 
120  taucoef = pspectype%tauCoefficient
121  ispeceev = pspectype%iSpec2iSpecEEv
122  idens = 1.0_rfreal/pspectype%pMaterial%dens
123 
124 ! ******************************************************************************
125 ! Checks: Defensive coding, should never occur
126 ! ******************************************************************************
127 
128  IF ( pspectype%discreteFlag .EQV. .false. ) THEN
129  CALL errorstop(global,err_illegal_value,__line__)
130  END IF ! pSpecType%discreteFlag
131 
132  IF ( pspectype%velocityMethod /= spec_methv_eqeul ) THEN
133  CALL errorstop(global,err_illegal_value,__line__)
134  END IF ! pSpecType%velocityMethod
135 
136  IF ( taucoef <= 0.0_rfreal ) THEN
137  CALL errorstop(global,err_illegal_value,__line__)
138  END IF ! tauCoef
139 
140  IF ( pregion%mixtInput%indSd /= 1 ) THEN
141  CALL errorstop(global,err_illegal_value,__line__)
142  END IF ! pRegion%mixtInput%indSd
143 
144  IF ( pregion%mixt%cvState /= cv_mixt_state_cons ) THEN
145  CALL errorstop(global,err_cv_state_invalid,__line__)
146  END IF ! pRegion%mixt%cvState
147 
148  IF ( pregion%spec%cvState /= cv_mixt_state_cons ) THEN
149  CALL errorstop(global,err_cv_state_invalid,__line__)
150  END IF ! pRegion%spec%cvState
151 
152 ! ******************************************************************************
153 ! Compute fluxes
154 ! ******************************************************************************
155 
156  DO ifl = 1,pgrid%nFaces
157  c1 = pgrid%f2c(1,ifl)
158  c2 = pgrid%f2c(2,ifl)
159 
160  nx = pgrid%fn(xcoord,ifl)
161  ny = pgrid%fn(ycoord,ifl)
162  nz = pgrid%fn(zcoord,ifl)
163  nm = pgrid%fn(xyzmag,ifl)
164 
165 ! ==============================================================================
166 ! Get data
167 ! ==============================================================================
168 
169  ir1 = 1.0_rfreal/pcvmixt(cv_mixt_dens,c1)
170  ug1 = ir1*pcvmixt(cv_mixt_xmom,c1)
171  vg1 = ir1*pcvmixt(cv_mixt_ymom,c1)
172  wg1 = ir1*pcvmixt(cv_mixt_zmom,c1)
173  eo1 = ir1*pcvmixt(cv_mixt_ener,c1)
174  p1 = pdvmixt(dv_mixt_pres,c1)
175 
176  ir2 = 1.0_rfreal/pcvmixt(cv_mixt_dens,c2)
177  ug2 = ir2*pcvmixt(cv_mixt_xmom,c2)
178  vg2 = ir2*pcvmixt(cv_mixt_ymom,c2)
179  wg2 = ir2*pcvmixt(cv_mixt_zmom,c2)
180  eo2 = ir2*pcvmixt(cv_mixt_ener,c2)
181  p2 = pdvmixt(dv_mixt_pres,c2)
182 
183  ry1 = pcvspec(ispec,c1)
184  ry2 = pcvspec(ispec,c2)
185 
186  phi1 = ry1*idens
187  phi2 = ry2*idens
188 
189  us1 = peev(eev_spec_xvel,ispeceev,c1)
190  vs1 = peev(eev_spec_yvel,ispeceev,c1)
191  ws1 = peev(eev_spec_zvel,ispeceev,c1)
192  ts1 = peev(eev_spec_temp,ispeceev,c1)
193 
194  us2 = peev(eev_spec_xvel,ispeceev,c2)
195  vs2 = peev(eev_spec_yvel,ispeceev,c2)
196  ws2 = peev(eev_spec_zvel,ispeceev,c2)
197  ts2 = peev(eev_spec_temp,ispeceev,c2)
198 
199 ! ==============================================================================
200 ! Compute fluxes
201 ! ==============================================================================
202 
203  ry = 0.5_rfreal*(ry1 + ry2)
204 
205  ug = 0.5_rfreal*(ug1 + ug2)
206  vg = 0.5_rfreal*(vg1 + vg2)
207  wg = 0.5_rfreal*(wg1 + wg2)
208 
209  us = 0.5_rfreal*(us1 + us2)
210  vs = 0.5_rfreal*(vs1 + vs2)
211  ws = 0.5_rfreal*(ws1 + ws2)
212 
213 ! TEMPORARY
214  flx = ((us-ug)*nx + (vs-vg)*ny + (ws-wg)*nz)*nm
215 ! flx = 0.0_RFREAL
216 ! END TEMPORARY
217 
218  term = ry*flx
219 
220 ! ==============================================================================
221 ! Accumulate into residuals
222 ! ==============================================================================
223 
224  rhsspec(ispec ,c1) = rhsspec(ispec ,c1) + term
225  rhsspec(ispec ,c2) = rhsspec(ispec ,c2) - term
226 
227  rhsmixt(cv_mixt_dens,c1) = rhsmixt(cv_mixt_dens,c1) + term
228  rhsmixt(cv_mixt_dens,c2) = rhsmixt(cv_mixt_dens,c2) - term
229 
230  rhsmixt(cv_mixt_xmom,c1) = rhsmixt(cv_mixt_xmom,c1) + term*ug1
231  rhsmixt(cv_mixt_xmom,c2) = rhsmixt(cv_mixt_xmom,c2) - term*ug2
232 
233  rhsmixt(cv_mixt_ymom,c1) = rhsmixt(cv_mixt_ymom,c1) + term*vg1
234  rhsmixt(cv_mixt_ymom,c2) = rhsmixt(cv_mixt_ymom,c2) - term*vg2
235 
236  rhsmixt(cv_mixt_zmom,c1) = rhsmixt(cv_mixt_zmom,c1) + term*wg1
237  rhsmixt(cv_mixt_zmom,c2) = rhsmixt(cv_mixt_zmom,c2) - term*wg2
238 
239  rhsmixt(cv_mixt_ener,c1) = rhsmixt(cv_mixt_ener,c1) + term*eo1 + flx*p1*phi1
240  rhsmixt(cv_mixt_ener,c2) = rhsmixt(cv_mixt_ener,c2) - term*eo2 - flx*p2*phi2
241  END DO ! ifl
242 
243 ! ******************************************************************************
244 ! Compute fluxes through boundary faces
245 ! ******************************************************************************
246 
247  DO ipatch=1,pregion%grid%nPatches
248  ppatch => pregion%patches(ipatch)
249 
250  CALL spec_eqeulcorrpatch(pregion,ppatch,ispec)
251  END DO ! iPatch
252 
253 ! ******************************************************************************
254 ! End
255 ! ******************************************************************************
256 
257  CALL deregisterfunction(global)
258 
259 END SUBROUTINE spec_eqeulcorr
260 
261 ! ******************************************************************************
262 !
263 ! RCS Revision history:
264 !
265 ! $Log: SPEC_EqEulCorr.F90,v $
266 ! Revision 1.8 2008/12/06 08:44:40 mtcampbe
267 ! Updated license.
268 !
269 ! Revision 1.7 2008/11/19 22:17:52 mtcampbe
270 ! Added Illinois Open Source License/Copyright
271 !
272 ! Revision 1.6 2006/04/07 15:19:24 haselbac
273 ! Removed tabs
274 !
275 ! Revision 1.5 2005/11/27 02:08:47 haselbac
276 ! Rewrote to take advantage of EEv
277 !
278 ! Revision 1.4 2005/11/17 14:40:39 haselbac
279 ! Added corrections to momentum and energy equations
280 !
281 ! Revision 1.3 2005/11/10 02:34:15 haselbac
282 ! Added support for gravity
283 !
284 ! Revision 1.2 2005/03/31 17:17:15 haselbac
285 ! Changed computation of correction, cosmetics
286 !
287 ! Revision 1.1 2004/07/30 22:47:37 jferry
288 ! Implemented Equilibrium Eulerian method for Rocflu
289 !
290 ! ******************************************************************************
291 
292 
293 
294 
295 
296 
297 
subroutine spec_eqeulcorr(pRegion, iSpec)
NT p1
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
subroutine spec_eqeulcorrpatch(pRegion, pPatch, iSpec)
subroutine errorstop(global, errorCode, errorLine, addMessage)
Definition: ModError.F90:483
subroutine deregisterfunction(global)
Definition: ModError.F90:469