Topography flags

Starting from version 3.4a a flag array has been introduced in PALM for representing the topography. The new array flags is a 3D-INTEGER array dimensioned (nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) where each value describes the features of the respective grid point with respect to the topography. Strictly speaking, flags is a POINTER which by default points to the real array wall_flags_1. In case of using the multigrid method as pressure solver, additional arrays wall_flags_2, wall_flags_3, etc. are used containing the respective flag informations for the coarser grids. (Attention: The finest grid always has the largest number, i.e. if four multigrid levels are used, then the flags for the finest grid are stored in array wall_flags_4.)

Each INTEGER value has to be interpreted bitwise. As to the FORTRAN model bits are counted from right to left starting with bit 0. So far, the first seven bits are used for storing the following informations (a bit value of "1" means that the appropriate flag is set):


bit positionmeaning
0wall to the bottom
1wall to the top  (this cannot be used in the code so far)
2wall to the south
3wall to the north
4wall to the left
5wall to the rigth
6inside topography / building

Example:
If a gridpoint has two neighbouring walls to the bottom and to the left, then the flag bit value is "...010001" which gives the INTEGER value "17" = 1*24+1*20.

For a gridpoint in the free flow without any neighbouring wall no bits are set, i.e. the INTEGER value of the respective array element of flags is "0".

The intrinsic FORTRAN functions IBSET, IBITS, IAND, IOR, etc. can be used to manipulate the bits.

Examples:

flags(k,j,i) = IBSET( flags(k,j,i), 6 )

sets the sixth bit of array element (k,j,i) to "1".

IBITS( flags(k,j,i), 4, 1 )

gives the INTEGER value "1" if the fourth bit of array element (k,j,i) is "1", otherwise "0".

Here is an example from routine redblack (within poismg.f90) which shows how IBITS is used for implicit setting of Neumann boundary conditions:

p_mg(k,j,i+1) + IBITS( flags(k,j,i), 5, 1 ) * &
                ( p_mg(k,j,i) - p_mg(k,j,i+1) ) 

If there is no wall to the right of gridpoint (k,j,i) the term results to p_mg(k,j,i+1), otherwise it gives p_mg(k,j,i).


The flag array flags is calculated in routine init_grid using the topography information stored in nzb_local. Here also the flag arrays for the coarser grids needed for the multigrid scheme are calculated. This requires informations from a distance of more than one grid spacing away from the current gridpoint. Therfore, array nzb_local had to be extended for further ghost point levels (see init_grid).