[petsc-dev] SNESSolve and changing dimensions

Stefano Zampini stefano.zampini at gmail.com
Wed Apr 3 08:15:07 CDT 2019


Pierre,

using MatHeaderReplace should be discouraged in a SNES/TS callback ;-)
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),
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?

Il giorno mer 3 apr 2019 alle ore 14:52 Matthew Knepley via petsc-dev <
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> 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 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/cf58087d/attachment.html>


More information about the petsc-dev mailing list