tem_CoordOf_2d_Id Function

private function tem_CoordOf_2d_Id(Id2d, level) result(coord)

Arguments

Type IntentOptional Attributes Name
integer(kind=long_k), intent(in) :: Id2d

input element ID

integer, intent(in) :: level

Return Value integer, (4)

coordinate of element return value


Called by

proc~~tem_coordof_2d_id~~CalledByGraph proc~tem_coordof_2d_id tem_CoordOf_2d_Id proc~generate_treelm_slice generate_treelm_slice proc~generate_treelm_slice->proc~tem_coordof_2d_id proc~tem_load_internal tem_load_internal proc~tem_load_internal->proc~generate_treelm_slice proc~load_tem load_tem proc~load_tem->proc~tem_load_internal proc~tem_restart_readheader tem_restart_readHeader proc~tem_restart_readheader->proc~load_tem

Source Code

  function tem_CoordOf_2d_Id(id2d, level) result(coord)
    ! -------------------------------------------------------------------- !
    !> input element ID
    integer(kind=long_k), intent(in) :: Id2d
    integer, intent(in) :: level
    !> coordinate of element return value
    integer :: coord(4)
    ! -------------------------------------------------------------------- !
    integer(kind=long_k) :: fak(2)
    integer :: bitlevel
    integer :: i
    integer(kind=long_k) :: telem
    ! -------------------------------------------------------------------- !

    coord(:) = 0
    coord(4) = level
    fak(1) = 1
    fak(2) = 2
    bitlevel = 1

    tElem = id2d

    ! get x coordinate from
    !
    ! x = sum(iLevel=0, inf) { 2**iLevel * mod(tElem / (4**iLevel) ),2)   }
    ! y = sum(iLevel=0, inf) { 2**iLevel * mod(tElem /(2 * (4**iLevel) ),2)   }
    !
    do while ((tElem / fak(1)) > 0)
      do i=1,2
        coord(i) = coord(i) + bitlevel * int(mod(tElem / fak(i), 2_long_k))
      end do
      bitlevel = bitlevel * 2
      fak = fak * 4
    end do
  end function tem_CoordOf_2d_Id