[petsc-users] Setting a custom predictor in the generalized-alpha time stepper

David Kamensky david at coreform.com
Fri Aug 4 09:50:14 CDT 2023


Hi Jed,

What I'm trying to compute is basically a standard same-velocity or
same-acceleration predictor (although slightly more complicated, since I'm
restricting it to a sub-system).  I hadn't looked into
`SNESSetComputeInitialGuess` yet, although one difficulty is that it would
need access to the `X0`, `V0`, and `A0` members of the `TS_Alpha` struct,
which is only defined in `alpha2.c`, and thus not available through the
API.

For now, we just worked around this by patching PETSc to move the
definition of `TS_Alpha` up into a header to make it accessible.
(Modifying the library obviously introduces a maintenance headache; I also
considered just casting the `ts->data` pointer to `(char*)`, calculating
memory offsets based on `sizeof` the struct members, and casting back to
`Vec`, but that relies on compiler-specific assumptions, and could also
break if the PETSc source code was updated.)  We also shuffled the order of
some calls to `VecCopy` and `TSPreStage` in the routine `TSAlpha_Restart`,
so that `TSPreStage` can set the initial guess, although that sounds like
it would be unnecessary if we instead used a callback in
`SNESSetComputeInitialGuess` that had access to the internals of
`TS_Alpha`.

Thanks, David

On Thu, Aug 3, 2023 at 11:28 PM Jed Brown <jed at jedbrown.org> wrote:

> I think you can use TSGetSNES() and SNESSetComputeInitialGuess() to modify
> the initial guess for SNES. Would that serve your needs? Is there anything
> else you can say about how you'd like to compute this initial guess? Is
> there a paper or something?
>
> David Kamensky <david at coreform.com> writes:
>
> > Hi,
> >
> > My understanding is that the second-order generalized-alpha time stepper
> in
> > PETSc uses a same-displacement predictor as the initial guess for the
> > nonlinear solver that executes in each time step.  I'd like to be able to
> > set this to something else, to improve convergence.  However, my
> > (possibly-naive) attempts to use `TSSetPreStep` and `TSSetPreStage`
> haven't
> > worked out.  Is there any way to set a custom predictor?
> >
> > Thanks,
> > David Kamensky
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20230804/f6e9b61b/attachment.html>


More information about the petsc-users mailing list