SideExchange_MappedVector2D_t Subroutine

public subroutine SideExchange_MappedVector2D_t(this, mesh)

Arguments

TypeIntentOptionalAttributesName
class(MappedVector2D_t), intent(inout) :: this
type(Mesh2D), intent(inout) :: mesh

Contents


Source Code

  subroutine SideExchange_MappedVector2D_t(this,mesh)
    implicit none
    class(MappedVector2D_t),intent(inout) :: this
    type(Mesh2D),intent(inout) :: mesh
    ! Local
    integer :: e1,e2,s1,s2,e2Global
    integer :: flip,bcid
    integer :: i1,i2,ivar,idir
    integer :: r2
    integer :: rankId,offset
    integer,pointer :: elemtorank(:)

    ! This mapping is needed to resolve a build error with
    ! amdflang that appears to be caused by referencing
    ! the elemToRank attribute within the do concurrent
    ! https://github.com/FluidNumerics/SELF/issues/54
    elemtorank => mesh%decomp%elemToRank(:)

    rankId = mesh%decomp%rankId
    offset = mesh%decomp%offsetElem(rankId+1)

    if(mesh%decomp%mpiEnabled) then
      call this%MPIExchangeAsync(mesh)
    endif

    do concurrent(s1=1:4,e1=1:mesh%nElem,ivar=1:this%nvar,idir=1:2)

      e2Global = mesh%sideInfo(3,s1,e1)
      e2 = e2Global-offset
      s2 = mesh%sideInfo(4,s1,e1)/10
      flip = mesh%sideInfo(4,s1,e1)-s2*10
      bcid = mesh%sideInfo(5,s1,e1)

      if(e2Global > 0) then

        r2 = elemToRank(e2Global) ! Neighbor rank
        if(r2 == mesh%decomp%rankId) then

          if(flip == 0) then

            do i1 = 1,this%interp%N+1
              this%extBoundary(i1,s1,e1,ivar,idir) = &
                this%boundary(i1,s2,e2,ivar,idir)
            enddo

          elseif(flip == 1) then

            do i1 = 1,this%interp%N+1
              i2 = this%interp%N+2-i1
              this%extBoundary(i1,s1,e1,ivar,idir) = &
                this%boundary(i2,s2,e2,ivar,idir)
            enddo

          endif

        endif

      endif

    enddo

    if(mesh%decomp%mpiEnabled) then
      call mesh%decomp%FinalizeMPIExchangeAsync()
      ! Apply side flips for data exchanged with MPI
      call this%ApplyFlip(mesh)
    endif

  endsubroutine SideExchange_MappedVector2D_t