Pierre,

  You may be able to use SNESReset() instead of calling SNESDestroy() and 
creating a new SNES for each change in problem dimension; but you will still 
need to write an "outer loop" that calls SNESSolve() repeatedly and decides 
whether you should change the problem size. Note that you will need to call 
SNESSetJacobian() after each SNESReset() so that SNES "knows" the new size of 
your matrix.

   Barry




> On Apr 3, 2019, at 2:47 PM, Jed Brown via petsc-dev <petsc-dev@mcs.anl.gov> 
> wrote:
> 
> Pierre Jolivet via petsc-dev <petsc-dev@mcs.anl.gov> writes:
> 
>> I am just adapting the mesh depending on the solution from the previous 
>> SNESSolve.
>> At first, I wanted to avoid writing an outer loop around the SNESSolve, so I 
>> thought, let’s put the adaptation in the SNESSetJacobian.
>> It would have been preferable because it would have required fewer lines of 
>> code (as I had imagined this to work), that’s the main reason. I understand 
>> this is too much to ask of PETSc to continue working without any further 
>> information from the application.
> 
> SNES wants to be able to connect norms and differences between vectors
> at different iterations (e.g., rtol and stol).  I would just loop around
> SNESSolve for what you want.  Note that it may be fragile to adapt in
> early Newton iterations if globalization is a challenge for your
> problem.

Reply via email to