mg_copy_to_tree Subroutine

public subroutine mg_copy_to_tree(iw_from, iw_to, restrict, restrict_gc, factor, state_from)

Uses

  • proc~~mg_copy_to_tree~~UsesGraph proc~mg_copy_to_tree mg_copy_to_tree module~mod_forest mod_forest proc~mg_copy_to_tree->module~mod_forest module~mod_global_parameters mod_global_parameters proc~mg_copy_to_tree->module~mod_global_parameters module~mod_basic_types mod_basic_types module~mod_global_parameters->module~mod_basic_types module~mod_connectivity mod_connectivity module~mod_global_parameters->module~mod_connectivity module~mod_constants mod_constants module~mod_global_parameters->module~mod_constants module~mod_physicaldata mod_physicaldata module~mod_global_parameters->module~mod_physicaldata module~mod_variables mod_variables module~mod_global_parameters->module~mod_variables mpi mpi module~mod_global_parameters->mpi module~mod_variables->module~mod_basic_types

Copy a variable to the multigrid tree, including a layer of ghost cells

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: iw_from

Variable to use as right-hand side

integer, intent(in) :: iw_to

Copy to this variable

logical, intent(in), optional :: restrict

Restrict variable on multigrid tree

logical, intent(in), optional :: restrict_gc

Fill ghost cells after restrict

real(kind=dp), intent(in), optional :: factor

out = factor * in

type(state), intent(in), optional, target :: state_from(max_blocks)

If present, use this as the input state


Calls

proc~~mg_copy_to_tree~~CallsGraph proc~mg_copy_to_tree mg_copy_to_tree proc~mg_fill_ghost_cells~3 mg_fill_ghost_cells proc~mg_copy_to_tree->proc~mg_fill_ghost_cells~3 proc~mg_restrict~3 mg_restrict proc~mg_copy_to_tree->proc~mg_restrict~3 proc~mg_fill_ghost_cells_lvl~3 mg_fill_ghost_cells_lvl proc~mg_fill_ghost_cells~3->proc~mg_fill_ghost_cells_lvl~3 proc~mg_restrict_lvl~3 mg_restrict_lvl proc~mg_restrict~3->proc~mg_restrict_lvl~3 proc~buffer_ghost_cells~3 buffer_ghost_cells proc~mg_fill_ghost_cells_lvl~3->proc~buffer_ghost_cells~3 proc~buffer_refinement_boundaries~3 buffer_refinement_boundaries proc~mg_fill_ghost_cells_lvl~3->proc~buffer_refinement_boundaries~3 proc~set_ghost_cells~3 set_ghost_cells proc~mg_fill_ghost_cells_lvl~3->proc~set_ghost_cells~3 proc~sort_and_transfer_buffers~3 sort_and_transfer_buffers proc~mg_fill_ghost_cells_lvl~3->proc~sort_and_transfer_buffers~3 proc~restrict_onto~3 restrict_onto proc~mg_restrict_lvl~3->proc~restrict_onto~3 proc~restrict_set_buffer~3 restrict_set_buffer proc~mg_restrict_lvl~3->proc~restrict_set_buffer~3 proc~mg_restrict_lvl~3->proc~sort_and_transfer_buffers~3 proc~buffer_for_nb~3 buffer_for_nb proc~buffer_ghost_cells~3->proc~buffer_for_nb~3 proc~buffer_for_fine_nb~3 buffer_for_fine_nb proc~buffer_refinement_boundaries~3->proc~buffer_for_fine_nb~3 proc~mg_has_children~3 mg_has_children proc~buffer_refinement_boundaries~3->proc~mg_has_children~3 proc~mg_get_child_offset~3 mg_get_child_offset proc~restrict_onto~3->proc~mg_get_child_offset~3 proc~mg_ix_to_ichild~3 mg_ix_to_ichild proc~restrict_set_buffer~3->proc~mg_ix_to_ichild~3 proc~bc_to_gc~3 bc_to_gc proc~set_ghost_cells~3->proc~bc_to_gc~3 proc~box_get_gc~3 box_get_gc proc~set_ghost_cells~3->proc~box_get_gc~3 proc~box_set_gc~3 box_set_gc proc~set_ghost_cells~3->proc~box_set_gc~3 proc~copy_from_nb~3 copy_from_nb proc~set_ghost_cells~3->proc~copy_from_nb~3 proc~fill_buffered_nb~3 fill_buffered_nb proc~set_ghost_cells~3->proc~fill_buffered_nb~3 proc~fill_refinement_bnd~3 fill_refinement_bnd proc~set_ghost_cells~3->proc~fill_refinement_bnd~3 mpi_waitall mpi_waitall proc~sort_and_transfer_buffers~3->mpi_waitall proc~mpi_irecv_wrapper mpi_irecv_wrapper proc~sort_and_transfer_buffers~3->proc~mpi_irecv_wrapper proc~mpi_isend_wrapper mpi_isend_wrapper proc~sort_and_transfer_buffers~3->proc~mpi_isend_wrapper proc~sort_sendbuf~3 sort_sendbuf proc~sort_and_transfer_buffers~3->proc~sort_sendbuf~3 proc~buffer_for_fine_nb~3->proc~mg_get_child_offset~3 proc~box_gc_for_fine_neighbor~3 box_gc_for_fine_neighbor proc~buffer_for_fine_nb~3->proc~box_gc_for_fine_neighbor~3 proc~box_gc_for_neighbor~3 box_gc_for_neighbor proc~buffer_for_nb~3->proc~box_gc_for_neighbor~3 proc~copy_from_nb~3->proc~box_set_gc~3 proc~copy_from_nb~3->proc~box_gc_for_neighbor~3 proc~fill_buffered_nb~3->proc~box_set_gc~3 proc~fill_refinement_bnd~3->proc~mg_get_child_offset~3 proc~fill_refinement_bnd~3->proc~box_gc_for_fine_neighbor~3 proc~sides_rb~3 sides_rb proc~fill_refinement_bnd~3->proc~sides_rb~3 mpi_irecv mpi_irecv proc~mpi_irecv_wrapper->mpi_irecv mpi_isend mpi_isend proc~mpi_isend_wrapper->mpi_isend interface~mrgrnk~3 mrgrnk proc~sort_sendbuf~3->interface~mrgrnk~3 proc~i_mrgrnk~3 I_mrgrnk interface~mrgrnk~3->proc~i_mrgrnk~3

