[petsc-users] question about arbitrary eigenvector selection in SLEPC

Giacomo Mulas gmulas at oa-cagliari.inaf.it
Thu May 29 04:45:18 CDT 2014


Hi Jose, nice hearing from you. Thanks for your help.

On Wed, 28 May 2014, Jose E. Roman wrote:

> I don't see much problem.
>
>>
>> 2) should I destroy and recreate the eps after each call to EPSSolve and
>> before next call? Or, since the underlying matrix is always the same, can I
>> just call EPSSetInitialSpace(), EPSSetDeflationSpace(), update the internal
>> parameter to be passed to the arbitrary selection function and I can call
>> again EPSSolve?
>
> No need to recreate the solver. The only thing is EPSSetDeflationSpace() -
> I would suggest calling EPSRemoveDeflationSpace() and then
> EPSSetDeflationSpace() again with the extended set of vectors.  Do not
> call EPSSetDeflationSpace() with a single vector every time.

Yes, indeed. I did not detail it in my description but what I do is keep an
array Vec[] (allocated large enough at the beginning) and I attach
eigenvectors to it as I find them. 
After every call to EPSSolve I do

       ierr = EPSGetConverged(eps, &nconverged); CHKERRQ(ierr);
       if (nconverged > 0) {
 	for (petsck=0; petsck<=nconverged-1; petsck++) {
 	  EPSGetEigenpair(eps, petsck, &lambdar, &lambdai, xr, xi);
           newtotconverged = totconverged+petsk;
 	  ierr = VecDuplicate(xr, Cv+newtotconverged);
 	  ierr = VecCopy(xr, Cv[newtotconverged]);
         }
         totconverged += nconverged;
         ierr = EPSSetDeflationSpace(eps, totconverged, Cv);
       }

So every time I call EPSSetDeflationSpace() I do give it the complete set of
eigenvectors found so far, and their number, including the previously found
ones.
In the man page of EPSSetDeflationSpace it says that if another deflation
space was previously defined, it is killed and replaced by the new one,
that's why I did not explicitly call EPSRemoveDeflationSpace() until I'm
done.  Should I instead call EPSRemoveDeflationSpace every time before
calling EPSSetDeflationSpace?  i.e.  add a call to EPSRemoveDeflationSpace()
before the one to EPSSetDeflationSpace() in the snippet above?

>> 3) Since what I want is going on to find one eigenpair at a time of the same
>> problem until some condition is fulfilled, is there a way in which I can
>> achieve this without setting it up again and again every time? Can I specify
>> an arbitrary function that is called by EPSSolve to decide whether enough
>> eigenpairs were computed or not, instead of doing it in this somewhat
>> awkward manner?
>
> No.

ok. Then another question comes after this: how much overhead is involved in
setting up the deflation space etc.  for every eigenvector that is computed? 
I guess that EPSSolve, when more than one eigenpair is needed, actually does
the internal book-keeping of adding the already converged eigenvectors to
the deflation space, so doing it by hand out of EPSSolve looks inefficient
(even if maybe it's not so bad, I don't know the internals of the code).  If
I have a reasonable guess of how many eigenvectors I will need, would it be
much more efficient to determine more eigenvectors than one with each
EPSSolve call, with the risk of wasting time finding a few more than I need? 
How expensive is finding one eigenpair compared to the overhead of setting
up a new deflation space and calling EPSSolve repeatedly?  How do the costs
scale with the size of the matrix, and the size of the deflation space?

After I get at least one version of my code working properly, I will try
doing some tests with this, if it's useful.

Bye, thanks
Giacomo

-- 
_________________________________________________________________

Giacomo Mulas <gmulas at oa-cagliari.inaf.it>
_________________________________________________________________

INAF - Osservatorio Astronomico di Cagliari
via della scienza 5 - 09047 Selargius (CA)

tel.   +39 070 71180244
mob. : +39 329  6603810
_________________________________________________________________

"When the storms are raging around you, stay right where you are"
                          (Freddy Mercury)
_________________________________________________________________


More information about the petsc-users mailing list