<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On 12 Jul 2022, at 2:50 PM, Matthew Knepley <<a href="mailto:knepley@gmail.com" class="">knepley@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta charset="UTF-8" class=""><div dir="ltr" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><div dir="ltr" class="">On Tue, Jul 12, 2022 at 7:41 AM Matthew Knepley <<a href="mailto:knepley@gmail.com" class="">knepley@gmail.com</a>> wrote:<br class=""></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div dir="ltr" class=""><div dir="ltr" class="">On Tue, Jul 12, 2022 at 7:39 AM Pierre Jolivet <<a href="mailto:pierre@joliv.et" target="_blank" class="">pierre@joliv.et</a>> wrote:<br class=""></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div class=""><br class=""><div class=""><br class=""><blockquote type="cite" class=""><div class="">On 12 Jul 2022, at 2:32 PM, Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank" class="">knepley@gmail.com</a>> wrote:</div><br class=""><div class=""><div dir="ltr" class=""><div dir="ltr" class="">On Mon, Jul 11, 2022 at 1:17 PM Pierre Jolivet <<a href="mailto:pierre@joliv.et" target="_blank" class="">pierre@joliv.et</a>> wrote:<br class=""></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;">Hello,<br class="">Could anyone help me understand what is going on in the following example, please?<br class="">I have a VecNest.<br class="">I either: a) initialize all values to 0.0, then set a specific part of the vector to nonzero or b) initialize a part of the vector to 0.0 and set the other part to nonzero.<br class="">I don’t see why a) and b) produce different results.<br class=""><br class="">$ ./ex1111 -pc_type fieldsplit -ksp_monitor_true_residual -ksp_converged_reason -fieldsplit_pc_type jacobi -ksp_pc_side right -ksp_view_final_residual -nest_subvec true<span class="Apple-converted-space"> </span><br class=""> <span class="Apple-converted-space"> </span>0 KSP unpreconditioned resid norm 8.375635517980e-01 true resid norm 8.375635517980e-01 ||r(i)||/||b|| 1.000000000000e+00<br class=""> <span class="Apple-converted-space"> </span>1 KSP unpreconditioned resid norm 4.748816884247e-01 true resid norm 4.748816884247e-01 ||r(i)||/||b|| 5.669798875623e-01<br class=""> <span class="Apple-converted-space"> </span>2 KSP unpreconditioned resid norm 4.713006778679e-01 true resid norm 4.713006778679e-01 ||r(i)||/||b|| 5.627043784990e-01<br class=""> <span class="Apple-converted-space"> </span>3 KSP unpreconditioned resid norm 7.092979927129e-02 true resid norm 7.092979927129e-02 ||r(i)||/||b|| 8.468587144106e-02<br class=""> <span class="Apple-converted-space"> </span>4 KSP unpreconditioned resid norm 1.457836310255e-02 true resid norm 1.457836310255e-02 ||r(i)||/||b|| 1.740567992870e-02<br class=""> <span class="Apple-converted-space"> </span>5 KSP unpreconditioned resid norm 1.625040500524e-14 true resid norm 1.633468028779e-14 ||r(i)||/||b|| 1.950261595401e-14<br class="">Linear solve converged due to CONVERGED_RTOL iterations 5<br class="">KSP final norm of residual 1.63347e-14<br class="">$ ./ex1111 -pc_type fieldsplit -ksp_monitor_true_residual -ksp_converged_reason -fieldsplit_pc_type jacobi -ksp_pc_side right -ksp_view_final_residual -nest_subvec false<br class=""> <span class="Apple-converted-space"> </span>0 KSP unpreconditioned resid norm 0.000000000000e+00 true resid norm 8.375635517980e-01 ||r(i)||/||b|| inf<br class="">Linear solve converged due to CONVERGED_ATOL iterations 0<br class="">KSP final norm of residual 0.837564<br class=""></blockquote><div class=""><br class=""></div><div class="">I find if I assemble the vector, I get the same answers. Will try to figure out what assembly is doing.</div></div></div></div></blockquote><div class=""><br class=""></div><div class="">It’s probably reseting all these values <a href="https://petsc.org/main/src/vec/vec/interface/rvector.c.html#line511" target="_blank" class="">https://petsc.org/main/src/vec/vec/interface/rvector.c.html#line511</a>, which I believe are being used in VecNorm() inside VecNormalize().</div><div class="">I guess any call to VecNestSubVec() should invalidate those as well, otherwise we get wrong cached norms.</div><div class="">I will give this a go.</div></div></div></blockquote><div class=""><br class=""></div><div class="">I believe the bug is the following:</div><div class=""><br class=""></div><div class=""> <span class="Apple-converted-space"> </span>You change values in a subvector, which does StateIncrease on the subvector, but not StateIncrease on the nest vector, so it has its cached norm</div><div class=""><br class=""></div><div class="">I am not sure what to do about this, since how can the parent know you pulled out the subvector? Will think.</div></div></div></blockquote><div class=""><br class=""></div><div class="">Okay, the error is more subtle. VecSet() automatically computes some norms. VecNestGetSubVec() is broken with respect to caching.</div><div class="">I think the right fix now is VecNestGetSubVec/s() should increase the state no matter what. If we want to get more precise, we need</div><div class="">to have Restore() for the subvecs, which checks the state of the subvector when it is restored.</div><div class=""><br class=""></div><div class="">Do you want to change it?</div></div></div></div></blockquote><div><br class=""></div><div><a href="https://gitlab.com/petsc/petsc/-/merge_requests/5420" class="">https://gitlab.com/petsc/petsc/-/merge_requests/5420</a> gets the job done, and is hopefully not too far from what you had in mind.</div><div>If anyone is not confortable with the incurred cost (e.g., of recomputing some norms), please let me know.</div><div><br class=""></div><div>Thanks,</div><div>Pierre</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><div class="gmail_quote"><div class=""> Thanks,</div><div class=""><br class=""></div><div class=""> Matt</div><div class=""> </div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div dir="ltr" class=""><div class="gmail_quote"><div class=""> Matt</div><div class=""> </div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div class=""><div class=""><div class="">Thanks,</div><div class="">Pierre</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_quote"><div class=""> <span class="Apple-converted-space"> </span>Thanks,</div><div class=""><br class=""></div><div class=""> <span class="Apple-converted-space"> </span>Matt</div><div class=""> </div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;">Thanks,<br class="">Pierre<br class=""><br class=""></blockquote></div><br clear="all" class=""><div class=""><br class=""></div>--<span class="Apple-converted-space"> </span><br class=""><div dir="ltr" class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class="">What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br class="">-- Norbert Wiener</div><div class=""><br class=""></div><div class=""><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank" class="">https://www.cse.buffalo.edu/~knepley/</a><br class=""></div></div></div></div></div></div></div></div></div></blockquote></div><br class=""></div></blockquote></div><br clear="all" class=""><div class=""><br class=""></div>--<span class="Apple-converted-space"> </span><br class=""><div dir="ltr" class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class="">What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br class="">-- Norbert Wiener</div><div class=""><br class=""></div><div class=""><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank" class="">https://www.cse.buffalo.edu/~knepley/</a><br class=""></div></div></div></div></div></div></div></div></blockquote></div><br clear="all" class=""><div class=""><br class=""></div>--<span class="Apple-converted-space"> </span><br class=""><div dir="ltr" class="gmail_signature"><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class="">What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br class="">-- Norbert Wiener</div><div class=""><br class=""></div><div class=""><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank" class="">https://www.cse.buffalo.edu/~knepley/</a></div></div></div></div></div></div></div></div></div></blockquote></div><br class=""></body></html>