tem_intp_trilinear_vec Function

private function tem_intp_trilinear_vec(srcVal, targetCoord, nVals) result(phi)

This function returns the tri-linearly interpolated values from the eight source points to the target position located at targetCoord. The source points are arranged in a square from (0,0,0)x(1,1,1) The order of the source points are according to the morton curve 1 2 3 4 (0,0,0); (1,0,0); (0,1,0); (1,1,0) 5 6 7 8 (0,0,1); (1,0,1); (0,1,1); (1,1,1)

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in) :: srcVal(nVals,8)

source values of the square corners

real(kind=rk), intent(in) :: targetCoord(3)

interpolation location within the square

integer, intent(in) :: nVals

number of values

Return Value real(kind=rk), (nVals)

interpolated value


Called by

proc~~tem_intp_trilinear_vec~~CalledByGraph proc~tem_intp_trilinear_vec tem_intp_trilinear_vec interface~tem_intp_trilinear tem_intp_trilinear interface~tem_intp_trilinear->proc~tem_intp_trilinear_vec

Source Code

  function tem_intp_trilinear_vec( srcVal, targetCoord, nVals ) result( phi )
    ! -------------------------------------------------------------------- !
    !> number of values
    integer, intent(in) :: nVals
    !> source values of the square corners
    real(kind=rk), intent(in) :: srcVal(nVals,8)
    !> interpolation location within the square
    real(kind=rk), intent(in) :: targetCoord(3)
    !> interpolated value
    real(kind=rk) :: phi(nVals)
    ! -------------------------------------------------------------------- !
    real(kind=rk) :: phi_northFront, phi_southFront
    real(kind=rk) :: phi_northBack,  phi_southBack
    real(kind=rk) :: phi_front, phi_back
    integer :: iVal
    ! -------------------------------------------------------------------- !
    do iVal = 1, nVals
      ! Linear interpolation on the north nodes
      phi_northFront = (1._rk - targetCoord(1)) * srcVal(iVal,3) &
        &              + targetCoord(1) * srcVal(iVal,4)
      phi_southFront = (1._rk - targetCoord(1)) * srcVal(iVal,1) &
        &              + targetCoord(1) * srcVal(iVal,2)
      ! Linear interpolation on the cube back side (z = 1 )
      phi_northBack = (1._rk - targetCoord(1)) * srcVal(iVal,7) &
        &             + targetCoord(1) * srcVal(iVal,8)
      phi_southBack = (1._rk - targetCoord(1)) * srcVal(iVal,5) &
        &             + targetCoord(1) * srcVal(iVal,6)
      ! Linear interpolation on the cube front side (z = 0 )
      phi_front = (1._rk - targetCoord(2)) * phi_southFront &
        &         + targetCoord(2) * phi_northFront
      ! Linear interpolation on the cube back side (z = 1 )
      phi_back  = (1._rk - targetCoord(2)) * phi_southBack &
        &         + targetCoord(2) * phi_northBack
      phi(iVal) = (1._rk - targetCoord(3)) * phi_front &
        &         + targetCoord(3)*phi_back
    enddo

  end function tem_intp_trilinear_vec