晚安; 我正在尝试将一些 fortran 代码转换为 matlab,但我不明白什么
ist = grp%brp%faceIndicatorArray(-20)
ien = grp%brp%faceIndicatorArray(-19)
表示在下面的子程序中。我不习惯matlab中的负索引,所以这个(-20)和(-19)对应于数组中的哪个元素或什么?这是所有子程序:
subroutine calculateLiftAndDrag(grp,ivd,lift,drag,momentum)
! as the name says
IMPLICIT NONE
type(GridSolverData) :: grp
type(InputVariablesData) :: ivd
real :: lift,drag,momentum
integer :: i,ist,ien,ip
real :: flowTangent(2),flowNormal(2),wallTangent(2),wallNormal(2),r(2)
real :: p,tau_t,tau_n,PI,alphaRad,sum
lift = 0.0
drag = 0.0
momentum = 0.0
PI = 4.0*atan(1.0)
alphaRad = ivd%alpha*PI/180.
flowTangent(1) = cos(alphaRad)
flowTangent(2) = sin(alphaRad)
flowNormal(1) = - flowTangent(2)
flowNormal(2) = flowTangent(1)
! inviscid faces
ist = grp%brp%faceIndicatorArray(-20)
ien = grp%brp%faceIndicatorArray(-19)
do i=ist,ien
ip = grp%brp%faceIndicatorArray(i)
wallTangent(1) = grp%brp%faceTangentArray(ip,1)
wallTangent(2) = grp%brp%faceTangentArray(ip,2)
wallNormal(1) = -wallTangent(2)
wallNormal(2) = wallTangent(1)
p = grp%p(ip)
r = grp%coordinates(ip,:)-ivd%momentumPoint
lift = lift - 2.0*grp%wallLength(ip)*p(wallNormal(1)*flowNormal(1)+wallNormal(2)*flowNormal(2))
drag = drag - 2.0*grp%wallLength(ip)*p*(wallNormal(1)*flowTangent(1)+wallNormal(2)*flowTangent(2))
momentum = momentum - 2.0*grp%wallLength(ip)*p*(r(1)*wallNormal(2)-r(2)*wallNormal(1))
end do
如果有人可以提供帮助,我会很高兴。先感谢您。