← Back to team overview

dolfin team mailing list archive

Re: Preconditioner

 

On Tue, Dec 06, 2005 at 11:49:55PM +0100, Garth N. Wells wrote:

> I was thinking about defining PETSc preconditioners and a "userdefined"
> preconditioner using enum. We could define PETSc preconditioners, a "dolfin"
> preconditioner and a "userdefined" preconditioner.

With the enum approach, I don't think we need to have a case called
"userdefined". Either someone does

    solver.setPreconditioner(Preconditioner::ilu);

thus choosing one of the built-in preconditioners, which can be
something from PETSc or something that we have implemented in DOLFIN.

Or, a user does

    solver.setPreconditioner(pc);

where pc is an instance of the class Preconditioner (with member
function solve() overloaded).

The only thing we would have to do would thus be to put the enums
in the Preconditioner class and overload setPreconditioner in
KrylovSolver so it either accepts Preconditioner::type or
Preconditioner.

> I'm not sure if it's easier to put these into the class Preconditioner or to
> break them up in separate classes.

The above is the easiest I think, but perhaps we want to have only one
KrylovSolver::setPreconditioner() so that in particular one can pass
Preconditioner objects around in the code (and there would not be two
kinds of preconditioners: either Preconditioner or the fake
Preconditioner::Type).

Then we could declare a number of subclasses of Preconditioner, such
as

    class ILU : public Preconditioner { ... }
    class SOR : public Preconditioner { ... }

These would not actually implement the preconditioning in question,
but instead KrylovSolver would check that this is a special type of
preconditioner (a PETSc built-in) and just set the choice of
preconditioner in PETSc.

We could collect all of these in say Preconditioners.h since each
class will be very small.

With this approach, a user would do

    ILU ilu;
    KrylovSolver solver;
    solver.setPreconditioner(ilu);

Don't know which approach is best, the enums or this one.

/Anders



Follow ups

References