Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PLAG_RFLU_InitSolutionRandom.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 particle solution in a region from random state
26 !
27 ! Description: None.
28 !
29 ! Input:
30 ! pRegion Pointer to region
31 !
32 ! Output: None.
33 !
34 ! Notes: None.
35 !
36 ! ******************************************************************************
37 !
38 ! $Id: PLAG_RFLU_InitSolutionRandom.F90,v 1.13 2008/12/06 08:44:35 mtcampbe Exp $
39 !
40 ! Copyright: (c) 2004-2005 by the University of Illinois
41 !
42 ! ******************************************************************************
43 
44 SUBROUTINE plag_rflu_initsolutionrandom(pRegion)
45 
46  USE moddatatypes
47  USE moderror
48  USE moddatastruct, ONLY: t_region
49  USE modglobal, ONLY: t_global
50  USE modgrid, ONLY: t_grid
51  USE modparameters
52 
53  USE modrandom, ONLY: rand1uniform
54 
56 
57  IMPLICIT NONE
58 
59 ! ******************************************************************************
60 ! Declarations and definitions
61 ! ******************************************************************************
62 
63 ! ==============================================================================
64 ! Arguments
65 ! ==============================================================================
66 
67  TYPE(t_region), POINTER :: pregion
68 
69 ! ==============================================================================
70 ! Locals
71 ! ==============================================================================
72 
73  CHARACTER(CHRLEN) :: rcsidentstring
74  INTEGER :: errorflag,icont,infloopcntr,ipcl,npcls
75  INTEGER, POINTER, DIMENSION(:) :: pcvplagmass
76  INTEGER, POINTER, DIMENSION(:,:) :: paiv
77  REAL(RFREAL) :: delfrac,diamdel,diammax,diammin,diam,heatcapsum,massratio, &
78  massfluxratiosum,massfluxratiosumr,massfluxratiolimit, &
79  masssum,npclsfrac,rn,sploaddel,sploadmax,sploadmin,spload, &
80  tempdel,tempmax,tempmin,temp,udel,umax,umin,u,vdel,vmin, &
81  vmax,v,wdel,wmin,wmax,w,xdel,xloc,xmax,xmin,ydel,yloc,ymax, &
82  ymin,zdel,zloc,zmax,zmin
83  REAL(RFREAL), POINTER, DIMENSION(:) :: pdens,pinjcmassfluxratio,pspcheat
84  REAL(RFREAL), POINTER, DIMENSION(:,:) :: parv,pcv
85  TYPE(t_global), POINTER :: global
86  TYPE(t_grid), POINTER :: pgrid
87 
88 ! ******************************************************************************
89 ! Start
90 ! ******************************************************************************
91 
92  rcsidentstring = &
93  '$RCSfile: PLAG_RFLU_InitSolutionRandom.F90,v $ $Revision: 1.13 $'
94 
95  global => pregion%global
96 
97  CALL registerfunction(global,'PLAG_RFLU_InitSolutionRandom', &
98  'PLAG_RFLU_InitSolutionRandom.F90')
99 
100  IF ( global%verbLevel > verbose_none ) THEN
101  WRITE(stdout,'(A,1X,A)') solver_name, &
102  'Initializing particle solution from random state...'
103  END IF ! global%verbLevel
104 
105 ! ******************************************************************************
106 ! Set pointers and values
107 ! ******************************************************************************
108 
109  pgrid => pregion%grid
110 
111  delfrac = 0.01_rfreal
112 
113  pregion%plag%nextIdNumber = pregion%plag%nPcls
114 
115  npcls = pregion%plag%nPcls
116  npclsfrac = 0.1_rfreal
117  ipcl = 0
118  infloopcntr = 0
119 
120  massfluxratiolimit = 1.0e-10_rfreal
121 
122 ! ******************************************************************************
123 ! Build bounding box. NOTE not from grid, but from user input
124 ! ******************************************************************************
125 
126  xmin = pregion%plagInput%iniRandXMin
127  xmax = pregion%plagInput%iniRandXMax
128  ymin = pregion%plagInput%iniRandYMin
129  ymax = pregion%plagInput%iniRandYMax
130  zmin = pregion%plagInput%iniRandZMin
131  zmax = pregion%plagInput%iniRandZMax
132 
133  xdel = xmax - xmin
134  ydel = ymax - ymin
135  zdel = zmax - zmin
136 
137 ! ******************************************************************************
138 ! Set pointers and values for PLAG infrastructure
139 ! ******************************************************************************
140 
141  pdens => pregion%plagInput%dens
142  pspcheat => pregion%plagInput%spht
143  pinjcmassfluxratio => pregion%plagInput%injcMassFluxRatio
144 
145  pcvplagmass => pregion%plag%cvPlagMass
146  paiv => pregion%plag%aiv
147  parv => pregion%plag%arv
148  pcv => pregion%plag%cv
149 
150  massfluxratiosum = sum(pinjcmassfluxratio)
151 
152 ! ==============================================================================
153 ! Set inverse of massFluxRatioSum to avoid division by zero
154 ! ==============================================================================
155 
156  IF ( massfluxratiosum > massfluxratiolimit ) THEN
157  massfluxratiosumr = 1.0_rfreal/massfluxratiosum
158  ELSE
159  massfluxratiosumr = 1.0_rfreal
160  END IF ! massFluxRatioSum
161 
162  diammin = pregion%plagInput%iniRandDiamMin
163  diammax = pregion%plagInput%iniRandDiamMax
164  tempmin = pregion%plagInput%iniRandTempMin
165  tempmax = pregion%plagInput%iniRandTempMax
166  sploadmin = pregion%plagInput%iniRandSpLoadMin
167  sploadmax = pregion%plagInput%iniRandSpLoadMax
168 
169  umin = pregion%plagInput%iniRandUMin
170  umax = pregion%plagInput%iniRandUMax
171  vmin = pregion%plagInput%iniRandVMin
172  vmax = pregion%plagInput%iniRandVMax
173  wmin = pregion%plagInput%iniRandWMin
174  wmax = pregion%plagInput%iniRandWMax
175 
176  diamdel = diammax - diammin
177  tempdel = tempmax - tempmin
178  sploaddel = sploadmax - sploadmin
179 
180  udel = umax - umin
181  vdel = vmax - vmin
182  wdel = wmax - wmin
183 
184 ! ******************************************************************************
185 ! Define initial solution through an infinite loop. Exit loop once nPcls is
186 ! reached
187 ! ******************************************************************************
188 
189  infloop: DO
190  infloopcntr = infloopcntr + 1
191 
192  IF ( ipcl == npcls ) THEN
193  EXIT infloop
194  END IF ! iPcl
195 
196  ipcl = ipcl + 1
197 
198 ! ==============================================================================
199 ! Set random particle data
200 ! ==============================================================================
201 
202  rn = rand1uniform(pregion%randData)
203  xloc = xmin + xdel*rn
204 
205  rn = rand1uniform(pregion%randData)
206  yloc = ymin + ydel*rn
207 
208  rn = rand1uniform(pregion%randData)
209  zloc = zmin + zdel*rn
210 
211 ! TEMPORARY
212 ! Allows to create a cylindrical-configuration
213 !
214 ! IF ( yLoc*yLoc + zLoc*zLoc > 0.250_RFREAL ) THEN
215 ! iPcl = iPcl - 1
216 ! infLoopCntr = infLoopCntr - 1
217 !
218 ! CYCLE
219 ! END IF ! yLoc
220 ! END TEMPORARY
221 
222  rn = rand1uniform(pregion%randData)
223  diam = diammin + diamdel*rn
224 
225  rn = rand1uniform(pregion%randData)
226  temp = tempmin + tempdel*rn
227 
228  rn = rand1uniform(pregion%randData)
229  spload = sploadmin + sploaddel*rn
230 
231  rn = rand1uniform(pregion%randData)
232  u = umin + udel*rn
233 
234  rn = rand1uniform(pregion%randData)
235  v = vmin + vdel*rn
236 
237  rn = rand1uniform(pregion%randData)
238  w = wmin + wdel*rn
239 
240 ! ==============================================================================
241 ! Store data
242 ! ==============================================================================
243 
244  pcv(cv_plag_xpos,ipcl) = xloc
245  pcv(cv_plag_ypos,ipcl) = yloc
246  pcv(cv_plag_zpos,ipcl) = zloc
247 
248  DO icont = 1,pregion%plagInput%nCont
249  massratio = pinjcmassfluxratio(icont)*massfluxratiosumr
250  pcv(pcvplagmass(icont),ipcl) = pdens(icont)*massratio*global%pi/6.0_rfreal &
251  * diam**3
252  END DO ! iCont
253 
254  heatcapsum = sum(pcv(pcvplagmass(:),ipcl)*pspcheat(:))
255  masssum = sum(pcv(pcvplagmass(:),ipcl))
256 
257  pcv(cv_plag_xmom,ipcl) = masssum*u
258  pcv(cv_plag_ymom,ipcl) = masssum*v
259  pcv(cv_plag_zmom,ipcl) = masssum*w
260  pcv(cv_plag_ener,ipcl) = heatcapsum*temp
261 
262  parv(arv_plag_spload,ipcl) = spload
263  paiv(aiv_plag_pidini,ipcl) = ipcl
264  paiv(aiv_plag_icells,ipcl) = crazy_value_int ! Value used in initialization
265  paiv(aiv_plag_regini,ipcl) = crazy_value_int ! Value used in initialization
266 
267 ! ==============================================================================
268 ! Write some info
269 ! ==============================================================================
270 
271  IF ( ipcl/REAL(nPcls,KIND=RFREAL) > npclsfrac ) then
272  npclsfrac = npclsfrac + 0.1_rfreal
273 
274  IF ( global%verbLevel > verbose_low ) THEN
275  WRITE(stdout,'(A,3X,A,1X,I10,1X,A)') solver_name,'Generated',ipcl, &
276  'particles.'
277  END IF ! global%verbLevel
278  END IF ! iPcl
279 
280 ! ------------------------------------------------------------------------------
281 ! Check for infinite loop
282 ! ------------------------------------------------------------------------------
283 
284  IF ( infloopcntr >= 100*npcls ) THEN
285  CALL errorstop(global,err_infinite_loop,__line__)
286  END IF ! infLoopCntr
287  END DO infloop
288 
289 ! ******************************************************************************
290 ! End
291 ! ******************************************************************************
292 
293  IF ( global%verbLevel > verbose_none ) THEN
294  WRITE(stdout,'(A,1X,A)') solver_name, &
295  'Initializing particle solution from random state done.'
296  END IF ! global%verbLevel
297 
298  CALL deregisterfunction(global)
299 
300 END SUBROUTINE plag_rflu_initsolutionrandom
301 
302 ! ******************************************************************************
303 !
304 ! RCS Revision history:
305 !
306 ! $Log: PLAG_RFLU_InitSolutionRandom.F90,v $
307 ! Revision 1.13 2008/12/06 08:44:35 mtcampbe
308 ! Updated license.
309 !
310 ! Revision 1.12 2008/11/19 22:17:47 mtcampbe
311 ! Added Illinois Open Source License/Copyright
312 !
313 ! Revision 1.11 2007/03/27 00:22:31 haselbac
314 ! Some simplifications
315 !
316 ! Revision 1.10 2007/03/08 15:04:19 fnajjar
317 ! Fixed bug for massFluxRatioSum being zero and avoiding division by zero
318 !
319 ! Revision 1.9 2006/10/26 15:00:14 fnajjar
320 ! Added computation of particle momentum based on random velocity field
321 !
322 ! Revision 1.8 2006/09/18 20:34:26 fnajjar
323 ! Increased FORMAT output to I10 for particle size
324 !
325 ! Revision 1.7 2006/05/05 18:39:46 haselbac
326 ! Changed logic so serial grid no longer needed
327 !
328 ! Revision 1.4 2004/11/04 16:29:09 fnajjar
329 ! Deleted call to PLAG_SetMaxDimensions and nPcls definition
330 !
331 ! Revision 1.3 2004/10/11 22:10:54 haselbac
332 ! Bug fix and cosmetics
333 !
334 ! Revision 1.2 2004/10/11 19:38:48 fnajjar
335 ! Renamed ininPlag to nPclsIni to follow naming convention
336 !
337 ! Revision 1.1 2004/10/10 20:06:35 fnajjar
338 ! Initial import
339 !
340 ! ******************************************************************************
341 
342 
343 
344 
345 
346 
347 
Tfloat sum() const
Return the sum of all the pixel values in an image.
Definition: CImg.h:13022
double ymin() const
double xmax() const
double xmin() const
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
double zmin() const
REAL(RFREAL) function rand1uniform(rdata)
Definition: ModRandom.F90:345
*********************************************************************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
double zmax() const
double ymax() const
subroutine errorstop(global, errorCode, errorLine, addMessage)
Definition: ModError.F90:483
subroutine deregisterfunction(global)
Definition: ModError.F90:469
subroutine plag_rflu_initsolutionrandom(pRegion)