mg_fas_fmg Subroutine

public subroutine mg_fas_fmg(mg, have_guess, max_res)

Perform FAS-FMG cycle (full approximation scheme, full multigrid).

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg
logical, intent(in) :: have_guess

If false, start from phi = 0

real(kind=dp), intent(out), optional :: max_res

Store max(abs(residual))


Calls

proc~~mg_fas_fmg~~CallsGraph proc~mg_fas_fmg mg_fas_fmg proc~check_methods check_methods proc~mg_fas_fmg->proc~check_methods proc~correct_children correct_children proc~mg_fas_fmg->proc~correct_children proc~mg_add_timers mg_add_timers proc~mg_fas_fmg->proc~mg_add_timers proc~mg_fas_vcycle mg_fas_vcycle proc~mg_fas_fmg->proc~mg_fas_vcycle proc~mg_fill_ghost_cells_lvl mg_fill_ghost_cells_lvl proc~mg_fas_fmg->proc~mg_fill_ghost_cells_lvl proc~mg_timer_end mg_timer_end proc~mg_fas_fmg->proc~mg_timer_end proc~mg_timer_start mg_timer_start proc~mg_fas_fmg->proc~mg_timer_start proc~subtract_mean subtract_mean proc~mg_fas_fmg->proc~subtract_mean proc~update_coarse update_coarse proc~mg_fas_fmg->proc~update_coarse proc~mg_set_methods mg_set_methods proc~check_methods->proc~mg_set_methods proc~mg_prolong mg_prolong proc~correct_children->proc~mg_prolong proc~mg_add_timer mg_add_timer proc~mg_add_timers->proc~mg_add_timer proc~mg_fas_vcycle->proc~check_methods proc~mg_fas_vcycle->proc~correct_children proc~mg_fas_vcycle->proc~mg_add_timers proc~mg_fas_vcycle->proc~mg_fill_ghost_cells_lvl proc~mg_fas_vcycle->proc~mg_timer_end proc~mg_fas_vcycle->proc~mg_timer_start proc~mg_fas_vcycle->proc~subtract_mean proc~mg_fas_vcycle->proc~update_coarse mpi_allreduce mpi_allreduce proc~mg_fas_vcycle->mpi_allreduce proc~max_residual_lvl max_residual_lvl proc~mg_fas_vcycle->proc~max_residual_lvl proc~smooth_boxes smooth_boxes proc~mg_fas_vcycle->proc~smooth_boxes proc~buffer_ghost_cells buffer_ghost_cells proc~mg_fill_ghost_cells_lvl->proc~buffer_ghost_cells proc~buffer_refinement_boundaries buffer_refinement_boundaries proc~mg_fill_ghost_cells_lvl->proc~buffer_refinement_boundaries proc~set_ghost_cells set_ghost_cells proc~mg_fill_ghost_cells_lvl->proc~set_ghost_cells proc~sort_and_transfer_buffers sort_and_transfer_buffers proc~mg_fill_ghost_cells_lvl->proc~sort_and_transfer_buffers mpi_wtime mpi_wtime proc~mg_timer_end->mpi_wtime proc~mg_timer_start->mpi_wtime proc~subtract_mean->mpi_allreduce proc~get_sum get_sum proc~subtract_mean->proc~get_sum proc~update_coarse->proc~mg_fill_ghost_cells_lvl proc~mg_restrict_lvl mg_restrict_lvl proc~update_coarse->proc~mg_restrict_lvl proc~residual_box residual_box proc~update_coarse->proc~residual_box proc~buffer_for_nb buffer_for_nb proc~buffer_ghost_cells->proc~buffer_for_nb proc~buffer_for_fine_nb buffer_for_fine_nb proc~buffer_refinement_boundaries->proc~buffer_for_fine_nb proc~mg_has_children mg_has_children proc~buffer_refinement_boundaries->proc~mg_has_children proc~max_residual_lvl->proc~residual_box proc~mg_prolong->proc~sort_and_transfer_buffers proc~prolong_onto prolong_onto proc~mg_prolong->proc~prolong_onto proc~prolong_set_buffer prolong_set_buffer proc~mg_prolong->proc~prolong_set_buffer proc~mg_restrict_lvl->proc~sort_and_transfer_buffers proc~restrict_onto restrict_onto proc~mg_restrict_lvl->proc~restrict_onto proc~restrict_set_buffer restrict_set_buffer proc~mg_restrict_lvl->proc~restrict_set_buffer proc~ahelmholtz_set_methods ahelmholtz_set_methods proc~mg_set_methods->proc~ahelmholtz_set_methods proc~helmholtz_set_methods helmholtz_set_methods proc~mg_set_methods->proc~helmholtz_set_methods proc~laplacian_set_methods laplacian_set_methods proc~mg_set_methods->proc~laplacian_set_methods proc~vhelmholtz_set_methods vhelmholtz_set_methods proc~mg_set_methods->proc~vhelmholtz_set_methods proc~vlaplacian_set_methods vlaplacian_set_methods proc~mg_set_methods->proc~vlaplacian_set_methods proc~bc_to_gc bc_to_gc proc~set_ghost_cells->proc~bc_to_gc proc~box_get_gc box_get_gc proc~set_ghost_cells->proc~box_get_gc proc~box_set_gc box_set_gc proc~set_ghost_cells->proc~box_set_gc proc~copy_from_nb copy_from_nb proc~set_ghost_cells->proc~copy_from_nb proc~fill_buffered_nb fill_buffered_nb proc~set_ghost_cells->proc~fill_buffered_nb proc~fill_refinement_bnd fill_refinement_bnd proc~set_ghost_cells->proc~fill_refinement_bnd proc~smooth_boxes->proc~mg_fill_ghost_cells_lvl proc~smooth_boxes->proc~mg_timer_end proc~smooth_boxes->proc~mg_timer_start mpi_waitall mpi_waitall proc~sort_and_transfer_buffers->mpi_waitall proc~mpi_irecv_wrapper mpi_irecv_wrapper proc~sort_and_transfer_buffers->proc~mpi_irecv_wrapper proc~mpi_isend_wrapper mpi_isend_wrapper proc~sort_and_transfer_buffers->proc~mpi_isend_wrapper proc~sort_sendbuf sort_sendbuf proc~sort_and_transfer_buffers->proc~sort_sendbuf proc~box_gc_for_fine_neighbor box_gc_for_fine_neighbor proc~buffer_for_fine_nb->proc~box_gc_for_fine_neighbor proc~mg_get_child_offset mg_get_child_offset proc~buffer_for_fine_nb->proc~mg_get_child_offset proc~box_gc_for_neighbor box_gc_for_neighbor proc~buffer_for_nb->proc~box_gc_for_neighbor proc~copy_from_nb->proc~box_set_gc proc~copy_from_nb->proc~box_gc_for_neighbor proc~fill_buffered_nb->proc~box_set_gc proc~fill_refinement_bnd->proc~box_gc_for_fine_neighbor proc~fill_refinement_bnd->proc~mg_get_child_offset proc~sides_rb sides_rb proc~fill_refinement_bnd->proc~sides_rb mpi_irecv mpi_irecv proc~mpi_irecv_wrapper->mpi_irecv mpi_isend mpi_isend proc~mpi_isend_wrapper->mpi_isend proc~prolong_onto->proc~mg_get_child_offset proc~prolong_set_buffer->proc~mg_get_child_offset proc~restrict_onto->proc~mg_get_child_offset proc~mg_ix_to_ichild mg_ix_to_ichild proc~restrict_set_buffer->proc~mg_ix_to_ichild interface~mrgrnk mrgrnk proc~sort_sendbuf->interface~mrgrnk proc~i_mrgrnk I_mrgrnk interface~mrgrnk->proc~i_mrgrnk

