Calculates the gradient of a function using the weak form of the gradient and the average boundary state. This method will compute the average boundary state from the and attributes of
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
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) |
subroutine MappedDGGradient_MappedScalar3D_t(this,df)
!! Calculates the gradient of a function using the weak form of the gradient
!! and the average boundary state.
!! This method will compute the average boundary state from the
!! and attributes of
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,jaf,bfl,bfr
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
jaf = this%geometry%dsdx%interior(ii,j,k,iel,1,idir,1)* &
this%interior(ii,j,k,iel,ivar)
dfdx = dfdx+this%interp%dgMatrix(ii,i)*jaf
enddo
bfl = this%avgboundary(j,k,5,iel,ivar)* &
this%geometry%dsdx%boundary(j,k,5,iel,1,idir,1) ! west
bfr = this%avgboundary(j,k,3,iel,ivar)* &
this%geometry%dsdx%boundary(j,k,3,iel,1,idir,1) ! east
df(i,j,k,iel,ivar,idir) = dfdx+ &
(this%interp%bMatrix(i,1)*bfl+ &
this%interp%bMatrix(i,2)*bfr)/this%interp%qweights(i)
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
jaf = this%geometry%dsdx%interior(i,ii,k,iel,1,idir,2)* &
this%interior(i,ii,k,iel,ivar)
dfdx = dfdx+this%interp%dgMatrix(ii,j)*jaf
enddo
bfl = this%avgboundary(i,k,2,iel,ivar)* &
this%geometry%dsdx%boundary(i,k,2,iel,1,idir,2) ! south
bfr = this%avgboundary(i,k,4,iel,ivar)* &
this%geometry%dsdx%boundary(i,k,4,iel,1,idir,2) ! north
dfdx = dfdx+(this%interp%bMatrix(j,1)*bfl+ &
this%interp%bMatrix(j,2)*bfr)/this%interp%qweights(j)
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
jaf = this%geometry%dsdx%interior(i,j,ii,iel,1,idir,3)* &
this%interior(i,j,ii,iel,ivar)
dfdx = dfdx+this%interp%dgMatrix(ii,k)*jaf
enddo
bfl = this%avgboundary(i,j,1,iel,ivar)* &
this%geometry%dsdx%boundary(i,j,1,iel,1,idir,3) ! bottom
bfr = this%avgboundary(i,j,6,iel,ivar)* &
this%geometry%dsdx%boundary(i,j,6,iel,1,idir,3) ! top
dfdx = dfdx+(this%interp%bMatrix(k,1)*bfl+ &
this%interp%bMatrix(k,2)*bfr)/this%interp%qweights(k)
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 MappedDGGradient_MappedScalar3D_t