Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RFLU_ModGatherData.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: Gather and scatter solution data.
26 !
27 ! Description: None
28 !
29 ! Notes:
30 ! 1. This module collects routines to gather and scatter solution data
31 ! when partitioning or merging solution data for parallel multi-physics
32 ! calculations. The way the partitioning and merging is done means that
33 ! a single solution vector must be used. Since the solution data for
34 ! multi-physics calculations in RocfluMP is stored separately, it needs
35 ! to be gathered before partitioning, and scattered after merging.
36 !
37 ! ******************************************************************************
38 !
39 ! $Id: RFLU_ModGatherData.F90,v 1.8 2008/12/06 08:44:22 mtcampbe Exp $
40 !
41 ! Copyright: (c) 2003-2004 by the University of Illinois
42 !
43 ! ******************************************************************************
44 
46 
47  USE moddatatypes
48  USE modparameters
49  USE modglobal, ONLY: t_global
50  USE moddatastruct, ONLY: t_region
51  USE modgrid, ONLY: t_grid
52  USE moderror
53 
54  IMPLICIT NONE
55 
56  PRIVATE
57  PUBLIC :: rflu_countgathereddata, &
62 
63  INTEGER, PARAMETER, PUBLIC :: GATHER_MODE_ACTUAL_ONLY = 1, &
64  GATHER_MODE_ACTUAL_VIRTUAL = 2
65 
66  CONTAINS
67 
68 
69 ! ******************************************************************************
70 !
71 ! Purpose: Count gathered data - determine number of variables
72 !
73 ! Description: None.
74 !
75 ! Input:
76 ! pRegion Pointer to region
77 !
78 ! Output:
79 ! nVarsOut Number of variables to be gathered
80 !
81 ! Notes: None.
82 !
83 ! ******************************************************************************
84 
85  SUBROUTINE rflu_countgathereddata(pRegion,nVarsOut)
86 
87 ! ******************************************************************************
88 ! Declarations and definitions
89 ! ******************************************************************************
90 
91 ! ==============================================================================
92 ! Arguments
93 ! ==============================================================================
94 
95  INTEGER, INTENT(OUT) :: nvarsout
96  TYPE(t_region), POINTER :: pregion
97 
98 ! ==============================================================================
99 ! Locals
100 ! ==============================================================================
101 
102  INTEGER :: nvars
103  TYPE(t_global), POINTER :: global
104 
105 ! ******************************************************************************
106 ! Start
107 ! ******************************************************************************
108 
109  global => pregion%global
110 
111  CALL registerfunction(global,'RFLU_CountGatheredData',&
112  'RFLU_ModGatherData.F90')
113 
114 ! ******************************************************************************
115 ! Determine number of variables
116 ! ******************************************************************************
117 
118 ! ==============================================================================
119 ! Mixture
120 ! ==============================================================================
121 
122  nvars = pregion%mixtInput%nCv
123 
124 ! ==============================================================================
125 ! Physical modules
126 ! ==============================================================================
127 
128 #ifdef SPEC
129  IF ( global%specUsed .EQV. .true. ) THEN
130  nvars = nvars + pregion%specInput%nSpecies
131  END IF ! global%specUsed
132 #endif
133 
134 ! ******************************************************************************
135 ! Set nVarsOut
136 ! ******************************************************************************
137 
138  nvarsout = nvars
139 
140 ! ******************************************************************************
141 ! End
142 ! ******************************************************************************
143 
144  CALL deregisterfunction(global)
145 
146  END SUBROUTINE rflu_countgathereddata
147 
148 
149 
150 
151 
152 ! ******************************************************************************
153 !
154 ! Purpose: Create gathered data
155 !
156 ! Description: None.
157 !
158 ! Input:
159 ! pRegion Pointer to region
160 ! icType Cell type
161 ! gatherMode Gather mode
162 !
163 ! Output:
164 ! nVarsOut Number of variables to be gathered
165 ! cv Array to hold gathered data
166 !
167 ! Notes:
168 ! 1. Gather mode indicates whether actual cells or virtual cells are to
169 ! be gathered.
170 !
171 ! ******************************************************************************
172 
173  SUBROUTINE rflu_creategathereddata(pRegion,icType,gatherMode,nVarsOut,cv)
174 
175 ! ******************************************************************************
176 ! Declarations and definitions
177 ! ******************************************************************************
178 
179 ! ==============================================================================
180 ! Arguments
181 ! ==============================================================================
182 
183  INTEGER, INTENT(IN) :: gathermode,ictype
184  INTEGER, INTENT(OUT) :: nvarsout
185  REAL(RFREAL), DIMENSION(:,:), POINTER :: cv
186  TYPE(t_region), POINTER :: pregion
187 
188 ! ==============================================================================
189 ! Locals
190 ! ==============================================================================
191 
192  INTEGER :: errorflag,ncells,nvars
193  TYPE(t_global), POINTER :: global
194  TYPE(t_grid), POINTER :: pgrid
195 
196 ! ******************************************************************************
197 ! Start
198 ! ******************************************************************************
199 
200  global => pregion%global
201 
202  CALL registerfunction(global,'RFLU_CreateGatheredData',&
203  'RFLU_ModGatherData.F90')
204 
205 ! ******************************************************************************
206 ! Set pointers
207 ! ******************************************************************************
208 
209  pgrid => pregion%grid
210 
211 ! ******************************************************************************
212 ! Determine number of variables
213 ! ******************************************************************************
214 
215  CALL rflu_countgathereddata(pregion,nvars)
216 
217 ! ******************************************************************************
218 ! Determine number of cells
219 ! ******************************************************************************
220 
221  SELECT CASE ( gathermode )
222  CASE ( gather_mode_actual_only )
223  SELECT CASE ( ictype )
224  CASE ( cell_type_tet )
225  ncells = pgrid%nTets
226  CASE ( cell_type_hex )
227  ncells = pgrid%nHexs
228  CASE ( cell_type_pri )
229  ncells = pgrid%nPris
230  CASE ( cell_type_pyr )
231  ncells = pgrid%nPyrs
232  CASE default
233  CALL errorstop(global,err_reached_default,__line__)
234  END SELECT ! icType
235  CASE ( gather_mode_actual_virtual )
236  SELECT CASE ( ictype )
237  CASE ( cell_type_tet )
238  ncells = pgrid%nTetsTot
239  CASE ( cell_type_hex )
240  ncells = pgrid%nHexsTot
241  CASE ( cell_type_pri )
242  ncells = pgrid%nPrisTot
243  CASE ( cell_type_pyr )
244  ncells = pgrid%nPyrsTot
245  CASE default
246  CALL errorstop(global,err_reached_default,__line__)
247  END SELECT ! icType
248  CASE default
249  CALL errorstop(global,err_reached_default,__line__)
250  END SELECT ! gatherMode
251 
252 ! ******************************************************************************
253 ! Set nVarsOut
254 ! ******************************************************************************
255 
256  nvarsout = nvars
257 
258 ! ******************************************************************************
259 ! Allocate memory
260 ! ******************************************************************************
261 
262  ALLOCATE(cv(nvars,ncells),stat=errorflag)
263  global%error = errorflag
264  IF ( global%error /= err_none ) THEN
265  CALL errorstop(global,err_allocate,__line__,'cv')
266  END IF ! global%error
267 
268 ! ******************************************************************************
269 ! End
270 ! ******************************************************************************
271 
272  CALL deregisterfunction(global)
273 
274  END SUBROUTINE rflu_creategathereddata
275 
276 
277 
278 
279 
280 
281 
282 ! ******************************************************************************
283 !
284 ! Purpose: Destroy gathered data
285 !
286 ! Description: None.
287 !
288 ! Input:
289 ! pRegion Pointer to region
290 !
291 ! Output:
292 ! cv Array to be destroyed
293 !
294 ! Notes: None.
295 !
296 ! ******************************************************************************
297 
298  SUBROUTINE rflu_destroygathereddata(pRegion,cv)
299 
300 ! ******************************************************************************
301 ! Declarations and definitions
302 ! ******************************************************************************
303 
304 ! ==============================================================================
305 ! Arguments
306 ! ==============================================================================
307 
308  REAL(RFREAL), DIMENSION(:,:), POINTER :: cv
309  TYPE(t_region), POINTER :: pregion
310 
311 ! ==============================================================================
312 ! Locals
313 ! ==============================================================================
314 
315  INTEGER :: errorflag
316  TYPE(t_global), POINTER :: global
317 
318 ! ******************************************************************************
319 ! Start
320 ! ******************************************************************************
321 
322  global => pregion%global
323 
324  CALL registerfunction(global,'RFLU_DestroyGatheredData',&
325  'RFLU_ModGatherData.F90')
326 
327 ! ******************************************************************************
328 ! Deallocate memory
329 ! ******************************************************************************
330 
331  DEALLOCATE(cv,stat=errorflag)
332  global%error = errorflag
333  IF ( global%error /= err_none ) THEN
334  CALL errorstop(global,err_deallocate,__line__,'cv')
335  END IF ! global%error
336 
337 ! ******************************************************************************
338 ! End
339 ! ******************************************************************************
340 
341  CALL deregisterfunction(global)
342 
343  END SUBROUTINE rflu_destroygathereddata
344 
345 
346 
347 
348 
349 
350 ! ******************************************************************************
351 !
352 ! Purpose: Gather data
353 !
354 ! Description: None.
355 !
356 ! Input:
357 ! pRegion Pointer to region
358 ! icType Cell type
359 ! gatherMode Gather mode
360 !
361 ! Output:
362 ! cv Gathered data
363 !
364 ! Notes:
365 ! 1. Gather mode indicates whether actual cells or virtual cells are to
366 ! be gathered.
367 !
368 ! ******************************************************************************
369 
370  SUBROUTINE rflu_gatherdata(pRegion,icType,gatherMode,cv)
371 
372 ! ******************************************************************************
373 ! Declarations and definitions
374 ! ******************************************************************************
375 
376 ! ==============================================================================
377 ! Arguments
378 ! ==============================================================================
379 
380  INTEGER, INTENT(IN) :: gathermode,ictype
381  REAL(RFREAL), DIMENSION(:,:), POINTER :: cv
382  TYPE(t_region), POINTER :: pregion
383 
384 ! ==============================================================================
385 ! Locals
386 ! ==============================================================================
387 
388  INTEGER :: errorflag,icg,icl,ivar,ncells,nvars
389  INTEGER, DIMENSION(:), POINTER :: pxyz2cellglob
390  REAL(RFREAL), DIMENSION(:,:), POINTER :: pvar
391  TYPE(t_global), POINTER :: global
392  TYPE(t_grid), POINTER :: pgrid
393 
394 ! ******************************************************************************
395 ! Start
396 ! ******************************************************************************
397 
398  global => pregion%global
399 
400  CALL registerfunction(global,'RFLU_GatherData',&
401  'RFLU_ModGatherData.F90')
402 
403 ! ******************************************************************************
404 ! Set pointers
405 ! ******************************************************************************
406 
407  pgrid => pregion%grid
408 
409 ! ******************************************************************************
410 ! Determine number of cells and set renumbering pointer
411 ! ******************************************************************************
412 
413  SELECT CASE ( gathermode )
414  CASE ( gather_mode_actual_only )
415  SELECT CASE ( ictype )
416  CASE ( cell_type_tet )
417  ncells = pgrid%nTets
418  pxyz2cellglob => pgrid%tet2CellGlob
419  CASE ( cell_type_hex )
420  ncells = pgrid%nHexs
421  pxyz2cellglob => pgrid%hex2CellGlob
422  CASE ( cell_type_pri )
423  ncells = pgrid%nPris
424  pxyz2cellglob => pgrid%pri2CellGlob
425  CASE ( cell_type_pyr )
426  ncells = pgrid%nPyrs
427  pxyz2cellglob => pgrid%pyr2CellGlob
428  CASE default
429  CALL errorstop(global,err_reached_default,__line__)
430  END SELECT ! icType
431  CASE ( gather_mode_actual_virtual )
432  SELECT CASE ( ictype )
433  CASE ( cell_type_tet )
434  ncells = pgrid%nTetsTot
435  pxyz2cellglob => pgrid%tet2CellGlob
436  CASE ( cell_type_hex )
437  ncells = pgrid%nHexsTot
438  pxyz2cellglob => pgrid%hex2CellGlob
439  CASE ( cell_type_pri )
440  ncells = pgrid%nPrisTot
441  pxyz2cellglob => pgrid%pri2CellGlob
442  CASE ( cell_type_pyr )
443  ncells = pgrid%nPyrsTot
444  pxyz2cellglob => pgrid%pyr2CellGlob
445  CASE default
446  CALL errorstop(global,err_reached_default,__line__)
447  END SELECT ! icType
448  CASE default
449  CALL errorstop(global,err_reached_default,__line__)
450  END SELECT ! gatherMode
451 
452 ! ******************************************************************************
453 ! Gather data
454 ! ******************************************************************************
455 
456  DO icl = 1,ncells
457  icg = pxyz2cellglob(icl)
458 
459  nvars = 0
460 
461 ! ==============================================================================
462 ! Mixture
463 ! ==============================================================================
464 
465  pvar => pregion%mixt%cv
466 
467  DO ivar = cv_mixt_dens,cv_mixt_ener
468  nvars = nvars + 1
469  cv(nvars,icl) = pvar(ivar,icg)
470  END DO ! iVar
471 
472 ! ==============================================================================
473 ! Physical modules
474 ! ==============================================================================
475 
476 #ifdef SPEC
477  IF ( global%specUsed .EQV. .true. ) THEN
478  pvar => pregion%spec%cv
479 
480  DO ivar = 1,pregion%specInput%nSpecies
481  nvars = nvars + 1
482  cv(nvars,icl) = pvar(ivar,icg)
483  END DO ! iVar
484  END IF ! global%specUsed
485 #endif
486  END DO ! icl
487 
488 ! ******************************************************************************
489 ! End
490 ! ******************************************************************************
491 
492  CALL deregisterfunction(global)
493 
494  END SUBROUTINE rflu_gatherdata
495 
496 
497 
498 
499 
500 
501 ! ******************************************************************************
502 !
503 ! Purpose: Scatter gathered data
504 !
505 ! Description: None.
506 !
507 ! Input:
508 ! pRegion Pointer to region
509 ! icType Cell type
510 ! gatherMode Gather mode
511 !
512 ! Output:
513 ! cv Array holding gathered data
514 !
515 ! Notes:
516 ! 1. Gather mode indicates whether actual cells or virtual cells are to
517 ! be scattered.
518 !
519 ! ******************************************************************************
520 
521  SUBROUTINE rflu_scattergathereddata(pRegion,icType,gatherMode,cv)
522 
523 ! ******************************************************************************
524 ! Declarations and definitions
525 ! ******************************************************************************
526 
527 ! ==============================================================================
528 ! Arguments
529 ! ==============================================================================
530 
531  INTEGER, INTENT(IN) :: gathermode,ictype
532  REAL(RFREAL), DIMENSION(:,:), POINTER :: cv
533  TYPE(t_region), POINTER :: pregion
534 
535 ! ==============================================================================
536 ! Locals
537 ! ==============================================================================
538 
539  INTEGER :: errorflag,icg,icl,ivar,ncells,nvars
540  INTEGER, DIMENSION(:), POINTER :: pxyz2cellglob
541  REAL(RFREAL), DIMENSION(:,:), POINTER :: pvar
542  TYPE(t_global), POINTER :: global
543  TYPE(t_grid), POINTER :: pgrid
544 
545 ! ******************************************************************************
546 ! Start
547 ! ******************************************************************************
548 
549  global => pregion%global
550 
551  CALL registerfunction(global,'RFLU_ScatterGatheredData',&
552  'RFLU_ModGatherData.F90')
553 
554 ! ******************************************************************************
555 ! Set pointers
556 ! ******************************************************************************
557 
558  pgrid => pregion%grid
559 
560 ! ******************************************************************************
561 ! Determine number of cells and set renumbering pointer
562 ! ******************************************************************************
563 
564  SELECT CASE ( gathermode )
565  CASE ( gather_mode_actual_only )
566  SELECT CASE ( ictype )
567  CASE ( cell_type_tet )
568  ncells = pgrid%nTets
569  pxyz2cellglob => pgrid%tet2CellGlob
570  CASE ( cell_type_hex )
571  ncells = pgrid%nHexs
572  pxyz2cellglob => pgrid%hex2CellGlob
573  CASE ( cell_type_pri )
574  ncells = pgrid%nPris
575  pxyz2cellglob => pgrid%pri2CellGlob
576  CASE ( cell_type_pyr )
577  ncells = pgrid%nPyrs
578  pxyz2cellglob => pgrid%pyr2CellGlob
579  CASE default
580  CALL errorstop(global,err_reached_default,__line__)
581  END SELECT ! icType
582  CASE ( gather_mode_actual_virtual )
583  SELECT CASE ( ictype )
584  CASE ( cell_type_tet )
585  ncells = pgrid%nTetsTot
586  pxyz2cellglob => pgrid%tet2CellGlob
587  CASE ( cell_type_hex )
588  ncells = pgrid%nHexsTot
589  pxyz2cellglob => pgrid%hex2CellGlob
590  CASE ( cell_type_pri )
591  ncells = pgrid%nPrisTot
592  pxyz2cellglob => pgrid%pri2CellGlob
593  CASE ( cell_type_pyr )
594  ncells = pgrid%nPyrsTot
595  pxyz2cellglob => pgrid%pyr2CellGlob
596  CASE default
597  CALL errorstop(global,err_reached_default,__line__)
598  END SELECT ! icType
599  CASE default
600  CALL errorstop(global,err_reached_default,__line__)
601  END SELECT ! gatherMode
602 
603 ! ******************************************************************************
604 ! Scatter data for actual cells
605 ! ******************************************************************************
606 
607  DO icl = 1,ncells
608  icg = pxyz2cellglob(icl)
609 
610  nvars = 0
611 
612 ! ==============================================================================
613 ! Mixture
614 ! ==============================================================================
615 
616  pvar => pregion%mixt%cv
617 
618  DO ivar = cv_mixt_dens,cv_mixt_ener
619  nvars = nvars + 1
620  pvar(ivar,icg) = cv(nvars,icl)
621  END DO ! iVar
622 
623 ! ==============================================================================
624 ! Physical modules
625 ! ==============================================================================
626 
627 #ifdef SPEC
628  IF ( global%specUsed .EQV. .true. ) THEN
629  pvar => pregion%spec%cv
630 
631  DO ivar = 1,pregion%specInput%nSpecies
632  nvars = nvars + 1
633  pvar(ivar,icg) = cv(nvars,icl)
634  END DO ! iVar
635  END IF ! global%specUsed
636 #endif
637  END DO ! icl
638 
639 ! ******************************************************************************
640 ! End
641 ! ******************************************************************************
642 
643  CALL deregisterfunction(global)
644 
645  END SUBROUTINE rflu_scattergathereddata
646 
647 
648 
649 
650 END MODULE rflu_modgatherdata
651 
652 ! ******************************************************************************
653 !
654 ! RCS Revision history:
655 !
656 ! $Log: RFLU_ModGatherData.F90,v $
657 ! Revision 1.8 2008/12/06 08:44:22 mtcampbe
658 ! Updated license.
659 !
660 ! Revision 1.7 2008/11/19 22:17:33 mtcampbe
661 ! Added Illinois Open Source License/Copyright
662 !
663 ! Revision 1.6 2006/04/07 15:19:19 haselbac
664 ! Removed tabs
665 !
666 ! Revision 1.5 2004/11/02 02:31:56 haselbac
667 ! Replaced CV_MIXT_NEQS
668 !
669 ! Revision 1.4 2004/10/19 19:27:56 haselbac
670 ! Clean-up
671 !
672 ! Revision 1.3 2004/07/28 15:29:20 jferry
673 ! created global variable for spec use
674 !
675 ! Revision 1.2 2004/01/22 16:03:59 haselbac
676 ! Made contents of modules PRIVATE, only procs PUBLIC, to avoid errors on ALC
677 ! and titan
678 !
679 ! Revision 1.1 2003/11/25 21:03:30 haselbac
680 ! Initial revision
681 !
682 ! ******************************************************************************
683 
684 
685 
686 
687 
688 
689 
690 
691 
692 
693 
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
subroutine, public rflu_creategathereddata(pRegion, icType, gatherMode, nVarsOut, cv)
subroutine, public rflu_destroygathereddata(pRegion, cv)
subroutine errorstop(global, errorCode, errorLine, addMessage)
Definition: ModError.F90:483
subroutine, public rflu_countgathereddata(pRegion, nVarsOut)
subroutine deregisterfunction(global)
Definition: ModError.F90:469
subroutine, public rflu_gatherdata(pRegion, icType, gatherMode, cv)
subroutine, public rflu_scattergathereddata(pRegion, icType, gatherMode, cv)