Consider a potential/poisson equation on a very large, complicated geometry. Currently, an self-written FEM and linear solvers from NumPy are used. Performance is, of course, not good enough for larger problems.

I'd like to switch to PETSc and use algebraic multigrid preconditioners. Surprisingly, I could not find good documentation or examples on algebraic multigrid in PETSc. Are there any good examples? Or is it maybe to early to use algebraic multigrid, if I don't want to go into development too deep?

(This question is mainly intended to find more documentation about algebraic multigrid in PETSc, but please let me know if my approach is generally a bad idea.)


1 Answer 1


AMG can be used with all examples in PETSc. There are three robust implementations that you might want to use

  • -pc_type gamg is a native (smoothed) aggregation method.
  • -pc_type ml is a smoothed aggregation implementation from the ML project (part of Trilinos). Configure PETSc with --download-ml to make this solver available.
  • -pc_type hypre is a classical AMG implementation (BoomerAMG from Hypre). Configure PETSc with --download-hypre to make this solver available.
  • $\begingroup$ That's about what I already found in the documentation... But I'd be really glad to find a complete example plus (hopefully) some extensive documentation. $\endgroup$
    – Michael
    Commented Jul 9, 2017 at 11:20
  • 1
    $\begingroup$ @Michael Can you be more specific about what you hope to learn? Every example is a "complete example" in a limited sense and lots of the tests use multigrid. Many of the slide decks on the tutorials page discuss multigrid configuration and diagnostics. Ultimately, you have to get your hands dirty using the solver diagnostics and multigrid configuration options (-help shows all relevant options; you can pipe its output through grep). $\endgroup$
    – Jed Brown
    Commented Jul 13, 2017 at 23:25
  • $\begingroup$ So far, I simply didn't find a complete example code with algebraic multigrid, even though I browsed trough lots of resources. $\endgroup$
    – Michael
    Commented Jul 15, 2017 at 21:27
  • 2
    $\begingroup$ As I stated above, every example in PETSc is an AMG example because it requires no specific code, just run any example with the run-time argument -pc_type gamg. If you're interested is solving a particular kind of equation, perhaps 3D elasticity, then there are specific examples. If not, I'd recommend starting with src/snes/examples/tutorials/ex5.c which solves the Bratu equation. $\endgroup$
    – Jed Brown
    Commented Jul 17, 2017 at 18:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.