adding support for custom call to inner linear solve in SNES

Lisandro Dalcin dalcinl at gmail.com
Wed Aug 8 10:40:23 CDT 2007


On 8/8/07, Barry Smith <bsmith at mcs.anl.gov> wrote:
>     What problem is this suppose to be solving? Can you give an
> example of linsolve()?

Bary, I am working on block preconditioners for incompressible NS eqs
(those methods related to pressure Schur complement). In order to
define the preconditioner operation, I need to access the jacobian
(the coupled, saddle-point one) and extract from it four submatrices.
Furthermore, I need to calculate extra matrices (pressure mat matrix,
and a pressure Laplacian mat matrix).

All this logic is currently implemented (in python) by using a shell
preconditiner, and doing a lot of hackery. After thinking about all
this, It seemed natural to me to add a 'hook' in the inner SNES
linerar solve phase, in order to be able to do things like.

def my_snes_lin_solve(snes, ksp, b, x):
    appctx = snes.getApplicationContext()
    solvec = snes.getSolution()
    A, _, _ = ksp.getOperators()
    # now compute many things
    # and update data in appctx
    # for inner pcshell access
    ksp.solve(b,x)
    # do somehting more if you need it
    return

The linsolve() routine just enable users to define pre and post
linsolve operations. Other way (surelly better) would be to add
support for SNESSetPreLinearSolve() and SNESSetPostLinearSolve(); and
perhaps a SNESSetPreSolve()/SNESSetPostSolve(), for calling a user
rutine at the very beginning and at the very end of the nonlinear
solver iteration (similar to what TS already provides for
timestepping).

When you start to use Python, it is so easy to do really complicated
things, that I believe adding more support in PETSc for user
callbacks/hooks is worth the effort.



-- 
Lisandro Dalcín
---------------
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
Tel/Fax: +54-(0)342-451.1594




More information about the petsc-dev mailing list