tem_intp_bilinear_scalar Function

private function tem_intp_bilinear_scalar(srcVal, targetCoord) result(phi)

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

Arguments

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

source values of the square corners

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

interpolation location within the square

Return Value real(kind=rk)

interpolated value


Called by

proc~~tem_intp_bilinear_scalar~~CalledByGraph proc~tem_intp_bilinear_scalar tem_intp_bilinear_scalar interface~tem_intp_bilinear tem_intp_bilinear interface~tem_intp_bilinear->proc~tem_intp_bilinear_scalar

Source Code

  function tem_intp_bilinear_scalar( srcVal, targetCoord ) result( phi )
    ! -------------------------------------------------------------------- !
    !> source values of the square corners
    real(kind=rk), intent(in) :: srcVal(4)
    !> interpolation location within the square
    real(kind=rk), intent(in) :: targetCoord(2)
    !> interpolated value
    real(kind=rk) :: phi
    ! -------------------------------------------------------------------- !
    real(kind=rk) :: phi_north, phi_south
    ! -------------------------------------------------------------------- !
    ! Linear interpolation on the north nodes
    phi_north = (1._rk - targetCoord(1)) * srcVal(3) + targetCoord(1)*srcVal(4)
    ! Linear interpolation on the south nodes
    phi_south = (1._rk - targetCoord(1)) * srcVal(1) + targetCoord(1)*srcVal(2)
    ! Linear interpolation on the obtained north and south values
    phi       = (1._rk - targetCoord(2)) * phi_south + targetCoord(2)*phi_north

  end function tem_intp_bilinear_scalar