<div class="gmail_quote">On Sat, Sep 22, 2012 at 12:33 AM, Shao-Ching Huang <span dir="ltr"><<a href="mailto:huangsc@gmail.com" target="_blank">huangsc@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div id=":59t">Is this equivalent to setting up a SNES where the (constant) Jacobian<br>
is my A1 matrix, similar to ex35.c in the snes directory (despite with<br>
different PC type)?<br></div></blockquote></div><br><div>Sure, make your residual function</div><div><br></div><div>F(x) = A x - b</div><div><br></div><div>and "Jacobian"</div><div><br></div><div>J = A1</div><div>
<br></div><div>This is the defect correction version of your algorithm. You can make it better by bringing in the concept of orthogonality/spectral adaptivity either in via -snes_type ngmres or, recognizing that this system is linear, by making the operator A available to the linear solver. You can do that by (a) -snes_mf_operator which will finite difference F to compute the action or (b) by filling the first Jacobian slot in the SNES compute Jacobian callback with a MATSHELL that applies the entire A. I would start with (a) because it is simpler, especially if your underlying problem is nonlinear.</div>