subroutine ApplyFlip_MappedScalar3D_t(this,mesh)
! Apply side flips to sides where MPI exchanges took place.
implicit none
class(MappedScalar3D_t),intent(inout) :: this
type(Mesh3D),intent(inout) :: mesh
! Local
integer :: e1,s1,e2,s2
integer :: i,i2,j,j2
integer :: r2,flip,ivar
integer :: bcid
real(prec) :: extBuff(1:this%interp%N+1,1:this%interp%N+1)
do ivar = 1,this%nvar
do e1 = 1,this%nElem
do s1 = 1,6
e2 = mesh%sideInfo(3,s1,e1) ! Neighbor Element
s2 = mesh%sideInfo(4,s1,e1)/10
bcid = mesh%sideInfo(5,s1,e1)
if(e2 > 0) then ! Interior Element
r2 = mesh%decomp%elemToRank(e2) ! Neighbor Rank
if(r2 /= mesh%decomp%rankId) then
flip = mesh%sideInfo(4,s1,e1)-s2*10
! Need to update extBoundary with flip applied
if(flip == 0) then
do j = 1,this%interp%N+1
do i = 1,this%interp%N+1
extBuff(i,j) = this%extBoundary(i,j,s1,e1,ivar)
enddo
enddo
else if(flip == 1) then
do j = 1,this%interp%N+1
do i = 1,this%interp%N+1
i2 = this%interp%N+2-i
j2 = j
extBuff(i,j) = this%extBoundary(i2,j2,s1,e1,ivar)
enddo
enddo
else if(flip == 2) then
do j = 1,this%interp%N+1
do i = 1,this%interp%N+1
i2 = this%interp%N+2-i
j2 = this%interp%N+2-j
extBuff(i,j) = this%extBoundary(i2,j2,s1,e1,ivar)
enddo
enddo
else if(flip == 3) then
do j = 1,this%interp%N+1
do i = 1,this%interp%N+1
i2 = i
j2 = this%interp%N+2-j
extBuff(i,j) = this%extBoundary(i2,j2,s1,e1,ivar)
enddo
enddo
else if(flip == 4) then
do j = 1,this%interp%N+1
do i = 1,this%interp%N+1
extBuff(i,j) = this%extBoundary(j,i,s1,e1,ivar)
enddo
enddo
else if(flip == 5) then
do j = 1,this%interp%N+1
do i = 1,this%interp%N+1
i2 = this%interp%N+2-j
j2 = i
extBuff(i,j) = this%extBoundary(i2,j2,s1,e1,ivar)
enddo
enddo
else if(flip == 6) then
do j = 1,this%interp%N+1
do i = 1,this%interp%N+1
i2 = this%interp%N+2-j
j2 = this%interp%N+2-i
extBuff(i,j) = this%extBoundary(i2,j2,s1,e1,ivar)
enddo
enddo
else if(flip == 7) then
do j = 1,this%interp%N+1
do i = 1,this%interp%N+1
i2 = j
j2 = this%interp%N+2-i
extBuff(i,j) = this%extBoundary(i2,j2,s1,e1,ivar)
enddo
enddo
endif
do j = 1,this%interp%N+1
do i = 1,this%interp%N+1
this%extBoundary(i,j,s1,e1,ivar) = extBuff(i,j)
enddo
enddo
endif
endif
enddo
enddo
enddo
endsubroutine ApplyFlip_MappedScalar3D_t