← Back to team overview

dolfin team mailing list archive

Re: [HG] Fix check for Hypre in KrylovSolver.

 

On Thu, Mar 16, 2006 at 06:09:23AM -0600, Anders Logg wrote:

> > This appears to be a PETSc problem when destroying a solver before it
> > has been used to solve a linear system.
> > 
> > The problem can be avoided by not calling init(0,0) (as well as
> > readParameters()) in the KrylovSolver constructor. As far as I can see,
> > there is no need to call init(0,0) in the constructor. It creates a
> > PETSc solver, which is then deleted by KrylovSolver::init() the first
> > time KrylovSolver::solve() is called. Can the call be removed from the
> > constructor?
> > 
> > Garth
> 
> Aha. We had the following in the init() function before. I couldn't
> understand why it was there in the first place so I removed it. Seems
> we need it.
> 
>   // Don't reinitialize on first solve
>   if ( ksp != 0 && this->M == 0 && this->N == 0 )
>   {
>     this->M = M;
>     this->N = N;
>     return;
>   }
> 
> Does it work if you put it back?
> 
> I think we need to do init() in the constructor so that it is possible
> to call KrylovSolver::solver() and do stuff with the KSP pointer if
> someone should want to do that.
> 
> /Anders

When I think of it, maybe we can remove the KrylovSolver::solver()
function? The DOLFIN KrylovSolver is anyway doing pretty much what it
wants to do by itself and would perhaps not obey all options specified
by a user, especially since ksp is sometimes destroyed and then
created again in a solve.

If we remove it, we don't need to do init() in the constructor and the
problem will go away. Would that work?

We should probably add some comments that (1) PETSc gets confused if
the system changes size between solves (which is why we need to do
init() between solves) and that (2) PETSc gets confused if KSP is
created, destroyed and created again before a solve (which we avoid).
It's otherwise easy to forget as I did now.

/Anders



Follow ups

References