tem_treelmDef_map_toStencil Subroutine

public subroutine tem_treelmDef_map_toStencil(me)

Map the internally defined treelm offsets to the stencil offsets.

Arguments

Type IntentOptional Attributes Name
type(tem_stencilHeader_type) :: me

stencil to map


Source Code

  subroutine tem_treelmDef_map_toStencil( me )
    ! -------------------------------------------------------------------- !
    !> stencil to map
    type(tem_stencilHeader_type) :: me
    ! -------------------------------------------------------------------- !
    ! counters
    integer :: iDir, iQQQ
    ! -------------------------------------------------------------------- !

    ! allocate the map2treeDef with all 26 direct neighbors
    if ( allocated(me%map2treeDef) ) deallocate(me%map2treeDef)

    allocate( me%map2treeDef(qQQQ) )
    me%map2treeDef = 0

    ! loop over all 26 neighbors
    do iQQQ=1,qQQQ

      ! search for the correct entry in the stencil%cxDir array
      do iDir = 1, me%QQ

        if ( me%cxDir(1, iDir) == qOffset(iQQQ, 1)       &
          &  .and. me%cxDir(2, iDir) == qOffset(iQQQ, 2) &
          &  .and. me%cxDir(3, iDir) == qOffset(iQQQ, 3) ) then
          ! assign the correct position
          me%map2treeDef(iQQQ) = iDir
          EXIT
        end if

      end do

    end do

  end subroutine tem_treelmDef_map_toStencil