Source file multigrid.M

The source file multigrid.M contains the complete distributed multgrid-algorithm to solve a Poisson equation or a Helmholtz equation. Before compilation the source is preprocessed by the macro-processor m4 which allows a more compact notation. To obtain the final F90-program pipe the source file through m4
cat multigrid.M | m4
In the overview section the main ideas of the multigrid method are briefly sketched. The core of the multigrid is a recursive algorithm which consists of the following steps
  1. pre-smoothing: The simplest smoother is a Jacobi smoother which can be regarded as an explicit time stepper for the diffusion equation
    with the time step adjusted to the shortest wavelength. A small number a pre-smoothing steps is performed (usually 3-5).
  2. calculation of the defect: bcoarse = div grad f - b; since short wavelength have been efficiently smoothed the defect mainly consists of long wavelength components and therefore can be well represented on a coarser grid.
  3. restriction of defect: the defect is mapped to a coarser grid
  4. recursive call: the multigrid is called recursively to treat the Poisson equation on the coarser grid and to obtain a coarse grid solution fcoarse to the Poisson equation div grad fcoarse= bcoarse. Either one or two recursive calls can be applied, the first case is called a V-cycle, the second case a W-cycle.
  5. prolongation: the solution for the Poisson equation on the coarse grid fcoarse is interpolated and subtracted from the fine grid solution f.
  6. post-smoothing: finally again a small number a smoothing steps is performed using the same algorithm as for the pre-smoother
The recursive algorithm can be either implemented by performing recursive calls to the same subroutine or by producing a separate subroutine for each grid level. Here the second approach is used. Since the various copies are produced by the preprocessor the source file still contains only one copy of the main multigrid routine.

Subroutines:

Remarks: Multigrid related switches and parameters: