[petsc-users] SLEPc with offline preconditioner

Ye Jianbo Bob yelpoo at gmail.com
Sat May 26 08:37:20 CDT 2012


Hi Jose, I found shift-and-invert does not work with an iterative pc
solver. Say the examples given in source code

/home/bobye/pub/slepc/slepc-3.2-p3/src/eps/examples/tutorials/ex11.c
------------------------------------------------------------------
if I use the default setting, in fact I am not sure which pc it is
used, even which is coefficient matrix. But it works well. However, in
my cases, I am interested in how to reuse manipulation of A for
different eigenvalues problem.
bobye@:tutorials$ ./ex11 -n 30 -eps_nev 5

Fiedler vector of a 2-D regular mesh, N=900 (30x30 grid)

 Number of iterations of the method: 20
 Solution method: krylovschur

 Number of requested eigenvalues: 5
 Stopping condition: tol=1e-08, maxit=100
 Number of converged approximate eigenpairs: 7

           k          ||Ax-kx||/||kx||
   ----------------- ------------------
       0.010956        1.60437e-09
       0.021912        1.97096e-09
       0.043705         5.3322e-10
       0.054661        4.01148e-09
       0.087410         8.7469e-10
       0.097887         2.0693e-09
       0.108843        3.46988e-09
------------------------------------------------------------------
if I use direct pc
bobye@:tutorials$ ./ex11 -n 30 -eps_nev 5 -st_type sinvert -st_pc_type lu
It will report Detected zero pivot in LU factorization
------------------------------------------------------------------
if I use direct pc with shift value
bobye@:tutorials$ ./ex11 -n 30 -eps_nev 5 -st_type sinvert -st_shift
1e-9 -st_pc_type lu

Fiedler vector of a 2-D regular mesh, N=900 (30x30 grid)

 Number of iterations of the method: 1
 Solution method: krylovschur

 Number of requested eigenvalues: 5
 Stopping condition: tol=1e-08, maxit=100
 Number of converged approximate eigenpairs: 5

           k          ||Ax-kx||/||kx||
   ----------------- ------------------
       0.010956        5.37411e-08
       0.010956         5.3741e-08
       0.021912        5.13947e-14
       0.043705        1.95903e-11
       0.054661        2.62529e-09

------------------------------------------------------------------
if I use iterative pc with shift-and-invert, the result seems to be wrong.
bobye@:tutorials$ ./ex11 -n 30 -eps_nev 5 -st_type sinvert -st_pc_type
jacobi -st_ksp_rtol 1e-12

Fiedler vector of a 2-D regular mesh, N=900 (30x30 grid)

 Number of iterations of the method: 1
 Solution method: krylovschur

 Number of requested eigenvalues: 5
 Stopping condition: tol=1e-08, maxit=100
 Number of converged approximate eigenpairs: 12

           k          ||Ax-kx||/||kx||
   ----------------- ------------------
       2.000000           0.707107
       2.000000           0.707107
       2.000000           0.707107
       2.004191           0.704215
       3.000000           0.579634
       3.000000           0.578826
       3.000000           0.580728
       3.000000            0.57262
       3.000000           0.597176
       3.000000           0.562004
       3.000000           0.587957
       3.096958           0.710225


-jianbo

On Sat, May 26, 2012 at 5:47 PM, Jose E. Roman <jroman at dsic.upv.es> wrote:
>
> El 26/05/2012, a las 10:47, Ye Jianbo Bob escribió:
>
>> Hi, I have some problem when using SLEPc to compute eigenvalue
>> problems. I do not know how to implement my idea properly. Let me
>> explain in detail.
>>
>> I am interested in solving a set of eigenvalue problems (to find the
>> smallest magnitude eigenvalues)
>>
>> A x = \lambda B_i x
>> for i=1,2,3,...
>>
>> where A is the Laplacian of some regular grid, B_i is diagonal. It is
>> known that A is semi-positive with a null vector [1,1,...,1].
>>
>> I found SLEPc provides EPSSetDeflationSpace to set deflation space
>> when applies iterative eigen solver. But I am not sure what default
>> precondition is used when I defined my problem by setting
>> eps_smallest_magnitude through EPSSetWhichEigenpairs.
>>
>> It is possible to use shift-and-invert to explicitly address my
>> problem. If the shift value is 0, zero pivot will be reported during
>> LU precondition stage. But since my set of eigen problems has the
>> exact the same A, I hope I could somehow do the precondition (direct
>> solver) offline only associate with A and apply the iterative eigen
>> solver online with set of different B_i.
>>
>> The very initiative is the direct solver applied in precondition stage
>> is O(N^2) while the matrix-free eigen solver is O(N), thus I think
>> this would improve the efficiency of my situation. Is there any way to
>> realize it?
>>
>> Here is some rough idea:
>> To prevent the zero pivot during LU, I would dampshift A with a small
>> quantity A-\sigma I, and then compute its LU offline and store it. In
>> online stage, I could build an ST shell that read LU computed in
>> offline stage and solve. This is only an approximated approach,
>> hopefully not degrading the performance.
>>
>> Thank you!
>
> You can use STSHELL to perform any customized spectral transformation. But in your case I don't think it is necessary. [1,1,...,1] is also an eigenvector of the matrix pair (A,B), so you can pass it through EPSSetDeflationSpace, then use shift-and-invert with zero target - in that case the internal KSP will have A as the coefficient matrix and KSPSetNullSpace will be invoked with the [1,1,...,1] vector. The only thing is that you have to use a KSP solver that supports nullspaces. I am not sure if PETSc's direct solvers (or external solvers) support it, so you may have to use an iterative solver (e.g., -st_ksp_type bcgs -st_pc_type bjacobi -st_ksp_rtol 1e-9).
>
> Jose
>


More information about the petsc-users mailing list