7.4 External Boundary Conditions

Most problems include some sort of boundary conditions. These conditions are normally applied in the ghost cells surrounding the actual computational domain. Examples of boundary conditions are imposed values, reflection walls, symmetry planes, inlets, and exits.

The Multiblock framework keeps track of where boundary conditions are to be applied. You register a subroutine that the framework will call to apply each type of external boundary condition.



int MBLK_Register_bc(const int bcnum, int ghostWidth, const MBLK_BcFn bcfn);
subroutine MBLK_Register_bc(bcnum, ghostwidth, bcfn, err)
integer,intent(in) :: bcnum, ghostWidth
integer,intent(out) :: err
subroutine :: bcfn
This is call is used to bind an external boundary condition subroutine, written by you, to a boundary condition number. MBLK_Register_bc should only be called from the driver.

When you ask the framework to apply boundary conditions, it will call this routine. The routine should be declared like:

 !In Fortran
 subroutine applyMyBC(param1,param2,start,end)
 varies :: param1, param2
 integer :: start(3), end(3)
 end subroutine

 /* In C */
 void applyMyBC(void *param1,void *param2,int *start,int *end);

param1 and param2 are not used by the framework- they are passed in unmodified from MBLK_Apply_bc and MBLK_Apply_bc_all. param1 and param2 typically contain the block data and dimensions.

start and end are 3-element arrays that give the ,, block locations where the boundary condition is to be applied. They are both inclusive and both relative to the block interior- you must shift them over your ghost cells. The C versions are 0-based (the first index is zero); the Fortran versions are 1-based (the first index is one).

For example, a Fortran subroutine to apply the constant value 1.0 across the boundary, with a 2-deep ghost region, would be:

 !In Fortran
 subroutine applyMyBC(grid,size,start,end)
 integer :: size(3), i,j,k
 double precision :: grid(size(1),size(2),size(3))
 integer :: start(3), end(3)
 start=start+2 ! Back up over ghost region
 end=end+2
 do i=start(1),end(1)
 do j=start(2),end(2)
 do k=start(3),end(3)
     grid(i,j,k)=1.0
 end do
 end do
 end do

 end subroutine



int MBLK_Apply_bc(const int bcnum, void *param1,void *param2);
subroutine MBLK_Apply_bc(bcnum, param1,param2,err)
integer,intent(in)::bcnum
varies,intent(inout)::param1
varies,intent(inout)::param2
integer,intent(out)::err
MBLK_Apply_bc call is made to apply all boundry condition functions of type bcnum to the block. param1 and param2 are passed unmodified to the boundary condition function.



int MBLK_Apply_bc_all(void* param1, void* param2);
subroutine MBLK_Apply_bc_all(param1,param2, err)
integer,intent(out)::err
varies,intent(inout)::param1
varies,intent(inout)::param2
This call is same as MBLK_Apply_bc except it applies all external boundary conditions to the block.

January 17, 2008
MBlock Homepage
Charm Homepage