Get the id of neighbor nb of boxes(id), through its parent
| Type | Intent | Optional | 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 |
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