firedrakeproject / asQ

A library for implementing ParaDIAG timestepping algorithms using Firedrake
MIT License
4 stars 1 forks source link

Default options for all-at-once preconditioners #187

Closed JHopeCollins closed 4 months ago

JHopeCollins commented 4 months ago

Previously we tried to allow a default option prefix for the blocks of the CirculantPC and JacobiPC. However, because Firedrake's OptionsManager deletes options from the global database once it's used them, the default options were only being used by the first block on each slice - this block then deleted the default options so they weren't used for later blocks on that slice.

This PR fixes this behaviour by manually pulling off the default options into a new dict and passing that to each block. Each block is then given an enumerated prefix to check for it's own options, which will override any matching defaults. This means that each block can use a mixture of the default options and options specifically for that block.

For example we could default to using SOR preconditioning for each block, but use Jacobi on one block and set different tolerances for some blocks by:

sparams = {
'pc_type': 'python',
'pc_python_type': 'asQ.CirculantPC',
'circulant_block': {
    'ksp_type': 'gmres',
    'pc_type': 'sor',
    'ksp_rtol': 1e-5},
'circulant_block_3': {
    'pc_type': 'jacobi',
    'ksp_rtol': 1e-3'},
'circulant_block_5': {
    'ksp_rtol': 1e-4}}

The slice options for SliceJacobiPC can also now be different for each slice with slice_jacobi_slice_%d, and defaulted with slice_jacobi_slice.