update_elemPosToTotalPos Subroutine

private subroutine update_elemPosToTotalPos(levelDesc, levelPointer, tree, computeStencil)

Update the found dependencies, which were built for non-ordered lists Out of fluid, ghost and halo lists, the totalList is constructed in an ordered fashion. The element order as in the TotalList is later passed on to the solver.

Arguments

Type IntentOptional Attributes Name
type(tem_levelDesc_type), intent(inout) :: levelDesc(tree%global%minlevel:)

the level descriptor to be filled

integer, intent(in) :: levelPointer(:)

Pointer from original treeID list to level wise fluid list

type(treelmesh_type), intent(in) :: tree

the global tree

type(tem_stencilHeader_type), intent(inout) :: computeStencil(:)

array of all stencils used in the simulation


Calls

proc~~update_elempostototalpos~~CallsGraph proc~update_elempostototalpos update_elemPosToTotalPos proc~update_buffer_elempos update_buffer_elemPos proc~update_elempostototalpos->proc~update_buffer_elempos proc~tem_treeidintotal tem_treeIDinTotal proc~update_elempostototalpos->proc~tem_treeidintotal proc~update_buffer_elempos->proc~tem_treeidintotal proc~tem_etypeofid tem_eTypeOfId proc~tem_treeidintotal->proc~tem_etypeofid tem_positioninsorted tem_positioninsorted proc~tem_treeidintotal->tem_positioninsorted interface~positionofval~5 positionofval proc~tem_etypeofid->interface~positionofval~5 proc~posofval_label posofval_label interface~positionofval~5->proc~posofval_label

Called by

proc~~update_elempostototalpos~~CalledByGraph proc~update_elempostototalpos update_elemPosToTotalPos proc~tem_find_allelements tem_find_allElements proc~tem_find_allelements->proc~update_elempostototalpos proc~tem_create_leveldesc tem_create_levelDesc proc~tem_create_leveldesc->proc~tem_find_allelements proc~tem_dimbydim_construction tem_dimByDim_construction proc~tem_dimbydim_construction->proc~tem_create_leveldesc proc~tem_build_face_info tem_build_face_info proc~tem_build_face_info->proc~tem_dimbydim_construction

Contents


Source Code

  subroutine update_elemPosToTotalPos( levelDesc, levelPointer, tree,          &
    &                                  computeStencil )
    ! ---------------------------------------------------------------------------
    !> the global tree
    type(treelmesh_type), intent(in)            :: tree
    !> Pointer from original treeID list to level wise fluid list
    integer, intent(in)                         :: levelPointer(:)
    !> the level descriptor to be filled
    type(tem_levelDesc_type), intent(inout)     :: levelDesc(tree%global%minlevel:)
    !> array of all stencils used in the simulation
    type(tem_stencilHeader_type), intent(inout) :: computeStencil(:)
    ! ---------------------------------------------------------------------------
    integer :: iLevel, iElem, iStencil, iStencilElem, pos
    integer :: nUpdates, iError
    integer(kind=long_k) :: nTreeID
    logical :: needUpdate
    ! ---------------------------------------------------------------------------
    write(logUnit(3),*) 'Updating dependencies ...'

    ! Update the element positions from the position in the original
    ! elem list to the total list
    do iLevel = tree%global%minlevel, tree%global%maxlevel
      call update_buffer_elemPos( buffer    = levelDesc( iLevel )%sendbuffer,  &
        &                         levelDesc = levelDesc( iLevel ),             &
        &                         iError    = iError )
      if (iError > 0) &
        write(dbgUnit(1),*)  'error in sendbuffer ',iError,' l',iLevel

      call update_buffer_elemPos( buffer    = levelDesc( iLevel )%recvbuffer,  &
        &                         levelDesc = levelDesc( iLevel ),             &
        &                         iError    = iError )
      if( iError > 0 ) &
        write(dbgUnit(1),*) 'error in recvbuffer ',iError,' l',iLevel

      call update_buffer_elemPos(                                              &
        &            buffer    = levelDesc( iLevel )%sendbufferFromCoarser,    &
        &            levelDesc = levelDesc( iLevel ),                          &
        &            iError    = iError )
      if( iError > 0 ) &
        write(dbgUnit(1),*) 'error in sendFCbuff ',iError,' l',iLevel

      call update_buffer_elemPos(                                              &
        &            buffer    = levelDesc( iLevel )%recvbufferFromCoarser,    &
        &            levelDesc = levelDesc( iLevel ),                          &
        &            iError    = iError )
      if( iError > 0 ) &
        write(dbgUnit(1),*) 'error in recvFCbuff ',iError,' l',iLevel

      call update_buffer_elemPos(                                              &
        &            buffer    = levelDesc( iLevel )%sendbufferFromFiner,      &
        &            levelDesc = levelDesc( iLevel ),                          &
        &            iError    = iError )
      if( iError > 0 ) &
        write(dbgUnit(1),*) 'error in sendFFbuff ',iError,' l',iLevel

      call update_buffer_elemPos(                                              &
        &            buffer    = levelDesc( iLevel )%recvbufferFromFiner,      &
        &            levelDesc = levelDesc( iLevel ),                          &
        &            iError    = iError )
      if( iError > 0 ) &
        write(dbgUnit(1),*) 'error in recvFFbuff ',iError,' l',iLevel
    end do ! iLevel

    write(logUnit(4),*) 'Updating the stencil entries'
    ! update stencil elem entry from original treeID list to levelwise fluid
    ! list
    do iStencil = 2, size( computeStencil )
      if( .not. computeStencil( iStencil )%useAll ) then
        do iElem = 1, computeStencil( iStencil )%nElems
          computeStencil( iStencil )%elem%val( iElem ) =                       &
            &   levelPointer( computeStencil( iStencil )%elem%val( iElem ))
        end do
      end if
    end do

    ! Update the totalPos in the element-stencils to the sorted total list
    write(logUnit(4),*) ' Updating entries in the element stencils...'
    nUpdates =  0
    do iLevel = tree%global%minlevel, tree%global%maxlevel
      do iElem = 1, levelDesc(iLevel)%elem%tID%nVals
        do iStencil = 1, levelDesc( iLevel )%elem%stencil%val( iElem )%nVals
          do iStencilElem = 1, levelDesc( iLevel )%elem%stencil%               &
            &                                  val( iElem )%val( iStencil )%QQN
            needUpdate = .false.
            pos = levelDesc( iLevel )%elem%stencil%val( iElem )%               &
              &                        val( iStencil )%totalPos( iStencilElem )
            if( pos > 0 ) then
              nTreeID = levelDesc( iLevel )%elem%tID%val( pos )
              if( pos > levelDesc( iLevel )%nElems ) needUpdate = .true.
              if( .not. needUpdate ) then
                if( levelDesc( iLevel )%total( pos ) /= nTreeID )            &
                  &                                         needUpdate = .true.
              end if
              if( needUpdate ) then
                ! Totalpos needs update!
                nUpdates = nUpdates + 1
                levelDesc( iLevel )%elem%stencil%val( iElem )%                 &
                  &                   val( iStencil )%totalPos( iStencilElem ) &
                  &  = tem_treeIDinTotal( nTreeID, levelDesc( iLevel ))
              end if
            end if ! pos > 0
          end do ! iStencilElem
        end do ! iStencil
      end do ! iElem
    end do ! iLevel
    write(logUnit(8),"(A,I0)") '   Updated nEntries: ', nUpdates
    write(logUnit(8),"(A   )") ' Finished updating dependencies'

   end subroutine update_elemPosToTotalPos