Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PLAG_BinSortNozzleInlet.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: sort particle entering nozzle by bins.
26 !
27 ! Description: none.
28 !
29 ! Input: iReg = region number
30 ! iLev = current level
31 ! region = region data (dimensions, plag variables)
32 ! iRegBin = region number to bin
33 !
34 ! Output: to plot file.
35 !
36 ! Notes: none.
37 !
38 !******************************************************************************
39 !
40 ! $Id: PLAG_BinSortNozzleInlet.F90,v 1.6 2008/12/06 08:45:07 mtcampbe Exp $
41 !
42 ! Copyright: (c) 2004 by the University of Illinois
43 !
44 !******************************************************************************
45 
46 SUBROUTINE plag_binsortnozzleinlet ( iReg, iLev, region, iRegBin )
47 
48  USE moddatatypes
49  USE moderror
50  USE modpartlag, ONLY : t_plag, t_plag_input
51  USE moddatastruct, ONLY : t_region
52  USE modglobal, ONLY : t_global
53 
54  USE modmpi
55  USE modparameters
57  IMPLICIT NONE
58 
59 ! ... parameters
60  INTEGER :: ireg, ilev, iregbin
61 
62  TYPE(t_region) :: region
63 
64 ! ... loop variables
65  INTEGER :: i,j
66 
67 ! ... local variables
68  CHARACTER(CHRLEN) :: rcsidentstring
69  CHARACTER(CHRLEN+4) :: fname
70 
71  INTEGER :: errorflag, ndimplag
72  INTEGER :: pidini,regini,icell,indexi,indexj,indexk
73  INTEGER :: ibin,nbins
74  INTEGER :: ibinlog,nbinslog
75  INTEGER :: icontal,icontalox
76  INTEGER, POINTER :: cvmass(:)
77  INTEGER, POINTER :: aiv(:,:)
78  INTEGER, DIMENSION(0:500) :: sizebin,sizebinlog
79 
80  REAL(RFREAL) :: diambinmicron,x,y,z,diammicron,diammicronlog
81  REAL(RFREAL) :: diammaxlog,diamminlog,diambinlogdelta,ribin
82  REAL(RFREAL) :: dlogjph,dlogjmh
83  REAL(RFREAL) :: massl,xminrange,xposplag
84  REAL(RFREAL) :: diammax,diammin
85  REAL(RFREAL), DIMENSION(0:500) :: compalbin,compaloxbin,compalbinlog,&
86  compaloxbinlog
87  REAL(RFREAL), DIMENSION(0:500) :: diambin, diambinlog,weightbin
88  REAL(RFREAL), DIMENSION(0:500) :: diam32bin,diam43bin,&
89  diam2bin,diam3bin,diam4bin,massalbin,&
90  massaloxbin,masstotbin
91  REAL(RFREAL), DIMENSION(0:500) :: xmombin,ymombin,zmombin
92  REAL(RFREAL), DIMENSION(0:500) :: uvelbin,vvelbin,wvelbin
93  REAL(RFREAL), DIMENSION(0:500) :: diam32binlog,diam43binlog,&
94  diam2binlog,diam3binlog,diam4binlog,&
95  massalbinlog,massaloxbinlog,masstotbinlog
96  REAL(RFREAL), DIMENSION(0:500) :: xmombinlog,ymombinlog,zmombinlog
97  REAL(RFREAL), DIMENSION(0:500) :: uvelbinlog,vvelbinlog,wvelbinlog
98  REAL(RFREAL), POINTER :: cv(:,:), dv(:,:)
99 
100  TYPE(t_global), POINTER :: global
101 
102 !******************************************************************************
103 
104  rcsidentstring = '$RCSfile: PLAG_BinSortNozzleInlet.F90,v $ $Revision: 1.6 $'
105 
106  global => region%global
107 
108  CALL registerfunction( global,'PLAG_BinSortNozzleInlet', 'PLAG_BinSortNozzleInlet.F90' )
109 
110 ! set parameters --------------------------------------------------------------
111 
112  ndimplag = region%levels(ilev)%plag%nPcls
113 
114  sizebin(0:500) = 0
115  sizebinlog(0:500) = 0
116  diambin(0:500) = 0.0_rfreal
117  diambinlog(0:500) = 0.0_rfreal
118  weightbin(0:500) = 1.0_rfreal
119 
120  diamminlog = log( 5.0_rfreal)
121  diammaxlog = log(250.0_rfreal)
122  diambinmicron = 5.0_rfreal
123 
124  diammin = 5.0_rfreal
125  diammax = 250.0_rfreal
126 
127  nbins=50
128  nbinslog=25
129 
130  icontal = 1
131  icontalox = 2
132  compalbin(0:500) = 0.0_rfreal
133  compaloxbin(0:500) = 0.0_rfreal
134  compalbinlog(0:500) = 0.0_rfreal
135  compaloxbinlog(0:500) = 0.0_rfreal
136 
137  massalbin(0:500) = 0.0_rfreal
138  massaloxbin(0:500) = 0.0_rfreal
139  masstotbin(0:500) = 0.0_rfreal
140 
141  xmombin(0:500) = 0.0_rfreal
142  ymombin(0:500) = 0.0_rfreal
143  zmombin(0:500) = 0.0_rfreal
144 
145  uvelbin(0:500) = 0.0_rfreal
146  vvelbin(0:500) = 0.0_rfreal
147  wvelbin(0:500) = 0.0_rfreal
148 
149  massalbinlog(0:500) = 0.0_rfreal
150  massaloxbinlog(0:500) = 0.0_rfreal
151  masstotbinlog(0:500) = 0.0_rfreal
152 
153  xmombinlog(0:500) = 0.0_rfreal
154  ymombinlog(0:500) = 0.0_rfreal
155  zmombinlog(0:500) = 0.0_rfreal
156 
157  uvelbinlog(0:500) = 0.0_rfreal
158  vvelbinlog(0:500) = 0.0_rfreal
159  wvelbinlog(0:500) = 0.0_rfreal
160 
161  IF (ireg /= iregbin) goto 1999
162 
163  print*,'PLAG_BinSortNozzleInlet: iRegBin, nDimPlag = ',iregbin,ndimplag
164 
165 ! set values ------------------------------------------------------------------
166 
167 ! TEMPORARY: Data Pertinent to c1
168 
169  xminrange = 0.0_rfreal
170 
171  SELECT CASE (iregbin)
172  CASE(41)
173  xminrange = 0.39_rfreal
174 
175  CASE(52)
176  xminrange = 0.465_rfreal
177 
178  CASE default
179  xminrange = 0.0_rfreal
180  END SELECT ! iRegBin
181 
182  diambinlogdelta = (diammaxlog-diamminlog)/REAL((nBinsLog-1),kind=rfreal)
183 
184  DO ibin = 1, nbinslog
185  ribin = REAL(ibin,kind=rfreal)
186  diambinlog(ibin) = ((nbinslog-ribin)*diamminlog +(ribin-1.0_rfreal)*diammaxlog)/&
187  REAL((nBinsLog-1),kind=rfreal)
188 
189  dlogjph = ( (nbinslog-ribin-0.5_rfreal)*diamminlog &
190  +(ribin+0.5_rfreal-1)*diammaxlog)/ &
191  REAL((nBinsLog-1),kind=rfreal)
192 
193  dlogjmh = ( (nbinslog-ribin+0.5_rfreal)*diamminlog &
194  +(ribin-0.5_rfreal-1)*diammaxlog)/ &
195  REAL((nBinsLog-1),kind=rfreal)
196 
197  weightbin(ibin) = exp(dlogjph) -exp(dlogjmh)
198 
199 ! PRINT*,' iBin, diamBin, weightBin = ', iBin,EXP(diamBinLog(iBin)),weightBin(iBin)
200  END DO
201 
202 ! set pointers ----------------------------------------------------------------
203 
204  aiv => region%levels(ilev)%plag%aiv
205  cv => region%levels(ilev)%plag%cv
206  dv => region%levels(ilev)%plag%dv
207  cvmass => region%levels(ilev)%plag%cvPlagMass
208 
209 ! determine size ---------------------------------------------------------------
210 
211  DO i = 1, ndimplag
212  xposplag = cv(cv_plag_xpos,i)
213 
214  IF ( xposplag >= xminrange ) THEN
215  diammicron = dv(dv_plag_diam,i)*1.0e+06_rfreal
216 
217  ibin=nint(diammicron/diambinmicron)
218 
219  IF(diammicron < diammin ) ibin = 1
220  IF(diammicron > diammax ) ibin = nbins
221 
222  sizebin(ibin) = sizebin(ibin)+1
223 
224  massl = sum(cv(cvmass(:),i))
225 
226  massalbin(ibin) = massalbin(ibin) +cv(cvmass(icontal),i)
227  massaloxbin(ibin) = massaloxbin(ibin) +cv(cvmass(icontalox),i)
228  masstotbin(ibin) = masstotbin(ibin) +massl
229 
230  diam2bin(ibin) = diam2bin(ibin) +diammicron**2
231  diam3bin(ibin) = diam3bin(ibin) +diammicron**3
232  diam4bin(ibin) = diam4bin(ibin) +diammicron**4
233 
234  xmombin(ibin) = xmombin(ibin) +cv(cv_plag_xmom,i)
235  ymombin(ibin) = ymombin(ibin) +cv(cv_plag_ymom,i)
236  zmombin(ibin) = zmombin(ibin) +cv(cv_plag_zmom,i)
237  ENDIF ! xPosPlag
238  ENDDO ! i
239 
240  DO ibin = 1, nbins
241  IF ( sizebin(ibin) > 0 ) THEN
242  compalbin(ibin) = massalbin(ibin)/masstotbin(ibin)
243  compaloxbin(ibin) = massaloxbin(ibin)/masstotbin(ibin)
244 
245  diam43bin(ibin) = diam4bin(ibin)/diam3bin(ibin)
246  diam32bin(ibin) = diam3bin(ibin)/diam2bin(ibin)
247 
248  uvelbin(ibin) = xmombin(ibin)/masstotbin(ibin)
249  vvelbin(ibin) = ymombin(ibin)/masstotbin(ibin)
250  wvelbin(ibin) = zmombin(ibin)/masstotbin(ibin)
251  END IF ! sizeBin
252  ENDDO ! iBin
253 
254 ! open file and write the header ----------------------------------------------
255 
256  WRITE(fname,'(A,I2,A,1PE11.5,A)') &
257  trim(global%casename)//'.plag_bin_reg_',iregbin,'_',global%currentTime,'.dat'
258  OPEN(if_plot,file=fname,status='unknown',form='formatted',iostat=errorflag)
259  global%error = errorflag
260  IF (global%error /= 0) CALL errorstop( global,err_file_open,__line__,fname )
261 
262  IF (global%currentTime <= 0._rfreal) THEN
263  WRITE(if_plot,1005,err=10) trim(global%casename),global%timeStamp
264  ELSE
265  WRITE(if_plot,1005,err=10) trim(global%casename),global%currentTime
266  ENDIF
267 
268  WRITE(if_plot,1010,err=10) 'diamBin sizeBin compAl compAlOx diam32 diam43 u v w'
269 
270  WRITE(if_plot,1015) iregbin, nbins
271 
272  DO ibin = 1, nbins
273  WRITE(if_plot,1020,err=10) ibin*5,sizebin(ibin),&
274  nint(compalbin(ibin)*100.0_rfreal),&
275  nint(compaloxbin(ibin)*100.0_rfreal), &
276  nint(diam32bin(ibin)),nint(diam43bin(ibin)),&
277  uvelbin(ibin),vvelbin(ibin),wvelbin(ibin)
278  ENDDO ! iBin
279 
280  CLOSE(if_plot,iostat=errorflag)
281  global%error = errorflag
282  IF (global%error /= 0) CALL errorstop( global,err_file_close,__line__,fname )
283 
284 ! write conserved variables for time-averaging ----------------------------------
285 
286  WRITE(fname,'(A,I2,A,1PE11.5,A)') &
287  trim(global%casename)//'.plag_cv_bin_reg_',iregbin,'_',global%currentTime,'.dat'
288  OPEN(if_plot,file=fname,status='unknown',form='formatted',iostat=errorflag)
289  global%error = errorflag
290  IF (global%error /= 0) CALL errorstop( global,err_file_open,__line__,fname )
291 
292  IF (global%currentTime <= 0._rfreal) THEN
293  WRITE(if_plot,1005,err=10) trim(global%casename),global%timeStamp
294  ELSE
295  WRITE(if_plot,1005,err=10) trim(global%casename),global%currentTime
296  ENDIF
297 
298  WRITE(if_plot,1010,err=10) 'diamBin sizeBin massAl massAlOxBin massTot diam2 diam3 diam4 xMom yMom zMom'
299 
300  WRITE(if_plot,1015) iregbin, nbins
301 
302  DO ibin = 1, nbins
303  WRITE(if_plot,1030,err=10) ibin*5,sizebin(ibin),&
304  massalbin(ibin),massaloxbin(ibin),masstotbin(ibin),&
305  diam2bin(ibin),diam3bin(ibin),diam4bin(ibin),&
306  xmombin(ibin),ymombin(ibin),zmombin(ibin)
307  ENDDO ! iBin
308 
309  CLOSE(if_plot,iostat=errorflag)
310  global%error = errorflag
311  IF (global%error /= 0) CALL errorstop( global,err_file_close,__line__,fname )
312 
313 ! compute log-binned distribution -----------------------------------------------
314 
315  DO i = 1, ndimplag
316  xposplag = cv(cv_plag_xpos,i)
317 
318  IF ( xposplag >= xminrange ) THEN
319  diammicron = dv(dv_plag_diam,i)*1.0e+06_rfreal
320  diammicronlog = log(diammicron)
321 
322  ibinlog=nint(1.0_rfreal + (diammicronlog-diamminlog)/diambinlogdelta)
323 
324  IF(diammicronlog < diamminlog ) ibinlog = 1
325  IF(diammicronlog > diammaxlog ) ibinlog = nbinslog
326 
327  sizebinlog(ibinlog) = sizebinlog(ibinlog)+1
328 
329  massl = sum(cv(cvmass(:),i))
330 
331  massalbinlog(ibinlog) = massalbinlog(ibinlog) +cv(cvmass(icontal),i)
332  massaloxbinlog(ibinlog) = massaloxbinlog(ibinlog) +cv(cvmass(icontalox),i)
333  masstotbinlog(ibinlog) = masstotbinlog(ibinlog) +massl
334 
335  diam2binlog(ibinlog) = diam2binlog(ibinlog) +diammicron**2
336  diam3binlog(ibinlog) = diam3binlog(ibinlog) +diammicron**3
337  diam4binlog(ibinlog) = diam4binlog(ibinlog) +diammicron**4
338 
339  xmombinlog(ibinlog) = xmombinlog(ibinlog) +cv(cv_plag_xmom,i)
340  ymombinlog(ibinlog) = ymombinlog(ibinlog) +cv(cv_plag_ymom,i)
341  zmombinlog(ibinlog) = zmombinlog(ibinlog) +cv(cv_plag_zmom,i)
342  ENDIF ! xPosPlag
343  ENDDO ! i
344 
345  DO ibinlog = 1, nbinslog
346  IF ( sizebinlog(ibinlog) > 0 ) THEN
347  compalbinlog(ibinlog) = massalbinlog(ibinlog)/masstotbinlog(ibinlog)
348  compaloxbinlog(ibinlog) = massaloxbinlog(ibinlog)/masstotbinlog(ibinlog)
349 
350  diam43binlog(ibinlog) = diam4binlog(ibinlog)/diam3binlog(ibinlog)
351  diam32binlog(ibinlog) = diam3binlog(ibinlog)/diam2binlog(ibinlog)
352 
353  uvelbinlog(ibinlog) = xmombinlog(ibinlog)/masstotbinlog(ibinlog)
354  vvelbinlog(ibinlog) = ymombinlog(ibinlog)/masstotbinlog(ibinlog)
355  wvelbinlog(ibinlog) = zmombinlog(ibinlog)/masstotbinlog(ibinlog)
356  END IF ! sizeBinLog
357  ENDDO ! iBinLog
358 
359 ! open file and write the header ----------------------------------------------
360 
361  WRITE(fname,'(A,I2,A,1PE11.5,A)') &
362  trim(global%casename)//'.plag_logbin_reg_',iregbin,'_',global%currentTime,'.dat'
363  OPEN(if_plot,file=fname,status='unknown',form='formatted',iostat=errorflag)
364  global%error = errorflag
365  IF (global%error /= 0) CALL errorstop( global,err_file_open,__line__,fname )
366 
367  IF (global%currentTime <= 0._rfreal) THEN
368  WRITE(if_plot,1005,err=10) trim(global%casename),global%timeStamp
369  ELSE
370  WRITE(if_plot,1005,err=10) trim(global%casename),global%currentTime
371  ENDIF
372 
373  WRITE(if_plot,1010,err=10) 'diamBinLog sizeBinLog sizeBinWeight compAl compAlOx diam32 diam43 u v w'
374  WRITE(if_plot,1015) iregbin, nbinslog
375 
376  DO ibinlog = 1, nbinslog
377  WRITE(if_plot,1025,err=10) exp(diambinlog(ibinlog)),sizebinlog(ibinlog),&
378  sizebinlog(ibinlog)/weightbin(ibinlog),&
379  nint(compalbinlog(ibinlog)*100.0_rfreal),&
380  nint(compaloxbinlog(ibinlog)*100.0_rfreal), &
381  nint(diam32binlog(ibinlog)),nint(diam43binlog(ibinlog)),&
382  uvelbinlog(ibinlog),vvelbinlog(ibinlog),wvelbinlog(ibinlog)
383  ENDDO ! iBin
384 
385 ! close file, handle errors ---------------------------------------------------
386 
387  CLOSE(if_plot,iostat=errorflag)
388  global%error = errorflag
389  IF (global%error /= 0) CALL errorstop( global,err_file_close,__line__,fname )
390 
391 1999 CONTINUE
392  CALL deregisterfunction( global )
393  goto 999
394 
395 10 CONTINUE
396  CALL errorstop( global,err_file_write,__line__,fname )
397 
398 ! formats ---------------------------------------------------------------------
399 
400 1005 FORMAT('TITLE="',a,'. Time: ',1pe11.5,'."')
401 1010 FORMAT('VARIABLES= ',a)
402 1015 FORMAT('ZONE T="',i5.5,'", I=',i10,', F=POINT')
403 1020 FORMAT(1x,i5,1x,i6,4(1x,i5),3(1x,1pe12.5))
404 1025 FORMAT((1x,1pe12.5),1x,i5,(1x,1pe12.5),4(1x,i5),3(1x,1pe12.5))
405 1030 FORMAT(1x,i4,1x,i6,9(1x,e23.16))
406 
407 999 CONTINUE
408 END SUBROUTINE plag_binsortnozzleinlet
409 
410 !******************************************************************************
411 !
412 ! RCS Revision history:
413 !
414 ! $Log: PLAG_BinSortNozzleInlet.F90,v $
415 ! Revision 1.6 2008/12/06 08:45:07 mtcampbe
416 ! Updated license.
417 !
418 ! Revision 1.5 2008/11/19 22:18:18 mtcampbe
419 ! Added Illinois Open Source License/Copyright
420 !
421 ! Revision 1.4 2004/12/13 18:07:15 fnajjar
422 ! Bug fix for out-of-bound bin indices
423 !
424 ! Revision 1.3 2004/11/17 22:14:15 fnajjar
425 ! Cosmetic changes and bug fixes
426 !
427 ! Revision 1.2 2004/11/13 22:01:04 fnajjar
428 ! Included log binning
429 !
430 ! Revision 1.1 2004/05/24 14:25:19 fnajjar
431 ! Initial import of binning routine
432 !
433 !******************************************************************************
434 
435 
436 
437 
438 
439 
440 
Tfloat sum() const
Return the sum of all the pixel values in an image.
Definition: CImg.h:13022
void int int REAL REAL * y
Definition: read.cpp:74
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
int status() const
Obtain the status of the attribute.
Definition: Attribute.h:240
subroutine plag_binsortnozzleinlet(iReg, iLev, region, iRegBin)
void int int int REAL REAL REAL * z
Definition: write.cpp:76
blockLoc i
Definition: read.cpp:79
void int int REAL * x
Definition: read.cpp:74
**********************************************************************Rocstar Simulation Suite Illinois Rocstar LLC All rights reserved ****Illinois Rocstar LLC IL **www illinoisrocstar com **sales illinoisrocstar com 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 **********************************************************************INTERFACE SUBROUTINE form
**********************************************************************Rocstar Simulation Suite Illinois Rocstar LLC All rights reserved ****Illinois Rocstar LLC IL **www illinoisrocstar com **sales illinoisrocstar com 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 **********************************************************************INTERFACE SUBROUTINE icell
virtual std::ostream & print(std::ostream &os) const
j indices j
Definition: Indexing.h:6
subroutine errorstop(global, errorCode, errorLine, addMessage)
Definition: ModError.F90:483
subroutine deregisterfunction(global)
Definition: ModError.F90:469
RT a() const
Definition: Line_2.h:140