MappedGradient_MappedScalar3D_t Subroutine

public subroutine MappedGradient_MappedScalar3D_t(this, df)

Calculates the gradient of a function using the strong form of the gradient in mapped coordinates.

Arguments

TypeIntentOptionalAttributesName
class(MappedScalar3D_t), intent(in) :: this
real(kind=prec), intent(out) :: df(1:this%N+1,1:this%N+1,1:this%N+1,1:this%nelem,1:this%nvar,1:3)

Contents


Source Code

  subroutine MappedGradient_MappedScalar3D_t(this,df)
  !! Calculates the gradient of a function using the strong form of the gradient
  !! in mapped coordinates.
    implicit none
    class(MappedScalar3D_t),intent(in) :: this
    real(prec),intent(out) :: df(1:this%N+1,1:this%N+1,1:this%N+1,1:this%nelem,1:this%nvar,1:3)
    ! Local
    integer :: iEl,iVar,i,j,k,ii,idir
    real(prec) :: dfdx,ja

    do concurrent(i=1:this%N+1,j=1:this%N+1, &
                  k=1:this%N+1,iel=1:this%nelem,ivar=1:this%nvar,idir=1:3)

      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,k,iel,1,idir,1)
        dfdx = dfdx+this%interp%dMatrix(ii,i)* &
               this%interior(ii,j,k,iel,ivar)*ja

      enddo
      df(i,j,k,iel,ivar,idir) = dfdx

    enddo

    do concurrent(i=1:this%N+1,j=1:this%N+1, &
                  k=1:this%N+1,iel=1:this%nelem,ivar=1:this%nvar,idir=1:3)

      dfdx = 0.0_prec
      do ii = 1,this%N+1
        ja = this%geometry%dsdx%interior(i,ii,k,iel,1,idir,2)
        dfdx = dfdx+this%interp%dMatrix(ii,j)* &
               this%interior(i,ii,k,iel,ivar)*ja
      enddo
      df(i,j,k,iel,ivar,idir) = (df(i,j,k,iel,ivar,idir)+dfdx)

    enddo

    do concurrent(i=1:this%N+1,j=1:this%N+1, &
                  k=1:this%N+1,iel=1:this%nelem,ivar=1:this%nvar,idir=1:3)

      dfdx = 0.0_prec
      do ii = 1,this%N+1
        ja = this%geometry%dsdx%interior(i,j,ii,iel,1,idir,3)
        dfdx = dfdx+this%interp%dMatrix(ii,k)* &
               this%interior(i,j,ii,iel,ivar)*ja
      enddo
      df(i,j,k,iel,ivar,idir) = (df(i,j,k,iel,ivar,idir)+dfdx)/ &
                                this%geometry%J%interior(i,j,k,iEl,1)

    enddo

  endsubroutine MappedGradient_MappedScalar3D_t