Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PLAG_ModDataStruct.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: Suite of routines for manipulation of particle data structure.
26 !
27 ! Description: None.
28 !
29 ! Notes: None.
30 !
31 ! ******************************************************************************
32 !
33 ! $Id: PLAG_ModDataStruct.F90,v 1.5 2008/12/06 08:44:34 mtcampbe Exp $
34 !
35 ! Copyright: (c) 2007 by the University of Illinois
36 !
37 ! ******************************************************************************
38 
40 
41  USE modglobal, ONLY: t_global
42  USE modparameters
43  USE moddatatypes
44  USE modglobal, ONLY: t_global
45  USE modgrid, ONLY: t_grid
46  USE modpartlag, ONLY: t_plag
47  USE moddatastruct, ONLY: t_region
48  USE moderror
49  USE modmpi
50 
52 
53  IMPLICIT NONE
54 
55  PRIVATE
56  PUBLIC :: plag_dstr_buildcell2pcllist, &
62 
63 ! ******************************************************************************
64 ! Declarations and definitions
65 ! ******************************************************************************
66 
67  CHARACTER(CHRLEN) :: RCSIdentString = &
68  '$RCSfile: PLAG_ModDataStruct.F90,v $ $Revision: 1.5 $'
69 
70 ! ******************************************************************************
71 ! Routines
72 ! ******************************************************************************
73 
74  CONTAINS
75 
76 
77 
78 
79 
80 
81 
82 ! ******************************************************************************
83 !
84 ! Purpose: Build cell-to-particle list in CSR format.
85 !
86 ! Description: None.
87 !
88 ! Input:
89 ! pRegion Pointer to region
90 !
91 ! Output: None.
92 !
93 ! Notes:
94 ! 1. This routine builds the list of cells which have non-zero particles
95 ! and the list of particles in CSR format as well as an access array for
96 ! the CSR list.
97 ! 2. In this routine, only memory for the list of cells and the access array
98 ! is allocated, NOT for the CSR list itself (see next note).
99 ! 3. The actual CSR list is expected to have been created before this
100 ! routine is called.
101 !
102 ! ******************************************************************************
103 
104 SUBROUTINE plag_dstr_buildcell2pcllist(pRegion)
105 
106  USE modsortsearch
107 
108  IMPLICIT NONE
109 
110 ! ******************************************************************************
111 ! Declarations
112 ! ******************************************************************************
113 
114 ! ==============================================================================
115 ! Arguments
116 ! ==============================================================================
117 
118  TYPE(t_region), POINTER :: pregion
119 
120 ! ==============================================================================
121 ! Locals
122 ! ==============================================================================
123 
124  INTEGER :: errorflag,icg,icsr,iloc,ipcl
125  INTEGER, DIMENSION(:), POINTER :: npclspercell
126  TYPE(t_global), POINTER :: global
127  TYPE(t_grid), POINTER :: pgrid
128  TYPE(t_plag), POINTER :: pplag
129 
130 ! ******************************************************************************
131 ! Start
132 ! ******************************************************************************
133 
134  global => pregion%global
135 
136  CALL registerfunction(global,'PLAG_DSTR_BuildCell2PclList',&
137  'PLAG_ModDataStruct.F90')
138 
139  IF ( global%verbLevel > verbose_none ) THEN
140  WRITE(stdout,'(A,1X,A)') solver_name,'Building cell-to-particle list...'
141  WRITE(stdout,'(A,3X,A,1X,I5.5)') solver_name,'Global region:', &
142  pregion%iRegionGlobal
143  END IF ! global%verbLevel
144 
145 ! ******************************************************************************
146 ! Set pointers and values
147 ! ******************************************************************************
148 
149  pgrid => pregion%grid
150  pplag => pregion%plag
151 
152  pplag%nCellsNzPcl = 0
153  pplag%nCellsNzPclMax = min(1000,pgrid%nCells) ! Initial guess
154 
155 ! ******************************************************************************
156 ! Build list of cells with non-zero particles and CSR info array which will be
157 ! used to access actual CSR data structure
158 ! ******************************************************************************
159 
160  CALL plag_dstr_createcell2pcllist(pregion)
161 
162  DO ipcl = 1,pplag%nPcls
163  icg = pplag%aiv(aiv_plag_icells,ipcl)
164 
165  IF ( pplag%nCellsNzPcl > 0 ) THEN
166  CALL binarysearchinteger(pplag%icgNzPcl(1:pplag%nCellsNzPcl), &
167  pplag%nCellsNzPcl,icg,iloc)
168 
169  IF ( iloc == element_not_found ) THEN
170  IF ( pplag%nCellsNzPcl == pplag%nCellsNzPclMax ) THEN
171  CALL plag_dstr_recreatecell2pcllist(pregion)
172  END IF ! pPlag%nCellsNzPcl
173 
174  pplag%nCellsNzPcl = pplag%nCellsNzPcl + 1
175  pplag%icgNzPcl(pplag%nCellsNzPcl) = icg
176  pplag%iPclPerCellCSRInfo(pplag%nCellsNzPcl) = 1
177 
178  CALL quicksortintegerinteger(pplag%icgNzPcl(1:pplag%nCellsNzPcl), &
179  pplag%iPclPerCellCSRInfo(1:pplag%nCellsNzPcl),pplag%nCellsNzPcl)
180  ELSE
181  pplag%iPclPerCellCSRInfo(iloc) = pplag%iPclPerCellCSRInfo(iloc) + 1
182  END IF ! iLoc
183  ELSE
184  pplag%nCellsNzPcl = 1
185  pplag%icgNzPcl(1) = icg
186  pplag%iPclPerCellCSRInfo(1) = 1
187  END IF ! pGrid%nCellsNzPcl
188  END DO ! iPcl
189 
190  IF ( global%verbLevel > verbose_low ) THEN
191  WRITE(stdout,'(A,3X,A,1X,I6)') solver_name,'Number of cells with '// &
192  'non-zero particles:',pplag%nCellsNzPcl
193  END IF ! global%verbLevel
194 
195 ! ******************************************************************************
196 ! Build actual CSR data structure
197 ! ******************************************************************************
198 
199 ! ==============================================================================
200 ! Finalize CSR info array and check for consistency
201 ! ==============================================================================
202 
203  DO icg = 2,pplag%nCellsNzPcl
204  pplag%iPclPerCellCSRInfo(icg) = pplag%iPclPerCellCSRInfo(icg) &
205  + pplag%iPclPerCellCSRInfo(icg-1)
206  END DO ! icg
207 
208  IF ( pplag%iPclPerCellCSRInfo(pplag%nCellsNzPcl) /= pplag%nPcls ) THEN
209  CALL errorstop(global,err_plag_dstr_invalid,__line__)
210  END IF ! pPlag%iPclPerCellCSRInfo
211 
212  ALLOCATE(npclspercell(pgrid%nCells),stat=errorflag)
213  global%error = errorflag
214  IF ( global%error /= err_none ) THEN
215  CALL errorstop(global,err_allocate,__line__,'nPclsPerCell')
216  END IF ! global%error
217 
218  DO icg = 1,pgrid%nCells
219  npclspercell(icg) = 0
220  END DO ! icg
221 
222  DO ipcl = 1,pplag%nPcls
223  icg = pplag%aiv(aiv_plag_icells,ipcl)
224 
225  CALL binarysearchinteger(pplag%icgNzPcl(1:pplag%nCellsNzPcl), &
226  pplag%nCellsNzPcl,icg,iloc)
227 
228  IF ( iloc /= element_not_found ) THEN
229  npclspercell(icg) = npclspercell(icg) + 1
230 
231  IF ( iloc > 1 ) THEN
232  icsr = pplag%iPclPerCellCSRInfo(iloc-1) + 1
233  ELSE
234  icsr = 1
235  END IF ! iLoc
236 
237  icsr = icsr + npclspercell(icg) - 1
238 
239  IF ( icsr > pplag%nPcls ) THEN ! Defensive coding
240  CALL errorstop(global,err_plag_dstr_invalid,__line__)
241  END IF ! iCSR
242 
243  pplag%iPclPerCellCSR(icsr) = ipcl
244  ELSE
245  CALL errorstop(global,err_plag_dstr_invalid,__line__)
246  END IF ! iLoc
247  END DO ! iPcl
248 
249  DEALLOCATE(npclspercell,stat=errorflag)
250  global%error = errorflag
251  IF ( global%error /= err_none ) THEN
252  CALL errorstop(global,err_deallocate,__line__,'nPclsPerCell')
253  END IF ! global%error
254 
255 ! ******************************************************************************
256 ! End
257 ! ******************************************************************************
258 
259  IF ( global%verbLevel > verbose_none ) THEN
260  WRITE(stdout,'(A,1X,A)') solver_name,'Building cell-to-particle list done.'
261  END IF ! global%verbLevel
262 
263  CALL deregisterfunction(global)
264 
265 END SUBROUTINE plag_dstr_buildcell2pcllist
266 
267 
268 
269 
270 
271 
272 
273 ! ******************************************************************************
274 !
275 ! Purpose: Add particle to data structure.
276 !
277 ! Description: None.
278 !
279 ! Input:
280 ! global Pointer to global data
281 ! pPlag Pointer to particle data structure (origin)
282 ! pPlag2 Pointer to particle data structure (target)
283 ! iPcl Index of particle in data structure (origin)
284 !
285 ! Output: None.
286 !
287 ! Notes: None.
288 !
289 ! ******************************************************************************
290 
291 SUBROUTINE plag_dstr_copyparticle(global,pPlag,pPlag2,iPcl)
292 
293  IMPLICIT NONE
294 
295 ! ******************************************************************************
296 ! Declarations
297 ! ******************************************************************************
298 
299 ! ==============================================================================
300 ! Arguments
301 ! ==============================================================================
302 
303  INTEGER, INTENT(IN) ::ipcl
304  TYPE(t_global), POINTER :: global
305  TYPE(t_plag), POINTER :: pplag,pplag2
306 
307 ! ==============================================================================
308 ! Locals
309 ! ==============================================================================
310 
311  INTEGER :: ivar
312 
313 ! ******************************************************************************
314 ! Start
315 ! ******************************************************************************
316 
317  CALL registerfunction(global,'PLAG_DSTR_CopyParticle',&
318  'PLAG_ModDataStruct.F90')
319 
320 ! ******************************************************************************
321 ! Start, increment counter, and check dimensions
322 ! ******************************************************************************
323 
324  pplag2%nPcls = pplag2%nPcls + 1
325 
326  IF ( pplag2%nPcls > pplag2%nPclsMax ) THEN
327  CALL errorstop(global,err_plag_memoverflow,__line__)
328  END IF ! pPlag2%nPcls
329 
330  IF ( (lbound(pplag2%cv,1) /= lbound(pplag%cv,1)) .OR. &
331  (ubound(pplag2%cv,1) /= ubound(pplag%cv,1)) ) THEN
332  CALL errorstop(global,err_lubound_mismatch,__line__)
333  END IF ! LBOUND
334 
335  IF ( (lbound(pplag2%arv,1) /= lbound(pplag%arv,1)) .OR. &
336  (ubound(pplag2%arv,1) /= ubound(pplag%arv,1)) ) THEN
337  CALL errorstop(global,err_lubound_mismatch,__line__)
338  END IF ! LBOUND
339 
340  IF ( (lbound(pplag2%aiv,1) /= lbound(pplag%aiv,1)) .OR. &
341  (ubound(pplag2%aiv,1) /= ubound(pplag%aiv,1)) ) THEN
342  CALL errorstop(global,err_lubound_mismatch,__line__)
343  END IF ! LBOUND
344 
345 ! ******************************************************************************
346 ! Copy data
347 ! ******************************************************************************
348 
349  DO ivar = 1,pplag2%nCv
350  pplag2%cv(ivar,pplag2%nPcls) = pplag%cv(ivar,ipcl)
351  END DO ! iVar
352 
353  DO ivar = 1,pplag2%nArv
354  pplag2%arv(ivar,pplag2%nPcls) = pplag%arv(ivar,ipcl)
355  END DO ! iVar
356 
357  DO ivar = 1,pplag2%nAiv
358  pplag2%aiv(ivar,pplag2%nPcls) = pplag%aiv(ivar,ipcl)
359  END DO ! iVar
360 
361 ! ******************************************************************************
362 ! End
363 ! ******************************************************************************
364 
365  CALL deregisterfunction(global)
366 
367 END SUBROUTINE plag_dstr_copyparticle
368 
369 
370 
371 
372 
373 
374 
375 
376 ! ******************************************************************************
377 !
378 ! Purpose: Wrapper for adding particles to data structure.
379 !
380 ! Description: None.
381 !
382 ! Input:
383 ! global Pointer to global data
384 ! pPlag Pointer to particle data structure (origin)
385 ! pPlag2 Pointer to particle data structure (target)
386 !
387 ! Output: None.
388 !
389 ! Notes: None.
390 !
391 ! ******************************************************************************
392 
393 SUBROUTINE plag_dstr_copyparticlewrapper(global,pPlag,pPlag2)
394 
395  IMPLICIT NONE
396 
397 ! ******************************************************************************
398 ! Declarations
399 ! ******************************************************************************
400 
401 ! ==============================================================================
402 ! Arguments
403 ! ==============================================================================
404 
405  TYPE(t_global), POINTER :: global
406  TYPE(t_plag), POINTER :: pplag,pplag2
407 
408 ! ==============================================================================
409 ! Locals
410 ! ==============================================================================
411 
412  INTEGER :: ipcl
413 
414 ! ******************************************************************************
415 ! Start
416 ! ******************************************************************************
417 
418  CALL registerfunction(global,'PLAG_DSTR_CopyParticleWrapper',&
419  'PLAG_ModDataStruct.F90')
420 
421 ! ******************************************************************************
422 ! Start
423 ! ******************************************************************************
424 
425  DO ipcl = 1,pplag%nPcls
426  CALL plag_dstr_copyparticle(global,pplag,pplag2,ipcl)
427  END DO ! iPcl
428 
429 ! ******************************************************************************
430 ! End
431 ! ******************************************************************************
432 
433  CALL deregisterfunction(global)
434 
435 END SUBROUTINE plag_dstr_copyparticlewrapper
436 
437 
438 
439 
440 
441 
442 
443 ! ******************************************************************************
444 !
445 ! Purpose: Allocate memory for cell-to-particle list.
446 !
447 ! Description: None.
448 !
449 ! Input:
450 ! pRegion Pointer to region
451 !
452 ! Output: None.
453 !
454 ! Notes: None.
455 !
456 ! ******************************************************************************
457 
458 SUBROUTINE plag_dstr_createcell2pcllist(pRegion)
459 
460  IMPLICIT NONE
461 
462 ! ******************************************************************************
463 ! Declarations
464 ! ******************************************************************************
465 
466 ! ==============================================================================
467 ! Arguments
468 ! ==============================================================================
469 
470  TYPE(t_region), POINTER :: pregion
471 
472 ! ==============================================================================
473 ! Locals
474 ! ==============================================================================
475 
476  INTEGER :: errorflag,icg
477  TYPE(t_global), POINTER :: global
478  TYPE(t_plag), POINTER :: pplag
479 
480 ! ******************************************************************************
481 ! Start
482 ! ******************************************************************************
483 
484  global => pregion%global
485 
486  CALL registerfunction(global,'PLAG_DSTR_CreateCell2PclList',&
487  'PLAG_ModDataStruct.F90')
488 
489 ! ******************************************************************************
490 ! Allocate memory
491 ! ******************************************************************************
492 
493  pplag => pregion%plag
494 
495  ALLOCATE(pplag%icgNzPcl(pplag%nCellsNzPclMax),stat=errorflag)
496  global%error = errorflag
497  IF ( global%error /= err_none ) THEN
498  CALL errorstop(global,err_allocate,__line__,'pPlag%icgNzPcl')
499  END IF ! global%error
500 
501  ALLOCATE(pplag%iPclPerCellCSRInfo(pplag%nCellsNzPclMax),stat=errorflag)
502  global%error = errorflag
503  IF ( global%error /= err_none ) THEN
504  CALL errorstop(global,err_allocate,__line__,'pPlag%iPclPerCellCSRInfo')
505  END IF ! global%error
506 
507  DO icg = 1,pplag%nCellsNzPclMax
508  pplag%iPclPerCellCSRInfo(icg) = 0
509  END DO ! icg
510 
511 ! ******************************************************************************
512 ! End
513 ! ******************************************************************************
514 
515  CALL deregisterfunction(global)
516 
517 END SUBROUTINE plag_dstr_createcell2pcllist
518 
519 
520 
521 
522 
523 
524 
525 ! ******************************************************************************
526 !
527 ! Purpose: Allocate memory for cell-to-particle list in CSR format.
528 !
529 ! Description: None.
530 !
531 ! Input:
532 ! pRegion Pointer to region
533 !
534 ! Output: None.
535 !
536 ! Notes: None.
537 !
538 ! ******************************************************************************
539 
540 SUBROUTINE plag_dstr_createpcllistcsr(pRegion)
541 
542  IMPLICIT NONE
543 
544 ! ******************************************************************************
545 ! Declarations
546 ! ******************************************************************************
547 
548 ! ==============================================================================
549 ! Arguments
550 ! ==============================================================================
551 
552  TYPE(t_region), POINTER :: pregion
553 
554 ! ==============================================================================
555 ! Locals
556 ! ==============================================================================
557 
558  INTEGER :: errorflag
559  TYPE(t_global), POINTER :: global
560  TYPE(t_plag), POINTER :: pplag
561 
562 ! ******************************************************************************
563 ! Start
564 ! ******************************************************************************
565 
566  global => pregion%global
567 
568  CALL registerfunction(global,'PLAG_DSTR_CreatePclListCSR',&
569  'PLAG_ModDataStruct.F90')
570 
571 ! ******************************************************************************
572 ! Allocate memory
573 ! ******************************************************************************
574 
575  pplag => pregion%plag
576 
577  IF ( pplag%nPcls > 0 ) THEN
578  ALLOCATE(pplag%iPclPerCellCSR(pplag%nPcls),stat=errorflag)
579  global%error = errorflag
580  IF ( global%error /= err_none ) THEN
581  CALL errorstop(global,err_allocate,__line__,'pPlag%iPclPerCellCSR')
582  END IF ! global%error
583  END IF ! pPlag%nPcls
584 
585 ! ******************************************************************************
586 ! End
587 ! ******************************************************************************
588 
589  CALL deregisterfunction(global)
590 
591 END SUBROUTINE plag_dstr_createpcllistcsr
592 
593 
594 
595 
596 
597 
598 ! ******************************************************************************
599 !
600 ! Purpose: Deallocate memory for cell-to-particle list.
601 !
602 ! Description: None.
603 !
604 ! Input:
605 ! pRegion Pointer to region
606 !
607 ! Output: None.
608 !
609 ! Notes: None.
610 !
611 ! ******************************************************************************
612 
613 SUBROUTINE plag_dstr_destroycell2pcllist(pRegion)
614 
615  IMPLICIT NONE
616 
617 ! ******************************************************************************
618 ! Declarations
619 ! ******************************************************************************
620 
621 ! ==============================================================================
622 ! Arguments
623 ! ==============================================================================
624 
625  TYPE(t_region), POINTER :: pregion
626 
627 ! ==============================================================================
628 ! Locals
629 ! ==============================================================================
630 
631  INTEGER :: errorflag
632  TYPE(t_global), POINTER :: global
633  TYPE(t_plag), POINTER :: pplag
634 
635 ! ******************************************************************************
636 ! Start
637 ! ******************************************************************************
638 
639  global => pregion%global
640 
641  CALL registerfunction(global,'PLAG_DSTR_DestroyCell2PclList',&
642  'PLAG_ModDataStruct.F90')
643 
644 ! ******************************************************************************
645 ! Deallocate memory
646 ! ******************************************************************************
647 
648  pplag => pregion%plag
649 
650  DEALLOCATE(pplag%icgNzPcl,stat=errorflag)
651  global%error = errorflag
652  IF ( global%error /= err_none ) THEN
653  CALL errorstop(global,err_deallocate,__line__,'pPlag%icgNzPcl')
654  END IF ! global%error
655 
656  DEALLOCATE(pplag%iPclPerCellCSRInfo,stat=errorflag)
657  global%error = errorflag
658  IF ( global%error /= err_none ) THEN
659  CALL errorstop(global,err_deallocate,__line__,'pPlag%iPclPerCellCSRInfo')
660  END IF ! global%error
661 
662 ! ******************************************************************************
663 ! End
664 ! ******************************************************************************
665 
666  CALL deregisterfunction(global)
667 
668 END SUBROUTINE plag_dstr_destroycell2pcllist
669 
670 
671 
672 
673 
674 
675 ! ******************************************************************************
676 !
677 ! Purpose: Deallocate memory for cell-to-particle list in CSR format.
678 !
679 ! Description: None.
680 !
681 ! Input:
682 ! pRegion Pointer to region
683 !
684 ! Output: None.
685 !
686 ! Notes: None.
687 !
688 ! ******************************************************************************
689 
690 SUBROUTINE plag_dstr_destroypcllistcsr(pRegion)
691 
692  IMPLICIT NONE
693 
694 ! ******************************************************************************
695 ! Declarations
696 ! ******************************************************************************
697 
698 ! ==============================================================================
699 ! Arguments
700 ! ==============================================================================
701 
702  TYPE(t_region), POINTER :: pregion
703 
704 ! ==============================================================================
705 ! Locals
706 ! ==============================================================================
707 
708  INTEGER :: errorflag
709  TYPE(t_global), POINTER :: global
710  TYPE(t_plag), POINTER :: pplag
711 
712 ! ******************************************************************************
713 ! Start
714 ! ******************************************************************************
715 
716  global => pregion%global
717 
718  CALL registerfunction(global,'PLAG_DSTR_DestroyPclListCSR',&
719  'PLAG_ModDataStruct.F90')
720 
721 ! ******************************************************************************
722 ! Allocate memory
723 ! ******************************************************************************
724 
725  pplag => pregion%plag
726 
727  IF ( ASSOCIATED(pplag%iPclPerCellCSR) .EQV. .true. ) THEN
728  DEALLOCATE(pplag%iPclPerCellCSR,stat=errorflag)
729  global%error = errorflag
730  IF ( global%error /= err_none ) THEN
731  CALL errorstop(global,err_deallocate,__line__,'pPlag%iPclPerCellCSR')
732  END IF ! global%error
733  END IF ! ASSOCIATED
734 
735 ! ******************************************************************************
736 ! End
737 ! ******************************************************************************
738 
739  CALL deregisterfunction(global)
740 
741 END SUBROUTINE plag_dstr_destroypcllistcsr
742 
743 
744 
745 
746 
747 
748 ! ******************************************************************************
749 !
750 ! Purpose: Wrapper for merging particle data structures.
751 !
752 ! Description: None.
753 !
754 ! Input:
755 ! global Pointer to global data
756 ! pGrid Pointer to grid data structure
757 ! pPlag Pointer to particle data structure (origin)
758 ! pPlag2 Pointer to particle data structure (target)
759 !
760 ! Output: None.
761 !
762 ! Notes: None.
763 !
764 ! ******************************************************************************
765 
766 SUBROUTINE plag_dstr_mergeparticlewrapper(pRegion,pPlag,pPlag2)
767 
768  IMPLICIT NONE
769 
770 ! ******************************************************************************
771 ! Declarations
772 ! ******************************************************************************
773 
774 ! ==============================================================================
775 ! Arguments
776 ! ==============================================================================
777 
778  TYPE(t_plag), POINTER :: pplag,pplag2
779  TYPE(t_region), POINTER :: pregion
780 
781 ! ==============================================================================
782 ! Locals
783 ! ==============================================================================
784 
785  INTEGER :: icg,icg2,ipcl,npclsnew,npclsold
786  TYPE(t_global), POINTER :: global
787  TYPE(t_grid), POINTER :: pgrid
788 
789 ! ******************************************************************************
790 ! Start
791 ! ******************************************************************************
792 
793  global => pregion%global
794 
795  CALL registerfunction(global,'PLAG_DSTR_MergeParticleWrapper',&
796  'PLAG_ModDataStruct.F90')
797 
798 ! ******************************************************************************
799 ! Set pointers
800 ! ******************************************************************************
801 
802  pgrid => pregion%grid
803 
804 ! ******************************************************************************
805 ! Copy particles and fix cell and region indices
806 ! ******************************************************************************
807 
808  npclsold = pplag2%nPcls
809 
810  CALL plag_dstr_copyparticlewrapper(global,pplag,pplag2)
811 
812  npclsnew = pplag2%nPcls
813 
814  DO ipcl = npclsold+1,npclsnew
815  icg2 = pplag2%aiv(aiv_plag_icells,ipcl)
816  icg = pgrid%pc2sc(icg2)
817 
818  pplag2%aiv(aiv_plag_icells,ipcl) = icg
819  pplag2%aiv(aiv_plag_regini,ipcl) = pregion%iRegionGlobal
820  END DO ! iPcl
821 
822 ! ******************************************************************************
823 ! End
824 ! ******************************************************************************
825 
826  CALL deregisterfunction(global)
827 
828 END SUBROUTINE plag_dstr_mergeparticlewrapper
829 
830 
831 
832 
833 
834 
835 
836 ! ******************************************************************************
837 !
838 ! Purpose: Re-allocate memory for cell-to-particle list.
839 !
840 ! Description: None.
841 !
842 ! Input:
843 ! pRegion Pointer to region
844 !
845 ! Output: None.
846 !
847 ! Notes: None.
848 !
849 ! ******************************************************************************
850 
852 
853  IMPLICIT NONE
854 
855 ! ******************************************************************************
856 ! Declarations
857 ! ******************************************************************************
858 
859 ! ==============================================================================
860 ! Arguments
861 ! ==============================================================================
862 
863  TYPE(t_region), POINTER :: pregion
864 
865 ! ==============================================================================
866 ! Locals
867 ! ==============================================================================
868 
869  INTEGER :: errorflag,icl
870  INTEGER, DIMENSION(:), POINTER :: temparray1,temparray2
871  TYPE(t_global), POINTER :: global
872  TYPE(t_grid), POINTER :: pgrid
873  TYPE(t_plag), POINTER :: pplag
874 
875 ! ******************************************************************************
876 ! Start
877 ! ******************************************************************************
878 
879  global => pregion%global
880 
881  CALL registerfunction(global,'PLAG_DSTR_RecreateCell2PclList',&
882  'PLAG_ModDataStruct.F90')
883 
884 ! ******************************************************************************
885 ! Allocate temporary array and copy into it
886 ! ******************************************************************************
887 
888  pgrid => pregion%grid
889  pplag => pregion%plag
890 
891  ALLOCATE(temparray1(pplag%nCellsNzPcl),stat=errorflag)
892  global%error = errorflag
893  IF ( global%error /= err_none ) THEN
894  CALL errorstop(global,err_allocate,__line__,'tempArray1')
895  END IF ! global%error
896 
897  ALLOCATE(temparray2(pplag%nCellsNzPcl),stat=errorflag)
898  global%error = errorflag
899  IF ( global%error /= err_none ) THEN
900  CALL errorstop(global,err_allocate,__line__,'tempArray2')
901  END IF ! global%error
902 
903  DO icl = 1,pplag%nCellsNzPcl
904  temparray1(icl) = pplag%icgNzPcl(icl)
905  temparray2(icl) = pplag%iPclPerCellCSRInfo(icl)
906  END DO ! icl
907 
908 ! ******************************************************************************
909 ! Reallocate array, expand size
910 ! ******************************************************************************
911 
912  CALL plag_dstr_destroycell2pcllist(pregion)
913 
914  pplag%nCellsNzPclMax = min(2*pplag%nCellsNzPclMax,pgrid%nCells)
915 
916  CALL plag_dstr_createcell2pcllist(pregion)
917 
918 ! ******************************************************************************
919 ! Copy into expanded array and deallocate temporary array
920 ! ******************************************************************************
921 
922  DO icl = 1,pplag%nCellsNzPcl
923  pplag%icgNzPcl(icl) = temparray1(icl)
924  pplag%iPclPerCellCSRInfo(icl) = temparray2(icl)
925  END DO ! icl
926 
927  DEALLOCATE(temparray1,stat=errorflag)
928  global%error = errorflag
929  IF ( global%error /= err_none ) THEN
930  CALL errorstop(global,err_deallocate,__line__,'tempArray1')
931  END IF ! global%error
932 
933  DEALLOCATE(temparray2,stat=errorflag)
934  global%error = errorflag
935  IF ( global%error /= err_none ) THEN
936  CALL errorstop(global,err_deallocate,__line__,'tempArray2')
937  END IF ! global%error
938 
939 ! ******************************************************************************
940 ! End
941 ! ******************************************************************************
942 
943  CALL deregisterfunction(global)
944 
945 END SUBROUTINE plag_dstr_recreatecell2pcllist
946 
947 
948 
949 
950 
951 
952 ! ******************************************************************************
953 ! End
954 ! ******************************************************************************
955 
956 END MODULE plag_moddatastruct
957 
958 ! ******************************************************************************
959 !
960 ! RCS Revision history:
961 !
962 ! $Log: PLAG_ModDataStruct.F90,v $
963 ! Revision 1.5 2008/12/06 08:44:34 mtcampbe
964 ! Updated license.
965 !
966 ! Revision 1.4 2008/11/19 22:17:46 mtcampbe
967 ! Added Illinois Open Source License/Copyright
968 !
969 ! Revision 1.3 2007/03/27 00:41:47 haselbac
970 ! Bug fix: Incorrect loop limit in copying particle data
971 !
972 ! Revision 1.2 2007/03/27 00:20:49 haselbac
973 ! Substantial additions to allow faster initialization
974 !
975 ! Revision 1.1 2007/03/12 23:33:29 haselbac
976 ! Initial revision
977 !
978 ! ******************************************************************************
979 
980 
981 
982 
983 
984 
985 
986 
987 
988 
989 
990 
991 
992 
993 
subroutine, public plag_dstr_destroypcllistcsr(pRegion)
subroutine plag_dstr_createcell2pcllist(pRegion)
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
subroutine binarysearchinteger(a, n, v, i, j)
subroutine, public plag_dstr_createpcllistcsr(pRegion)
subroutine plag_dstr_recreatecell2pcllist(pRegion)
subroutine plag_dstr_copyparticle(global, pPlag, pPlag2, iPcl)
subroutine quicksortintegerinteger(a, b, n)
subroutine, public plag_dstr_buildcell2pcllist(pRegion)
Vector_n min(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:346
subroutine, public plag_dstr_mergeparticlewrapper(pRegion, pPlag, pPlag2)
subroutine errorstop(global, errorCode, errorLine, addMessage)
Definition: ModError.F90:483
subroutine, public plag_dstr_destroycell2pcllist(pRegion)
subroutine deregisterfunction(global)
Definition: ModError.F90:469
subroutine, public plag_dstr_copyparticlewrapper(global, pPlag, pPlag2)