Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RFLU_ModBoundConvertCv.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: Suite of routines to convert state vector.
26 !
27 ! Description: None.
28 !
29 ! Notes:
30 !
31 ! ******************************************************************************
32 !
33 ! $Id: RFLU_ModBoundConvertCv.F90,v 1.3 2008/12/06 08:44:20 mtcampbe Exp $
34 !
35 ! Copyright: (c) 2006 by the University of Illinois
36 !
37 ! ******************************************************************************
38 
40 
41  USE moddatatypes
42  USE modparameters
43  USE moderror
44  USE modbndpatch, ONLY: t_patch
45  USE modglobal, ONLY: t_global
46  USE modgrid, ONLY: t_grid
47  USE moddatastruct, ONLY: t_region
48 
49  IMPLICIT NONE
50 
51  PRIVATE
52  PUBLIC :: rflu_bxv_convertcvcons2prim, &
54 
55  SAVE
56 
57 ! ******************************************************************************
58 ! Declarations and definitions
59 ! ******************************************************************************
60 
61 
62 ! ******************************************************************************
63 ! Routines
64 ! ******************************************************************************
65 
66  CONTAINS
67 
68 
69 
70 
71 ! ******************************************************************************
72 !
73 ! Purpose: Convert conserved state vector to primitive variables.
74 !
75 ! Description: None.
76 !
77 ! Input:
78 ! pRegion Pointer to data of current region
79 ! pPatch Pointer to data of current patch
80 ! cvStateFuture Future state of conserved variables
81 !
82 ! Output: None.
83 !
84 ! Notes: None.
85 !
86 ! ******************************************************************************
87 
88 SUBROUTINE rflu_bxv_convertcvcons2prim(pRegion,pPatch,cvStateFuture)
89 
90  USE modinterfaces, ONLY: mixtperf_r_m, &
92 
93 ! ******************************************************************************
94 ! Definitions and declarations
95 ! ******************************************************************************
96 
97 ! ==============================================================================
98 ! Arguments
99 ! ==============================================================================
100 
101  INTEGER, INTENT(IN) :: cvstatefuture
102  TYPE(t_patch), POINTER :: ppatch
103  TYPE(t_region), POINTER :: pregion
104 
105 ! ==============================================================================
106 ! Locals
107 ! ==============================================================================
108 
109  INTEGER :: icg,ifl,indmol
110  REAL(RFREAL) :: gc,ir,mw,p,r
111  REAL(RFREAL), DIMENSION(:,:), POINTER :: pcv,pdv,pgv
112  TYPE(t_global), POINTER :: global
113 
114 ! ******************************************************************************
115 ! Start
116 ! ******************************************************************************
117 
118  global => pregion%global
119 
120  CALL registerfunction(global,'RFLU_BXV_ConvertCvCons2Prim',&
121  'RFLU_ModBoundConvertCv.F90')
122 
123 ! ******************************************************************************
124 ! Set pointers and variables
125 ! ******************************************************************************
126 
127  pcv => ppatch%mixt%cv
128  pdv => ppatch%mixt%dv
129 
130  pgv => pregion%mixt%gv ! pGv taken from interior domain
131 
132  indmol = pregion%mixtInput%indMol
133 
134 ! ******************************************************************************
135 ! Actual conversion
136 ! ******************************************************************************
137 
138  SELECT CASE ( ppatch%mixt%cvState )
139 
140 ! ==============================================================================
141 ! Convert from conservative to primitive form
142 ! ==============================================================================
143 
144  CASE ( cv_mixt_state_cons )
145  SELECT CASE ( cvstatefuture )
146 
147 ! ------------------------------------------------------------------------------
148 ! Convert to duvwp form
149 ! ------------------------------------------------------------------------------
150 
151  CASE ( cv_mixt_state_duvwp )
152  ppatch%mixt%cvState = cv_mixt_state_duvwp
153 
154  DO ifl = 1,ppatch%nBFaces
155  ir = 1.0_rfreal/pcv(cv_mixt_dens,ifl)
156 
157  pcv(cv_mixt_xvel,ifl) = ir*pcv(cv_mixt_xmom,ifl)
158  pcv(cv_mixt_yvel,ifl) = ir*pcv(cv_mixt_ymom,ifl)
159  pcv(cv_mixt_zvel,ifl) = ir*pcv(cv_mixt_zmom,ifl)
160  pcv(cv_mixt_pres,ifl) = pdv(dv_mixt_pres,ifl)
161  END DO ! ifl
162 
163 ! ------------------------------------------------------------------------------
164 ! Convert to duvwt form
165 ! ------------------------------------------------------------------------------
166 
167  CASE (cv_mixt_state_duvwt)
168  ppatch%mixt%cvState = cv_mixt_state_duvwt
169 
170  SELECT CASE ( pregion%mixtInput%fluidModel )
171 
172 ! --------- Compressible fluid model -----------------------------------------
173 
174  CASE ( fluid_model_comp )
175  SELECT CASE ( pregion%mixtInput%gasModel )
176 
177 ! ------------- TC perfect gas or mixture thereof, pseudo-gas
178 
179  CASE ( gas_model_tcperf, &
180  gas_model_mixt_tcperf, &
181  gas_model_mixt_pseudo )
182  DO ifl = 1,ppatch%nBFaces
183  icg = ppatch%bf2c(ifl)
184 
185  r = pcv(cv_mixt_dens,ifl)
186  p = pdv(dv_mixt_pres,ifl)
187  ir = 1.0_rfreal/r
188 
189  pcv(cv_mixt_xvel,ifl) = ir*pcv(cv_mixt_xmom,ifl)
190  pcv(cv_mixt_yvel,ifl) = ir*pcv(cv_mixt_ymom,ifl)
191  pcv(cv_mixt_zvel,ifl) = ir*pcv(cv_mixt_zmom,ifl)
192 
193  mw = pgv(gv_mixt_mol,indmol*icg)
194  gc = mixtperf_r_m(mw)
195 
196  pcv(cv_mixt_temp,ifl) = mixtperf_t_dpr(r,p,gc)
197  END DO ! ifl
198 
199 ! ------------- Gas-liquid mixture
200 
201  CASE ( gas_model_mixt_gasliq )
202  DO ifl = 1,ppatch%nBFaces
203  icg = ppatch%bf2c(ifl)
204 
205  ir = 1.0_rfreal/pcv(cv_mixt_dens,ifl)
206 
207  pcv(cv_mixt_xvel,ifl) = ir*pcv(cv_mixt_xmom,ifl)
208  pcv(cv_mixt_yvel,ifl) = ir*pcv(cv_mixt_ymom,ifl)
209  pcv(cv_mixt_zvel,ifl) = ir*pcv(cv_mixt_zmom,ifl)
210 
211  pcv(cv_mixt_temp,ifl) = pdv(dv_mixt_temp,ifl)
212  END DO ! ifl
213  CASE default
214  CALL errorstop(global,err_reached_default,__line__)
215  END SELECT ! pRegion%mixtInput%gasModel
216 
217 ! --------- Default ----------------------------------------------------------
218 
219  CASE default
220  CALL errorstop(global,err_reached_default,__line__)
221  END SELECT ! pRegion%mixtInput%fluidModel
222 
223 ! ------------------------------------------------------------------------------
224 ! Default
225 ! ------------------------------------------------------------------------------
226 
227  CASE default
228  CALL errorstop(global,err_reached_default,__line__)
229  END SELECT ! cvStateFuture
230 
231 ! ==============================================================================
232 ! Error - invalid input
233 ! ==============================================================================
234 
235  CASE default
236  CALL errorstop(global,err_reached_default,__line__)
237  END SELECT ! pPatch%mixt%cvStateFuture
238 
239 ! ******************************************************************************
240 ! End
241 ! ******************************************************************************
242 
243  CALL deregisterfunction(global)
244 
245 END SUBROUTINE rflu_bxv_convertcvcons2prim
246 
247 
248 
249 
250 
251 
252 ! ******************************************************************************
253 !
254 ! Purpose: Convert primitive state vector to consverved variables.
255 !
256 ! Description: None.
257 !
258 ! Input:
259 ! pRegion Pointer to data of current region
260 ! pPatch Pointer to data of current patch
261 ! cvStateFuture Future state of conserved variables
262 !
263 ! Output: None.
264 !
265 ! Notes:
266 ! 1. Strictly speaking, cvStateFuture is not needed (there is only one
267 ! state for conserved variables), but kept for consistency with
268 ! RFLU_ConvertCvCons2Prim.
269 !
270 ! ******************************************************************************
271 
272 SUBROUTINE rflu_bxv_convertcvprim2cons(pRegion,pPatch,cvStateFuture)
273 
274  USE modinterfaces, ONLY: mixtperf_cv_cpr, &
277  mixtperf_g_cpr, &
279 
280 ! ******************************************************************************
281 ! Definitions and declarations
282 ! ******************************************************************************
283 
284 ! ==============================================================================
285 ! Arguments
286 ! ==============================================================================
287 
288  INTEGER, INTENT(IN) :: cvstatefuture
289  TYPE(t_patch), POINTER :: ppatch
290  TYPE(t_region), POINTER :: pregion
291 
292 ! ==============================================================================
293 ! Locals
294 ! ==============================================================================
295 
296  INTEGER :: icg,ifl,indcp,indmol
297  REAL(RFREAL) :: cp,cvm,cvg,cvl,cvv,g,gc,mw,p,r,rg,rv,ryg,ryl,ryv,t,u,v, &
298  vm2,w
299  REAL(RFREAL), DIMENSION(:,:), POINTER :: pcv,pdv,pgv
300  TYPE(t_global), POINTER :: global
301 
302 ! ******************************************************************************
303 ! Start
304 ! ******************************************************************************
305 
306  global => pregion%global
307 
308  CALL registerfunction(global,'RFLU_BXV_ConvertCvPrim2Cons',&
309  'RFLU_ModBoundConvertCv.F90')
310 
311 ! ******************************************************************************
312 ! Set pointers and variables
313 ! ******************************************************************************
314 
315  pcv => ppatch%mixt%cv
316  pdv => ppatch%mixt%dv
317 
318  pgv => pregion%mixt%gv ! pGv is taken from interior cells
319 
320  indcp = pregion%mixtInput%indCp
321  indmol = pregion%mixtInput%indMol
322 
323 ! ******************************************************************************
324 ! Actual conversion
325 ! ******************************************************************************
326 
327  IF ( ppatch%mixt%cvState == cv_mixt_state_duvwp .OR. &
328  ppatch%mixt%cvState == cv_mixt_state_duvwt ) THEN
329 
330 ! ==============================================================================
331 ! Convert from primitive to conservative form
332 ! ==============================================================================
333 
334  SELECT CASE ( cvstatefuture )
335  CASE ( cv_mixt_state_cons )
336  ppatch%mixt%cvState = cv_mixt_state_cons
337 
338  SELECT CASE ( pregion%mixtInput%gasModel )
339 
340 ! ------------------------------------------------------------------------------
341 ! Thermally and calorically perfect gas or pseudo-gas
342 ! ------------------------------------------------------------------------------
343 
344  CASE ( gas_model_tcperf, &
345  gas_model_mixt_tcperf, &
346  gas_model_mixt_pseudo )
347  DO ifl = 1,ppatch%nBFaces
348  icg = ppatch%bf2c(ifl)
349 
350  r = pcv(cv_mixt_dens,ifl)
351  u = pcv(cv_mixt_xvel,ifl)
352  v = pcv(cv_mixt_yvel,ifl)
353  w = pcv(cv_mixt_zvel,ifl)
354  p = pdv(dv_mixt_pres,ifl)
355 
356  pcv(cv_mixt_xmom,ifl) = r*u
357  pcv(cv_mixt_ymom,ifl) = r*v
358  pcv(cv_mixt_zmom,ifl) = r*w
359 
360  cp = pgv(gv_mixt_cp,indcp*icg)
361  mw = pgv(gv_mixt_mol,indmol*icg)
362  gc = mixtperf_r_m(mw)
363  g = mixtperf_g_cpr(cp,gc)
364 
365  pcv(cv_mixt_ener,ifl) = r*mixtperf_eo_dgpuvw(r,g,p,u,v,w)
366  END DO ! icg
367 
368 ! ------------------------------------------------------------------------------
369 ! Mixture of gas, liquid, and vapor
370 ! ------------------------------------------------------------------------------
371 
372  CASE ( gas_model_mixt_gasliq )
373  CALL errorstop(global,err_gasmodel_invalid,__line__, &
374  'Can only be used with species module.')
375 
376 ! ------------------------------------------------------------------------------
377 ! Other or invalid gas models
378 ! ------------------------------------------------------------------------------
379 
380  CASE default
381  CALL errorstop(global,err_reached_default,__line__)
382  END SELECT ! pRegion%mixtInput
383 
384  CASE default
385  CALL errorstop(global,err_reached_default,__line__)
386  END SELECT ! cvStateFuture
387 
388 ! ==============================================================================
389 ! Error - invalid input
390 ! ==============================================================================
391 
392  ELSE
393  CALL errorstop(global,err_reached_default,__line__)
394  END IF ! pPatch%mixt%cvState
395 
396 ! ******************************************************************************
397 ! End
398 ! ******************************************************************************
399 
400  CALL deregisterfunction(global)
401 
402 END SUBROUTINE rflu_bxv_convertcvprim2cons
403 
404 
405 
406 
407 
408 
409 
410 ! ******************************************************************************
411 ! End
412 ! ******************************************************************************
413 
414 END MODULE rflu_modboundconvertcv
415 
416 
417 ! ******************************************************************************
418 !
419 ! RCS Revision history:
420 !
421 ! $Log: RFLU_ModBoundConvertCv.F90,v $
422 ! Revision 1.3 2008/12/06 08:44:20 mtcampbe
423 ! Updated license.
424 !
425 ! Revision 1.2 2008/11/19 22:17:31 mtcampbe
426 ! Added Illinois Open Source License/Copyright
427 !
428 ! Revision 1.1 2006/08/19 15:37:43 mparmar
429 ! Initial revision
430 !
431 ! ******************************************************************************
432 
433 
434 
435 
436 
437 
438 
439 
unsigned char r() const
Definition: Color.h:68
real(rfreal) function mixtperf_r_m(M)
Definition: MixtPerf_R.F90:54
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
real(rfreal) function mixtperf_t_dpr(D, P, R)
Definition: MixtPerf_T.F90:85
real(rfreal) function mixtgasliq_eo_cvmtvm2(Cvm, T, Vm2)
subroutine, public rflu_bxv_convertcvcons2prim(pRegion, pPatch, cvStateFuture)
real(rfreal) function mixtperf_eo_dgpuvw(D, G, P, U, V, W)
Definition: MixtPerf_E.F90:40
subroutine errorstop(global, errorCode, errorLine, addMessage)
Definition: ModError.F90:483
subroutine deregisterfunction(global)
Definition: ModError.F90:469
real(rfreal) function mixtperf_g_cpr(Cp, R)
Definition: MixtPerf_G.F90:39
real(rfreal) function mixtperf_cv_cpr(Cp, R)
Definition: MixtPerf_Cv.F90:39
unsigned char g() const
Definition: Color.h:69
subroutine, public rflu_bxv_convertcvprim2cons(pRegion, pPatch, cvStateFuture)