[petsc-dev] SNESSolve and changing dimensions

Pierre Jolivet pierre.jolivet at enseeiht.fr
Wed Apr 3 08:31:24 CDT 2019


> On 3 Apr 2019, at 3:15 PM, Stefano Zampini <stefano.zampini at gmail.com> wrote:
> 
> Pierre,
> 
> using MatHeaderReplace should be discouraged in a SNES/TS callback ;-)

Gotcha!

> I coded this way to have the possibility of changing the MatType while running SNES or TS, not for variable sizes.
> 
> A tricky way of achieving what you want is to code a proper hook function (see https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/SNES/SNESSetUpdate.html <https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/SNES/SNESSetUpdate.html>), which gets called right before each linear solve.
> This is very tricky (and implementation dependent) because you also need to update/interpolate all the relevant vectors SNES may use later for line search
> 
> The proper solution would be to extend DMAdaptor to the case of user-defined refinements and stopping criterion callbacks. Matt? 

Following Matt’s message, I’ve permuted the two “loops" (SNESSolve and mesh adaptation), but if there is some way to do the adaptation in the inner loop coming along, I’ll give it a go.

Thanks,
Pierre

> Il giorno mer 3 apr 2019 alle ore 14:52 Matthew Knepley via petsc-dev <petsc-dev at mcs.anl.gov <mailto:petsc-dev at mcs.anl.gov>> ha scritto:
> On Wed, Apr 3, 2019 at 5:43 AM Pierre Jolivet via petsc-dev <petsc-dev at mcs.anl.gov <mailto:petsc-dev at mcs.anl.gov>> wrote:
> I’d like to do mesh adaptation in a Newton loop.
> I’m using a SNES with SNESSetFunction and SNESSetJacobian.
> My first question is: may the dimension of the linear systems change throughout the nonlinear iterations?
> 
> No. Everything we do is algebraic right now. You would have to reformulate Newton in
> some Banach space, and make sure all the measures you were using were discretization
> independent. Then you could allow the underlying linear algebra to change, but you would
> need operations for projecting the the new space, making BC in the new space, etc. There
> is a lot of machinery in the continuous space that PETSc does not have.
> 
> It sounds like it should be setup as an FAS.
> 
>   Thanks,
> 
>      Matt
>  
> If so, what are the proper things to do? I tried to do as Stefano in MFEM and use MatHeaderReplace https://github.com/mfem/mfem/blob/master/linalg/petsc.cpp#L3833 <https://github.com/mfem/mfem/blob/master/linalg/petsc.cpp#L3833> inside the function supplied to SNESSetJacobian, but I end up with a [0]PETSC ERROR: PCApply() line 455 in petsc/src/ksp/pc/interface/precon.c Preconditioner number of local rows 6561 does not equal resulting vector number of rows 1681 further down the road. Should I also call something like VecHeaderReplace (which apparently does not exist) on the residual Vec?
> 
> Thanks,
> Pierre
> 
> 
> -- 
> 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/>
> 
> 
> -- 
> Stefano

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20190403/8936fad1/attachment-0001.html>


More information about the petsc-dev mailing list