[petsc-users] [EXT]Re: Dynamic SNESVI bounds

Alexander B Prescott alexprescott at email.arizona.edu
Sat Sep 12 20:57:53 CDT 2020


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.

PetscErrorCode FormBounds(SNES snes,PetscInt step)
{
Vec x;
PetscScalar *xx;
ierr = SNESGetSolution(snes,&x);CHKERRQ(ierr);
ierr = VecGetArray(x,&xx);CHKERRQ(ierr);

..... do stuff that updates the VI bounds .....

ierr = VecRestoreArray(x,&xx);
ierr = VecDestroy(&x);CHKERRQ(ierr);
}

Best,
Alexander

On Fri, Sep 11, 2020 at 5:47 PM Matthew Knepley <knepley at gmail.com> wrote:

> *External Email*
> On Fri, Sep 11, 2020 at 8:09 PM Alexander B Prescott <
> alexprescott at email.arizona.edu> wrote:
>
>> 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.
>>
>
> It thinks snes>vec_sol has been freed. It seems like something illegal was
> done in Update(). Can you run under valgrind?
>
>   Thanks,
>
>     Matt
>
>
>> mpirun -n 1 a -snes_type vinewtonrsls -snes_monitor -snes_mf
>> -snes_converged_reason
>>
>>   0 SNES Function norm 1.319957381248e+02
>>   1 SNES Function norm 3.164228677282e+01
>>   2 SNES Function norm 5.157408019535e+00
>>   3 SNES Function norm 2.290604723696e-01
>> [0]PETSC ERROR: --------------------- Error Message
>> --------------------------------------------------------------
>> [0]PETSC ERROR: Corrupt argument:
>> https://www.mcs.anl.gov/petsc/documentation/faq.html#valgrind
>> [0]PETSC ERROR: Object already free: Parameter # 2
>> [0]PETSC ERROR: See https://www.mcs.anl.gov/petsc/documentation/faq.html
>> for trouble shooting.
>> [0]PETSC ERROR: Petsc Release Version 3.13.2, unknown
>> [0]PETSC ERROR: a on a arch-linux2-c-debug named
>> alexprescott-ThinkPad-T420s by alexprescott Fri Sep 11 16:49:38 2020
>> [0]PETSC ERROR: Configure options
>> [0]PETSC ERROR: #1 SNESComputeJacobian() line 2676 in
>> /home/alexprescott/Documents/petsc/src/snes/interface/snes.c
>> [0]PETSC ERROR: #2 SNESSolve_VINEWTONRSLS() line 386 in
>> /home/alexprescott/Documents/petsc/src/snes/impls/vi/rs/virs.c
>> [0]PETSC ERROR: #3 SNESSolve() line 4519 in
>> /home/alexprescott/Documents/petsc/src/snes/interface/snes.c
>> [0]PETSC ERROR: #4 PetscWrapperFcn() line 222 in petscshell_leq9nodes.c
>> [0]PETSC ERROR: #5 main() line 285 in petscshell_leq9nodes.c
>> [0]PETSC ERROR: PETSc Option Table entries:
>> [0]PETSC ERROR: -snes_converged_reason
>> [0]PETSC ERROR: -snes_mf
>> [0]PETSC ERROR: -snes_monitor
>> [0]PETSC ERROR: -snes_type vinewtonrsls
>> [0]PETSC ERROR: ----------------End of Error Message -------send entire
>> error message to petsc-maint at mcs.anl.gov----------
>>
>> Best,
>> Alexander
>>
>> On Thu, Sep 10, 2020 at 4:27 PM Barry Smith <bsmith at petsc.dev> wrote:
>>
>>> *External Email*
>>>
>>>   Yes, it should be simple to write the code to do this.
>>>
>>>   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.
>>>
>>>   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.
>>>
>>>   Barry
>>>
>>>
>>>
>>>
>>> On Sep 10, 2020, at 5:15 PM, Alexander B Prescott <
>>> alexprescott at email.arizona.edu> wrote:
>>>
>>> Hi there,
>>>
>>> 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?
>>> My goal is to update the bounds such that a specific entry in the
>>> solution vector remains the supremum throughout the entire execution.
>>>
>>> Best,
>>> Alexander
>>>
>>> --
>>> Alexander Prescott
>>> alexprescott at email.arizona.edu
>>> PhD Candidate, The University of Arizona
>>> Department of Geosciences
>>> 1040 E. 4th Street
>>> Tucson, AZ, 85721
>>>
>>>
>>>
>>
>> --
>> Alexander Prescott
>> alexprescott at email.arizona.edu
>> PhD Candidate, The University of Arizona
>> Department of Geosciences
>> 1040 E. 4th Street
>> Tucson, AZ, 85721
>>
>
>
> --
> What most experimenters take for granted before they begin their
> experiments is infinitely more interesting than any results to which their
> experiments lead.
> -- Norbert Wiener
>
> https://www.cse.buffalo.edu/~knepley/
> <http://www.cse.buffalo.edu/~knepley/>
>


-- 
Alexander Prescott
alexprescott at email.arizona.edu
PhD Candidate, The University of Arizona
Department of Geosciences
1040 E. 4th Street
Tucson, AZ, 85721
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20200912/9b1c6581/attachment.html>


More information about the petsc-users mailing list