On Sun, Jan 24, 2021 at 11:48 AM Zhang, Hong via petsc-dev <petsc-dev@mcs.anl.gov> wrote:
Some TS methods such as TSRK do have an array of vectors like this to store the stage values. But not all TS methods have it. I am fine adding the scratch for TSTheta and any other method missing it. A little drawback is that it is used only by TSGetStages and the TSStep implementation does not necessarily need it. So I like the idea to return a temporary array with GetStages and free it with RestoreStages when the TS method does not have an array for stages internally.

This array is just a few pointers, so incredibly small. Why make the user mess around with restore? It seems easier to just give access.

  Thanks,

     Matt
 
Hong

On Jan 24, 2021, at 1:08 AM, Stefano Zampini <stefano.zampini@gmail.com> wrote:

You actually do not need a RestoreStages if you use a scratch

Vec stages[2];

in TS_theta, and pass it back with TSGetStages_Theta. I understand PETSc philosophy is that every Get should have a Restore method, but is this really necessary for TSGetStages?

Il giorno sab 23 gen 2021 alle ore 21:05 Zhang, Hong <hongzhang@anl.gov> ha scritto:

Sorry for any disturbance it caused. It was for the convenience of the adjoint implementation. The stages returned by TSGetStages_Theta currently do not reflect the true stages associated with these methods. The endpoint variant actually has two stages. This will be changed in a separate forthcoming MR, where TSRestoreStages() will be added and TSGetStages will return an array of vectors for the endpoint variant.

Hong   

On Jan 21, 2021, at 4:16 AM, Stefano Zampini <stefano.zampini@gmail.com> wrote:

Hong,

I do not understand why you changed the behavior of TSGetStages_Theta https://gitlab.com/petsc/petsc/-/merge_requests/3500/diffs#a582bbaec75f4ae14bbf97d1d0404073ca89ff09_1194_1209 with this MR https://gitlab.com/petsc/petsc/-/merge_requests/3500 

Now, the non-endpoint variant does no longer use th->X as stage!

Please revert this change
Thanks
--
Stefano



--
Stefano



--
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