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~2~~CalledByGraph proc~bc_to_gc~2 bc_to_gc proc~set_ghost_cells~2 set_ghost_cells proc~set_ghost_cells~2->proc~bc_to_gc~2 proc~mg_fill_ghost_cells_lvl~2 mg_fill_ghost_cells_lvl proc~mg_fill_ghost_cells_lvl~2->proc~set_ghost_cells~2 proc~mg_ghost_cell_buffer_size~2 mg_ghost_cell_buffer_size proc~mg_ghost_cell_buffer_size~2->proc~set_ghost_cells~2 proc~mg_allocate_storage~2 mg_allocate_storage proc~mg_allocate_storage~2->proc~mg_ghost_cell_buffer_size~2 proc~mg_fas_fmg~2 mg_fas_fmg proc~mg_fas_fmg~2->proc~mg_fill_ghost_cells_lvl~2 proc~mg_fas_vcycle~2 mg_fas_vcycle proc~mg_fas_fmg~2->proc~mg_fas_vcycle~2 proc~update_coarse~2 update_coarse proc~mg_fas_fmg~2->proc~update_coarse~2 proc~mg_fas_vcycle~2->proc~mg_fill_ghost_cells_lvl~2 proc~smooth_boxes~2 smooth_boxes proc~mg_fas_vcycle~2->proc~smooth_boxes~2 proc~mg_fas_vcycle~2->proc~update_coarse~2 proc~mg_fill_ghost_cells~2 mg_fill_ghost_cells proc~mg_fill_ghost_cells~2->proc~mg_fill_ghost_cells_lvl~2 proc~smooth_boxes~2->proc~mg_fill_ghost_cells_lvl~2 proc~update_coarse~2->proc~mg_fill_ghost_cells_lvl~2 proc~diffusion_solve_acoeff~2 diffusion_solve_acoeff proc~diffusion_solve_acoeff~2->proc~mg_fas_fmg~2 proc~diffusion_solve_acoeff~2->proc~mg_fas_vcycle~2 proc~diffusion_solve_vcoeff~2 diffusion_solve_vcoeff proc~diffusion_solve_vcoeff~2->proc~mg_fas_fmg~2 proc~diffusion_solve_vcoeff~2->proc~mg_fas_vcycle~2 proc~diffusion_solve~2 diffusion_solve proc~diffusion_solve~2->proc~mg_fas_fmg~2 proc~diffusion_solve~2->proc~mg_fas_vcycle~2

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, iv) = c0 * mg%boxes(id)%cc(0,&
           iv) + c1 * mg%boxes(id)%cc(1, iv) + c2 * mg%boxes(id)%cc(2, iv)
    case (mg_neighb_highx)
       mg%boxes(id)%cc(nc+1, iv) = c0 * mg%boxes(id)%cc(nc+1,&
           iv) + c1 * mg%boxes(id)%cc(nc, iv) + c2 * mg%boxes(id)%cc(nc-1, iv)
    end select
  end subroutine bc_to_gc