Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PLAG_RFLU_InjcTileCalcRhs.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: computes the RHS for the multiphase injection algorithm
26 ! specific to RFLU.
27 !
28 ! Description: None.
29 !
30 ! Input:
31 ! pRegion Region pointer
32 !
33 ! Output: None.
34 !
35 ! Notes: None.
36 !
37 !******************************************************************************
38 !
39 ! $Id: PLAG_RFLU_InjcTileCalcRhs.F90,v 1.8 2008/12/06 08:44:35 mtcampbe Exp $
40 !
41 ! Copyright: (c) 2004 by the University of Illinois
42 !
43 !******************************************************************************
44 
45 SUBROUTINE plag_rflu_injctilecalcrhs( pRegion )
46 
47  USE moddatatypes
49  USE modbndpatch, ONLY : t_patch
50  USE moddatastruct, ONLY : t_region
51  USE modglobal, ONLY : t_global
52  USE moderror
53  USE modparameters
54 
56 
57  IMPLICIT NONE
58 
59 ! ******************************************************************************
60 ! Definitions and declarations
61 ! ******************************************************************************
62 
63 ! ==============================================================================
64 ! Arguments
65 ! ==============================================================================
66 
67  TYPE(t_region), POINTER :: pregion
68 
69 ! ==============================================================================
70 ! Locals
71 ! ==============================================================================
72 
73  CHARACTER(CHRLEN) :: rcsidentstring
74 
75  INTEGER :: bctype,c1,distrib,errorflag,i2dvals,icont,icvmass,ifc, &
76  ipatch,itile,ncont,npatches
77 
78  INTEGER, POINTER, DIMENSION(:) :: bf2c,pcvtilemass
79 
80  REAL(RFREAL) :: area,cp,heatcapsum,heatcapsumr,injcvelratio,&
81  massfluxlimit,massfluxsum,massfluxsumr,minj, &
82  nm,nx,ny,nz,rhomixtbcond,tinj,tiletemp,tilevelnrm
83  REAL(RFREAL), POINTER, DIMENSION(:) :: injcmassfluxratio, injctemp, specheat
84  REAL(RFREAL), POINTER, DIMENSION(:,:) :: cv, fn, prhs, vals
85 
86  TYPE(t_global), POINTER :: global
87  TYPE(t_patch), POINTER :: ppatch
88  TYPE(t_tile_plag), POINTER :: ptileplag
89 
90 ! TEMPORARY
91  REAL(RFREAL) :: heatcapratio,massfluxratio,rhoplag
92 ! END TEMPORARY
93 
94 ! ******************************************************************************
95 ! Start
96 ! ******************************************************************************
97 
98  rcsidentstring = '$RCSfile: PLAG_RFLU_InjcTileCalcRhs.F90,v $ $Revision: 1.8 $'
99 
100  global => pregion%global
101 
102  CALL registerfunction(global,'PLAG_RFLU_InjcTileCalcRhs',&
103  'PLAG_RFLU_InjcTileCalcRhs.F90')
104 
105 ! ******************************************************************************
106 ! Set pointers and variables
107 ! ******************************************************************************
108 
109  ncont = pregion%plagInput%nCont
110  npatches = pregion%grid%nPatches
111 
112  injcvelratio = pregion%plagInput%injcVelRatio
113  injcmassfluxratio => pregion%plagInput%injcMassFluxRatio
114  specheat => pregion%plagInput%spht
115  injctemp => pregion%plagInput%injcTemp
116 
117  cv => pregion%mixt%cv
118 
119  massfluxlimit = 1.0e-10_rfreal
120 
121 ! ******************************************************************************
122 ! Loop over patches
123 ! ******************************************************************************
124 
125  DO ipatch=1,npatches
126 
127  ppatch => pregion%patches(ipatch)
128  vals => ppatch%mixt%vals
129 
130  bf2c => ppatch%bf2c
131  fn => ppatch%fn
132 
133  bctype = ppatch%bcType
134  distrib = ppatch%mixt%distrib
135 
136 !===============================================================================
137 ! Select injection boundary condition
138 !===============================================================================
139 
140  IF ( (bctype >= bc_injection .AND. bctype <= bc_injection + bc_range) .OR. &
141  (bctype >= bc_inflow .AND. bctype <= bc_inflow + bc_range) ) THEN
142 
143 !-------------------------------------------------------------------------------
144 ! Loop over face patches
145 !-------------------------------------------------------------------------------
146 
147  DO ifc = 1, ppatch%nBFaces
148  itile = ifc
149  c1 = bf2c(ifc)
150 
151  nx = fn(xcoord,ifc)
152  ny = fn(ycoord,ifc)
153  nz = fn(zcoord,ifc)
154  nm = fn(xyzmag,ifc)
155 
156  i2dvals = distrib * ifc
157  minj = vals(bcdat_inject_mfrate,i2dvals)
158  tinj = vals(bcdat_inject_temp ,i2dvals)
159 
160 !-------------------------------------------------------------------------------
161 ! Compute mixture density on boundary
162 ! Using a low-order projection based on cell value
163 !-------------------------------------------------------------------------------
164 
165  rhomixtbcond = cv(cv_mixt_dens,c1)
166 
167 !-------------------------------------------------------------------------------
168 ! Update tile Rhs datastructure
169 !-------------------------------------------------------------------------------
170 
171  ptileplag => ppatch%tilePlag
172 
173  prhs => ptileplag%rhs
174  pcvtilemass => ptileplag%cvTileMass
175 
176  SELECT CASE(bctype)
177 
178 !-------------------------------------------------------------------------------
179 ! Injection
180 !-------------------------------------------------------------------------------
181 
182  CASE(bc_injection)
183  massfluxsum = sum( minj * injcmassfluxratio(:) )
184  heatcapsum = dot_product( specheat, minj * injcmassfluxratio(:) )
185 
186  tiletemp = tinj
187  tilevelnrm = injcvelratio * minj / rhomixtbcond
188  area = nm
189 
190  DO icont = 1, ncont
191  icvmass = pcvtilemass(icont)
192  prhs(icvmass,itile) = -area *minj *injcmassfluxratio(icont)
193  END DO ! iCont
194 
195  prhs(cv_tile_momnrm,itile) = -area *massfluxsum *tilevelnrm
196 
197  prhs(cv_tile_ener ,itile) = -area * &
198  ( 0.5_rfreal*massfluxsum*tilevelnrm**2 &
199  + heatcapsum *tiletemp )
200 
201 !-------------------------------------------------------------------------------
202 ! Inflow based on velocity and temperature
203 !-------------------------------------------------------------------------------
204 
205  CASE(bc_inflow_veltemp)
206  area = nm
207 
208  massfluxsum = 0.0_rfreal
209  heatcapsum = 0.0_rfreal
210  tilevelnrm = 0.0_rfreal
211  tiletemp = 0.0_rfreal
212 
213  DO icont = 1, ncont
214  rhoplag = pregion%plagInput%dens(icont)
215  massfluxsum = massfluxsum + injcmassfluxratio(icont) *rhoplag
216  heatcapsum = heatcapsum + specheat(icont) *injcmassfluxratio(icont) *rhoplag
217  END DO ! iCont
218 
219 ! ==============================================================================
220 ! Set inverse of massFluxSum to avoid division by zero
221 ! ==============================================================================
222 
223  IF ( massfluxsum > massfluxlimit ) THEN
224  massfluxsumr = 1.0_rfreal/massfluxsum
225  heatcapsumr = 1.0_rfreal/heatcapsum
226  ELSE
227  massfluxsumr = 1.0_rfreal
228  heatcapsumr = 1.0_rfreal
229  END IF ! massFluxSum
230 
231  DO icont = 1, ncont
232  icvmass = pcvtilemass(icont)
233  rhoplag = pregion%plagInput%dens(icont)
234 
235  massfluxratio = injcmassfluxratio(icont) *rhoplag *massfluxsumr
236  heatcapratio = injcmassfluxratio(icont) *rhoplag &
237  * specheat(icont) *heatcapsumr
238 
239  tilevelnrm = tilevelnrm +massfluxratio *injcmassfluxratio(icont)
240  tiletemp = tiletemp +heatcapratio *injctemp(icont)
241 
242  prhs(icvmass,itile) = -area * injcmassfluxratio(icont) *rhoplag
243  END DO ! iCont
244 
245  prhs(cv_tile_momnrm,itile) = -area *massfluxsum *tilevelnrm
246 
247  prhs(cv_tile_ener ,itile) = -area * &
248  ( 0.5_rfreal*massfluxsum*tilevelnrm**2 &
249  + heatcapsum *tiletemp )
250 
251 !-------------------------------------------------------------------------------
252 ! Trap error for default
253 !-------------------------------------------------------------------------------
254 
255  CASE default
256  CALL errorstop(global,err_reached_default,__line__)
257  END SELECT ! bcType
258 
259  END DO ! ifc
260  ENDIF ! bcType
261  ENDDO ! iPatch
262 
263 ! finalize --------------------------------------------------------------------
264 
265  CALL deregisterfunction( global )
266 
267 END SUBROUTINE plag_rflu_injctilecalcrhs
268 
269 !******************************************************************************
270 !
271 ! RCS Revision history:
272 !
273 ! $Log: PLAG_RFLU_InjcTileCalcRhs.F90,v $
274 ! Revision 1.8 2008/12/06 08:44:35 mtcampbe
275 ! Updated license.
276 !
277 ! Revision 1.7 2008/11/19 22:17:48 mtcampbe
278 ! Added Illinois Open Source License/Copyright
279 !
280 ! Revision 1.6 2007/03/09 15:16:31 fnajjar
281 ! Fixed bug for massFluxSum being zero and avoiding division by zero
282 !
283 ! Revision 1.5 2006/09/18 20:35:30 fnajjar
284 ! Activated tile datastructure for inflow bc and created proper particle bc
285 !
286 ! Revision 1.4 2006/08/19 15:40:07 mparmar
287 ! Renamed patch variables
288 !
289 ! Revision 1.3 2006/04/07 15:19:24 haselbac
290 ! Removed tabs
291 !
292 ! Revision 1.2 2004/12/07 22:56:24 fnajjar
293 ! Removed rhoVrel being obsolete
294 !
295 ! Revision 1.1 2004/03/08 22:36:08 fnajjar
296 ! Initial import of RFLU-specific injection routines
297 !
298 !******************************************************************************
299 
300 
301 
302 
303 
304 
305 
subroutine plag_rflu_injctilecalcrhs(pRegion)
Tfloat sum() const
Return the sum of all the pixel values in an image.
Definition: CImg.h:13022
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
subroutine errorstop(global, errorCode, errorLine, addMessage)
Definition: ModError.F90:483
long double dot_product(pnt vec1, pnt vec2)
subroutine deregisterfunction(global)
Definition: ModError.F90:469