[petsc-users] preconditioned eigensolver in slepc

Verena Kuhlemann vkuhlem at gmail.com
Thu Feb 16 10:16:12 CST 2012


Thanks for the answer.

When I want to set a preconditioner then I will need to do that via
STGetKSP and the KSPGetPC ?
In the end I want to use a shell preconditioner.

On Thu, Feb 16, 2012 at 7:54 AM, Jose E. Roman <jroman at dsic.upv.es> wrote:

>
> El 16/02/2012, a las 16:41, Verena Kuhlemann escribió:
>
> > Hi,
> >
> > I am trying to use LOBPCG via Slepc and I am a little confused on how to
> set the preconditioner and operator matrices. I have a shell matrix A and a
> matrix P that should be used for the preconditioning. Here is the relevant
> part of my code:
> >
> > EPSCreate(PETSC_COMM_WORLD,&eps);
> > EPSSetOperators(eps, A, PETSC_NULL);
> > EPSSetProblemType(eps, EPS_HEP);
> > EPSSetType(eps, EPSBLOPEX);
> > EPSGetST(eps, &st);
> > STPrecondSetMatForPC(st, P);
> > STGetKSP(st,&ksp);
> > KSPGetPC(ksp, &pc);
> > KSPSetOperators(ksp,A, P, DIFFERENT_NONZERO_PATTERN); //do I have to set
> this?? If I don't the program complains that a matrix is not set
> > PCSetType(pc, PCJACOBI);
> > EPSSetUp(eps);
> >
> >
> > Is that correct or do I need to do something else?
> >
> > Thanks,
> > Verena
>
> It works for me like this:
>
>  ierr = EPSCreate(PETSC_COMM_WORLD,&eps);CHKERRQ(ierr);
>  ierr = EPSSetOperators(eps,A,PETSC_NULL);CHKERRQ(ierr);
>  ierr = EPSSetProblemType(eps,EPS_HEP);CHKERRQ(ierr);
>  ierr = EPSSetType(eps,EPSBLOPEX);CHKERRQ(ierr);
>  ierr = EPSGetST(eps,&st);CHKERRQ(ierr);
>  ierr = STPrecondSetMatForPC(st,P);CHKERRQ(ierr);
>  ierr = EPSSetFromOptions(eps);CHKERRQ(ierr);
>
> You don't need to manipulate the KSP or PC objects.
>
> If you want to check whether your matrix P is being used in Blopex, you
> can do
>  ierr = PetscObjectSetName((PetscObject)P,"My precond");CHKERRQ(ierr);
>
> then run with -eps_view and you will see "Matrix Object:    My precond
> 1 MPI processes" in the PC section.
>
> Jose
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20120216/55226c7a/attachment.htm>


More information about the petsc-users mailing list