← Back to team overview

dolfin team mailing list archive

Re: LU, GMRES and preconditioners

 

On Tue, Aug 15, 2006 at 01:54:02PM +0200, Garth N. Wells wrote:
> 
> 
> Anders Logg wrote:
> > On Tue, Aug 15, 2006 at 01:38:42PM +0200, Garth N. Wells wrote:
> >> Anders Logg wrote:
> >>> I'd like to change the behaviour of classes LU and GMRES so that one
> >>> may do
> >>>
> >>>     Matrix A;
> >>>     Vector x, b;
> >>>
> >>>     GMRES::solve(A, x, b);
> >>>
> >>> or
> >>>
> >>>     GMRES::solve(A, x, b, Preconditioner::ilu);
> >>>
> >>> and
> >>>
> >>>     LU::solve(A, x, b);
> >>>
> >>> LU and GMRES would thus not be subclasses or typedefs of
> >>> PETSc/uBlasLU/KrylovSolver but instead simple classes with static
> >>> functions for simple solution of linear systems. This would then be
> >>> the fast and easy way to solve a linear system. For more advanced
> >>> usage, one would create a KrylovSolver or PETScKrylovSolver and then
> >>> call solver.solve(). But often, one only wants to solve one linear
> >>> system and not many and then it's convenient to skip the extra step of
> >>> creating the solver.
> >>>
> >> OK with me.
> > 
> > ok. I can fix this (if it works out with the preconditioners).
> > 
> >>> This connects to the design of preconditioners. I think we decided to
> >>> put the list of preconditioners in Preconditioner so this should be
> >>> ok. What's the status of the redesign of preconditioners?
> >>>
> >> I don't that think we settled on the design of the preconiditoners. It 
> >> would be nice to have just one enum list of preconditioners in 
> >> Preconditioner.h, but I haven't had time to look at it yet.
> > 
> > ok. Would it be enough to have a class Preconditioner which just lists
> > all available preconditioners by name (ilu etc) in an enum type? And
> > then the solvers just return a run-time error if the preconditioner is
> > not implemented.
> > 
> 
> I was thinking more along the lines of Preconditioner being a typedef 
> for PETScPreconditioner or uBlasPreconditioner. Would it work to have
> 
> 
>     enum Preconditioner
>     {
>       // List of preconditioners
>     }
> 
>     typedef PETScPreconidtioner Preconditioner;

Don't think that would work. Preconditioner can't be both an enum type
and a class. We could do something like putting the list of
preconditioners in a separate file named DefaultPreconditioners.h and
then #include it inside the class definition of both
PETScPreconditioner and uBlasPreconditioner. Then we do the typedef as
above and it would look like we have Preconditioner::ilu etc:

DefaultPreconditioners.h:

#ifndef, namespace dolfin etc

enum DefaultPreconditioners{
{
    none,
    ilu
    ...
}

PETScPreconditioner.h:

#ifndef, namespace dolfin etc

class PETScPreconditioner
{
public:

#include <dolfin/DefaultPreconditioners.h>

    ...

}

Same in uBlasPreconditioner. Would that work?

> Also, I wouldn't return a run-time error. It would be better to use a 
> default preconditioner and print a warning message.

Sounds good.

/Anders


> Garth
> 
> > /Anders
> > _______________________________________________
> > DOLFIN-dev mailing list
> > DOLFIN-dev@xxxxxxxxxx
> > http://www.fenics.org/mailman/listinfo/dolfin-dev
> _______________________________________________
> DOLFIN-dev mailing list
> DOLFIN-dev@xxxxxxxxxx
> http://www.fenics.org/mailman/listinfo/dolfin-dev


Follow ups

References