| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mg_t), | intent(inout) | :: | mg | |||
| integer, | intent(in) | :: | id |
Id of box that gets children |
subroutine mg_add_children(mg, id) type(mg_t), intent(inout) :: mg integer, intent(in) :: id !< Id of box that gets children integer :: lvl, i, nb, child_nb(2**(3-1)) integer :: c_ids(mg_num_children) integer :: c_id, c_ix_base(3) if (mg%n_boxes + mg_num_children > size(mg%boxes)) then error stop "mg_add_children: not enough space" end if c_ids = [(mg%n_boxes+i, i=1,mg_num_children)] mg%n_boxes = mg%n_boxes + mg_num_children mg%boxes(id)%children = c_ids c_ix_base = 2 * mg%boxes(id)%ix - 1 lvl = mg%boxes(id)%lvl+1 do i = 1, mg_num_children c_id = c_ids(i) mg%boxes(c_id)%rank = mg%boxes(id)%rank mg%boxes(c_id)%ix = c_ix_base + mg_child_dix(:, i) mg%boxes(c_id)%lvl = lvl mg%boxes(c_id)%parent = id mg%boxes(c_id)%children = mg_no_box mg%boxes(c_id)%neighbors = mg_no_box mg%boxes(c_id)%r_min = mg%boxes(id)%r_min + mg%dr(:,& lvl) * mg_child_dix(:, i) * mg%box_size mg%boxes(c_id)%dr(:) = mg%dr(:, lvl) end do ! Set boundary conditions at children do nb = 1, mg_num_neighbors if (mg%boxes(id)%neighbors(nb) < mg_no_box) then child_nb = c_ids(mg_child_adj_nb(:, nb)) ! Neighboring children mg%boxes(child_nb)%neighbors(nb) = mg%boxes(id)%neighbors(nb) end if end do end subroutine mg_add_children