pure function riemannflux2d_advection_diffusion_2d_t(this,sL,sR,dsdx,nhat) result(flux)
class(advection_diffusion_2d_t),intent(in) :: this
real(prec),intent(in) :: sL(1:this%nvar)
real(prec),intent(in) :: sR(1:this%nvar)
real(prec),intent(in) :: dsdx(1:this%nvar,1:2)
real(prec),intent(in) :: nhat(1:2)
real(prec) :: flux(1:this%nvar)
! Local
integer :: ivar
real(prec) :: un,dsdn
un = this%u*nhat(1)+this%v*nhat(2)
do ivar = 1,this%nvar
dsdn = dsdx(ivar,1)*nhat(1)+dsdx(ivar,2)*nhat(2)
flux(ivar) = 0.5_prec*( &
(sL(ivar)+sR(ivar))+abs(un)*(sL(ivar)-sR(ivar)))- & ! advective flux
this%nu*dsdn
enddo
endfunction riemannflux2d_advection_diffusion_2d_t