exchange_elements Subroutine

public subroutine exchange_elements(me, sparta)

Exchange mesh elements with other process The following data within treelmesh_type is updated in this routine: treeID, ElemPropertyBits, Part_First, Part_Last Data pathList is deallocated.

Arguments

Type IntentOptional Attributes Name
type(treelmesh_type), intent(inout) :: me

Tree Mesh type nElems and offset should be ready before this routine

type(tem_sparta_type), intent(in) :: sparta

How many elements to exchange with other processes


Source Code

  subroutine exchange_elements( me, sparta )
    ! -------------------------------------------------------------------- !
    !> Tree Mesh type
    !! nElems and offset should be ready before this routine
    type( treelmesh_type ), intent(inout) :: me
    !> How many elements to exchange with other processes
    type( tem_sparta_type ), intent(in) :: sparta
    ! -------------------------------------------------------------------- !
    integer :: iError, iProp
    ! -------------------------------------------------------------------- !

    ! Exchange treeID and propertyBits ---------------------------------
    call tem_exchange_sparta( me = sparta, &
      &                       val = me%treeID, &
      &                       nComponents = 1, &
      &                       comm = me%global%comm )
    call tem_exchange_sparta( me = sparta, &
      &                       val = me%ElemPropertyBits, &
      &                       nComponents = 1, &
      &                       comm = me%global%comm )
    ! Exchange treeID and propertyBits ---------------------------------

    ! Update Part_first and Part_Last ------------------------
    call MPI_allgather( me%treeID(1), 1, long_k_mpi,  &
      &                 me%Part_First, 1, long_k_mpi, &
      &                 me%global%comm, iError        )
    call MPI_allgather( me%treeID(me%nElems), 1, long_k_mpi, &
      &                 me%Part_Last, 1, long_k_mpi,         &
      &                 me%global%comm, iError               )
    ! Update Part_first and Part_Last ------------------------

    do iProp=1,me%global%nProperties
      call gather_Property( Property = me%Property(iProp),                     &
        &                   Header   = me%global%Property(iProp),              &
        &                   BitField = me%ElemPropertyBits,                    &
        &                   comm     = me%global%comm )
    end do

    if (allocated(me%pathList)) deallocate( me%pathList  )

  end subroutine exchange_elements