Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PLAG_UpdateDataStruct.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: Update the particle datastructure by removing particles flagged for
26 ! deletion.
27 !
28 ! Description: None.
29 !
30 ! Input:
31 ! pRegion Pointer to region
32 !
33 ! Output: None.
34 !
35 ! Notes: None.
36 !
37 ! ******************************************************************************
38 !
39 ! $Id: PLAG_UpdateDataStruct.F90,v 1.12 2008/12/06 08:44:36 mtcampbe Exp $
40 !
41 ! Copyright: (c) 2004 by the University of Illinois
42 !
43 ! ******************************************************************************
44 
45 #ifdef RFLO
46 SUBROUTINE plag_updatedatastruct(pRegion,iReg)
47 #endif
48 
49 #ifdef RFLU
50 SUBROUTINE plag_updatedatastruct(pRegion)
51 #endif
52 
53  USE moddatatypes
54  USE modparameters
55  USE moderror
56  USE modglobal, ONLY: t_global
57  USE moddatastruct, ONLY: t_region
58  USE modpartlag, ONLY: t_plag
59  USE modmpi
60 
62 
63  IMPLICIT NONE
64 
65 ! ******************************************************************************
66 ! Declarations and definitions
67 ! ******************************************************************************
68 
69 ! ==============================================================================
70 ! Arguments
71 ! ==============================================================================
72 
73 #ifdef RFLO
74  TYPE(t_region) :: pregion
75  INTEGER, INTENT(IN) :: ireg
76 #endif
77 
78 #ifdef RFLU
79  TYPE(t_region), POINTER :: pregion
80 #endif
81 
82 ! ==============================================================================
83 ! Locals
84 ! =============================================================================
85 
86  CHARACTER(CHRLEN) :: rcsidentstring
87 
88 #ifdef RFLO
89  INTEGER :: ilev
90 #endif
91 #ifdef RFLU
92  INTEGER :: ireg
93 #endif
94 
95  INTEGER :: iaiv,iarv,icv,idv,igap,ipcl,itv,naiv,narv,ncv,ndv,&
96  npclsbeg,npclsend,npclsprev,ntv
97  INTEGER, DIMENSION(:,:), POINTER :: paiv,paivold
98  REAL(RFREAL), DIMENSION(:,:), POINTER :: parv,parvold,pcv,pcvold,pdv,&
99  prhs,prhssum,ptv
100  TYPE(t_global), POINTER :: global
101  TYPE(t_plag), POINTER :: pplag
102 
103 ! ******************************************************************************
104 ! Start
105 ! ******************************************************************************
106 
107  rcsidentstring = '$RCSfile: PLAG_UpdateDataStruct.F90,v $ $Revision: 1.12 $'
108 
109  global => pregion%global
110 
111  CALL registerfunction(global,'PLAG_UpdateDataStruct',&
112  'PLAG_UpdateDataStruct.F90')
113 
114 ! ******************************************************************************
115 ! Set variables and pointers
116 ! ******************************************************************************
117 
118 #ifdef RFLO
119  ilev = pregion%currLevel
120  pplag => pregion%levels(ilev)%plag
121 #endif
122 
123 #ifdef RFLU
124  pplag => pregion%plag
125 #endif
126 
127  paiv => pplag%aiv
128  parv => pplag%arv
129  pcv => pplag%cv
130  pdv => pplag%dv
131  prhs => pplag%rhs
132  prhssum => pplag%rhsSum
133  ptv => pplag%tv
134 
135  paivold => pplag%aivOld
136  parvold => pplag%arvOld
137  pcvold => pplag%cvOld
138 
139 ! ******************************************************************************
140 ! Get dimensions
141 ! ******************************************************************************
142 
143  naiv = pplag%nAiv
144  narv = pplag%nArv
145  ncv = pplag%nCv
146  ndv = pplag%nDv
147  ntv = pplag%nTv
148 
149 #ifdef RFLU
150  ireg = pregion%iRegionGlobal
151 #endif
152 
153 ! ******************************************************************************
154 ! Loop over particles
155 ! ******************************************************************************
156 
157  igap = 1
158  ipcl = pplag%nPcls
159 
160  searchloop: DO
161 
162 ! ==============================================================================
163 ! Copy data if DELETE status in iGap and KEEP status in iPcl
164 ! ==============================================================================
165 
166  IF ( ( paiv(aiv_plag_status,igap) /= plag_status_keep .AND. &
167  paiv(aiv_plag_status,igap) /= plag_status_comm ) .AND. &
168  ( paiv(aiv_plag_status,ipcl) == plag_status_keep .OR. &
169  paiv(aiv_plag_status,ipcl) == plag_status_comm ) ) THEN
170 
171 ! ------------------------------------------------------------------------------
172 ! Copy data and set status to keep
173 ! ------------------------------------------------------------------------------
174 
175  DO iaiv = 1, naiv
176  paiv(iaiv,igap) = paiv(iaiv,ipcl)
177  paivold(iaiv,igap) = paivold(iaiv,ipcl)
178  END DO ! iAiv
179 
180  DO iarv = 1, narv
181  parv(iarv,igap) = parv(iarv,ipcl)
182  parvold(iarv,igap) = parvold(iarv,ipcl)
183  END DO ! iArv
184 
185  DO icv = 1, ncv
186  pcv(icv,igap) = pcv(icv,ipcl)
187  pcvold( icv,igap) = pcvold(icv,ipcl)
188  prhs(icv,igap) = prhs(icv,ipcl)
189  prhssum(icv,igap) = prhssum(icv,ipcl)
190  END DO ! iCv
191 
192  DO idv = 1, ndv
193  pdv(idv,igap) = pdv(idv,ipcl)
194  END DO ! iDv
195 
196  DO itv = 1, ntv
197  ptv(itv,igap) = ptv(itv,ipcl)
198  END DO ! iDv
199 
200  paiv(aiv_plag_status,igap) = paiv(aiv_plag_status,ipcl)
201 
202 ! ------------------------------------------------------------------------------
203 ! Increment/decrement counters
204 ! ------------------------------------------------------------------------------
205 
206  igap = igap + 1
207  ipcl = ipcl - 1
208 
209 ! ==============================================================================
210 ! Update counters if KEEP or COMM status in iGap and DELETE status in iPcl
211 ! ==============================================================================
212 
213  ELSE
214  IF ( paiv(aiv_plag_status,igap) == plag_status_keep .OR. &
215  paiv(aiv_plag_status,igap) == plag_status_comm ) THEN
216  igap = igap + 1
217  END IF ! pAiv
218 
219  IF ( paiv(aiv_plag_status,ipcl) == plag_status_delete ) THEN
220  ipcl = ipcl - 1
221  END IF ! pAiv
222  END IF ! pAiv(AIV_PLAG_STATUS,iGap)
223 
224 ! ==============================================================================
225 ! Exit update
226 ! ==============================================================================
227 
228  IF ( igap > ipcl ) THEN
229  EXIT searchloop
230  END IF ! iGap
231  END DO searchloop
232 
233 ! ******************************************************************************
234 ! Update number of particles
235 ! ******************************************************************************
236 
237  npclsprev = pplag%nPcls
238  pplag%nPcls = ipcl
239 
240  npclsbeg = max(1,pplag%nPcls+1)
241  npclsend = npclsprev
242 
243 ! ******************************************************************************
244 ! Initialize datastructure to crazy for particles between nPclsBeg and nPclsEnd
245 ! ******************************************************************************
246 
247  DO ipcl = npclsbeg, npclsend
248  DO iaiv = 1, naiv
249  paiv(iaiv,ipcl) = crazy_value_int
250  paivold(iaiv,ipcl) = crazy_value_int
251  END DO ! iAiv
252 
253  DO iarv = 1, narv
254  parv(iarv,ipcl) = REAL(crazy_value_int,kind=rfreal)
255  parvold(iarv,ipcl) = REAL(crazy_value_int,kind=rfreal)
256  END DO ! iArv
257 
258  DO icv = 1, ncv
259  pcv(icv,ipcl) = REAL(crazy_value_int,kind=rfreal)
260  pcvold(icv,ipcl) = REAL(crazy_value_int,kind=rfreal)
261  prhs(icv,ipcl) = REAL(crazy_value_int,kind=rfreal)
262  prhssum(icv,ipcl) = REAL(crazy_value_int,kind=rfreal)
263  END DO ! iCv
264 
265  DO idv = 1, ndv
266  pdv(idv,ipcl) = REAL(crazy_value_int,kind=rfreal)
267  END DO ! iDv
268 
269  DO itv = 1, ntv
270  ptv(itv,ipcl) = REAL(crazy_value_int,kind=rfreal)
271  END DO ! iTv
272  END DO ! iPcl
273 
274 ! ******************************************************************************
275 ! End
276 ! ******************************************************************************
277 
278  CALL deregisterfunction(global)
279 
280 END SUBROUTINE plag_updatedatastruct
281 
282 ! ******************************************************************************
283 !
284 ! RCS Revision history:
285 !
286 ! $Log: PLAG_UpdateDataStruct.F90,v $
287 ! Revision 1.12 2008/12/06 08:44:36 mtcampbe
288 ! Updated license.
289 !
290 ! Revision 1.11 2008/11/19 22:17:48 mtcampbe
291 ! Added Illinois Open Source License/Copyright
292 !
293 ! Revision 1.10 2006/04/07 15:19:24 haselbac
294 ! Removed tabs
295 !
296 ! Revision 1.9 2005/12/30 16:29:59 fnajjar
297 ! Added dv and tv in data reshuffle for consistency in GatherSurfStats
298 !
299 ! Revision 1.8 2005/05/18 22:22:33 fnajjar
300 ! Adapted to parallelization within RFLU
301 !
302 ! Revision 1.7 2004/07/01 23:05:11 fnajjar
303 ! Added aivOld to data shuffle kernel to inline with particle trajectory motion
304 !
305 ! Revision 1.6 2004/05/22 00:15:16 fnajjar
306 ! Bug fixes for proper definition of nPclsBeg and nPclsEnd
307 !
308 ! Revision 1.5 2004/05/05 21:47:44 fnajjar
309 ! Bug Fix: updating cvOld and arvOld in datastructure
310 !
311 ! Revision 1.4 2004/05/05 21:20:38 fnajjar
312 ! Clean up and simplification
313 !
314 ! Revision 1.3 2004/04/09 22:58:59 fnajjar
315 ! Made routine RFLO-aware with ifdef and included bug fix for datastructure reinitialization
316 !
317 ! Revision 1.2 2004/04/07 20:26:07 fnajjar
318 ! Redesigned kernel to account for degeneracy case of last particle to be removed
319 !
320 ! Revision 1.1 2004/03/26 21:33:48 fnajjar
321 ! Initial import for plag datastructure update
322 !
323 ! ******************************************************************************
324 
325 
326 
327 
328 
329 
330 
Vector_n max(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:354
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
subroutine deregisterfunction(global)
Definition: ModError.F90:469