Barry,<br><br>&nbsp; Thanks for the reply;<br><br><div class="gmail_quote">On Mon, Dec 1, 2008 at 4:56 PM, Barry Smith <span dir="ltr">&lt;<a href="mailto:bsmith@mcs.anl.gov">bsmith@mcs.anl.gov</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d"><br>
On Dec 1, 2008, at 12:28 PM, Edson Tadeu wrote:<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
 &nbsp;Hi,<br>
<br>
 &nbsp; I&#39;m solving non-linear problems with Line Search, and sometimes I need to change an entire row of the Jacobian together with the corresponding element in the Function, but I only know which rows/elements need to be changed when I&#39;m computing the Jacobian. So, what I&#39;d like to know first is:<br>

</blockquote>
<br></div>
 &nbsp; Maybe if you explain why you need to &quot;change an entire row of the Jacobian together with the corresponding element in the Function&quot; we could come up<br>
with some suggestions on how to proceed.<div class="Ih2E3d"></div></blockquote><div><br>It&#39;s because, depending on some conditions, I need to make some change of variables in the original equations, otherwise the Jacobian will have linear dependent rows. For example, I need to tell that x(4) = 1.0-x(3) (instead of the original equation for x(4)). I would do it by changing the Jacobian like this:<br>
<br>J(4,3) = 1; J(4,4) = 1; all other columns of row 4 of J are zero. F(4) = 0.<br><br>This way, I would have delta_x(4) = -delta_x(3). I&#39;ve solved this now by directly changing the delta solution vector (delta_x) in the pre check phase... it seems to be working, but it doesn&#39;t seem to be the right way, I don&#39;t know...<br>
<br>&nbsp;</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="Ih2E3d"><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
<br>
 &nbsp;1) Am I allowed to change the Function vector from inside FormJacobian? (I&#39;ve looked inside SNESSolve_LS, and it seems that this is not allowed, because &quot;fnorm&quot; is evaluated before SNESComputeJacobian, and if I change F inside FormJacobian, fnorm would be wrong).<br>

<br>
 &nbsp;or<br>
<br>
 &nbsp;2) Am I allowed to change the Function vector from PreCheck routine?<br>
<br>
 &nbsp;If none of that is allowed, another solution that I thought was to compute the Jacobian while computing the Function. The FAQ says that &quot;You are free to have your &#39;FormFunction&#39; compute as much of the Jacobian at that point as you like, keep the information in the user context (the final argument to FormFunction and FormJacobian) and then retreive the information in your FormJacobian() function&quot;. The problem is that FormFunction is called many times more than FormJacobian, and Jacobian calculation is slow, so:<br>

<br>
 &nbsp;3) Is there any way to know when I should really recompute the Jacobian from inside FormFunction? (I don&#39;t think so, but...)<br>
</blockquote>
<br></div>
 &nbsp;No. But if you do not use any line search at all then each function evaluation will have an associated Jacobian so you can compute them<br>
together. (Of course you lose the globalization of the line search so SNES may not converge). &nbsp;You can turn off all line searches with -snes_ls basic<br>
from the command line or from the code SNESLineSearchSet(snes,SNESLineSeachNo,PETSC_NULL);<br><font color="#888888">
<br>
 &nbsp; Barry</font><div><div></div><div class="Wj3C7c"></div></div></blockquote><div><br>&nbsp;Ok, but the whole reason that I&#39;m using SNES is to speed up my computations by using the Line Search algorithms (or maybe Trust Region). I had coded an algorithm before that manually computed using full steps, and it were working, but were slow!<br>
<br></div></div>&nbsp; Thanks,<br>Edson<br><br>