Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RFLU_InitFlowScratch.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: Initialize flow field in a region from scratch.
26 !
27 ! Description: Use user input to define initial flow field.
28 !
29 ! Input:
30 ! pRegion Pointer to region
31 !
32 ! Output: None.
33 !
34 ! Notes: None.
35 !
36 ! ******************************************************************************
37 !
38 ! $Id: RFLU_InitFlowScratch.F90,v 1.5 2008/12/06 08:44:56 mtcampbe Exp $
39 !
40 ! Copyright: (c) 2002-2006 by the University of Illinois
41 !
42 ! ******************************************************************************
43 
44 SUBROUTINE rflu_initflowscratch(pRegion)
45 
46  USE moddatatypes
47  USE moderror
48  USE moddatastruct, ONLY: t_region
49  USE modmixture, ONLY: t_mixt_input
50  USE modglobal, ONLY: t_global
51  USE modparameters
52 
58  mixtperf_g_cpr, &
59  mixtperf_r_m, &
61 
62  IMPLICIT NONE
63 
64 ! ******************************************************************************
65 ! Declarations and definitions
66 ! ******************************************************************************
67 
68 ! ==============================================================================
69 ! Arguments
70 ! ==============================================================================
71 
72  TYPE(t_region), POINTER :: pregion
73 
74 ! ==============================================================================
75 ! Locals
76 ! ==============================================================================
77 
78  CHARACTER(CHRLEN) :: rcsidentstring
79  INTEGER :: cvmixtpres,cvmixtxvel,cvmixtyvel,cvmixtzvel,icg,indcp,indmol
80  REAL(RFREAL) :: cp,cvm,cvg,cvv,eo,g,gc,mw,r,rhog,rhol,rhov,rg,rv,vm2,yg,yl,yv
81  REAL(RFREAL), DIMENSION(:,:), POINTER :: pcv,pgv
82  TYPE(t_global), POINTER :: global
83  TYPE(t_mixt_input), POINTER :: pmixtinput
84 
85 ! ******************************************************************************
86 ! Start
87 ! ******************************************************************************
88 
89  rcsidentstring = '$RCSfile: RFLU_InitFlowScratch.F90,v $'
90 
91  global => pregion%global
92 
93  CALL registerfunction(global,'RFLU_InitFlowScratch', &
94  'RFLU_InitFlowScratch.F90')
95 
96  IF ( global%verbLevel > verbose_none ) THEN
97  WRITE(stdout,'(A,1X,A)') solver_name, &
98  'Initializing flow field from scratch...'
99  END IF ! global%verbLevel
100 
101 ! ******************************************************************************
102 ! Set pointers and variables
103 ! ******************************************************************************
104 
105  pcv => pregion%mixt%cv
106  pgv => pregion%mixt%gv
107  pmixtinput => pregion%mixtInput
108 
109  indcp = pregion%mixtInput%indCp
110  indmol = pregion%mixtInput%indMol
111 
112 ! ******************************************************************************
113 ! Initialize flow field based on user input and fluid model
114 ! ******************************************************************************
115 
116  SELECT CASE ( pmixtinput%fluidModel )
117 
118 ! ==============================================================================
119 ! Incompressible fluid model
120 ! ==============================================================================
121 
122  CASE ( fluid_model_incomp )
123  pregion%mixt%cvState = cv_mixt_state_prim
124 
125  cvmixtxvel = rflu_getcvloc(global,pmixtinput%fluidModel,cv_mixt_xvel)
126  cvmixtyvel = rflu_getcvloc(global,pmixtinput%fluidModel,cv_mixt_yvel)
127  cvmixtzvel = rflu_getcvloc(global,pmixtinput%fluidModel,cv_mixt_zvel)
128  cvmixtpres = rflu_getcvloc(global,pmixtinput%fluidModel,cv_mixt_pres)
129 
130  DO icg = 1,pregion%grid%nCellsTot
131  pcv(cvmixtxvel,icg) = pregion%mixtInput%iniVelX
132  pcv(cvmixtyvel,icg) = pregion%mixtInput%iniVelY
133  pcv(cvmixtzvel,icg) = pregion%mixtInput%iniVelZ
134  pcv(cvmixtpres,icg) = pregion%mixtInput%iniPress
135  END DO ! icg
136 
137 ! ==============================================================================
138 ! Compressible fluid model
139 ! ==============================================================================
140 
141  CASE ( fluid_model_comp )
142  pregion%mixt%cvState = cv_mixt_state_cons
143 
144  SELECT CASE ( pregion%mixtInput%gasModel )
145 
146 ! ------------------------------------------------------------------------------
147 ! Gas models without liquid phase
148 ! ------------------------------------------------------------------------------
149 
150  CASE ( gas_model_tcperf, &
151  gas_model_tperf, &
152  gas_model_mixt_tcperf, &
153  gas_model_mixt_tperf, &
154  gas_model_mixt_pseudo )
155  DO icg = 1,pregion%grid%nCellsTot
156  mw = pgv(gv_mixt_mol,indmol*icg)
157  cp = pgv(gv_mixt_cp ,indcp *icg)
158 
159  gc = mixtperf_r_m(mw)
160  g = mixtperf_g_cpr(cp,gc)
161 
162  r = pregion%mixtInput%iniDens
163 
164  pcv(cv_mixt_dens,icg) = r
165  pcv(cv_mixt_xmom,icg) = r*pregion%mixtInput%iniVelX
166  pcv(cv_mixt_ymom,icg) = r*pregion%mixtInput%iniVelY
167  pcv(cv_mixt_zmom,icg) = r*pregion%mixtInput%iniVelZ
168 
169  eo = mixtperf_eo_dgpuvw(pcv(cv_mixt_dens,icg),g, &
170  pregion%mixtInput%iniPress, &
171  pregion%mixtInput%iniVelX, &
172  pregion%mixtInput%iniVelY, &
173  pregion%mixtInput%iniVelZ)
174 
175  pcv(cv_mixt_ener,icg) = pcv(cv_mixt_dens,icg)*eo
176  END DO ! icg
177 
178 ! ------------------------------------------------------------------------------
179 ! Mixture of gas, liquid, and vapor
180 ! ------------------------------------------------------------------------------
181 
182  CASE ( gas_model_mixt_gasliq )
183  rg = mixtperf_r_m(pregion%specInput%specType(1)%pMaterial%molw)
184  cvg = mixtperf_cv_cpr(pregion%specInput%specType(1)%pMaterial%spht,rg)
185 
186  rv = mixtperf_r_m(pregion%specInput%specType(2)%pMaterial%molw)
187  cvv = mixtperf_cv_cpr(pregion%specInput%specType(2)%pMaterial%spht,rv)
188 
189  rhol = mixtliq_d_dobpppobttto(global%refDensityLiq, &
190  global%refBetaPLiq, &
191  global%refBetaTLiq, &
192  pregion%mixtInput%iniPress, &
193  global%refPressLiq, &
194  pregion%mixtInput%iniTemp, &
195  global%refTempLiq)
196 
197  DO icg = 1,pregion%grid%nCellsTot
198  yg = pregion%specInput%specType(1)%initVal
199  yv = pregion%specInput%specType(2)%initVal
200  yl = 1.0_rfreal - yg - yv
201 
202  rhog = mixtperf_d_prt(pregion%mixtInput%iniPress,rg, &
203  pregion%mixtInput%iniTemp)
204  rhov = mixtperf_d_prt(pregion%mixtInput%iniPress,rv, &
205  pregion%mixtInput%iniTemp)
206 
207  r = 1.0_rfreal/(yg/rhog + yv/rhov + yl/rhol)
208 
209  pcv(cv_mixt_dens,icg) = r
210  pcv(cv_mixt_xmom,icg) = r*pregion%mixtInput%iniVelX
211  pcv(cv_mixt_ymom,icg) = r*pregion%mixtInput%iniVelY
212  pcv(cv_mixt_zmom,icg) = r*pregion%mixtInput%iniVelZ
213 
214  cvm = yg*cvg + yv*cvv + yl*global%refCvLiq
215 
216  vm2 = pregion%mixtInput%iniVelX*pregion%mixtInput%iniVelX &
217  + pregion%mixtInput%iniVelY*pregion%mixtInput%iniVelY &
218  + pregion%mixtInput%iniVelZ*pregion%mixtInput%iniVelZ
219 
220  pcv(cv_mixt_ener,icg) = pcv(cv_mixt_dens,icg)* &
221  mixtgasliq_eo_cvmtvm2(cvm,pregion%mixtInput%iniTemp,vm2)
222  END DO ! icg
223 
224 ! ------------------------------------------------------------------------------
225 ! Default
226 ! ------------------------------------------------------------------------------
227 
228  CASE default
229  CALL errorstop(global,err_reached_default,__line__)
230  END SELECT ! pRegion%mixtInput%gasModel
231 
232 ! ==============================================================================
233 ! Default
234 ! ==============================================================================
235 
236  CASE default
237  CALL errorstop(global,err_reached_default,__line__)
238  END SELECT ! pRegion%mixtInput%fluidModel
239 
240 ! ******************************************************************************
241 ! End
242 ! ******************************************************************************
243 
244  IF ( global%verbLevel > verbose_none ) THEN
245  WRITE(stdout,'(A,1X,A)') solver_name, &
246  'Initializing flow field from scratch done.'
247  END IF ! global%verbLevel
248 
249  CALL deregisterfunction(global)
250 
251 END SUBROUTINE rflu_initflowscratch
252 
253 ! ******************************************************************************
254 !
255 ! RCS Revision history:
256 !
257 ! $Log: RFLU_InitFlowScratch.F90,v $
258 ! Revision 1.5 2008/12/06 08:44:56 mtcampbe
259 ! Updated license.
260 !
261 ! Revision 1.4 2008/11/19 22:18:06 mtcampbe
262 ! Added Illinois Open Source License/Copyright
263 !
264 ! Revision 1.3 2006/03/26 20:22:26 haselbac
265 ! Added support for GL model
266 !
267 ! Revision 1.2 2005/11/10 02:43:23 haselbac
268 ! Added support for variable properties
269 !
270 ! Revision 1.1 2005/04/15 15:08:18 haselbac
271 ! Initial revision
272 !
273 ! ******************************************************************************
274 
275 
276 
277 
278 
279 
280 
INTEGER function rflu_getcvloc(global, fluidModel, var)
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
real(rfreal) function mixtperf_d_prt(P, R, T)
Definition: MixtPerf_D.F90:71
subroutine rflu_initflowscratch(pRegion)
real(rfreal) function mixtgasliq_eo_cvmtvm2(Cvm, T, Vm2)
real(rfreal) function mixtliq_d_dobpppobttto(Dz, Bp, Bt, P, Po, T, To)
Definition: MixtLiq_D.F90:40
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