[petsc-users] SPAI preconditioner in PETSc
Danesh Daroui
danesh.daroui at ltu.se
Tue May 10 06:44:37 CDT 2011
Hi,
I have tried to use SPAI (Sparse Approximate Inverse) preconditioner in
PETSc as describes in manual. I choose the preconditioner as below:
ierr=KSPCreate(PETSC_COMM_WORLD, &ksp);
ierr=KSPSetOperators(ksp, Mp, Mp, DIFFERENT_NONZERO_PATTERN);
// conjugate gradient method is used
ierr=KSPSetType(ksp, KSPGMRES);
// SPAI preconditioner is used
ierr=KSPGetPC(ksp, &prec);
ierr=PCSetType(prec, PCSPAI);
// set up the solver according to the options
ierr=KSPSetFromOptions(ksp);
ierr=KSPSetUp(ksp);
// solve the equation using an iterative solver
ierr=KSPSolve(ksp, bp, xp);
But when I run my code I get following error:
[0]PETSC ERROR: --------------------- Error Message
------------------------------------
[0]PETSC ERROR: Unknown type. Check for miss-spelling or missing
external package needed for type
seehttp://www.mcs.anl.gov/petsc/petsc-as/documentation/installation.html#external!
[0]PETSC ERROR: Unable to find requested PC type spai!
[0]PETSC ERROR:
------------------------------------------------------------------------
[0]PETSC ERROR: Petsc Release Version 3.1.0, Patch 8, Thu Mar 17
13:37:48 CDT 2011
[0]PETSC ERROR: See docs/changes/index.html for recent updates.
[0]PETSC ERROR: See docs/faq.html for hints about trouble shooting.
[0]PETSC ERROR: See docs/index.html for manual pages.
[0]PETSC ERROR:
------------------------------------------------------------------------
[0]PETSC ERROR: Unknown Name on a linux-gnu named linux-sclt.site by dan
Tue May 10 13:34:25 2011
[0]PETSC ERROR: Libraries linked
from /home/danesh/petsc-3.1-p8/linux-gnu-intel/lib
[0]PETSC ERROR: Configure run at Mon May 9 19:30:35 2011
[0]PETSC ERROR: Configure options PETSC_ARCH=linux-gnu-intel
--with-scalar-type=complex --with-clanguage=c++ --with-mpi=0
--with-cc=icc --with-fc=gfortran --with-cxx=icpc
--with-blas-lapack-dir=/home/danesh/intel/mkl/lib/intel64/
--with-debugging=0
[0]PETSC ERROR:
------------------------------------------------------------------------
[0]PETSC ERROR: PCSetType() line 67 in src/ksp/pc/interface/pcset.c
I also checked the SPAI web page and they have also mentioned that there
is an interface for PETSc but nothing more. Have anyone used this
preconditioner before? Does anybody know how it can be used in PETSc? I
know that SPAI uses least squares for approximate inverse and thus it
needs a sparsity pattern, so it can simply be called as I did and it
needs more parameters which I don't know how can be passed to PETSc.
I have also another questions. In my code, even when the solution is
converged withing few iterations, the result is far different from
correct solution that I have. I am suspecting that there something wrong
with matrix filling in my code. Is there anyway to use direct solver in
PETSc so I will verify that my matrices are correct before trying
iterative solvers?
Thanks,
Danesh
More information about the petsc-users
mailing list