preconditioner for matrix-free linear system

Satish Balay balay at
Tue Apr 14 14:02:10 CDT 2009

On Tue, 14 Apr 2009, Yongcheng Zhou wrote:

> Thanks Matt, Satish and Barry. I think I have to convert my matrix into a PETSc
> matrix in block AIJ type. I wan reluctant to do this since I might need to solve
> linear system many times and I had preferred to use matrix free approach.

You can still do this with AIJ type..

> Another question. In calling PETSc for solving the linear system for the
> second time, I got this:
>   You can not initialize PETSc a second time!
> But I did destroy and finalized last PETSc structure, via
>   MatDestroy(A);
>   VecDestroy(x);
>   VecDestroy(b);
>   KSPDestroy(ksp);
>   PetscFinalize();
> Any suggestion is greatly welcome!

As the message says - you can't call PetscInitialize()/Finalize()
multiple times. The same thing with MPI_Init()/Finalize().

So you'll have to remove these 2 calls from your loop [or function
that gets called multiple times] - to a location where they get called
only once.


More information about the petsc-users mailing list