box_gc_for_fine_neighbor Subroutine

private subroutine box_gc_for_fine_neighbor(box, nb, di, nc, iv, gc)

Get ghost cells for a fine neighbor

Arguments

Type IntentOptional Attributes Name
type(mg_box_t), intent(in) :: box
integer, intent(in) :: nb

Direction of fine neighbor

integer, intent(in) :: di(3)

Index offset of fine neighbor

integer, intent(in) :: nc
integer, intent(in) :: iv
real(kind=dp), intent(out) :: gc(nc,nc)

Called by

proc~~box_gc_for_fine_neighbor~3~~CalledByGraph proc~box_gc_for_fine_neighbor~3 box_gc_for_fine_neighbor proc~buffer_for_fine_nb~3 buffer_for_fine_nb proc~buffer_for_fine_nb~3->proc~box_gc_for_fine_neighbor~3 proc~fill_refinement_bnd~3 fill_refinement_bnd proc~fill_refinement_bnd~3->proc~box_gc_for_fine_neighbor~3 proc~buffer_refinement_boundaries~3 buffer_refinement_boundaries proc~buffer_refinement_boundaries~3->proc~buffer_for_fine_nb~3 proc~set_ghost_cells~3 set_ghost_cells proc~set_ghost_cells~3->proc~fill_refinement_bnd~3 proc~mg_fill_ghost_cells_lvl~3 mg_fill_ghost_cells_lvl proc~mg_fill_ghost_cells_lvl~3->proc~buffer_refinement_boundaries~3 proc~mg_fill_ghost_cells_lvl~3->proc~set_ghost_cells~3 proc~mg_ghost_cell_buffer_size~3 mg_ghost_cell_buffer_size proc~mg_ghost_cell_buffer_size~3->proc~buffer_refinement_boundaries~3 proc~mg_ghost_cell_buffer_size~3->proc~set_ghost_cells~3 proc~mg_allocate_storage~3 mg_allocate_storage proc~mg_allocate_storage~3->proc~mg_ghost_cell_buffer_size~3 proc~mg_fas_fmg~3 mg_fas_fmg proc~mg_fas_fmg~3->proc~mg_fill_ghost_cells_lvl~3 proc~mg_fas_vcycle~3 mg_fas_vcycle proc~mg_fas_fmg~3->proc~mg_fas_vcycle~3 proc~update_coarse~3 update_coarse proc~mg_fas_fmg~3->proc~update_coarse~3 proc~mg_fas_vcycle~3->proc~mg_fill_ghost_cells_lvl~3 proc~smooth_boxes~3 smooth_boxes proc~mg_fas_vcycle~3->proc~smooth_boxes~3 proc~mg_fas_vcycle~3->proc~update_coarse~3 proc~mg_fill_ghost_cells~3 mg_fill_ghost_cells proc~mg_fill_ghost_cells~3->proc~mg_fill_ghost_cells_lvl~3 proc~smooth_boxes~3->proc~mg_fill_ghost_cells_lvl~3 proc~update_coarse~3->proc~mg_fill_ghost_cells_lvl~3 proc~diffusion_solve_acoeff~3 diffusion_solve_acoeff proc~diffusion_solve_acoeff~3->proc~mg_fas_fmg~3 proc~diffusion_solve_acoeff~3->proc~mg_fas_vcycle~3 proc~diffusion_solve_vcoeff~3 diffusion_solve_vcoeff proc~diffusion_solve_vcoeff~3->proc~mg_fas_fmg~3 proc~diffusion_solve_vcoeff~3->proc~mg_fas_vcycle~3 proc~diffusion_solve~3 diffusion_solve proc~diffusion_solve~3->proc~mg_fas_fmg~3 proc~diffusion_solve~3->proc~mg_fas_vcycle~3 proc~mg_copy_to_tree mg_copy_to_tree proc~mg_copy_to_tree->proc~mg_fill_ghost_cells~3 proc~mg_tree_from_amrvac mg_tree_from_amrvac proc~mg_tree_from_amrvac->proc~mg_allocate_storage~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

  subroutine box_gc_for_fine_neighbor(box, nb, di, nc, iv, gc)
    type(mg_box_t), intent(in) :: box
    integer, intent(in)     :: nb
    !< Direction of fine neighbor
    integer, intent(in)     :: di(3)
    !< Index offset of fine neighbor
    integer, intent(in)     :: nc, iv
    real(dp), intent(out)   :: gc(nc, nc)
    real(dp)                :: tmp(0:nc/2+1, 0:nc/2+1), grad(3-1)
    integer                 :: i, j, hnc

    hnc = nc/2

    ! First fill a temporary array with data next to the fine grid
    select case (nb)
    case (mg_neighb_lowx)
       tmp = box%cc(1, di(2):di(2)+hnc+1, di(3):di(3)+hnc+1, iv)
    case (mg_neighb_highx)
       tmp = box%cc(nc, di(2):di(2)+hnc+1, di(3):di(3)+hnc+1, iv)
    case (mg_neighb_lowy)
       tmp = box%cc(di(1):di(1)+hnc+1, 1, di(3):di(3)+hnc+1, iv)
    case (mg_neighb_highy)
       tmp = box%cc(di(1):di(1)+hnc+1, nc, di(3):di(3)+hnc+1, iv)
    case (mg_neighb_lowz)
       tmp = box%cc(di(1):di(1)+hnc+1, di(2):di(2)+hnc+1, 1, iv)
    case (mg_neighb_highz)
       tmp = box%cc(di(1):di(1)+hnc+1, di(2):di(2)+hnc+1, nc, iv)
    case default
       error stop
    end select

    ! Now interpolate the coarse grid data to obtain values 'straight' next to
    ! the fine grid points
    do j = 1, hnc
       do i = 1, hnc
          grad(1)          = 0.125_dp * (tmp(i+1, j) - tmp(i-1, j))
          grad(2)          = 0.125_dp * (tmp(i, j+1) - tmp(i, j-1))
          gc(2*i-1, 2*j-1) = tmp(i, j) - grad(1) - grad(2)
          gc(2*i, 2*j-1)   = tmp(i, j) + grad(1) - grad(2)
          gc(2*i-1, 2*j)   = tmp(i, j) - grad(1) + grad(2)
          gc(2*i, 2*j)     = tmp(i, j) + grad(1) + grad(2)
       end do
    end do
  end subroutine box_gc_for_fine_neighbor