Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PLAG_InCellTest.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
26 !
27 ! Description: none.
28 !
29 ! Input: region = data of current region
30 ! posPlag = particle position vector
31 ! indexSearch = indices for cell search
32 ! ijkNR,ijkNRI,ijkNRJ,ijkNRK = cell indices for all faces.
33 !
34 ! Output: indexNew = new cell index
35 ! cellLocate = logical variable set to TRUE if test successful
36 !
37 ! Notes: reverse sign of face vectors to point inward for lbound=1,3,5
38 ! to check inside cell.
39 ! use scaled values for face normals to perform test.
40 !
41 !******************************************************************************
42 !
43 ! $Id: PLAG_InCellTest.F90,v 1.3 2008/12/06 08:44:33 mtcampbe Exp $
44 !
45 ! Copyright: (c) 2002 by the University of Illinois
46 !
47 !******************************************************************************
48 
49 SUBROUTINE plag_incelltest(region, posPlag, indexSearch, &
50  ijknr,ijknri,ijknrj,ijknrk, &
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  IMPLICIT NONE
60 
61 ! ... parameters
62  TYPE(t_region) :: region
63 
64  INTEGER , INTENT(IN) :: ijknr,ijknri,ijknrj,ijknrk
65  INTEGER, DIMENSION(4), INTENT(IN) :: indexsearch
66  INTEGER, DIMENSION(4), INTENT(OUT) :: indexnew
67 
68  LOGICAL, INTENT(OUT) :: celllocate
69 
70  REAL(RFREAL), DIMENSION(3), INTENT(IN) :: posplag
71 
72 ! ... loop variables
73  INTEGER :: lbound
74 
75 ! ... local variables
76  CHARACTER(CHRLEN) :: rcsidentstring
77 
78  INTEGER :: ilev, nbound
79 
80  REAL(RFREAL), PARAMETER :: epsdegentol = -1.0e-10_rfreal
81  REAL(RFREAL) :: dpface
82  REAL(RFREAL), DIMENSION(3) :: diffpos, facecentroid, sface
83 
84  REAL(RFREAL), POINTER, DIMENSION(:,:) :: psnormal
85  REAL(RFREAL), POINTER, DIMENSION(:,:,:) :: pfc
86 
87  TYPE(t_global), POINTER :: global
88 
89 !******************************************************************************
90 
91  rcsidentstring = '$RCSfile: PLAG_InCellTest.F90,v $ $Revision: 1.3 $'
92 
93  global => region%global
94 
95  CALL registerfunction( global, 'PLAG_inCellTest',&
96  'PLAG_InCellTest.F90' )
97 
98 ! Get dimensions --------------------------------------------------------------
99 
100  ilev = region%currLevel
101 
102  nbound = 6
103  celllocate = .false.
104 
105 ! Set pointers ----------------------------------------------------------------
106 
107  pfc => region%levels(ilev)%plag%fc
108 
109 ! Loop over all cell faces ----------------------------------------------------
110 
111  DO lbound = 1, nbound
112 
113  SELECT CASE (lbound)
114 
115 ! - i-face check --------------------------------------------------------------
116 
117  CASE(1)
118  sface(1:3) = -region%levels(ilev)%plag%si(xcoord:zcoord,ijknr)
119  facecentroid(1:3) = pfc(xcoord:zcoord,icoord,ijknr)
120 
121  CASE(2)
122  sface(1:3) = region%levels(ilev)%plag%si(xcoord:zcoord,ijknri)
123  facecentroid(1:3) = pfc(xcoord:zcoord,icoord,ijknri)
124 
125 ! - j-face check --------------------------------------------------------------
126 
127  CASE(3)
128  sface(1:3) = -region%levels(ilev)%plag%sj(xcoord:zcoord,ijknr)
129  facecentroid(1:3) = pfc(xcoord:zcoord,jcoord,ijknr)
130 
131  CASE(4)
132  sface(1:3) = region%levels(ilev)%plag%sj(xcoord:zcoord,ijknrj)
133  facecentroid(1:3) = pfc(xcoord:zcoord,jcoord,ijknrj)
134 
135 ! - k-face check -------------------------------------------------------------
136 
137  CASE(5)
138  sface(1:3) = -region%levels(ilev)%plag%sk(xcoord:zcoord,ijknr)
139  facecentroid(1:3) = pfc(xcoord:zcoord,kcoord,ijknr)
140 
141  CASE(6)
142  sface(1:3) = region%levels(ilev)%plag%sk(xcoord:zcoord,ijknrk)
143  facecentroid(1:3) = pfc(xcoord:zcoord,kcoord,ijknrk)
144 
145  END SELECT ! lbound
146 
147 ! - Compute position vector difference ----------------------------------------
148 ! and perform dot product with face vectors ---------------------------------
149 ! need to check (r_p - r_fc). n_fc > 0 --------------------------------------
150 
151  diffpos(1:3) = posplag(1:3)-facecentroid(1:3)
152  dpface = dot_product( sface,diffpos )
153 
154 ! - exit immediately if particle is outside the cell --------------------------
155 
156  IF ( dpface < epsdegentol ) goto 999
157 
158  ENDDO ! lbound
159 
160 ! Particle passed all face tests ----------------------------------------------
161 
162  celllocate = .true.
163  indexnew(1:4) = indexsearch(1:4)
164 
165 ! finalize --------------------------------------------------------------------
166 
167 999 CONTINUE
168  CALL deregisterfunction( global )
169 
170 END SUBROUTINE plag_incelltest
171 
172 !******************************************************************************
173 !
174 ! RCS Revision history:
175 !
176 ! $Log: PLAG_InCellTest.F90,v $
177 ! Revision 1.3 2008/12/06 08:44:33 mtcampbe
178 ! Updated license.
179 !
180 ! Revision 1.2 2008/11/19 22:17:46 mtcampbe
181 ! Added Illinois Open Source License/Copyright
182 !
183 ! Revision 1.1 2004/12/01 20:57:35 fnajjar
184 ! Initial revision after changing case
185 !
186 ! Revision 1.9 2004/03/23 15:54:21 fnajjar
187 ! Defined epsDegenTol for skewed grids allowing tolerance in particle search algorithm
188 !
189 ! Revision 1.8 2003/11/03 21:21:51 fnajjar
190 ! Changed definition of face vectors pointing to PLAG datastructure
191 !
192 ! Revision 1.7 2003/04/25 21:09:04 jferry
193 ! various streamlining, including removing scaling of normals by area
194 !
195 ! Revision 1.6 2003/04/18 19:21:30 fnajjar
196 ! Redefined dpFace to be a true dot product using FORTRAN90 intrinisic
197 !
198 ! Revision 1.5 2003/04/17 01:31:34 fnajjar
199 ! Scaled normals by area
200 !
201 ! Revision 1.4 2003/04/17 00:11:23 fnajjar
202 ! Included Proper INTENT for calling sequence
203 !
204 ! Revision 1.3 2003/04/16 22:33:42 fnajjar
205 ! Bug fix for selecting appropriate normals of face vectors
206 !
207 ! Revision 1.2 2003/01/16 20:15:11 f-najjar
208 ! Removed iRegionGlobal
209 !
210 ! Revision 1.1 2002/10/25 14:16:31 f-najjar
211 ! Initial Import of Rocpart
212 !
213 !
214 !******************************************************************************
215 
216 
217 
218 
219 
220 
221 
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
subroutine plag_incelltest(region, posPlag, indexSearch, ijkNR, ijkNRI, ijkNRJ, ijkNRK, indexNew, cellLocate)
long double dot_product(pnt vec1, pnt vec2)
subroutine deregisterfunction(global)
Definition: ModError.F90:469