find_neighb Function

private function find_neighb(boxes, id, nb) result(nb_id)

Get the id of neighbor nb of boxes(id), through its parent

Arguments

Type IntentOptional Attributes Name
type(mg_box_t), intent(in) :: boxes(:)

List with all the boxes

integer, intent(in) :: id

Box whose neighbor we are looking for

integer, intent(in) :: nb

Neighbor index

Return Value integer


Calls

proc~~find_neighb~~CallsGraph proc~find_neighb find_neighb proc~mg_ix_to_ichild mg_ix_to_ichild proc~find_neighb->proc~mg_ix_to_ichild

Called by

proc~~find_neighb~~CalledByGraph proc~find_neighb find_neighb proc~set_neighbs set_neighbs proc~set_neighbs->proc~find_neighb proc~mg_set_neighbors_lvl mg_set_neighbors_lvl proc~mg_set_neighbors_lvl->proc~set_neighbs proc~mg_build_rectangle mg_build_rectangle proc~mg_build_rectangle->proc~mg_set_neighbors_lvl

Source Code

  function find_neighb(boxes, id, nb) result(nb_id)
    type(mg_box_t), intent(in) :: boxes(:)
    !< List with all the boxes
    integer, intent(in)      :: id
    !< Box whose neighbor we are looking for
    integer, intent(in)      :: nb
    !< Neighbor index
    integer                  :: nb_id, p_id, c_ix, d, old_pid

    p_id    = boxes(id)%parent
    old_pid = p_id
    c_ix    = mg_ix_to_ichild(boxes(id)%ix)
    d       = mg_neighb_dim(nb)

    ! Check if neighbor is in same direction as ix is (low/high). If so,
    ! use neighbor of parent
    if (mg_child_low(d, c_ix) .eqv. mg_neighb_low(nb)) then
       p_id = boxes(p_id)%neighbors(nb)
    end if

    ! The child ix of the neighbor is reversed in direction d
    nb_id = boxes(p_id)%children(mg_child_rev(c_ix, d))
  end function find_neighb