← Back to team overview

dolfin team mailing list archive

Re: A note on the new solve() function

 

On Thu, May 08, 2008 at 09:06:23PM +0200, Martin Sandve Alnæs wrote:
> 2008/5/8 Anders Logg <logg@xxxxxxxxx>:
> > It's now possible to use all Krylov methods and preconditioners by
> > just calling solve(). Here are some examples:
> >
> >  solve(A, x, b);
> >  solve(A, x, b, lu);
> >  solve(A, x, b, gmres);
> >  solve(A, x, b, gmres, ilu);
> >  solve(A, x, b, bicgstab, sor);
> >  solve(A, x, b, cg, amg);
> >
> > Without any options, solve() will just use LU.
> >
> > Note that each time solve is called, a new solver object will be
> > created and then destroyed. This means that if you want to solve
> > repeatedly, it will be a little more efficient to create a solver
> > object instead of calling solve() many times. But the good thing
> > is that the overhead is small. In a simple test I made (which is
> > in sandbox/la/solve), the overhead was only 5%:
> >
> >  --- Calling solve repeatedly: 22.8 seconds
> >  --- Reusing solver: 21.64 seconds
> >
> >  --- Calling solve repeatedly: 22.81 seconds
> >  --- Reusing solver: 21.75 seconds
> >
> > This is for solving a 263169 x 263169 system (Poisson) 10 times with
> > GMRES (from PETSc) and AMG (from PETSc/Hypre).
> >
> > I don't know how to get this working in the Python interface, since
> > the enum variables don't seem to get wrapped. Anyone knows how to
> > fix this?
> 
> They do get wrapped, I use this code:
> 
> from dolfin.dolfin import <...>, gmres
> ...
> solver = KrylovSolver(gmres)

Aha!

I've imported them now so the above examples should work.
I've verified that

  solve(A, x, b, gmres, amg)

works in Python. Very nice.

-- 
Anders


References