Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PLAG_RFLU_InitSolSerial_3D.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 serial region in 3d.
26 !
27 ! Description: None.
28 !
29 ! Input:
30 ! pRegion Pointer to serial region
31 !
32 ! Output: None.
33 !
34 ! Notes: None.
35 !
36 ! ******************************************************************************
37 !
38 ! $Id: PLAG_RFLU_InitSolSerial_3D.F90,v 1.3 2008/12/06 08:44:35 mtcampbe Exp $
39 !
40 ! Copyright: (c) 2005-2007 by the University of Illinois
41 !
42 ! ******************************************************************************
43 
44 SUBROUTINE plag_rflu_initsolserial_3d(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 modpartlag, ONLY: t_plag
52  USE modparameters
53 
58  USE rflu_modoctree
59 
61 
62  IMPLICIT NONE
63 
64 ! ******************************************************************************
65 ! Declarations and definitions
66 ! ******************************************************************************
67 
68 ! ==============================================================================
69 ! Arguments
70 ! ==============================================================================
71 
72  TYPE(t_region), POINTER :: pregion
73 
74 ! ==============================================================================
75 ! Locals
76 ! ==============================================================================
77 
78  CHARACTER(CHRLEN) :: rcsidentstring
79  INTEGER :: ccsize,errorflag,icg,icl,ipcl,ivar
80  INTEGER, DIMENSION(:), ALLOCATABLE :: cc
81  REAL(RFREAL) :: delfrac,xdel,xmax,xmin,xpcl,ydel,ymax,ymin,ypcl,zdel,zmax, &
82  zmin,zpcl
83  TYPE(t_global), POINTER :: global
84  TYPE(t_grid), POINTER :: pgrid
85  TYPE(t_plag), POINTER :: pplag
86 
87 ! ******************************************************************************
88 ! Start
89 ! ******************************************************************************
90 
91  rcsidentstring = &
92  '$RCSfile: PLAG_RFLU_InitSolSerial_3D.F90,v $ $Revision: 1.3 $'
93 
94  global => pregion%global
95 
96  CALL registerfunction(global,'PLAG_RFLU_InitSolSerial_3D', &
97  'PLAG_RFLU_InitSolSerial_3D.F90')
98 
99  IF ( global%verbLevel > verbose_none ) THEN
100  WRITE(stdout,'(A,1X,A)') solver_name,'Initializing particle solution '// &
101  'for serial region in 3d...'
102  WRITE(stdout,'(A,3X,A,1X,I5.5)') solver_name,'Global region:', &
103  pregion%iRegionGlobal
104  END IF ! global%verbLevel
105 
106 ! ******************************************************************************
107 ! Set pointers and values
108 ! ******************************************************************************
109 
110  pgrid => pregion%grid
111 
112  pplag => pregion%plag
113 
114  ccsize = min(100,pgrid%nCells) ! Must be larger than unity
115 
116  delfrac = 0.01_rfreal
117 
118 ! ******************************************************************************
119 ! Get (slightly enlarged) grid bounding box
120 ! ******************************************************************************
121 
122  xmin = minval(pgrid%xyz(xcoord,1:pgrid%nVert))
123  xmax = maxval(pgrid%xyz(xcoord,1:pgrid%nVert))
124  ymin = minval(pgrid%xyz(ycoord,1:pgrid%nVert))
125  ymax = maxval(pgrid%xyz(ycoord,1:pgrid%nVert))
126  zmin = minval(pgrid%xyz(zcoord,1:pgrid%nVert))
127  zmax = maxval(pgrid%xyz(zcoord,1:pgrid%nVert))
128 
129  xdel = xmax - xmin
130  ydel = ymax - ymin
131  zdel = zmax - zmin
132 
133  xmin = xmin - delfrac*xdel
134  xmax = xmax + delfrac*xdel
135  ymin = ymin - delfrac*ydel
136  ymax = ymax + delfrac*ydel
137  zmin = zmin - delfrac*zdel
138  zmax = zmax + delfrac*zdel
139 
140 ! ******************************************************************************
141 ! Build Octree and cell-to-face list
142 ! ******************************************************************************
143 
144  CALL rflu_createoctree(global,pgrid%nCells)
145 
146  CALL rflu_buildoctree(pgrid%cofg(xcoord,1:pgrid%nCells), &
147  pgrid%cofg(ycoord,1:pgrid%nCells), &
148  pgrid%cofg(zcoord,1:pgrid%nCells), &
150 
151  ALLOCATE(cc(ccsize),stat=errorflag)
152  global%error = errorflag
153  IF ( global%error /= err_none ) THEN
154  CALL errorstop(global,err_allocate,__line__,'cc')
155  END IF ! global%error
156 
157  CALL rflu_createcell2facelist(pregion)
158  CALL rflu_buildcell2facelist(pregion)
159 
160 ! ******************************************************************************
161 ! Loop over particles in serial region
162 ! ******************************************************************************
163 
164  DO ipcl = 1,pplag%nPcls
165 
166 ! ==============================================================================
167 ! Get particle location and get nearest cells from Octree
168 ! ==============================================================================
169 
170  xpcl = pplag%cv(cv_plag_xpos,ipcl)
171  ypcl = pplag%cv(cv_plag_ypos,ipcl)
172  zpcl = pplag%cv(cv_plag_zpos,ipcl)
173 
174  CALL rflu_queryoctree(xpcl,ypcl,zpcl,ccsize,cc)
175 
176 ! ==============================================================================
177 ! Perform in-cell test on cells
178 ! ==============================================================================
179 
180  cellloop: DO icl = 1,ccsize
181  icg = cc(icl)
182 
183  IF ( rflu_ict_testincell(pregion,xpcl,ypcl,zpcl,icg) .EQV. .true. ) THEN
184  pplag%aiv(aiv_plag_icells,ipcl) = icg
185  pplag%aiv(aiv_plag_regini,ipcl) = pregion%iRegionGlobal
186 
187  EXIT cellloop
188  END IF ! RFLU_ICT_TestInCell
189  END DO cellloop
190  END DO ! iPclSerial
191 
192 ! ******************************************************************************
193 ! Destroy Octree and cell-to-face list
194 ! ******************************************************************************
195 
196  CALL rflu_destroyoctree(global)
197 
198  DEALLOCATE(cc,stat=errorflag)
199  global%error = errorflag
200  IF ( global%error /= err_none ) THEN
201  CALL errorstop(global,err_deallocate,__line__,'cc')
202  END IF ! global%error
203 
204  CALL rflu_destroycell2facelist(pregion)
205 
206 ! ******************************************************************************
207 ! End
208 ! ******************************************************************************
209 
210  IF ( global%verbLevel > verbose_none ) THEN
211  WRITE(stdout,'(A,1X,A)') solver_name, &
212  'Initializing particle solution for serial region in 3d done.'
213  END IF ! global%verbLevel
214 
215  CALL deregisterfunction(global)
216 
217 END SUBROUTINE plag_rflu_initsolserial_3d
218 
219 ! ******************************************************************************
220 !
221 ! RCS Revision history:
222 !
223 ! $Log: PLAG_RFLU_InitSolSerial_3D.F90,v $
224 ! Revision 1.3 2008/12/06 08:44:35 mtcampbe
225 ! Updated license.
226 !
227 ! Revision 1.2 2008/11/19 22:17:47 mtcampbe
228 ! Added Illinois Open Source License/Copyright
229 !
230 ! Revision 1.1 2007/03/15 21:58:29 haselbac
231 ! Initial revision
232 !
233 ! Revision 1.4 2007/03/09 20:32:37 fnajjar
234 ! Fixed incorrect registration name
235 !
236 ! Revision 1.3 2006/05/22 15:33:09 fnajjar
237 ! Fixed bug for uninitialized delFrac
238 !
239 ! Revision 1.2 2006/05/05 18:41:10 haselbac
240 ! Fix from last ci
241 !
242 ! Revision 1.1 2006/05/05 17:27:57 haselbac
243 ! Initial revision
244 !
245 ! ******************************************************************************
246 
247 
248 
249 
250 
251 
252 
subroutine, public rflu_buildcell2facelist(pRegion)
subroutine, public rflu_destroycell2facelist(pRegion)
double ymin() const
double xmax() const
subroutine, public rflu_queryoctree(XPT, YPT, ZPT, NUMP, NEIGHP)
subroutine, public rflu_createcell2facelist(pRegion)
double xmin() const
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
double zmin() const
subroutine, public rflu_buildoctree(XI, YI, ZI, XLOW, XUPP, YLOW, YUPP, ZLOW, ZUPP)
subroutine, public rflu_destroyoctree(global)
double zmax() const
double ymax() const
LOGICAL function, public rflu_ict_testincell(pRegion, xLoc, yLoc, zLoc, icg)
Vector_n min(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:346
subroutine plag_rflu_initsolserial_3d(pRegion)
subroutine errorstop(global, errorCode, errorLine, addMessage)
Definition: ModError.F90:483
subroutine deregisterfunction(global)
Definition: ModError.F90:469
subroutine, public rflu_createoctree(global, nPoints)