/Multigrid-1D-Dirichlet-BC

Multigrid method with arbitrary level on V cycle

Primary LanguageFortran

1D Poisson Multigrid Solver

1D Poisson Equation Problem


with Dirichlet Boundary Condition


The exact solution is



Exact Solver on Coarsest Level

The coarsest grid should be solved to exact solution
The program provides two solvers

  1. Gauss-Seidel with residual L2-norm less than tolerance
  2. LU decomposition (Not include)
  3. CG Solver (Not include)
tol = 1.0d-8
exact_solver = 1 

Set Level

Set arbitrary level. The coarsest grid should greater than 3

if (Level_Nx(Level_num).le.3) then
    write(*,*) Level_num," level is high for ",Nx," grid "
    stop
end if

Set Multigrid Solver

Gauss-Seidel scheme is selected to be smoother

V Cycle Scheme

subroutine MG_Vcycle(Nx,dx,RHS,U,Level_num,tol,exact_solver,I_cycle)
    implicit none
    integer,intent(in) :: Nx,Level_num,exact_solver
    real*8 ,intent(in) :: dx,tol
    real*8,dimension(0:Nx), intent(in)     :: RHS
    real*8,dimension(0:Nx), intent(inout)  :: U
    integer,dimension(Level_num) :: Level_Nx
    real*8 ,dimension(Level_num) :: Level_dx
    real*8  :: rms0,rms,rmsc
    integer :: Max_Iter,Relax_Iter
    integer :: i,k,Level,iter
    integer, intent(inout) :: I_cycle

Multigrid V cycle Result

The following tables are the result of Multigrid V cycle with 7, 8, and 9 levels

Solver Np Cycle CPU Time
MG7 4096 7 0.0085
MG8 4096 7 0.0021
MG9 4096 7 0.0011
Solver Np Cycle CPU Time
MG7 8192 7 0.0673
MG8 8192 7 0.0088
MG9 8192 7 0.0030
Solver Np Cycle CPU Time
MG7 16384 7 0.5301
MG8 16384 7 0.0684
MG9 16384 7 0.0110

Compile and Run

Use PGI Compiler

make

Run

./Run

Reference

See wikipedia