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~3~~CallsGraph proc~find_neighb~3 find_neighb proc~mg_ix_to_ichild~3 mg_ix_to_ichild proc~find_neighb~3->proc~mg_ix_to_ichild~3

Called by

proc~~find_neighb~3~~CalledByGraph proc~find_neighb~3 find_neighb proc~set_neighbs~3 set_neighbs proc~set_neighbs~3->proc~find_neighb~3 proc~mg_set_neighbors_lvl~3 mg_set_neighbors_lvl proc~mg_set_neighbors_lvl~3->proc~set_neighbs~3 proc~mg_build_rectangle~3 mg_build_rectangle proc~mg_build_rectangle~3->proc~mg_set_neighbors_lvl~3 proc~mg_tree_from_amrvac mg_tree_from_amrvac proc~mg_tree_from_amrvac->proc~mg_set_neighbors_lvl~3 proc~mg_tree_from_amrvac->proc~mg_build_rectangle~3 proc~mg_setup_multigrid mg_setup_multigrid proc~mg_setup_multigrid->proc~mg_tree_from_amrvac proc~mg_update_refinement mg_update_refinement proc~mg_update_refinement->proc~mg_tree_from_amrvac proc~amr_coarsen_refine amr_coarsen_refine proc~amr_coarsen_refine->proc~mg_update_refinement proc~improve_initial_condition improve_initial_condition proc~improve_initial_condition->proc~mg_setup_multigrid proc~main main proc~main->proc~mg_setup_multigrid proc~main->proc~improve_initial_condition proc~resettree_convert resettree_convert proc~main->proc~resettree_convert proc~settree settree proc~main->proc~settree proc~timeintegration timeintegration proc~main->proc~timeintegration proc~resettree resettree proc~resettree->proc~amr_coarsen_refine proc~resettree_convert->proc~amr_coarsen_refine proc~settree->proc~amr_coarsen_refine program~agile agile program~agile->proc~main proc~timeintegration->proc~resettree

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