On usage of PETSc interface

Hi everyone,

A bit of a silly question, but whenever I need to use the PETSc interface I struggle, I’m not sure where to find the options to things, etc. My asking for references really, so here it goes:

  1. Where do I find the PETScOptions for a relevant solver/preconditioner?

For instance, no idea how to setup the ilu depth, and I can’t seem to find which options are available for the “petsc_amg” perconditioner. In this case, I would be interested in the hypre_euclid options as apparently I get better behavior with its default presents. Following the code, I found out that the petsc_amg correspongs to the PETSc PCMG (https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/PC/PCMG.html), but there are less options than what I’ve seen in several posts.

  1. Is the ‘info’ method working in the last version? I am using a conda installation, and info always gives me an empty output. I have used it generally to see the parameters available from PETScKrylovSolver or PETScPreconditioner, without success.

Thanks in advance.

1 Like

Hi,

You can try to use snes directly using petsc4py. Similar to how it is done in dolfinx

See also Using petsc4py.PETSc.SNES directly

3 Likes

Thank you for the answer, but I have no interest in using SNES.

The links given by @bhaveshshrimali are examples with a PETSc SNES object which have an underlying PETSc KSP object. That’s why it’s cited as a guide.

When you refer to dolfin::PETScKrylovSolver, that’s a wrapper provided by DOLFIN which hides a lot of the underlying functionality of the PETSc object. In fact, you can directly acquire the KSP object via dolfin::PETScKrylovSolver::ksp().

In almost every case that someone wants to use a PETSc Krylov or nonlinear solver, I’d recommend creating and using the PETSc objects directly. For example through petsc4py as demonstrated in the example above.

As for where to find PETSc’s options list… you provided the link yourself. The PETSc webpage documentation is quite extensive.

Perhaps you’re also forgetting to set options to your PETSc objects? Cf. DOLFIN wrappers here and here and the PETSc documentation here.

1 Like

Then sorry @bhaveshshrimali for not going through your suggested link, and thanks @nate for the clarification. I had a hard time looking for the options online, and if it serves for reference, I will leave it written here: All of the options are detailed in the PETSc User Manual (the pdf, not the webpage), in great detail and with all of the relevant variants.

As you mention @nate, I will use from now on the KSP interface directly, it is much richer and gives direct access to everything.

Best!
Nicolas