Skip to content

ISSUE 3763: Fix default solver options in documentation #4254

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion CITATION.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ If you publish results using Firedrake, we would be grateful if you would cite t

@manual{FiredrakeUserManual,
title = {Firedrake User Manual},
author = {David A. Ham and Paul H. J. Kelly and Lawrence Mitchell and Colin J. Cotter and Robert C. Kirby and Koki Sagiyama and Nacime Bouziani and Thomas J. Gregory and Jack Betteridge and Daniel R. Shapero and Reuben W. Nixon-Hill and Connor J. Ward and Patrick E. Farrell and Pablo D. Brubeck and India Marsden and Daiane I. Dolci and Joshua Hope-Collins and Sophia Vorderwuelbecke and Thomas H. Gibson and Miklós Homolya and Tianjiao Sun and Andrew T. T. McRae and Fabio Luporini and Alastair Gregory and Michael Lange and Simon W. Funke and Florian Rathgeber and Gheorghe-Teodor Bercea and Graham R. Markall},
author = {David A. Ham and Paul H. J. Kelly and Lawrence Mitchell and Colin J. Cotter and Robert C. Kirby and Koki Sagiyama and Nacime Bouziani and Thomas J. Gregory and Jack Betteridge and Daniel R. Shapero and Reuben W. Nixon-Hill and Connor J. Ward and Patrick E. Farrell and Pablo D. Brubeck and India Marsden and Daiane I. Dolci and Joshua Hope-Collins and Umberto Zerbinati and Sophia Vorderwuelbecke and Thomas H. Gibson and Miklós Homolya and Tianjiao Sun and Andrew T. T. McRae and Fabio Luporini and Alastair Gregory and Michael Lange and Simon W. Funke and Florian Rathgeber and Gheorghe-Teodor Bercea and Graham R. Markall},
organization = {Imperial College London and University of Oxford and Baylor University and University of Washington},
edition = {First edition},
year = {2023},
Expand Down
50 changes: 31 additions & 19 deletions docs/source/solving-interface.rst
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ definite, and therefore can choose the conjugate gradient method,
rather than GMRES.

.. code-block:: python3

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

no need for extra whitespace

solve(a == L, solver_parameters={'ksp_type': 'cg'})

To change the preconditioner used, we set the ``'pc_type'`` option.
Expand All @@ -271,17 +271,21 @@ precondition the system with:
solver_parameters={'pc_type': 'hypre',
'pc_hypre_type': 'boomeramg'})

Although the `KSP` name suggests that only Krylov methods are
supported, this is not the case. We may, for example, solve the
system directly by computing an LU factorisation of the problem. To
Although the ``KSP`` name suggests that only Krylov methods are
supported, this is not the case. We may, for example, solve the
system directly by computing an LU factorisation of the problem. To
do this, we set the ``pc_type`` to ``'lu'`` and tell PETSc to use a
"preconditioner only" Krylov method:

.. code-block:: python3

solve(a == L,
solver_parameters={'ksp_type': 'preonly',
'pc_type': 'lu'})
solve(a == L,
solver_parameters={
'mat_type': 'aij',
'ksp_type': 'preonly',
'ksp_rtol': 1e-7,
'pc_type': 'lu'
})

In a similar manner, we can use Jacobi preconditioned Richardson
iterations with:
Expand All @@ -290,7 +294,7 @@ iterations with:

solve(a == L,
solver_parameters={'ksp_type': 'richardson',
'pc_type': 'jacobi'}
'pc_type': 'jacobi'})

.. note::

Expand Down Expand Up @@ -728,32 +732,40 @@ solving with.
Default solver options
~~~~~~~~~~~~~~~~~~~~~~

If no parameters are passed to a solve call, we use, in most cases,

If no parameters are passed to a ``solve`` call, we use, in most cases,
the defaults that PETSc supplies for solving the linear or nonlinear
system. We describe the most commonly modified options (along with
their defaults in Firedrake) here. For linear variational solves we
system. We describe the most commonly modified options (along with
their defaults in Firedrake) here. For linear variational solves we
use:

* ``ksp_type``: GMRES, with a restart (``ksp_gmres_restart``) of 30
* ``ksp_rtol``: 1e-7
* ``ksp_atol``: 1e-50
* ``ksp_divtol`` 1e4
* ``ksp_max_it``: 10000
* ``pc_type``: ILU (Jacobi preconditioning for mixed problems)
* ``mat_type``: ``aij``
* ``ksp_type``: ``preonly``
* ``ksp_rtol``: ``1e-7``
* ``ksp_atol``: ``1e-50``
* ``ksp_divtol``: ``1e4``
* ``ksp_max_it``: ``10000``
Comment on lines +745 to +747
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, please make sure the rest of the file is up to date. The options in 753-763 should have:

{'mat_type': 'aij',
 'ksp_type': 'preonly',
 'ksp_rtol': 1e-05,
 'pc_type': 'lu',
 'pc_factor_mat_solver_type': 'mumps',
 'pc_factor_mat_mumps_icntl_14': 200,
 'snes_type': 'newtonls',
 'snes_linesearch_type': 'basic'}

* ``pc_type``: ``lu``


For nonlinear variational solves we have:

* ``snes_type``: Newton linesearch
* ``ksp_type``: GMRES, with a restart (``ksp_gmres_restart``) of 30
* ``ksp_type``: ``preonly``
* ``mat_type``: ``aij``
* ``snes_rtol``: 1e-8
* ``snes_atol``: 1e-50
* ``snes_stol``: 1e-8
* ``snes_max_it``: 50
* ``snes_type`` : ``newtonls``
* ``snes_linesearch_type`` : `basic`
* ``ksp_rtol``: 1e-5
* ``ksp_atol``: 1e-50
* ``ksp_divtol``: 1e4
* ``ksp_max_it``: 10000
* ``pc_type``: ILU (Jacobi preconditioning for mixed problems)
* ``pc_type``: ``lu``
* ``pc_factor_mat_solver_type`` : ``mumps``
* ``pc_factor_mat_mumps_icntl_14``: 200
Comment on lines +767 to +768
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These parameters are only relevant if MUMPS is present. Do we want to keep them in the documentation? If so, they should also be included above in the linear solver parameters.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I wait for approval for whether I should update mumps or not? @pbrubeck @connorjward

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have to try quite hard to not have MUMPS installed. I think these options should be documented.


To see the full view that PETSc has of solver objects, you can pass a
view flag to the solve call. For linear solves pass:
Expand Down