2011/1/16 Barry Smith <span dir="ltr"><<a href="mailto:bsmith@mcs.anl.gov">bsmith@mcs.anl.gov</a>></span><br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="im"><br>
On Jan 16, 2011, at 5:59 PM, Darcoux Christine wrote:<br>
<br>
> I am new to PETSc and I am interested to use the nonlinear solver in a CFD code for low speed compressible fluid.<br>
><br>
> According to some papers, it seems that GMRES (or any other Krylov method) could be used to precondition FGMRES in a way that is completely matrix-free. Is it something possible with the fgmres implementation provided by PETSc ?<br>
<br>
</div> Yes, but like anything with "matrix-free" is the question how you provide a decent preconditioner without forming any matrices. If you can do that then you are all set.<br>
<br>
KSPSetOperators(ksp,A,B,...) or SNESSetJacobian(snes,A,B, ....) where A is a a MATSHELL that does matrix vector products or use MatCreateMFFD()<br>
<br>
-ksp_type fgmres -pc_type ksp -ksp_ksp_type gmres -ksp_view<br>
<br>
If B is some approximate representation of A then B will be used to construct the preconditioner, if you never have a matrix-representation but have a function/subroutine that is supposedly a good preconditioner then you would use PCSHELL to provide it. So there are several possibilities depending on what you have and what you want to do.<br>
<br>
Barry<br>
<br>
> Christine<br>
><br></blockquote><div><br><br>Thank you for the detailled explanations. My idea is to simply precondition fGMRES with GMRES to avoid creating a B that is an approximate representation of A. If A is represented by a mat-vec routine, I think that the preconditionner M (approximation of the inverse of A) could be defined by the action of GMRES. Here's a code pseudo-code showing how I would like to define such an M. <br>
<br>1. Define matrix A as a mat-vec operation (matrix free), right-hand-side b and x0 a zero vector <br>2. The tricky part is now to define M by a mat-vec function like this<br><br>function precon_matvec(x) { <br> //Basically, GMRES approximates inverse(A) with a polynomial <br>
// P(A) so that x = x0 + P(A)*r, where r is the residual. Thus in the <br> // call to GMRES, x0 is a zero vector and the right-hand-side is x. <br> return gmres(A, x, x0, tolerance=gmres_tol, maxiter=10) <br>}<br>
<br>M = CreateMatrixFreePreconditionner (precon_matvec)<br><br>3. Now call fGMRES with the above M preconditionner<br><br>Is it possible to acheive something like this with PETSc ?<br></div></div><br>