[petsc-dev] Matrix Free Conjugate Gradient

Jed Brown jedbrown at mcs.anl.gov
Sat Dec 1 00:08:59 CST 2012


On Fri, Nov 30, 2012 at 11:53 PM, Hesameddin Ilatikhameneh <
hilatikh at purdue.edu> wrote:

> Could you provide more information/example.
> I don't know that for example for matrix-free conjugate gradient in Petsc
> which matrix operation I should do.
> I guess that I need to write the function that gives Jacobian times a
> vector which is vector (Since I don't want to store Jacobian).
> If it is so, which vector is that vector? Petsc will do which parts of the
> algorithm?
>

You implement

PetscErrorCode YourMatMult(Mat A,Vec X,Vec Y);

which computes Y <-- A*X. There is a section of the user's manual, as well
as a couple examples linked from the page I sent.

You only need to implement that one function, then pass -pc_type none so
that no preconditioning is done. PETSc will do everything else in the solve.


>
> Thanks for your help.
>
> Hesam
>
> ----- Original Message -----
> From: "Jed Brown" <jedbrown at mcs.anl.gov>
> To: "For users of the development version of PETSc" <petsc-dev at mcs.anl.gov
> >
> Sent: Saturday, December 1, 2012 12:37:22 AM
> Subject: Re: [petsc-dev] Matrix Free Conjugate Gradient
>
>
> http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatShellSetOperation.html
>
>
>
> Note that without an assembled matrix, you'll generally need to write your
> own preconditioner, which you can do using PCShell.
>
>
>
> On Fri, Nov 30, 2012 at 11:24 PM, Hesameddin Ilatikhameneh <
> hilatikh at purdue.edu > wrote:
>
>
> Hello,
>
> We have a very large system (100M variables) which we want to minimize its
> energy. We are using Petsc extensively for matrix operations.
> I know that it is theoretically possible to use conjugate gradient method
> without storing Jacobian matrix (which is very huge in this case) since the
> conjugate gradient needs Jacobian times a vector not Jacobian itself.
>
> I read your manual about matrix free methods but I couldn't find where I
> can determine that function to Jacobian times a vector.
>
> I appreciate your help.
>
> Thanks
> Hesam
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20121201/408367d3/attachment.html>


More information about the petsc-dev mailing list