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 13 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 36 additions & 20 deletions docs/source/solving-interface.rst
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,6 @@ definite, and therefore can choose the conjugate gradient method,
rather than GMRES.

.. code-block:: python3

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

To change the preconditioner used, we set the ``'pc_type'`` option.
Expand All @@ -271,17 +270,23 @@ 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',
'pc_factor_mat_solver_type' : 'mumps',
'pc_factor_mat_mumps_icntl_14' : 200
})

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

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

.. note::

Expand Down Expand Up @@ -728,32 +735,41 @@ 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 +748 to +750
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``
* ``pc_factor_mat_solver_type`` : ``mumps``
* ``pc_factor_mat_mumps_icntl_14``: 200


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

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
Loading