Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PLAG_RFLU_InitSolSerial_1D.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 for 1d cases.
26 !
27 ! Description: None.
28 !
29 ! Input:
30 ! pRegion Pointer to serial region
31 !
32 ! Output: None.
33 !
34 ! Notes:
35 ! 1. Assume grid spacing is constant!
36 ! 2. Assume cells are numbered in ascending order in direction of increasing
37 ! x-coordinate.
38 !
39 ! ******************************************************************************
40 !
41 ! $Id: PLAG_RFLU_InitSolSerial_1D.F90,v 1.4 2008/12/06 08:44:35 mtcampbe Exp $
42 !
43 ! Copyright: (c) 2007 by the University of Illinois
44 !
45 ! ******************************************************************************
46 
47 SUBROUTINE plag_rflu_initsolserial_1d(pRegion)
48 
49  USE moddatatypes
50  USE moderror
51  USE moddatastruct, ONLY: t_region
52  USE modglobal, ONLY: t_global
53  USE modgrid, ONLY: t_grid
54  USE modpartlag, ONLY: t_plag
55  USE modparameters
56 
61 
63 
64  IMPLICIT NONE
65 
66 ! ******************************************************************************
67 ! Declarations and definitions
68 ! ******************************************************************************
69 
70 ! ==============================================================================
71 ! Arguments
72 ! ==============================================================================
73 
74  TYPE(t_region), POINTER :: pregion
75 
76 ! ==============================================================================
77 ! Locals
78 ! ==============================================================================
79 
80  LOGICAL :: foundflag
81  CHARACTER(CHRLEN) :: errorstring,rcsidentstring
82  INTEGER :: dicg,dicgdel,dicgmax,dicgmin,errorflag,icg,icg2,ipcl
83  REAL(RFREAL) :: idx,xmax,xmin,xpcl,ypcl,zpcl
84  TYPE(t_global), POINTER :: global
85  TYPE(t_grid), POINTER :: pgrid
86  TYPE(t_plag), POINTER :: pplag
87 
88 ! ******************************************************************************
89 ! Start
90 ! ******************************************************************************
91 
92  rcsidentstring = &
93  '$RCSfile: PLAG_RFLU_InitSolSerial_1D.F90,v $ $Revision: 1.4 $'
94 
95  global => pregion%global
96 
97  CALL registerfunction(global,'PLAG_RFLU_InitSolSerial_1D', &
98  'PLAG_RFLU_InitSolSerial_1D.F90')
99 
100  IF ( global%verbLevel > verbose_none ) THEN
101  WRITE(stdout,'(A,1X,A)') solver_name,'Initializing particle solution '// &
102  'for serial region in 1d...'
103  WRITE(stdout,'(A,3X,A,1X,I5.5)') solver_name,'Global region:', &
104  pregion%iRegionGlobal
105  END IF ! global%verbLevel
106 
107 ! ******************************************************************************
108 ! Set pointers and values
109 ! ******************************************************************************
110 
111  pgrid => pregion%grid
112  pplag => pregion%plag
113 
114 ! ******************************************************************************
115 ! Compute grid spacing
116 ! ******************************************************************************
117 
118  xmin = minval(pgrid%xyz(xcoord,1:pgrid%nVert))
119  xmax = maxval(pgrid%xyz(xcoord,1:pgrid%nVert))
120  idx = pgrid%nCells/(xmax-xmin)
121 
122 ! ******************************************************************************
123 ! Build cell-to-face list (needed for in-cell test)
124 ! ******************************************************************************
125 
126  CALL rflu_createcell2facelist(pregion)
127  CALL rflu_buildcell2facelist(pregion)
128 
129 ! ******************************************************************************
130 ! Loop over particles in serial region
131 ! ******************************************************************************
132 
133  DO ipcl = 1,pplag%nPcls
134 
135 ! ==============================================================================
136 ! Get particle location and determine cell which should contain this particle
137 ! ==============================================================================
138 
139  xpcl = pplag%cv(cv_plag_xpos,ipcl)
140  ypcl = pplag%cv(cv_plag_ypos,ipcl)
141  zpcl = pplag%cv(cv_plag_zpos,ipcl)
142 
143  icg = int(1.0_rfreal + idx*(xpcl-xmin))
144 
145 ! ==============================================================================
146 ! Carry out in-cell test
147 ! ==============================================================================
148 
149  IF ( rflu_ict_testincell(pregion,xpcl,ypcl,zpcl,icg) .EQV. .true. ) THEN
150  pplag%aiv(aiv_plag_icells,ipcl) = icg
151  pplag%aiv(aiv_plag_regini,ipcl) = pregion%iRegionGlobal
152 
153 ! ==============================================================================
154 ! If the in-cell test failed, then the only reason should be that particle is
155 ! located right on a face and may be regarded as being in adjacent cell due
156 ! to machine precision issues, so check those cells, too.
157 ! ==============================================================================
158 
159  ELSE
160  IF ( icg == 1 ) THEN
161  dicgmin = 1
162  dicgmax = 1
163  dicgdel = 1
164  ELSE IF ( icg == pgrid%nCells ) THEN
165  dicgmin = -1
166  dicgmax = -1
167  dicgdel = 1
168  ELSE
169  dicgmin = -1
170  dicgmax = 1
171  dicgdel = 2
172  END IF ! icg
173 
174  foundflag = .false.
175 
176  DO dicg = dicgmin,dicgmax,dicgdel
177  icg2 = icg + dicg
178 
179  IF ( rflu_ict_testincell(pregion,xpcl,ypcl,zpcl,icg2) .EQV. .true. ) THEN
180  pplag%aiv(aiv_plag_icells,ipcl) = icg2
181  pplag%aiv(aiv_plag_regini,ipcl) = pregion%iRegionGlobal
182 
183  foundflag = .true.
184  END IF ! RFLU_ICT_TestInCell
185  END DO ! dIcg
186 
187 ! ------------------------------------------------------------------------------
188 ! If that check fails, too, then there must be an error
189 ! ------------------------------------------------------------------------------
190 
191  IF ( foundflag .EQV. .false. ) THEN
192  WRITE(errorstring,'(I6)') ipcl
193  CALL errorstop(global,err_plag_pcl_not_found,__line__,trim(errorstring))
194  END IF ! foundFlag
195  END IF ! RFLU_ICT_TestInCell
196  END DO ! iPcl
197 
198 ! ******************************************************************************
199 ! Destroy cell-to-face list
200 ! ******************************************************************************
201 
202  CALL rflu_destroycell2facelist(pregion)
203 
204 ! ******************************************************************************
205 ! End
206 ! ******************************************************************************
207 
208  IF ( global%verbLevel > verbose_none ) THEN
209  WRITE(stdout,'(A,1X,A)') solver_name, &
210  'Initializing particle solution for serial region in 1d done.'
211  END IF ! global%verbLevel
212 
213  CALL deregisterfunction(global)
214 
215 END SUBROUTINE plag_rflu_initsolserial_1d
216 
217 ! ******************************************************************************
218 !
219 ! RCS Revision history:
220 !
221 ! $Log: PLAG_RFLU_InitSolSerial_1D.F90,v $
222 ! Revision 1.4 2008/12/06 08:44:35 mtcampbe
223 ! Updated license.
224 !
225 ! Revision 1.3 2008/11/19 22:17:47 mtcampbe
226 ! Added Illinois Open Source License/Copyright
227 !
228 ! Revision 1.2 2007/03/27 00:22:01 haselbac
229 ! Fixed indentation
230 !
231 ! Revision 1.1 2007/03/15 21:58:29 haselbac
232 ! Initial revision
233 !
234 ! ******************************************************************************
235 
236 
237 
238 
239 
240 
241 
subroutine, public rflu_buildcell2facelist(pRegion)
subroutine, public rflu_destroycell2facelist(pRegion)
double xmax() const
subroutine, public rflu_createcell2facelist(pRegion)
double xmin() const
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
LOGICAL function, public rflu_ict_testincell(pRegion, xLoc, yLoc, zLoc, icg)
subroutine errorstop(global, errorCode, errorLine, addMessage)
Definition: ModError.F90:483
subroutine deregisterfunction(global)
Definition: ModError.F90:469
subroutine plag_rflu_initsolserial_1d(pRegion)