PCHYPRE — PETSc 3.25.2 documentation

Skip to main content
`Ctrl`+`K`

# PCHYPRE

Allows you to use the matrix element based preconditioners in the LLNL package hypre as PETSc `PC`

## Options Database Keys

- -pc_hypre_type - One of `euclid`, `ilu`, `pilut`, `parasails`, `boomeramg`, `ams`, or `ads`

- -pc_hypre_boomeramg_nodal_coarsen n - where `n` is from 1 to 6 (see `HYPRE_BoomerAMGSetNodal()`)

- -pc_hypre_boomeramg_vec_interp_variant v - where `v` is from 1 to 3 (see `HYPRE_BoomerAMGSetInterpVecVariant()`)

- Many others - run with `-pc_type hypre` `-pc_hypre_type XXX` `-help` to see options for the XXX preconditioner

## Notes

Apart from `-pc_hypre_type` (for which there is `PCHYPRESetType()`), the many hypre options can ONLY be set via the options database (e.g. the command line or with `PetscOptionsSetValue()`, there are no functions to set them)

The options `-pc_hypre_boomeramg_max_iter` and `-pc_hypre_boomeramg_tol` refer to the number of iterations (V-cycles) and tolerance that boomerAMG does EACH time it is called. So for example, if `-pc_hypre_boomeramg_max_iter` is set to 2 then 2-V-cycles are being used to define the preconditioner (`-pc_hypre_boomeramg_tol` should be set to 0.0 - the default - to strictly use a fixed number of iterations per hypre call). `-ksp_max_it` and `-ksp_rtol` STILL determine the total number of iterations and tolerance for the Krylov solver. For example, if `-pc_hypre_boomeramg_max_iter` is 2 and `-ksp_max_it` is 10 then AT MOST twenty V-cycles of BoomerAMG will be used.

Note that the option `-pc_hypre_boomeramg_relax_type_all` defaults to symmetric relaxation (symmetric-SOR/Jacobi), which is required for Krylov solvers like CG that expect symmetry. Otherwise, you may want to use `-pc_hypre_boomeramg_relax_type_all SOR/Jacobi`.

If you provide a near null space to your matrix with `MatSetNearNullSpace()` it is ignored by hypre’s BoomerAMG UNLESS you also use the following two options: `-pc_hypre_boomeramg_nodal_coarsen <n> -pc_hypre_boomeramg_vec_interp_variant <v>`

See `PCPFMG`, `PCSMG`, and `PCSYSPFMG` for access to hypre’s other (nonalgebraic) multigrid solvers

For `PCHYPRE` type of `ams` or `ads` auxiliary data must be provided to the preconditioner with `PCHYPRESetDiscreteGradient()`, `PCHYPRESetDiscreteCurl()`, `PCHYPRESetInterpolations()`, `PCHYPRESetAlphaPoissonMatrix()`, `PCHYPRESetBetaPoissonMatrix()`, `PCHYPRESetEdgeConstantVectors()`, `PCHYPREAMSSetInteriorNodes()`

Sometimes people want to try algebraic multigrid as a “standalone” solver, that is not accelerating it with a Krylov method. Though we generally do not recommend this since it is usually slower, one should use a `KSPType` of `KSPRICHARDSON` (or equivalently `-ksp_type richardson`) to achieve this. Using `KSPPREONLY` will not work since it only applies a single cycle of multigrid.

PETSc provides its own geometric and algebraic multigrid solvers `PCMG` and `PCGAMG`, also see `PCHMG` which is useful for certain multicomponent problems.

hypre supports performance logging via the `Caliper` library. With `--download-hypre --download-caliper`, hypre will be automatically configured with the support.

Enabling Caliper logging requires setting the `CALI_CONFIG` environment variable before running your hypre code. For example,

.vb export CALI_CONFIG=runtime-report,max_column_width=200,calc.inclusive,mpi-report,output=stdout .ve

Then run a hypre code, and you will see profiling results on `stdout`. See https://software.llnl.gov/Caliper/#guides for more options.

## GPU Notes

To configure hypre BoomerAMG so that it can utilize NVIDIA GPUs run `./configure --download-hypre --with-cuda` Then pass `VECCUDA` vectors and `MATAIJCUSPARSE` matrices to the solvers and PETSc will automatically utilize hypre’s GPU solvers.

To configure hypre BoomerAMG so that it can utilize AMD GPUs run ./configure –download-hypre –with-hip Then pass `VECHIP` vectors to the solvers and PETSc will automatically utilize hypre’s GPU solvers.

## See Also

KSP: Linear System Solvers, `PCCreate()`, `PCSetType()`, `PCType`, `PC`, `PCHYPRESetType()`, `PCPFMG`, `PCGAMG`, `PCSYSPFMG`, `PCSMG`, `PCHYPRESetDiscreteGradient()`, `PCHYPRESetDiscreteCurl()`, `PCHYPRESetInterpolations()`, `PCHYPRESetAlphaPoissonMatrix()`, `PCHYPRESetBetaPoissonMatrix()`, `PCHYPRESetEdgeConstantVectors()`, `PCHYPREAMSSetInteriorNodes()`

## Level

intermediate

## Location

src/ksp/pc/impls/hypre/impl/ihypre.c

## Examples

src/ksp/ksp/tutorials/ex79.c

Index of all PC routines
Table of Contents for all manual pages
Index of all manual pages