Called by

proc~~mg_fas_fmg~~CalledByGraph proc~mg_fas_fmg mg_fas_fmg proc~diffusion_solve diffusion_solve proc~diffusion_solve->proc~mg_fas_fmg proc~diffusion_solve_acoeff diffusion_solve_acoeff proc~diffusion_solve_acoeff->proc~mg_fas_fmg proc~diffusion_solve_vcoeff diffusion_solve_vcoeff proc~diffusion_solve_vcoeff->proc~mg_fas_fmg

Source Code

  subroutine mg_fas_fmg(mg, have_guess, max_res)
    type(mg_t), intent(inout)       :: mg
    logical, intent(in)             :: have_guess
    !< If false, start from phi = 0
    real(dp), intent(out), optional :: max_res
    !< Store max(abs(residual))
    integer                         :: lvl, i, id

    call check_methods(mg)
    if (timer_smoother == -1) call mg_add_timers(mg)

    call mg_timer_start(mg%timers(timer_total_fmg))

    if (.not. have_guess) then
       do lvl = mg%highest_lvl, mg%lowest_lvl, -1
          do i = 1, size(mg%lvls(lvl)%my_ids)
             id = mg%lvls(lvl)%my_ids(i)
             mg%boxes(id)%cc(:, :, mg_iphi) = 0.0_dp
          end do
       end do
    end if

    ! Ensure ghost cells are filled correctly
    call mg_fill_ghost_cells_lvl(mg, mg%highest_lvl, mg_iphi)

    do lvl = mg%highest_lvl,  mg%lowest_lvl+1, -1
       ! Set rhs on coarse grid and restrict phi
       call mg_timer_start(mg%timers(timer_update_coarse))
       call update_coarse(mg, lvl)
       call mg_timer_end(mg%timers(timer_update_coarse))
    end do

    if (mg%subtract_mean) then
       ! For fully periodic solutions, the mean source term has to be zero
       call subtract_mean(mg, mg_irhs, .false.)
    end if

    do lvl = mg%lowest_lvl, mg%highest_lvl
       ! Store phi_old
       do i = 1, size(mg%lvls(lvl)%my_ids)
          id = mg%lvls(lvl)%my_ids(i)
          mg%boxes(id)%cc(:, :, mg_iold) = mg%boxes(id)%cc(:, :, mg_iphi)
       end do

       if (lvl > mg%lowest_lvl) then
          ! Correct solution at this lvl using lvl-1 data
          ! phi = phi + prolong(phi_coarse - phi_old_coarse)
          call mg_timer_start(mg%timers(timer_correct))
          call correct_children(mg, lvl-1)
          call mg_timer_end(mg%timers(timer_correct))

          ! Update ghost cells
          call mg_fill_ghost_cells_lvl(mg, lvl, mg_iphi)
       end if

       ! Perform V-cycle, possibly set residual on last iteration
       if (lvl == mg%highest_lvl) then
          call mg_fas_vcycle(mg, lvl, max_res, standalone=.false.)
       else
          call mg_fas_vcycle(mg, lvl, standalone=.false.)
       end if
    end do

    call mg_timer_end(mg%timers(timer_total_fmg))
  end subroutine mg_fas_fmg