| 1 | !!****if* source/Grid/GridMain/UG/Grid_getBlkIndexLimits
|
|---|
| 2 | !!
|
|---|
| 3 | !! NAME
|
|---|
| 4 | !! Grid_getBlkIndexLimits
|
|---|
| 5 | !!
|
|---|
| 6 | !! SYNOPSIS
|
|---|
| 7 | !!
|
|---|
| 8 | !! call Grid_getBlkIndexLimits(integer(IN) :: blockId,
|
|---|
| 9 | !! integer(OUT) :: blkLimits(2,MDIM),
|
|---|
| 10 | !! integer(OUT) :: blkLimitsGC(2,MDIM),
|
|---|
| 11 | !! optional,integer(IN) :: gridDataStruct)
|
|---|
| 12 | !!
|
|---|
| 13 | !! DESCRIPTION
|
|---|
| 14 | !!
|
|---|
| 15 | !! Returns the indices of the upper and lower bounds of a block.
|
|---|
| 16 | !! blkLimitsGC holds the entire dimension of the block (including guardcells)
|
|---|
| 17 | !! blkLimits returns the indices of the interior of the block.
|
|---|
| 18 | !!
|
|---|
| 19 | !! The first dimension holds the lower and upper bounds of the block.
|
|---|
| 20 | !! The second dimension is of size MDIM to hold the upper and lower
|
|---|
| 21 | !! indices of each dimension.
|
|---|
| 22 | !!
|
|---|
| 23 | !! This routine is also used to calculate the size of the internal
|
|---|
| 24 | !! index size of a block. In FLASH2, this was simply NXB, NYB and NZB.
|
|---|
| 25 | !! In FLASH3, since we are supporting blocksizes that are not fixed you
|
|---|
| 26 | !! should calculate on the size of the block on a per block basis. See
|
|---|
| 27 | !! example below.
|
|---|
| 28 | !!
|
|---|
| 29 | !! Please note that the face centered variables have an extra data point
|
|---|
| 30 | !! along the corresponding dimension. For example variable centered on the
|
|---|
| 31 | !! faces along IAXIS dimension have equivalent of NXB+1 data points in the
|
|---|
| 32 | !! interior. If the optional argument gridDataStruct is specified, and it
|
|---|
| 33 | !! is one of the face-centered data structures, the values returned in the
|
|---|
| 34 | !! the two output arrays will reflect the additional data point. Since most
|
|---|
| 35 | !! of FLASH applications use only cell centered variable, most users need not
|
|---|
| 36 | !! concern themselves with this argument.
|
|---|
| 37 | !!
|
|---|
| 38 | !!
|
|---|
| 39 | !! ARGUMENTS
|
|---|
| 40 | !!
|
|---|
| 41 | !! blockId - the local blockID
|
|---|
| 42 | !! blkLimits - array returned holding the upper and lower indices of
|
|---|
| 43 | !! the interior of a block (no guardcells!)
|
|---|
| 44 | !!
|
|---|
| 45 | !! blkLimitsGC - array returned holding the upper and lower indices
|
|---|
| 46 | !! of an entire block, that is, including guardcells.
|
|---|
| 47 | !! gridDataStruct - Grid data structure being operated on, the valid
|
|---|
| 48 | !! values are CENTER, CENTER_FACES, FACEX, FACEY, and FACEZ.
|
|---|
| 49 | !! Specifying gridDataStructure= CENTER or CENTER_FACES is
|
|---|
| 50 | !! equivalent to not including the optional argument in the
|
|---|
| 51 | !! call.
|
|---|
| 52 | !!
|
|---|
| 53 | !! EXAMPLE
|
|---|
| 54 | !!
|
|---|
| 55 | !! Take a 2 dimensional block of size NXB x NYB, with ghost cells along
|
|---|
| 56 | !! each dimension being GX and GY. This block could be stored in an array of
|
|---|
| 57 | !! size (NXB+2*GX,NYB+2*GY). For this array the returned values of blkLimits and blkLimitsGC
|
|---|
| 58 | !! are as follows.
|
|---|
| 59 | !!
|
|---|
| 60 | !! blkLimitsGC(LOW, IAXIS) = 1 !lower bound index of the first cell in the entire block in xdir
|
|---|
| 61 | !! blkLimitsGC(LOW, JAXIS) = 1
|
|---|
| 62 | !! blkLimitsGC(LOW, KAXIS) = 1
|
|---|
| 63 | !!
|
|---|
| 64 | !! blkLimitsGC(HIGH, IAXIS) = NXB+2*GX !upper bound index of the last cell in the entire block in xdir
|
|---|
| 65 | !! blkLimitsGC(HIGH, JAXIS) = NYB +2*GY
|
|---|
| 66 | !! blkLimitsGC(HIGH, KAXIS) = 1 !because there are only 2 dimensions
|
|---|
| 67 | !!
|
|---|
| 68 | !!
|
|---|
| 69 | !! blkLimits(LOW, IAXIS) = GX+1 !lower bound index of the first interior cell of a block in xdir
|
|---|
| 70 | !! blkLimits(LOW, JAXIS) = GY+1
|
|---|
| 71 | !! blkLimits(LOW, KAXIS) = 1
|
|---|
| 72 | !!
|
|---|
| 73 | !! blkLimits(HIGH, IAXIS) = NXB+GX !the upper bound index of the last interior cell of a block in xdir
|
|---|
| 74 | !! blkLimits(HIGH, JAXIS) = NYB+GY
|
|---|
| 75 | !! blkLimits(HIGH, KAXIS) = 1 !because there are only 2 dimensions
|
|---|
| 76 | !!
|
|---|
| 77 | !! For the same block, if the Optional argument was present and was FACEX, then
|
|---|
| 78 | !! blkLimits(HIGH,IAXIS)=NXB+1, and blkLimitsGC(HIGH,IAXIS)=NXB+1+2*GX, and
|
|---|
| 79 | !! all other values of blkLimits and blkLimitsGC are the same as those of the
|
|---|
| 80 | !! default case. Similarly if optional argument had a value FACEY, then
|
|---|
| 81 | !! blkLimits(HIGH,JAXIS)=NYB+1, and blkLimitsGC(HIGH,JAXIS)=NYB+1+2*GY, and
|
|---|
| 82 | !! all others are same as before.
|
|---|
| 83 | !!
|
|---|
| 84 | !!
|
|---|
| 85 | !! To calculate NXB, NYB and NZB for a given block
|
|---|
| 86 | !!
|
|---|
| 87 | !! NXB = blkLimits(HIGH,IAXIS) - blkLimits(LOW,IAXIS) +1
|
|---|
| 88 | !! NYB = blkLimits(HIGH,JAXIS) - blkLimits(LOW,JAXIS) +1
|
|---|
| 89 | !! NZB = blkLimits(HIGH,KAXIS) - blkLimits(LOW,KAXIS) +1
|
|---|
| 90 | !!
|
|---|
| 91 | !!
|
|---|
| 92 | !! NOTES
|
|---|
| 93 | !!
|
|---|
| 94 | !! The #define constants IAXIS, JAXIS and KAXIS
|
|---|
| 95 | !! are defined in constants.h and are
|
|---|
| 96 | !! meant to ease the readability of the code.
|
|---|
| 97 | !! instead of blkLimits(HIGH,3) the code reads
|
|---|
| 98 | !! blkLimits(HIGH, KAXIS)
|
|---|
| 99 | !!
|
|---|
| 100 | !!
|
|---|
| 101 | !!
|
|---|
| 102 | !!***
|
|---|
| 103 |
|
|---|
| 104 | #ifdef DEBUG_ALL
|
|---|
| 105 | #define DEBUG_GRID
|
|---|
| 106 | #endif
|
|---|
| 107 |
|
|---|
| 108 | module Grid_getBlkIndexLimits_mod
|
|---|
| 109 | contains
|
|---|
| 110 | subroutine Grid_getBlkIndexLimits(blockId, blkLimits, blkLimitsGC, gridDataStruct)
|
|---|
| 111 | use Grid_data, ONLY : gr_ilo,gr_ihi,gr_jlo,gr_jhi,gr_klo,gr_khi,&
|
|---|
| 112 | gr_iloGc,gr_ihiGc,gr_jloGc,gr_jhiGc,gr_kloGc,gr_khiGc,&
|
|---|
| 113 | gr_meshMe
|
|---|
| 114 | use Driver_interface, ONLY : Driver_abortFlash
|
|---|
| 115 | implicit none
|
|---|
| 116 |
|
|---|
| 117 | #include "constants.h"
|
|---|
| 118 | #include "Flash.h"
|
|---|
| 119 | integer,intent(IN) :: blockId
|
|---|
| 120 | integer,dimension(2,MDIM),intent(OUT) :: blkLimits,blkLimitsGC
|
|---|
| 121 | integer,optional, intent(IN) :: gridDataStruct
|
|---|
| 122 | integer,dimension(MDIM) :: faces
|
|---|
| 123 |
|
|---|
| 124 | blkLimits(LOW,IAXIS) = gr_ilo
|
|---|
| 125 | blkLimits(HIGH,IAXIS) = gr_ihi
|
|---|
| 126 | blkLimits(LOW,JAXIS) = gr_jlo
|
|---|
| 127 | blkLimits(HIGH,JAXIS) = gr_jhi
|
|---|
| 128 | blkLimits(LOW,KAXIS) = gr_klo
|
|---|
| 129 | blkLimits(HIGH,KAXIS) = gr_khi
|
|---|
| 130 |
|
|---|
| 131 | blkLimitsGC(LOW,IAXIS) = gr_iloGc
|
|---|
| 132 | blkLimitsGC(HIGH,IAXIS) = gr_ihiGc
|
|---|
| 133 | blkLimitsGC(LOW,JAXIS) = gr_jloGc
|
|---|
| 134 | blkLimitsGC(HIGH,JAXIS) = gr_jhiGc
|
|---|
| 135 | blkLimitsGC(LOW,KAXIS) = gr_kloGc
|
|---|
| 136 | blkLimitsGC(HIGH,KAXIS) = gr_khiGc
|
|---|
| 137 | if(present(gridDataStruct)) then
|
|---|
| 138 | faces = 0
|
|---|
| 139 | if((gridDataStruct==FACEX).or.(gridDataStruct==SCRATCH_FACEX)) then
|
|---|
| 140 | faces(IAXIS)=1
|
|---|
| 141 | elseif((gridDataStruct==FACEY).or.(gridDataStruct==SCRATCH_FACEY)) then
|
|---|
| 142 | faces(JAXIS)=1
|
|---|
| 143 | elseif((gridDataStruct==FACEZ).or.(gridDataStruct==SCRATCH_FACEZ)) then
|
|---|
| 144 | faces(KAXIS)=1
|
|---|
| 145 | elseif(gridDataStruct==SCRATCH) then
|
|---|
| 146 | !! This will have to be removed once we eliminate SCRATCH data struct
|
|---|
| 147 | faces = 1
|
|---|
| 148 | elseif((gridDataStruct/=CENTER).and.(gridDataStruct/=SCRATCH_CTR) .and. &
|
|---|
| 149 | (gridDataStruct/=CENTER_FACES)) then
|
|---|
| 150 | if(gr_meshMe == MASTER_PE)print*,'In BlkIndexLimits the provided data structure is',gridDataStruct
|
|---|
| 151 | call Driver_abortFlash("called index limits with invalid gridDataStruct")
|
|---|
| 152 | end if
|
|---|
| 153 | blkLimitsGC(HIGH,:)=blkLimitsGC(HIGH,:)+faces
|
|---|
| 154 | blkLimits(HIGH,:)=blkLimits(HIGH,:)+faces
|
|---|
| 155 | end if
|
|---|
| 156 |
|
|---|
| 157 | end subroutine Grid_getBlkIndexLimits
|
|---|
| 158 |
|
|---|
| 159 | end module |
|---|