The following GitHub - triscale-innov/LidJul.jl: GMG, Poisson solver and Lid cavity repo contains a simple Julia implementation of a Geometric Multi-Grid (GMG) solver. This solver is compared with available Julia linear solvers (AMG, iterative, direct,…) and used in a toy 2D CFD simulation.
Note that it is a WIP developed for training/educational purpose and is not a tool ready for serious computing.
The solver is adapted from the Harald Köstler’s implementation:
“Multigrid HowTo: A simple Multigrid solver in C++ in less than 200 lines of code”
https://www10.cs.fau.de/publications/reports/TechRep_2008-03.pdf
The solution for a 2D Poisson’s equation with a 128x128 mesh :
And the computing times for various solvers (GMG wins )
┌────────────────────┬───────────┬─────────────┬────────────┬───────────┬─────────┐
│ solver │ init_time │ solver_time │ Total Time │ residual │ niters │
├────────────────────┼───────────┼─────────────┼────────────┼───────────┼─────────┤
│ gauss_seidel │ 8.900E-08 │ 4.492E-03 │ 4.492E-03 │ NaN │ 10 │
│ GMG_GSSmoother │ 7.034E-05 │ 5.264E-03 │ 5.335E-03 │ 1.148E-10 │ 17 │
│ TTSolver │ 6.101E-03 │ 3.554E-04 │ 6.457E-03 │ 4.886E-11 │ nothing │
│ PCGAMG{SmoothA} │ 1.383E-02 │ 4.145E-02 │ 5.529E-02 │ 1.916E-09 │ 16 │
│ PCGAMG{RugeStuben} │ 2.825E-02 │ 4.817E-02 │ 7.643E-02 │ 6.521E-10 │ 12 │
│ SparseLU │ 9.333E-02 │ 6.262E-03 │ 9.959E-02 │ 1.748E-12 │ nothing │
│ PCGnothing │ 5.100E-08 │ 1.431E-01 │ 1.431E-01 │ 5.959E-09 │ 605 │
│ SparseAMG │ 8.246E-02 │ 6.945E-02 │ 1.519E-01 │ 6.521E-10 │ 12 │
│ jacobi │ 5.700E-08 │ 3.014E-01 │ 3.014E-01 │ 9.707E+01 │ 2000 │
│ PCGILU │ 2.629E-01 │ 7.272E-02 │ 3.356E-01 │ 4.687E-10 │ 8 │
│ sor │ 3.000E-08 │ 4.922E-01 │ 4.922E-01 │ 6.332E+01 │ 2000 │
│ ssor │ 3.100E-08 │ 9.461E-01 │ 9.461E-01 │ 6.332E+01 │ 2000 │
│ PCGDiagonalPrecond │ 2.945E-04 │ 5.147E+00 │ 5.148E+00 │ 6.132E-09 │ 602 │
└────────────────────┴───────────┴─────────────┴────────────┴───────────┴─────────┘
A simple CFD application of the solver (Lid Cavity).
Finally the GMG solver is used in the Julia translation fo the classical Benjamin Seibold’s MIT18086_NAVIERSTOKES
matlab implementation that simulates a square lid cavity. See the details here:
All your comments are more than welcomed !