← Back to team overview

dolfin team mailing list archive

Re: Preconditioner

 

I won't say it's not possible to simplify it, but this is probably as
easy as it gets.

The purpose of the class Preconditioner is to allow a user to define
her own preconditioner as an operator that approximately solves the
the linear system. To do that, we have to tell PETSc to call the
solve() member function that the user has overloaded. Since PETSc does
not now about our class Preconditioner, we have to give PETSc the
pointer to a static function (PCApply) which in turn calls the
solve() member function on the object that is passed along in the
pointer pc->data.

This is not part of the standard PETSc interface, which is why we
include <src/ksp/pc/pcimpl.h>. In the current PETSc
development version, this interface has been moved to
<private/pcimpl.h>.

One thing we need to think about is if we want to differentiate
between PETSc preconditioners and user-defined preconditioners.
One option would be to have two functions:

    // Specify PETSc preconditioner
    KrylovSolver::setPreconditioner(Preconditioner::Type type);

    // Specify DOLFIN preconditioner
    KrylovSolver::setPreconditioner(Preconditioner pc);

Another option would be just

    // Specify preconditioner
    KrylovSolver::setPreconditioner(Preconditioner pc);

Then we would have to create a set of static members of the class
preconditioner which are instances of Preconditioner that can be
passed as arguments to setPreconditioner():

    solver.setPreconditioner(Preconditioner::ilu);

In either case, the syntax for a user would look the same, but in the
first case, the preconditioner is an enum and in the second an
instance of Preconditioner. The first option is simpler.

/Anders


On Tue, Dec 06, 2005 at 07:38:14PM +0100, Garth N. Wells wrote:
> I've had a look at Preconditioner.h and Preconditioner.cpp to try to transfer
> precondtioner stuff in KrylovSolver to Preconditioner. The code in
> Preconditioner.cpp is pretty cryptic though. Is it possible to simply it?
> 
> Garth  
> 
> 
> 
> 
> _______________________________________________
> DOLFIN-dev mailing list
> DOLFIN-dev@xxxxxxxxxx
> http://www.fenics.org/cgi-bin/mailman/listinfo/dolfin-dev
> 

-- 
Anders Logg
Research Assistant Professor
Toyota Technological Institute at Chicago
http://www.tti-c.org/logg/



References