Source Code

  subroutine mg_copy_to_tree(iw_from, iw_to, restrict, restrict_gc, factor,&
      state_from)
    use mod_global_parameters
    use mod_forest
    integer, intent(in)            :: iw_from
    !< Variable to use as right-hand side
    integer, intent(in)            :: iw_to
    !< Copy to this variable
    logical, intent(in), optional  :: restrict
    !< Restrict variable on multigrid tree
    logical, intent(in), optional  :: restrict_gc
    !< Fill ghost cells after restrict
    real(dp), intent(in), optional :: factor
    !< out = factor * in
    !> If present, use this as the input state
    type(state), intent(in), optional, target :: state_from(max_blocks)
    integer                        :: iigrid, igrid, id
    integer                        :: nc, lvl, ilo1,ilo2,ilo3, ihi1,ihi2,ihi3
    type(tree_node), pointer       :: pnode
    real(dp)                       :: fac
    logical                        :: do_restrict, do_gc

    if (.not. mg%is_allocated) error stop "mg_copy_to_tree: tree not allocated yet"

    fac = 1.0_dp; if (present(factor)) fac = factor
    do_restrict = .false.; if (present(restrict)) do_restrict = restrict
    do_gc = .false.; if (present(restrict_gc)) do_gc = restrict_gc

    ilo1=ixMlo1-1;ilo2=ixMlo2-1;ilo3=ixMlo3-1;
    ihi1=ixMhi1+1;ihi2=ixMhi2+1;ihi3=ixMhi3+1;

    do iigrid = 1, igridstail
       igrid =  igrids(iigrid);
       pnode => igrid_to_node(igrid, mype)%node
       id    =  pnode%id
       lvl   =  mg%boxes(id)%lvl
       nc    =  mg%box_size_lvl(lvl)

       ! Include one layer of ghost cells on grid leaves
       if (present(state_from)) then
          mg%boxes(id)%cc(0:nc+1,0:nc+1,0:nc+1,&
              iw_to) = fac * state_from(igrid)%w(ilo1:ihi1,ilo2:ihi2,ilo3:ihi3,&
              iw_from)
       else
          mg%boxes(id)%cc(0:nc+1,0:nc+1,0:nc+1,&
              iw_to) = fac * ps(igrid)%w(ilo1:ihi1,ilo2:ihi2,ilo3:ihi3,&
              iw_from)
       end if
    end do

    if (do_restrict) then
       call mg_restrict(mg, iw_to)
       if (do_gc) call mg_fill_ghost_cells(mg, iw_to)
    end if

  end subroutine mg_copy_to_tree