
To recognize boundaries and apply the boundary conditions defined by the user, PARAMESH requires that the user define a list of physical volumes to be associated with the list of boundaries, and for each boundary assign a number which defines the boundary condition to be applied at that boundary. This is best explained with an example.
Suppose that in our tutorial we wish to apply non-periodic boundary conditions at each face of the solution domain. As shown in the figure below, in 2D we have four different boundaries. To each of these we assign an index number, less than or equal to -20, which identifies the actual boundary condition which the user wishes to have applied (and which the user specifies in their customized version of the routine AMR_1BLK_BCSET). These boundary condition indeces are set up by the user in the array boundary_index.When a sub-grid block which borders a physical boundary requests to have its guardcells at that boundary filled, the MPI version of PARAMESH has to be able to recognize the presence of the physical boundary. For efficiency reasons, the MPI version of PARAMESH begins its search for a neighbor block by computing the center coordinate of that neighbor block, and then searching for that in the complete ordered list of blocks. If it does not locate a valid neighbor, it then asks the question, `Does the center coordinate of the neighbor block that I wish to find lie in an area which is designated to be a physical boundary?'. In the example below the boxed areas outside the physical domain represent areas in which boundary conditions should be applied to fill guardcells. When the center coordinate of the neighboring block lies inside one of these areas, the guardcell filling routine detects this, determines which boundary `area' is involved, and looks up the boundary condition index which is passed on to AMR_1BLK_BCSET so the correct algorithm is applied to fill theses guardcells. The boundary `areas' are defined by the user through the array boundary_box.
Here is an example which would apply different boundary conditions at each face of the solution domain in our tutorial example.
For the first boundary, (the left boundary in this example), we assign an index of -21, by setting boundary_index(1) = -21. Then, we define the area to be associated with boundary number 1, by setting appropriate values of boundary_box(1:2,1:ndim,1). We repeat this process for each boundary in turn. These boundary definitions can be stored in any order, provided the order in boundary_index and boundary_box is the same.
! Specify volumes associated with each boundary condition
! left x boundary
boundary_index(1) = -21
boundary_box(1,1,1) = -1.e30
boundary_box(2,1,1) = grid_xmin
boundary_box(1,2,1) = -1.e30
boundary_box(2,2,1) = +1.e20
boundary_box(1,3,1) = -1.e30
boundary_box(2,3,1) = +1.e30
! right x boundary
boundary_index(2) = -22
boundary_box(1,1,2) = grid_xmax
boundary_box(2,1,2) = 1.e30
boundary_box(1,2,2) = -1.e30
boundary_box(2,2,2) = +1.e30
boundary_box(1,3,2) = -1.e30
boundary_box(2,3,2) = +1.e30
! left y boundary
boundary_index(3) = -23
boundary_box(1,1,3) = -1.e30
boundary_box(2,1,3) = +1.e30
boundary_box(1,2,3) = -1.e30
boundary_box(2,2,3) = grid_ymin
boundary_box(1,3,3) = -1.e30
boundary_box(2,3,3) = +1.e30
! right y boundary
boundary_index(4) = -24
boundary_box(1,1,4) = -1.e30
boundary_box(2,1,4) = +1.e30
boundary_box(1,2,4) = grid_ymax
boundary_box(2,2,4) = 1.e30
boundary_box(1,3,4) = -1.e30
boundary_box(2,3,4) = +1.e30
In this figure we illustrate the 4 boundary conditions specified above.
Because we are using periodic boundary conditions in this example, setting values for boundary_box and boundary_index will have no effect. However we include this step in the tutorial to introduce you to the mechanism you must use when setting up aperiodic boundary conditions.
One final note. The mechanism that defines periodic boundary conditions takes precedence over any setting of boundary_index and boundary_box. Periodic boundary conditions are established as in the SHMEM example by using the neigh array to specify that blocks connect in a wraparound fashion at a periodic boundary. Specifying a periodic boundary condition through use of neigh, for a particular coordinate direction, overrides any boundary condition for that coordinate direction specified through boundary_index and boundary_box.