<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""><br class=""></div>  The XXXGetYYY routines generally do not increase the reference count of what they obtain, some are paired with an XXXRestoreYYY routine but the ones without closing partners generally do not need a destroy called. The intention is that the gotten object is just used inside the calling routine and not kept in a data structure for later use.<div class=""><br class=""></div><div class="">  Barry</div><div class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Sep 12, 2020, at 8:57 PM, Alexander B Prescott <<a href="mailto:alexprescott@email.arizona.edu" class="">alexprescott@email.arizona.edu</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="">Hi Matt, I was able to find the problem after reading your note. I was calling VecDestroy() at the end of my SNESSetUpdate() function in an attempt to just destroy the local Vec variable, but apparently it does more than that. Removing the call to VecDestroy() removed the error code. Here's a code snippet of the relevant portions of the function for reference.</div><div class=""><br class=""></div><div class="">PetscErrorCode FormBounds(SNES snes,PetscInt step)</div><div class="">{<br class=""></div><div style="margin-left:40px" class="">Vec                                     x;</div><div style="margin-left:40px" class="">PetscScalar              *xx;</div><div style="margin-left:40px" class="">ierr = SNESGetSolution(snes,&x);CHKERRQ(ierr);</div><div style="margin-left:40px" class="">ierr = VecGetArray(x,&xx);CHKERRQ(ierr);</div><div style="margin-left:40px" class=""><br class=""></div><div style="margin-left:40px" class="">..... do stuff that updates the VI bounds .....</div><div style="margin-left:40px" class=""><br class=""></div><div style="margin-left:40px" class="">ierr = VecRestoreArray(x,&xx);</div><div style="margin-left:40px" class="">ierr = VecDestroy(&x);CHKERRQ(ierr);</div>}<br class=""><div class=""><div class=""><br class=""></div><div class="">Best,</div><div class="">Alexander<br class=""></div></div></div><br class=""><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Sep 11, 2020 at 5:47 PM Matthew Knepley <<a href="mailto:knepley@gmail.com" class="">knepley@gmail.com</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><p style="text-align:center" class=""><font color="red" class=""><strong class="">External Email</strong><br class=""></font></p><div dir="ltr" class=""><div dir="ltr" class="">On Fri, Sep 11, 2020 at 8:09 PM Alexander B Prescott <<a href="mailto:alexprescott@email.arizona.edu" target="_blank" class="">alexprescott@email.arizona.edu</a>> wrote:<br class=""></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" class=""><div class="">Hi Barry, thanks for the help, I've done as you suggested. Now, I get an error that I'm unfamiliar with that goes away if I comment out SNESSetUpdate(). This error pops up after several successful iterations, so I'm not sure what's goin on here. The full message is copied below.</div></div></blockquote><div class=""><br class=""></div><div class="">It thinks snes>vec_sol has been freed. It seems like something illegal was done in Update(). Can you run under valgrind?</div><div class=""><br class=""></div><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:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr" class=""><div class="">mpirun -n 1 a -snes_type vinewtonrsls -snes_monitor -snes_mf -snes_converged_reason</div><div class=""><br class=""></div><div class="">  0 SNES Function norm 1.319957381248e+02 <br class="">  1 SNES Function norm 3.164228677282e+01 <br class="">  2 SNES Function norm 5.157408019535e+00 <br class="">  3 SNES Function norm 2.290604723696e-01 <br class="">[0]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------<br class="">[0]PETSC ERROR: Corrupt argument: <a href="https://www.mcs.anl.gov/petsc/documentation/faq.html#valgrind" target="_blank" class="">https://www.mcs.anl.gov/petsc/documentation/faq.html#valgrind</a><br class="">[0]PETSC ERROR: Object already free: Parameter # 2<br class="">[0]PETSC ERROR: See <a href="https://www.mcs.anl.gov/petsc/documentation/faq.html" target="_blank" class="">https://www.mcs.anl.gov/petsc/documentation/faq.html</a> for trouble shooting.<br class="">[0]PETSC ERROR: Petsc Release Version 3.13.2, unknown <br class="">[0]PETSC ERROR: a on a arch-linux2-c-debug named alexprescott-ThinkPad-T420s by alexprescott Fri Sep 11 16:49:38 2020<br class="">[0]PETSC ERROR: Configure options <br class="">[0]PETSC ERROR: #1 SNESComputeJacobian() line 2676 in /home/alexprescott/Documents/petsc/src/snes/interface/snes.c<br class="">[0]PETSC ERROR: #2 SNESSolve_VINEWTONRSLS() line 386 in /home/alexprescott/Documents/petsc/src/snes/impls/vi/rs/virs.c<br class="">[0]PETSC ERROR: #3 SNESSolve() line 4519 in /home/alexprescott/Documents/petsc/src/snes/interface/snes.c<br class="">[0]PETSC ERROR: #4 PetscWrapperFcn() line 222 in petscshell_leq9nodes.c<br class="">[0]PETSC ERROR: #5 main() line 285 in petscshell_leq9nodes.c<br class="">[0]PETSC ERROR: PETSc Option Table entries:<br class="">[0]PETSC ERROR: -snes_converged_reason<br class="">[0]PETSC ERROR: -snes_mf<br class="">[0]PETSC ERROR: -snes_monitor<br class="">[0]PETSC ERROR: -snes_type vinewtonrsls<br class="">[0]PETSC ERROR: ----------------End of Error Message -------send entire error message to <a href="mailto:petsc-maint@mcs.anl.gov" class="">petsc-maint@mcs.anl.gov</a>----------</div><div class=""><br class=""></div><div class="">Best,</div><div class="">Alexander<br class=""></div></div><br class=""><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Sep 10, 2020 at 4:27 PM Barry Smith <<a href="mailto:bsmith@petsc.dev" target="_blank" class="">bsmith@petsc.dev</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class=""><p style="text-align:center" class=""><font color="red" class=""><strong class="">External Email</strong><br class=""></font></p><div class=""><br class=""></div>  Yes, it should be simple to write the code to do this.<div class=""><br class=""></div><div class="">  Provide a function that calls SNESVISetVariableBounds() using your criteria then call SNESSetUpdate() to have that function called on each iteration of SNES to reset the bounds.</div><div class=""><br class=""></div><div class="">  If this will converge to what you desire I have no clue. But each step will find a result that satisfies the current bounds you set.</div><div class=""><br class=""></div><div class="">  Barry</div><div class=""><br class=""></div><div class="">  <br class=""><div class=""><br class=""><div class=""><br class=""><blockquote type="cite" class=""><div class="">On Sep 10, 2020, at 5:15 PM, Alexander B Prescott <<a href="mailto:alexprescott@email.arizona.edu" target="_blank" class="">alexprescott@email.arizona.edu</a>> wrote:</div><br class=""><div class=""><div dir="ltr" class=""><div class="">Hi there,</div><div class=""><br class=""></div><div class="">I have a quick question (hopefully)  that I didn't find addressed in the documentation or user list archives. Is it possible to change the SNES Variational Inequality bounds from one solver iteration to the next?</div><div class="">My goal is to update the bounds such that a specific entry in the solution vector remains the supremum throughout the entire execution.</div><div class=""><br class=""></div><div class="">Best,</div><div class="">Alexander<br class=""></div><div class=""><br class="">-- <br class=""><div dir="ltr" class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div style="font-size:12.8px" class=""><span style="font-family:arial,sans-serif" class="">Alexander</span><span style="font-family:arial,sans-serif" class=""> </span><span style="font-family:arial,sans-serif" class="">Prescott</span><br class=""></div><div style="font-size:12.8px" class=""><span style="font-family:arial,sans-serif" class=""><a href="mailto:alexprescott@email.arizona.edu" target="_blank" class="">alexprescott@email.arizona.edu</a></span></div><div style="font-size:12.8px" class=""><div style="font-family:arial,sans-serif" class=""><span class="">PhD</span> <span class="">Candidate</span>, The University of Arizona</div><div style="font-family:arial,sans-serif" class="">Department of Geosciences</div><div style="font-family:arial,sans-serif" class="">1040 E. 4th Street</div><div style="font-family:arial,sans-serif" class="">Tucson, AZ, 85721</div></div></div></div></div></div></div></div></div></div>
</div></blockquote></div><br class=""></div></div></div></blockquote></div><br clear="all" class=""><br class="">-- <br class=""><div dir="ltr" class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div style="font-size:12.8px" class=""><span style="font-family:arial,sans-serif" class="">Alexander</span><span style="font-family:arial,sans-serif" class=""> </span><span style="font-family:arial,sans-serif" class="">Prescott</span><br class=""></div><div style="font-size:12.8px" class=""><span style="font-family:arial,sans-serif" class=""><a href="mailto:alexprescott@email.arizona.edu" target="_blank" class="">alexprescott@email.arizona.edu</a></span></div><div style="font-size:12.8px" class=""><div style="font-family:arial,sans-serif" class=""><span class="">PhD</span> <span class="">Candidate</span>, The University of Arizona</div><div style="font-family:arial,sans-serif" class="">Department of Geosciences</div><div style="font-family:arial,sans-serif" class="">1040 E. 4th Street</div><div style="font-family:arial,sans-serif" class="">Tucson, AZ, 85721</div></div></div></div></div></div></div></div>
</blockquote></div><br clear="all" class=""><div class=""><br class=""></div>-- <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=""><br class="">-- <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 style="font-size:12.8px" class=""><span style="font-family:arial,sans-serif" class="">Alexander</span><span style="font-family:arial,sans-serif" class=""> </span><span style="font-family:arial,sans-serif" class="">Prescott</span><br class=""></div><div style="font-size:12.8px" class=""><span style="font-family:arial,sans-serif" class=""><a href="mailto:alexprescott@email.arizona.edu" target="_blank" class="">alexprescott@email.arizona.edu</a></span></div><div style="font-size:12.8px" class=""><div style="font-family:arial,sans-serif" class=""><span class="">PhD</span> <span class="">Candidate</span>, The University of Arizona</div><div style="font-family:arial,sans-serif" class="">Department of Geosciences</div><div style="font-family:arial,sans-serif" class="">1040 E. 4th Street</div><div style="font-family:arial,sans-serif" class="">Tucson, AZ, 85721</div></div></div></div></div></div></div></div>
</div></blockquote></div><br class=""></div></body></html>