Copy a variable to the multigrid tree, including a layer of ghost cells
| Type | Intent | Optional | 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 |
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