[FLASH-USERS] Grid_bcApplyToRegionSpecialized

Klaus Weide klaus at flash.uchicago.edu
Mon Aug 24 14:35:23 EDT 2009


On Thu, 20 Aug 2009, turcotte wrote:

Hello Sylvain,

I think that the problems with your Grid_bcApplyToRegionSpecialized 
implementation are a result of neglecting an index offset for the y 
direction.  I have inserted changes to fix this below (untested), as well 
as some other coments.  For a more general template, I suggest you look at 
Grid/GridBoundaryConditions/OneRow/Grid_bcApplyToRegionSpecialized.F90; 
that version is basically an adapter from the 
Grid_bcApplyToRegionSpecialized to the Grid_applyBCEdge interface.


> For a 2D box in cylindrical coordinates, applying the BC on the x=0 boundary,
> I loop thusly:
>   applied=.true.
>   
>   sizeX=regionSize(BC_DIR)
>   allocate(xCoord(sizeX))
> 
>   sizeY=regionSize(2)
>   allocate(yCoord(sizeY))
> 
>   call Grid_getCellCoords(IAXIS,blockID,CENTER,.true.,xCoord,sizeX)
>   call Grid_getCellCoords(JAXIS,blockID,CENTER,.true.,yCoord,sizeY)

You should use gr_extendedGetCellCoords instead of Grid_getCellCoords, as 
pointed out in Dongwook's response.

Also declare an INTEGER variable jOffset, and use it like this:

   jOffset = endPoints(LOW,secondDir) - 1

>   do j = 1,sizeY
Note change in the index range in next line...
>      do i = 1,guard  !was: sizeX
>         regionData(i,j,:,VELY_VAR) = value
Note changed comment in next line...
>           ! where value will be a function of xCoord(i) and yCoord(j+jOffset)
>      enddo
>   enddo
> 

I hope these changes fix your problems.  As written, this will only be 
correct for the lower boundary in the x direction, and only for 
cell-centered variables (i.e., gridDataStruct==CENTER), so make sure
your Grid_bcApplyToRegionSpecialized.F90 immediately returns (with applied 
= .FALSE.) when that is not the case.

Klaus



More information about the flash-users mailing list