<div dir="ltr"><div dir="ltr">Thanks Jose,<div><br></div><div>I think I understand now. Another question: what is the right way to setup a linear preconditioning matrix for the inner linear solver of JD?</div><div><br></div><div>I was trying to do something like this:</div><div><br></div><div><div> /*</div><div> Create eigensolver context</div><div> */</div><div> ierr = EPSCreate(PETSC_COMM_WORLD,&eps);CHKERRQ(ierr);</div><div><br></div><div> /*</div><div> Set operators. In this case, it is a standard eigenvalue problem</div><div> */</div><div> ierr = EPSSetOperators(eps,A,NULL);CHKERRQ(ierr);</div><div> ierr = EPSSetProblemType(eps,EPS_HEP);CHKERRQ(ierr);</div><div> ierr = EPSGetST(eps,&st);CHKERRQ(ierr);</div><div> ierr = STPrecondSetMatForPC(st,B);CHKERRQ(ierr);</div><div><br></div><div> /*</div><div> Set solver parameters at runtime</div><div> */</div><div> ierr = EPSSetFromOptions(eps);CHKERRQ(ierr);</div><div><br></div><div> /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -</div><div> Solve the eigensystem</div><div> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */</div><div><br></div><div> ierr = EPSSolve(eps);CHKERRQ(ierr);</div></div><div><br></div><div><br></div><div>But did not work. A complete example is attached. I could try to dig into the code, but you may already know the answer.</div><div><br></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Oct 23, 2019 at 3:58 AM Jose E. Roman <<a href="mailto:jroman@dsic.upv.es">jroman@dsic.upv.es</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">Yes, it is confusing. Here is the explanation: when you use a target, the preconditioner is built from matrix A-sigma*B. By default, instead of TARGET_MAGNITUDE we set LARGEST_MAGNITUDE, and in Jacobi-Davidson we treat this case by setting sigma=PETSC_MAX_REAL. In this case, the preconditioner is built from matrix B. The thing is that in a standard eigenproblem we have B=I, and hence there is no point in using a preconditioner, that is why we set PCNONE.<br>
<br>
Jose<br>
<br>
<br>
> El 22 oct 2019, a las 19:57, Fande Kong via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a>> escribió:<br>
> <br>
> Hi All,<br>
> <br>
> It looks like the preconditioner is hard-coded in the Jacobi-Davidson solver. I could not select a preconditioner rather than the default setting.<br>
> <br>
> For example, I was trying to select LU, but PC NONE was still used. I ran standard example 2 in slepc/src/eps/examples/tutorials, and had the following results.<br>
> <br>
> <br>
> Thanks,<br>
> <br>
> Fande<br>
> <br>
> <br>
> ./ex2 -eps_type jd -st_ksp_type gmres -st_pc_type lu -eps_view <br>
> <br>
> 2-D Laplacian Eigenproblem, N=100 (10x10 grid)<br>
> <br>
> EPS Object: 1 MPI processes<br>
> type: jd<br>
> search subspace is orthogonalized<br>
> block size=1<br>
> type of the initial subspace: non-Krylov<br>
> size of the subspace after restarting: 6<br>
> number of vectors after restarting from the previous iteration: 1<br>
> threshold for changing the target in the correction equation (fix): 0.01<br>
> problem type: symmetric eigenvalue problem<br>
> selected portion of the spectrum: largest eigenvalues in magnitude<br>
> number of eigenvalues (nev): 1<br>
> number of column vectors (ncv): 17<br>
> maximum dimension of projected problem (mpd): 17<br>
> maximum number of iterations: 1700<br>
> tolerance: 1e-08<br>
> convergence test: relative to the eigenvalue<br>
> BV Object: 1 MPI processes<br>
> type: svec<br>
> 17 columns of global length 100<br>
> vector orthogonalization method: classical Gram-Schmidt<br>
> orthogonalization refinement: if needed (eta: 0.7071)<br>
> block orthogonalization method: GS<br>
> doing matmult as a single matrix-matrix product<br>
> DS Object: 1 MPI processes<br>
> type: hep<br>
> solving the problem with: Implicit QR method (_steqr)<br>
> ST Object: 1 MPI processes<br>
> type: precond<br>
> shift: 1.79769e+308<br>
> number of matrices: 1<br>
> KSP Object: (st_) 1 MPI processes<br>
> type: gmres<br>
> restart=30, using Classical (unmodified) Gram-Schmidt Orthogonalization with no iterative refinement<br>
> happy breakdown tolerance 1e-30<br>
> maximum iterations=90, initial guess is zero<br>
> tolerances: relative=0.0001, absolute=1e-50, divergence=10000.<br>
> left preconditioning<br>
> using PRECONDITIONED norm type for convergence test<br>
> PC Object: (st_) 1 MPI processes<br>
> type: none<br>
> linear system matrix = precond matrix:<br>
> Mat Object: 1 MPI processes<br>
> type: shell<br>
> rows=100, cols=100<br>
> Solution method: jd<br>
> <br>
> Number of requested eigenvalues: 1<br>
> Linear eigensolve converged (1 eigenpair) due to CONVERGED_TOL; iterations 20<br>
> ---------------------- --------------------<br>
> k ||Ax-kx||/||kx||<br>
> ---------------------- --------------------<br>
> 7.837972 7.71944e-10<br>
> ---------------------- --------------------<br>
> <br>
> <br>
> <br>
<br>
</blockquote></div>