Thanks for the answer. <div><br></div><div>When I want to set a preconditioner then I will need to do that via STGetKSP and the KSPGetPC ?</div><div>In the end I want to use a shell preconditioner.<br><br><div class="gmail_quote">
On Thu, Feb 16, 2012 at 7:54 AM, Jose E. Roman <span dir="ltr"><<a href="mailto:jroman@dsic.upv.es">jroman@dsic.upv.es</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
El 16/02/2012, a las 16:41, Verena Kuhlemann escribió:<br>
<div><div class="h5"><br>
> Hi,<br>
><br>
> 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:<br>
><br>
> EPSCreate(PETSC_COMM_WORLD,&eps);<br>
> EPSSetOperators(eps, A, PETSC_NULL);<br>
> EPSSetProblemType(eps, EPS_HEP);<br>
> EPSSetType(eps, EPSBLOPEX);<br>
> EPSGetST(eps, &st);<br>
> STPrecondSetMatForPC(st, P);<br>
> STGetKSP(st,&ksp);<br>
> KSPGetPC(ksp, &pc);<br>
> 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<br>
> PCSetType(pc, PCJACOBI);<br>
> EPSSetUp(eps);<br>
><br>
><br>
> Is that correct or do I need to do something else?<br>
><br>
> Thanks,<br>
> Verena<br>
<br>
</div></div>It works for me like this:<br>
<br>
ierr = EPSCreate(PETSC_COMM_WORLD,&eps);CHKERRQ(ierr);<br>
ierr = EPSSetOperators(eps,A,PETSC_NULL);CHKERRQ(ierr);<br>
ierr = EPSSetProblemType(eps,EPS_HEP);CHKERRQ(ierr);<br>
ierr = EPSSetType(eps,EPSBLOPEX);CHKERRQ(ierr);<br>
ierr = EPSGetST(eps,&st);CHKERRQ(ierr);<br>
ierr = STPrecondSetMatForPC(st,P);CHKERRQ(ierr);<br>
ierr = EPSSetFromOptions(eps);CHKERRQ(ierr);<br>
<br>
You don't need to manipulate the KSP or PC objects.<br>
<br>
If you want to check whether your matrix P is being used in Blopex, you can do<br>
ierr = PetscObjectSetName((PetscObject)P,"My precond");CHKERRQ(ierr);<br>
<br>
then run with -eps_view and you will see "Matrix Object: My precond 1 MPI processes" in the PC section.<br>
<span class="HOEnZb"><font color="#888888"><br>
Jose<br>
<br>
</font></span></blockquote></div><br></div>