Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PLAG_InCellTestRobust.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: Perform in cell test based on robust search algorithm
26 !
27 ! Description: none.
28 !
29 ! Input:
30 ! region = data of current region
31 ! posPlag = particle position vector
32 ! indexCurr = indices for current cell
33 !
34 ! Output: indexNew = new cell index
35 ! cellLocate = logical variable set to TRUE if test successful
36 !
37 ! Notes:
38 ! 1. compute distance between posPlag and face centroids
39 ! for dummy cells and take minimum distance
40 ! 2. if such distance does not exist, search fails
41 !
42 !******************************************************************************
43 !
44 ! $Id: PLAG_InCellTestRobust.F90,v 1.3 2008/12/06 08:44:33 mtcampbe Exp $
45 !
46 ! Copyright: (c) 2004 by the University of Illinois
47 !
48 !******************************************************************************
49 
50 SUBROUTINE plag_incelltestrobust( region, posPlag, indexCurr, &
51  indexnew,celllocate )
52 
53  USE moddatatypes
54  USE moddatastruct, ONLY : t_region
55  USE modglobal, ONLY : t_global
56  USE modpartlag, ONLY : t_plag
57  USE moderror
58  USE modparameters
59 
60  USE modinterfaces, ONLY : rflo_getcelloffset, &
64 
65  IMPLICIT NONE
66 
67 #include "Indexing.h"
68 
69 ! *****************************************************************************
70 ! Declarations
71 ! *****************************************************************************
72 
73 ! =============================================================================
74 ! Arguments
75 ! =============================================================================
76 
77  TYPE(t_region) :: region
78 
79  INTEGER, DIMENSION(4), INTENT(IN ) :: indexcurr
80  INTEGER, DIMENSION(4), INTENT(OUT) :: indexnew
81 
82  LOGICAL, INTENT(OUT) :: celllocate
83 
84  REAL(RFREAL), DIMENSION(3), INTENT(IN ) :: posplag
85 
86 ! =============================================================================
87 ! Locals
88 ! =============================================================================
89 
90  CHARACTER(CHRLEN) :: rcsidentstring
91 
92  INTEGER :: i,icoff,ijcoff,ijkc,inoff,ijnoff,ijknr,ijknri,ijknrj,ijknrk, &
94  k,kpcbeg,kpcend,kpnbeg,kpnend,nsearch
95  INTEGER, DIMENSION(4) :: indexsearch
96 
97  REAL(RFREAL) :: distpos,distposmin
98  REAL(RFREAL), DIMENSION(3) :: facecentroid
99 
100  REAL(RFREAL), POINTER, DIMENSION(:,:,:) :: pfc
101 
102  TYPE(t_global), POINTER :: global
103 
104 ! *****************************************************************************
105 ! Start
106 ! *****************************************************************************
107 
108  rcsidentstring = '$RCSfile: PLAG_InCellTestRobust.F90,v $ $Revision: 1.3 $'
109 
110  global => region%global
111 
112  CALL registerfunction( global, 'PLAG_InCellTestRobust',&
113  'PLAG_InCellTestRobust.F90' )
114 
115 ! *****************************************************************************
116 ! Set variables and pointers
117 ! *****************************************************************************
118 
119  celllocate = .false.
120  distposmin = huge(1.0_rfreal)
121  nsearch = 0
122  indexnew(1:4) = crazy_value_int
123 
124  ilev = region%currLevel
125 
126  pfc => region%levels(ilev)%plag%fc
127 
128 ! *****************************************************************************
129 ! Get extent of physical cells and nodes
130 ! *****************************************************************************
131 
132  CALL rflo_getdimensphys( region,ilev,ipcbeg,ipcend, &
133  jpcbeg,jpcend,kpcbeg,kpcend )
134  CALL rflo_getcelloffset( region,ilev,icoff,ijcoff )
135  CALL rflo_getnodeoffset( region,ilev,inoff,ijnoff )
136 
137  CALL rflo_getdimensphysnodes( region,ilev,ipnbeg,ipnend, &
138  jpnbeg,jpnend,kpnbeg,kpnend )
139 
140 ! *****************************************************************************
141 ! Load indices for nodes and cells
142 ! *****************************************************************************
143 
144  i = indexcurr(2)
145  j = indexcurr(3)
146  k = indexcurr(4)
147 
148  ijknr = indijk(i, j ,k ,inoff,ijnoff)
149  ijknri = indijk(i+1,j ,k ,inoff,ijnoff)
150  ijknrj = indijk(i,j+1 ,k ,inoff,ijnoff)
151  ijknrk = indijk(i ,j ,k+1,inoff,ijnoff)
152 
153  ijkc = indijk(i,j,k,icoff,ijcoff)
154 
155 ! *****************************************************************************
156 ! Perform search for indices of dummy cells
157 ! *****************************************************************************
158 
159  IF ( i-1 < ipcbeg ) THEN
160  facecentroid(1:3) = pfc(xcoord:zcoord,icoord,ijknr)
161  distpos = sum( (facecentroid(1:3)-posplag(1:3))**2 )
162 
163  IF ( distpos < distposmin ) THEN
164  distposmin = distpos
165  ijkc = indijk(i-1,j ,k ,icoff,ijcoff)
166  indexsearch(1:4) = (/ijkc,i-1,j,k/)
167  nsearch = nsearch+1
168  ENDIF ! distPos
169 
170  ENDIF ! i-1
171 
172  IF ( i+1 > ipcend ) THEN
173  facecentroid(1:3) = pfc(xcoord:zcoord,icoord,ijknri)
174  distpos = sum( (facecentroid(1:3)-posplag(1:3))**2 )
175 
176  IF ( distpos < distposmin ) THEN
177  distposmin = distpos
178  ijkc = indijk(i+1,j ,k ,icoff,ijcoff)
179  indexsearch(1:4) = (/ijkc,i+1,j,k/)
180  nsearch = nsearch+1
181  ENDIF ! distPos
182 
183  ENDIF ! i+1
184 
185  IF ( j-1 < jpcbeg ) THEN
186  facecentroid(1:3) = pfc(xcoord:zcoord,jcoord,ijknr)
187  distpos = sum( (facecentroid(1:3)-posplag(1:3))**2 )
188 
189  IF ( distpos < distposmin ) THEN
190  distposmin = distpos
191  ijkc = indijk(i ,j-1,k ,icoff,ijcoff)
192  indexsearch(1:4) = (/ijkc,i,j-1,k/)
193  nsearch = nsearch+1
194  ENDIF ! distPos
195 
196  ENDIF ! j-1
197 
198  IF ( j+1 > jpcend ) THEN
199  facecentroid(1:3) = pfc(xcoord:zcoord,jcoord,ijknrj)
200  distpos = sum( (facecentroid(1:3)-posplag(1:3))**2 )
201 
202  IF ( distpos < distposmin ) THEN
203  distposmin = distpos
204  ijkc = indijk(i ,j+1,k ,icoff,ijcoff)
205  indexsearch(1:4) = (/ijkc,i,j+1,k/)
206  nsearch = nsearch+1
207  ENDIF ! distPos
208 
209  ENDIF ! j+1
210 
211  IF ( k-1 < kpcbeg ) THEN
212  facecentroid(1:3) = pfc(xcoord:zcoord,kcoord,ijknr)
213  distpos = sum( (facecentroid(1:3)-posplag(1:3))**2 )
214 
215  IF ( distpos < distposmin ) THEN
216  distposmin = distpos
217  ijkc = indijk(i ,j ,k-1,icoff,ijcoff)
218  indexsearch(1:4) = (/ijkc,i,j,k-1/)
219  nsearch = nsearch+1
220  ENDIF ! distPos
221 
222  ENDIF ! k-1
223 
224  IF ( k+1 > kpcend ) THEN
225  facecentroid(1:3) = pfc(xcoord:zcoord,kcoord,ijknrk)
226  distpos = sum( (facecentroid(1:3)-posplag(1:3))**2 )
227 
228  IF ( distpos < distposmin ) THEN
229  distposmin = distpos
230  ijkc = indijk(i ,j ,k+1,icoff,ijcoff)
231  indexsearch(1:4) = (/ijkc,i,j,k+1/)
232  nsearch = nsearch+1
233  ENDIF ! distPos
234 
235  ENDIF ! k+1
236 
237  IF ( nsearch /= 0 ) THEN
238  celllocate = .true.
239  indexnew(1:4) = indexsearch(1:4)
240  ENDIF ! nSearch
241 
242 ! *****************************************************************************
243 ! End
244 ! *****************************************************************************
245 
246 999 CONTINUE
247  CALL deregisterfunction( global )
248 
249 END SUBROUTINE plag_incelltestrobust
250 
251 !******************************************************************************
252 !
253 ! RCS Revision history:
254 !
255 ! $Log: PLAG_InCellTestRobust.F90,v $
256 ! Revision 1.3 2008/12/06 08:44:33 mtcampbe
257 ! Updated license.
258 !
259 ! Revision 1.2 2008/11/19 22:17:46 mtcampbe
260 ! Added Illinois Open Source License/Copyright
261 !
262 ! Revision 1.1 2004/04/09 23:17:19 fnajjar
263 ! Initial Import for robust cell search algorithm
264 !
265 !******************************************************************************
266 
267 
268 
269 
270 
271 
272 
Tfloat sum() const
Return the sum of all the pixel values in an image.
Definition: CImg.h:13022
**********************************************************************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 jpnbeg
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
**********************************************************************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 kpnbeg
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
**********************************************************************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 jpnend
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
**********************************************************************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 ipnbeg
subroutine rflo_getcelloffset(region, iLev, iCellOffset, ijCellOffset)
subroutine rflo_getdimensphysnodes(region, iLev, ipnbeg, ipnend, jpnbeg, jpnend, kpnbeg, kpnend)
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 deregisterfunction(global)
Definition: ModError.F90:469
**********************************************************************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 ipnend
subroutine rflo_getdimensphys(region, iLev, ipcbeg, ipcend, jpcbeg, jpcend, kpcbeg, kpcend)