Dear Jose,
        Many thanks for the guidance. I haven't yet extensively tested the 
program, but I will cautiously
claim that it seems to be working
on the small   test problem described below (i.e. a small modification of your 
ex1f.F program).  I am currently
 using version 3.20, but I will upgrade to 3.22 when it comes out.
For the Laplace problem with n=50 , using the gd method and seeking to find the 
two leading eigenmodes (nev=2)
  using a space of dimension ncv = 30, with default tolerance,  on the first 
solution
(using a randomized initial subspace) the algorithm requires 91 iterations to 
converge,
 whereas for the second solution (using the previous solution invariant 
subspace as an initial subspace)
it finds the solution in 2 iterations.
      Many thanks once again and best wishes,
         Dan.



>The Fortran interface is not fully tested. In particular, this function is not 
>employed in any of the Fortran examples.

>The Fortran interface has undergone successive improvements in recent times. I 
>have tried the following:

  >    Vec, pointer :: subspace_receive(:)
   >   ...
    >  PetscCall(EPSGetConverged(eps, nconv, ierr))
    >  PetscCall(MatCreateVecs(A, PETSC_NULL_VEC, xr, ierr))
    >  PetscCall(VecDuplicateVecsF90(xr, nconv, subspace_receive, ierr))
    >  PetscCall(EPSGetInvariantSubspace(eps, subspace_receive, ierr))
    >  ...
    >  PetscCall(VecDestroyVecsF90(nconv, subspace_receive, ierr))
    >  PetscCall(VecDestroy(xr, ierr))

>I have tested this in the 'main' branch and it works as expected (note that 
>'main' will become version 3.22 in two weeks). You can try with version 3.21 
>and it may work, > probably not in older versions.

  *   Jose







> El 16 sept 2024, a las 11:07, dazza simplythebest <sayos...@hotmail.com> 
> escribió:
>
> Dear All and Jose,
>                              I am now trying to code up the extraction of the 
> invariant subspace, but I seem to be running into
> a compilation problem. I am using the slepc example file ex1f.F as a base, 
> and have added the following lines:
>
> !Declaration
>       Vec subspace_receive
> .
> .
> .
> ! Executed code (following EPSSolve)
>           call EPSGetConverged(eps,nconv,ierr); CHKERRA(ierr)
>       call VecDuplicateVecs(xr, nconv, subspace_receive, ierr); CHKERRA(ierr)
>       call EPSGetInvariantSubspace(eps, subspace_receive, ierr) ; 
> CHKERRA(ierr).
> .
> .
>
> However, I get the following compilation error when I include the call 
> EPSGetInvariantSubspace(eps, subspace_receive, ierr) line:
>
>
> minitest.F(133): error #8284: If the actual argument is scalar, the dummy 
> argument shall be scalar unless the actual argument is of type character or 
> is an element of an array that is not assumed shape, pointer, or polymorphic. 
>   [B]
>       call EPSGetInvariantSubspace(eps, subspace_receive, ierr) ; if (ierr 
> .ne. 0) then;call PetscErrorF(ierr,133,"minitest.F");call 
> MPIU_Abort(PETSC_COMM_SELF,ierr);endif
> -----------^
> compilation aborted for minitest.F (code 1)
>
>
> If I comment out the call EPSGetInvariantSubspace(eps, subspace_receive, 
> ierr) line the code compiles, links and runs successfully.
> I presume that I must be making a silly mistake in the above lines, but I 
> can't quite see what it is.  (There is some discussion in the
> manual of there being a different situation if the matrix is real but the 
> eigenvalues are complex, but for this case the eigenvalues
>  are real). Can you offer any guidance ?! I can provide the whole code of 
> course if that would help.
>    Many thanks and best wishes,
>                                         Dan.
>
>
>
>
>
> From: Jose E. Roman <jro...@dsic.upv.es>
> Sent: Monday, September 2, 2024 7:06 AM
> To: dazza simplythebest <sayos...@hotmail.com>
> Cc: petsc-users@mcs.anl.gov <petsc-users@mcs.anl.gov>
> Subject: Re: [petsc-users] How to create an array of vectors of type Vec (for 
> use with slepc EPSGetInvariantSubspace)
>  You can use VecDuplicateVecs() to create an array of Vec.
> Yes, you can use VecLoad() to read the data from a binary file.
>
> Jose
>
>
> > El 2 sept 2024, a las 8:56, dazza simplythebest <sayos...@hotmail.com> 
> > escribió:
> >
> > Dear All,
> >            I am seeking to perform a large number of eigenvalue 
> > calculations (related to a fluid dynamics
> >  problem) using the slepc  framework. I have written the program that calls 
> > slepc and validated its solutions against
> >  known results for special cases - the Jacobi-Davidson iteration seemed to 
> > perform best on this problem.
> >  Since in the 'production-level' calculation I will step through a 
> > parameter space which should
> > mean only small changes to the eigenproblem between each calculation, it 
> > seems to make sense
> >  to use the previous solution as the initial guess for the next calculation.
> >
> >  The sequence to execute this strategy would seem to be:
> > To write out the current soln subspace:
> >
> > call EPSGetInvariantSubspace
> > [ call VecView   -> binary file (if a file storage is required for possible 
> > restart)]
> >
> > To then read in this data to use it as the initial subspace for the next 
> > run:
> >
> > call  EPSSetInitialSpace
> >
> > My question is that EPSGetInvariantSubspace needs an 'array of nconv 
> > vectors', how does one create
> >  such an array ? My understanding is that the Vec structure is just a 
> > one-dimensional array (with contents
> >  possibly scattered in non-contiguous memory locations !?) , so do we just 
> > need to create a long Vec
> >  that stores multiple vectors ? How can we do this (the examples I have 
> > seen thus far use a MatCreateVecs to specify the size
> >  of the Vec)?
> >
> > If loading such a subspace from a binary file (created maybe by VecView), 
> > presumably VecLoad is the
> >  best way to load such an array of vectors from the binary file ?
> >
> >  Best wishes and many thanks,
> >                                             Dan.

Reply via email to