bc_to_gc Subroutine

private subroutine bc_to_gc(mg, id, nc, iv, nb, bc_type)

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg
integer, intent(in) :: id
integer, intent(in) :: nc
integer, intent(in) :: iv
integer, intent(in) :: nb

Neighbor direction

integer, intent(in) :: bc_type

Type of b.c.


Called by

proc~~bc_to_gc~3~~CalledByGraph proc~bc_to_gc~3 bc_to_gc proc~set_ghost_cells~3 set_ghost_cells proc~set_ghost_cells~3->proc~bc_to_gc~3 proc~mg_fill_ghost_cells_lvl~3 mg_fill_ghost_cells_lvl 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~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 bc_to_gc(mg, id, nc, iv, nb, bc_type)
    type(mg_t), intent(inout) :: mg
    integer, intent(in)       :: id
    integer, intent(in)       :: nc
    integer, intent(in)       :: iv
    integer, intent(in)       :: nb
    !< Neighbor direction
    integer, intent(in)       :: bc_type
    !< Type of b.c.
    real(dp)                  :: c0, c1, c2, dr

    ! If we call the interior point x1, x2 and the ghost point x0, then a
    ! Dirichlet boundary value b can be imposed as:
    ! x0 = -x1 + 2*b
    ! A Neumann b.c. can be imposed as:
    ! x0 = x1 +/- dx * b
    ! A continuous boundary (same slope) as:
    ! x0 = 2 * x1 - x2
    ! Below, we set coefficients to handle these cases
    select case (bc_type)
    case (mg_bc_dirichlet)
       c0 = 2
       c1 = -1
       c2 = 0
    case (mg_bc_neumann)
       dr = mg%dr(mg_neighb_dim(nb), mg%boxes(id)%lvl)
       c0 = dr * mg_neighb_high_pm(nb) ! This gives a + or - sign
       c1 = 1
       c2 = 0
    case (mg_bc_continuous)
       c0 = 0
       c1 = 2
       c2 = -1
    case default
       error stop "bc_to_gc: unknown boundary condition"
    end select

    select case (nb)
    case (mg_neighb_lowx)
       mg%boxes(id)%cc(0, 1:nc, 1:nc, iv) = c0 * mg%boxes(id)%cc(0, 1:nc, 1:nc,&
           iv) + c1 * mg%boxes(id)%cc(1, 1:nc, 1:nc,&
           iv) + c2 * mg%boxes(id)%cc(2, 1:nc, 1:nc, iv)
    case (mg_neighb_highx)
       mg%boxes(id)%cc(nc+1, 1:nc, 1:nc, iv) = c0 * mg%boxes(id)%cc(nc+1, 1:nc,&
           1:nc, iv) + c1 * mg%boxes(id)%cc(nc, 1:nc, 1:nc,&
           iv) + c2 * mg%boxes(id)%cc(nc-1, 1:nc, 1:nc, iv)
    case (mg_neighb_lowy)
       mg%boxes(id)%cc(1:nc, 0, 1:nc, iv) = c0 * mg%boxes(id)%cc(1:nc, 0, 1:nc,&
           iv) + c1 * mg%boxes(id)%cc(1:nc, 1, 1:nc,&
           iv) + c2 * mg%boxes(id)%cc(1:nc, 2, 1:nc, iv)
    case (mg_neighb_highy)
       mg%boxes(id)%cc(1:nc, nc+1, 1:nc, iv) = c0 * mg%boxes(id)%cc(1:nc, nc+1,&
           1:nc, iv) + c1 * mg%boxes(id)%cc(1:nc, nc, 1:nc,&
           iv) + c2 * mg%boxes(id)%cc(1:nc, nc-1, 1:nc, iv)
    case (mg_neighb_lowz)
       mg%boxes(id)%cc(1:nc, 1:nc, 0, iv) = c0 * mg%boxes(id)%cc(1:nc, 1:nc, 0,&
           iv) + c1 * mg%boxes(id)%cc(1:nc, 1:nc, 1,&
           iv) + c2 * mg%boxes(id)%cc(1:nc, 1:nc, 2, iv)
    case (mg_neighb_highz)
       mg%boxes(id)%cc(1:nc, 1:nc, nc+1, iv) = c0 * mg%boxes(id)%cc(1:nc, 1:nc,&
           nc+1, iv) + c1 * mg%boxes(id)%cc(1:nc, 1:nc, nc,&
           iv) + c2 * mg%boxes(id)%cc(1:nc, 1:nc, nc-1, iv)
    end select
  end subroutine bc_to_gc