Calculates the gradient of a function using the strong form of the gradient in mapped coordinates.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(MappedScalar2D_t), | intent(in) | :: | this | |||
real(kind=prec), | intent(out) | :: | df(1:this%N+1,1:this%N+1,1:this%nelem,1:this%nvar,1:2) |
subroutine MappedGradient_MappedScalar2D_t(this,df)
!! Calculates the gradient of a function using the strong form of the gradient
!! in mapped coordinates.
implicit none
class(MappedScalar2D_t),intent(in) :: this
real(prec),intent(out) :: df(1:this%N+1,1:this%N+1,1:this%nelem,1:this%nvar,1:2)
! Local
integer :: iEl,iVar,i,j,ii,idir
real(prec) :: dfdx,ja
do concurrent(i=1:this%N+1,j=1:this%N+1,iel=1:this%nElem,ivar=1:this%nVar,idir=1:2)
dfdx = 0.0_prec
do ii = 1,this%N+1
! dsdx(j,i) is contravariant vector i, component j
ja = this%geometry%dsdx%interior(ii,j,iel,1,idir,1)
dfdx = dfdx+this%interp%dMatrix(ii,i)*this%interior(ii,j,iel,ivar)*ja
enddo
df(i,j,iel,ivar,idir) = dfdx
enddo
do concurrent(i=1:this%N+1,j=1:this%N+1,iel=1:this%nElem,ivar=1:this%nVar,idir=1:2)
dfdx = 0.0_prec
do ii = 1,this%N+1
ja = this%geometry%dsdx%interior(i,ii,iel,1,idir,2)
dfdx = dfdx+this%interp%dMatrix(ii,j)*this%interior(i,ii,iel,ivar)*ja
enddo
df(i,j,iel,ivar,idir) = (df(i,j,iel,ivar,idir)+dfdx)/this%geometry%J%interior(i,j,iEl,1)
enddo
endsubroutine MappedGradient_MappedScalar2D_t