<div dir="ltr"><div>Hi Jed,</div><div><br></div><div>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. </div><div><br></div><div>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`. <br></div><div><br></div><div>Thanks, David<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Aug 3, 2023 at 11:28 PM Jed Brown <<a href="mailto:jed@jedbrown.org">jed@jedbrown.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">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?<br>
<br>
David Kamensky <<a href="mailto:david@coreform.com" target="_blank">david@coreform.com</a>> writes:<br>
<br>
> Hi,<br>
><br>
> My understanding is that the second-order generalized-alpha time stepper in<br>
> PETSc uses a same-displacement predictor as the initial guess for the<br>
> nonlinear solver that executes in each time step. I'd like to be able to<br>
> set this to something else, to improve convergence. However, my<br>
> (possibly-naive) attempts to use `TSSetPreStep` and `TSSetPreStage` haven't<br>
> worked out. Is there any way to set a custom predictor?<br>
><br>
> Thanks,<br>
> David Kamensky<br>
</blockquote></div>