Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PLAG_GetCellIndices.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: Search algorithm for cell indices.
26 !
27 ! Description: none.
28 !
29 ! Input: region = current region.
30 !
31 ! Output: region%levels%plag%aiv
32 ! region%levels%plag%aivOld
33 !
34 ! Notes: none.
35 !
36 !******************************************************************************
37 !
38 ! $Id: PLAG_GetCellIndices.F90,v 1.4 2009/10/26 00:19:32 mtcampbe Exp $
39 !
40 ! Copyright: (c) 2002 by the University of Illinois
41 !
42 !******************************************************************************
43 
44 SUBROUTINE plag_getcellindices( region, iReg )
45 
46  USE moddatatypes
47  USE moddatastruct, ONLY : t_region
48  USE modglobal, ONLY : t_global
49  USE modpartlag, ONLY : t_plag, t_plag_input
53  USE moderror
54  USE modparameters
56  IMPLICIT NONE
57 
58 #include "Indexing.h"
59 
60 ! ... parameters
61  TYPE(t_region) :: region
62 
63  INTEGER :: ireg
64 
65 ! ... loop variables
66  INTEGER :: i, icelllev, ilevels, ipcls, j, k
67 
68 ! ... local variables
69  CHARACTER(CHRLEN) :: rcsidentstring
70 
71  INTEGER :: icoff, ijcoff, ijkc, inoff, ijnoff, ilev, &
72  ijknr, ijknri, ijknrj,ijknrk, ihigh, ilow, iskip, ipcbeg,ipcend, &
73  jpcbeg,jpcend, jhigh, jlow, jskip, &
74  kpcbeg,kpcend, khigh, klow, kskip, &
75  ncont, ncelllev, ncelllevmax, nlevels, npcls
76  INTEGER, DIMENSION(4) :: indexcurr, indexnew, indexsearch
77  INTEGER, POINTER, DIMENSION(:,:) :: paiv, paivold
78 
79  LOGICAL :: celllocate, celllocaterobust
80 
81  REAL(RFREAL) :: massl,taulr,diaml
82 
83  REAL(RFREAL), DIMENSION(3) :: posplag
84  REAL(RFREAL), POINTER, DIMENSION(:,:) :: pcv, pcvold
85  REAL(RFREAL), POINTER, DIMENSION(:,:) :: pdv
86 
87  TYPE(t_plag), POINTER :: pplag
88  TYPE(t_global), POINTER :: global
89  TYPE(t_region), POINTER :: pregion
90 
91 !******************************************************************************
92 
93  rcsidentstring = '$RCSfile: PLAG_GetCellIndices.F90,v $ $Revision: 1.4 $'
94 
95  global => region%global
96 
97  CALL registerfunction( global, 'PLAG_getCellIndices',&
98  'PLAG_GetCellIndices.F90' )
99 
100 ! Get dimensions --------------------------------------------------------------
101 
102  ilev = region%currLevel
103 
104  npcls = region%levels(ilev)%plag%nPcls
105  ncelllevmax = 1
106  nlevels = 8
107 
108  CALL rflo_getdimensphys( region,ilev,ipcbeg,ipcend, &
109  jpcbeg,jpcend,kpcbeg,kpcend )
110  CALL rflo_getcelloffset( region,ilev,icoff,ijcoff )
111  CALL rflo_getnodeoffset( region,ilev,inoff,ijnoff )
112 
113 ! Set pointers ----------------------------------------------------------------
114 
115  pplag => region%levels(ilev)%plag
116 
117  paiv => pplag%aiv
118  paivold => pplag%aivOld
119  pcv => pplag%cv
120  pcvold => pplag%cvOld
121  pdv => pplag%dv
122 
123 ! Loop over Lagrangian particles ----------------------------------------------
124 
125  DO ipcls = 1, npcls
126 
127 ! - Load current index --------------------------------------------------------
128 
129  indexcurr(1) = paivold(aiv_plag_icells,ipcls)
130  indexcurr(2) = paivold(aiv_plag_indexi,ipcls)
131  indexcurr(3) = paivold(aiv_plag_indexj,ipcls)
132  indexcurr(4) = paivold(aiv_plag_indexk,ipcls)
133 
134 ! - Load particle positions ---------------------------------------------------
135 
136  posplag(xcoord) = pcv(cv_plag_xpos,ipcls)
137  posplag(ycoord) = pcv(cv_plag_ypos,ipcls)
138  posplag(zcoord) = pcv(cv_plag_zpos,ipcls)
139 
140 ! - Set particle status -------------------------------------------------------
141 
142  paiv(aiv_plag_status,ipcls) = plag_status_keep
143  paivold(aiv_plag_status,ipcls) = plag_status_keep
144 
145 ! - Search current and surrounding cells --------------------------------------
146 
147  ncelllev = 1
148 
149  DO WHILE(ncelllev <= ncelllevmax)
150 
151  DO ilevels = 1, nlevels
152 
153  SELECT CASE(ilevels)
154 
155 ! -- current cell -------------------------------------------------------------
156  CASE(1)
157  ilow = indexcurr(2)
158  ihigh = indexcurr(2)
159  iskip = 1
160 
161  jlow = indexcurr(3)
162  jhigh = indexcurr(3)
163  jskip = 1
164 
165  klow = indexcurr(4)
166  khigh = indexcurr(4)
167  kskip = 1
168 
169 ! -- i-cell shift -------------------------------------------------------------
170  CASE(2)
171  ilow = indexcurr(2)-ncelllev
172  ihigh = indexcurr(2)+ncelllev
173  iskip = ncelllev+1
174 
175  jlow = indexcurr(3)
176  jhigh = indexcurr(3)
177  jskip = 1
178 
179  klow = indexcurr(4)
180  khigh = indexcurr(4)
181  kskip = 1
182 
183 ! -- j-cell shift -------------------------------------------------------------
184  CASE(3)
185  ilow = indexcurr(2)
186  ihigh = indexcurr(2)
187  iskip = 1
188 
189  jlow = indexcurr(3)-ncelllev
190  jhigh = indexcurr(3)+ncelllev
191  jskip = ncelllev+1
192 
193  klow = indexcurr(4)
194  khigh = indexcurr(4)
195  kskip = 1
196 
197 ! -- k-cell shift -------------------------------------------------------------
198  CASE(4)
199  ilow = indexcurr(2)
200  ihigh = indexcurr(2)
201  iskip = 1
202 
203  jlow = indexcurr(3)
204  jhigh = indexcurr(3)
205  jskip = 1
206 
207  klow = indexcurr(4)-ncelllev
208  khigh = indexcurr(4)+ncelllev
209  kskip = ncelllev+1
210 
211 ! -- ij edge cell shift -------------------------------------------------------------
212  CASE(5)
213  ilow = indexcurr(2)-ncelllev
214  ihigh = indexcurr(2)+ncelllev
215  iskip = ncelllev+1
216 
217  jlow = indexcurr(3)-ncelllev
218  jhigh = indexcurr(3)+ncelllev
219  jskip = ncelllev+1
220 
221  klow = indexcurr(4)
222  khigh = indexcurr(4)
223  kskip = 1
224 
225 ! -- ik edge cell shift -------------------------------------------------------
226  CASE(6)
227  ilow = indexcurr(2)-ncelllev
228  ihigh = indexcurr(2)+ncelllev
229  iskip = ncelllev+1
230 
231  jlow = indexcurr(3)
232  jhigh = indexcurr(3)
233  jskip = 1
234 
235  klow = indexcurr(4)-ncelllev
236  khigh = indexcurr(4)+ncelllev
237  kskip = ncelllev+1
238 
239 ! -- jk edge cell shift -------------------------------------------------------
240  CASE(7)
241  ilow = indexcurr(2)
242  ihigh = indexcurr(2)
243  iskip = 1
244 
245  jlow = indexcurr(3)-ncelllev
246  jhigh = indexcurr(3)+ncelllev
247  jskip = ncelllev+1
248 
249  klow = indexcurr(4)-ncelllev
250  khigh = indexcurr(4)+ncelllev
251  kskip = ncelllev+1
252 
253 ! -- ijk corner cell shift ----------------------------------------------------
254  CASE(8)
255  ilow = indexcurr(2)-ncelllev
256  ihigh = indexcurr(2)+ncelllev
257  iskip = ncelllev+1
258 
259  jlow = indexcurr(3)-ncelllev
260  jhigh = indexcurr(3)+ncelllev
261  jskip = ncelllev+1
262 
263  klow = indexcurr(4)-ncelllev
264  khigh = indexcurr(4)+ncelllev
265  kskip = ncelllev+1
266 
267  END SELECT !iLevels
268 
269 ! -- Perform search -----------------------------------------------------------
270 
271  DO k=klow,khigh,kskip
272  DO j=jlow,jhigh,jskip
273  DO i=ilow,ihigh,iskip
274  ijkc = indijk(i, j ,k ,icoff,ijcoff)
275  ijknr = indijk(i, j ,k ,inoff,ijnoff)
276  ijknri = indijk(i+1,j ,k ,inoff,ijnoff)
277  ijknrj = indijk(i,j+1 ,k ,inoff,ijnoff)
278  ijknrk = indijk(i ,j ,k+1,inoff,ijnoff)
279 
280  indexsearch(1) = ijkc
281  indexsearch(2) = i
282  indexsearch(3) = j
283  indexsearch(4) = k
284 
285  CALL plag_incelltest(region, posplag, indexsearch, &
286  ijknr,ijknri,ijknrj,ijknrk, &
287  indexnew,celllocate)
288 
289  IF ( celllocate .EQV. .true. ) goto 999
290 
291  END DO ! i
292  END DO ! j
293  END DO ! k
294 
295  END DO ! iLevels
296 
297  ncelllev = ncelllev+1
298 
299  END DO ! nCellLev
300 
301 ! - Trap error if unable to locate --------------------------------------------
302 
303  IF ( celllocate .EQV. .false. ) THEN
304  massl = sum( pplag%cv(pplag%cvPlagMass(:),ipcls) )
305  diaml = pdv(dv_plag_diam,ipcls)
306 
307  IF ( diaml > 1.0e-14_rfreal ) THEN
308  taulr = 3.0_rfreal*global%pi*pplag%tv(tv_plag_muelmixt,ipcls)*diaml/massl
309  ELSE
310  taulr = 0.0_rfreal
311  ENDIF
312 
313  WRITE(stdout,'(A)') &
314  '##### Rocpart Warning: PLAG_inCellTest Unable to Locate Cell #####'
315  WRITE(stdout,1010) 'Default Search Failed to Locate Cell for Particle',&
316  global%currentTime, ireg, ipcls,&
317  paivold(aiv_plag_pidini,ipcls), &
318  paivold(aiv_plag_regini,ipcls), &
319  paivold(aiv_plag_icells,ipcls), &
320  paivold(aiv_plag_indexi,ipcls), &
321  paivold(aiv_plag_indexj,ipcls), &
322  paivold(aiv_plag_indexk,ipcls), &
323  pcvold(cv_plag_xpos:cv_plag_zpos,ipcls), &
324  posplag(1:3), &
325  pdv(dv_plag_uvel:dv_plag_wvel,ipcls), &
326  pdv(dv_plag_uvelmixt:dv_plag_wvelmixt,ipcls),&
327  pdv(dv_plag_diam,ipcls),massl,taulr
328 
329 ! -- Invoke robust cell search for particles potentially located --------------
330 ! in dummy cells ---------------------------------------------------------
331 
332  CALL plag_incelltestrobust( region, posplag,indexcurr, &
333  indexnew,celllocaterobust )
334 
335 ! TEMPORARY
336 ! Delete Particle from data structure failing robust cell search
337 ! due to clobbered geometry datastructure. Relevant for complex geometries.
338 !
339  WRITE(stdout,'(A)') &
340  '##### Rocpart Warning: Deleting Particle Following Robust Cell Search #####'
341  paiv(aiv_plag_status,ipcls) = plag_status_delete
342  paivold(aiv_plag_status,ipcls) = plag_status_delete
343 ! END TEMPORARY
344 
345  IF ( celllocaterobust .EQV. .true. ) goto 999
346 
347  WRITE(stdout,'(A)') &
348  '##### Rocpart Error: PLAG_inCellTestRobust Unable to Locate Cell with Robust Search #####'
349  WRITE(stdout,1010) 'Unable to Locate Cell for Particle',&
350  global%currentTime, ireg, ipcls,&
351  paivold(aiv_plag_pidini,ipcls), &
352  paivold(aiv_plag_regini,ipcls), &
353  paivold(aiv_plag_icells,ipcls), &
354  paivold(aiv_plag_indexi,ipcls), &
355  paivold(aiv_plag_indexj,ipcls), &
356  paivold(aiv_plag_indexk,ipcls), &
357  pcvold(cv_plag_xpos:cv_plag_zpos,ipcls), &
358  posplag(1:3), &
359  pdv(dv_plag_uvel:dv_plag_wvel,ipcls), &
360  pdv(dv_plag_uvelmixt:dv_plag_wvelmixt,ipcls)
361 
362 ! CALL ErrorStop( global,ERR_PLAG_CELLINDEX,__LINE__ )
363 
364 ! TEMPORARY
365 ! Delete Particle from data structure for testing
366  paiv(aiv_plag_status,ipcls) = plag_status_delete
367  paivold(aiv_plag_status,ipcls) = plag_status_delete
368 ! END TEMPORARY
369 
370  END IF ! cellLocate
371 
372 ! - Load new cell indices -----------------------------------------------------
373 
374 999 CONTINUE
375 
376 ! Dont load aiv into aivOld till end of RK-stage since
377 ! search algorithm is modulated by RK time-stepping that
378 ! is based on cvOld
379 !
380 ! pAivOld(AIV_PLAG_ICELLS,iPcls) = pAiv(AIV_PLAG_ICELLS,iPcls)
381 ! pAivOld(AIV_PLAG_INDEXI,iPcls) = pAiv(AIV_PLAG_INDEXI,iPcls)
382 ! pAivOld(AIV_PLAG_INDEXJ,iPcls) = pAiv(AIV_PLAG_INDEXJ,iPcls)
383 ! pAivOld(AIV_PLAG_INDEXK,iPcls) = pAiv(AIV_PLAG_INDEXK,iPcls)
384 
385  paiv(aiv_plag_icells,ipcls) = indexnew(1)
386  paiv(aiv_plag_indexi,ipcls) = indexnew(2)
387  paiv(aiv_plag_indexj,ipcls) = indexnew(3)
388  paiv(aiv_plag_indexk,ipcls) = indexnew(4)
389 
390  END DO ! iPcls
391 
392 ! finalize --------------------------------------------------------------------
393 
394  CALL deregisterfunction( global )
395 
396 1010 FORMAT(a,'Time = ', 1pe12.5, ', iReg = ', i5, ', iPcls = ', i8, &
397  ', aivOld = ',6i5,', posOld = ',3(1pe15.7),&
398  ', posCurr = ', 3(1pe15.7),', pVel = ', 3(1pe15.7), &
399  ', mVel = ', 3(1pe15.7),&
400  ', diam = ', 1pe15.7,', mass = ',1pe15.7,' , tauL = ', 1pe15.7)
401 
402 END SUBROUTINE plag_getcellindices
403 !******************************************************************************
404 !
405 ! RCS Revision history:
406 !
407 ! $Log: PLAG_GetCellIndices.F90,v $
408 ! Revision 1.4 2009/10/26 00:19:32 mtcampbe
409 ! Updates for completion of NATIVE_MP_IO
410 !
411 ! Revision 1.3 2008/12/06 08:44:33 mtcampbe
412 ! Updated license.
413 !
414 ! Revision 1.2 2008/11/19 22:17:46 mtcampbe
415 ! Added Illinois Open Source License/Copyright
416 !
417 ! Revision 1.1 2004/12/01 20:57:33 fnajjar
418 ! Initial revision after changing case
419 !
420 ! Revision 1.9 2004/08/05 20:10:41 fnajjar
421 ! Included deletion flag for aiv after robust cell search algorithm
422 !
423 ! Revision 1.8 2004/07/01 14:15:54 fnajjar
424 ! Added variables to IO when particle search fails
425 !
426 ! Revision 1.7 2004/07/01 14:13:38 fnajjar
427 ! Commented out aivOld loading from aiv since it should be done at initial RK-stage
428 !
429 ! Revision 1.6 2004/04/09 23:10:20 fnajjar
430 ! Added robust kernel for incell testing
431 !
432 ! Revision 1.5 2003/05/15 02:57:05 jblazek
433 ! Inlined index function.
434 !
435 ! Revision 1.4 2003/04/18 22:49:04 fnajjar
436 ! Bug fix to move IF statement of cellLocation inside ijk DO-loop
437 !
438 ! Revision 1.3 2003/01/16 20:43:27 f-najjar
439 ! Include iReg in calling sequence
440 !
441 ! Revision 1.2 2003/01/16 20:15:11 f-najjar
442 ! Removed iRegionGlobal
443 !
444 ! Revision 1.1 2002/10/25 14:15:43 f-najjar
445 ! Initial Import of Rocpart
446 !
447 !
448 !******************************************************************************
449 
450 
451 
452 
453 
454 
455 
Tfloat sum() const
Return the sum of all the pixel values in an image.
Definition: CImg.h:13022
j indices k indices k
Definition: Indexing.h:6
**********************************************************************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 kpcbeg
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
**********************************************************************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 jpcbeg
**********************************************************************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 ipcend
subroutine plag_incelltest(region, posPlag, indexSearch, ijkNR, ijkNRI, ijkNRJ, ijkNRK, indexNew, cellLocate)
subroutine rflo_getnodeoffset(region, iLev, iNodeOffset, ijNodeOffset)
subroutine plag_incelltestrobust(region, posPlag, indexCurr, indexNew, cellLocate)
**********************************************************************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 ipcbeg
blockLoc i
Definition: read.cpp:79
subroutine rflo_getcelloffset(region, iLev, iCellOffset, ijCellOffset)
j indices j
Definition: Indexing.h:6
**********************************************************************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 jpcend
subroutine plag_getcellindices(region, iReg)
subroutine deregisterfunction(global)
Definition: ModError.F90:469
subroutine rflo_getdimensphys(region, iLev, ipcbeg, ipcend, jpcbeg, jpcend, kpcbeg, kpcend)
RT a() const
Definition: Line_2.h:140