[petsc-dev] Matrix Free Conjugate Gradient

Hesameddin Ilatikhameneh hilatikh at purdue.edu
Sat Dec 1 00:48:21 CST 2012


Sorry but I didn't get/understand the answer to my questions:

1- I don't want to store Jacobian matrix so how is that Mat A is input of the function PetscErrorCode YourMatMult(Mat A,Vec X,Vec Y)?

2- I need to find each row of Jacobian and multiply it with a vector which is needed in Petsc CG and store that to a vector. So there should be very specific function associated with specific method (like CG in this case).

3- What is vector X in YourMatMult(Mat A,Vec X,Vec Y)? Where this matrix-multipication will be used? 

Thanks 
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 1:08:59 AM
Subject: Re: [petsc-dev] Matrix Free Conjugate Gradient

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 



More information about the petsc-dev mailing list