[petsc-dev] [petsc-users] How to pass the parameters for KSP

Barry Smith bsmith at mcs.anl.gov
Wed Oct 6 21:05:57 CDT 2010


This discussion should take place on the petsc-dev at mcs.anl.gov mailing list since it involves developing PETSc source code, not using it.

Convergence tests are done via a standard method for all Krylov methods so if by "Tolerance" you mean the usual rtol or atol you should use the same mechanism as biCG-stab

The matrix that defines the linear system as passed as the first matrix to KSPSetOperators() and as in the biCG-stab code can be accessed via PCGetOperators(). 

The matrix that is used to construct the preconditioner is the second matrix to KSPSetOperators() and similarly can be accessed via PCGetOperators().

If you have some other matrix for some other purpose then you need to provide a custom function to set it for your solver: see for example how KSPGMRESSetRestart() is handled as
a custom function that sets something directly into the KSP_GMRES data structure

Similar for whatever this flag and err arguments might be.

The right hand side is handled the same by all the KSP solvers, see how it is accessed in KSPSolve_BCGS.

You will have to understand exactly the structure and flow of the KSPSolve_BCGS before implementing your own.

   Barry

  
On Oct 6, 2010, at 8:56 PM, vedaprakash subramanian wrote:

> I need my KSP to take in Tolerence, flag, err, 3 matrices, right hand side vector. How can I make it to take all the parameters.
> 
> On Mon, Sep 20, 2010 at 11:00 AM, <petsc-users-request at mcs.anl.gov> wrote:
> Send petsc-users mailing list submissions to
>        petsc-users at mcs.anl.gov
> 
> To subscribe or unsubscribe via the World Wide Web, visit
>        https://lists.mcs.anl.gov/mailman/listinfo/petsc-users
> or, via email, send a message with subject or body 'help' to
>        petsc-users-request at mcs.anl.gov
> 
> You can reach the person managing the list at
>        petsc-users-owner at mcs.anl.gov
> 
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of petsc-users digest..."
> 
> 
> Today's Topics:
> 
>   1.  How to pass the parameters for KSP (vedaprakash subramanian)
>   2. Re:  How to pass the parameters for KSP (Barry Smith)
> 
> 
> ----------------------------------------------------------------------
> 
> Message: 1
> Date: Sun, 19 Sep 2010 19:05:48 -0600
> From: vedaprakash subramanian <vedaprakashsubramanian at gmail.com>
> Subject: [petsc-users] How to pass the parameters for KSP
> To: petsc-users at mcs.anl.gov
> Message-ID:
>        <AANLkTinjiGMTMVB1yVx6JEvPhjGi_=T+QY6HK7wnHgOa at mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
> 
> I am converting a MATLAB function into a KSP solver. I am doing it similar
> to BiCGStab. But I wanted to know how to pass the arguments of the function
> into KSP solver.
> 
> Thanks,
> Vedaprakash
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20100919/9d902e74/attachment-0001.htm>
> 
> ------------------------------
> 
> Message: 2
> Date: Sun, 19 Sep 2010 21:49:47 -0500
> From: Barry Smith <bsmith at mcs.anl.gov>
> Subject: Re: [petsc-users] How to pass the parameters for KSP
> To: PETSc users list <petsc-users at mcs.anl.gov>
> Message-ID: <27B820EF-3A6A-424B-8A43-2A43E82089B3 at mcs.anl.gov>
> Content-Type: text/plain; charset=us-ascii
> 
> 
>  What arguments? Do you mean the right hand side x and the matrix? Or do you mean parameters like the relative tolerance in convergence?
> 
>  See src/ksp/ksp/examples/tutorials/ex1.c for a simple example.
> 
>   Barry
> 
> On Sep 19, 2010, at 8:05 PM, vedaprakash subramanian wrote:
> 
> > I am converting a MATLAB function into a KSP solver. I am doing it similar to BiCGStab. But I wanted to know how to pass the arguments of the function into KSP solver.
> >
> > Thanks,
> > Vedaprakash
> 
> 
> 
> ------------------------------
> 
> _______________________________________________
> petsc-users mailing list
> petsc-users at mcs.anl.gov
> https://lists.mcs.anl.gov/mailman/listinfo/petsc-users
> 
> 
> End of petsc-users Digest, Vol 21, Issue 32
> *******************************************
> 




More information about the petsc-dev mailing list