<div dir="ltr"><div dir="ltr">On Thu, Jul 6, 2023 at 3:42 PM YuSh Lo <<a href="mailto:ysjosh.lo@gmail.com">ysjosh.lo@gmail.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>I am using SNES to solve some nonlinear functions.</div><div>After each iteration, I have an user-defined updating to do. </div><div>Some values in the solution vectors must be inserted to some different location. </div><div>I have tried to do it in the beginning of form RHS and form Jacobian, but the vector is read-only. The results are correct although some warnings are thrown with debug build saying that the vector is in wrong state. I also tried setting a function with SNESSetupdate, but the convergence is bad. </div><div>Is the vector I get using SNESGetSolution the same as the vector that will be used in following forming Jacobian and RHS?, and is it again read only?</div></div></blockquote><div><br></div><div>For these kinds of things, it might be easiest to put this in the line search. I would write a custom line search routine that did your modifications. That way you are assured that it does not short circuit anything else since the line search is where we are updating the solution directly.</div><div><br></div><div>It should also work in the Update(), and we could try to determine what is wrong here, but that would be more digging. I think making it a line search is easier.</div><div><br></div><div> Thanks,</div><div><br></div><div> Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Thanks,</div><div>Josh</div><div> </div></div>
</blockquote></div><br clear="all"><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div><div><br></div><div><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>