[petsc-users] Call KSP routine before each timestep

Matthew Knepley knepley at gmail.com
Mon May 1 15:24:20 CDT 2017


On Mon, May 1, 2017 at 3:13 PM, Scott Dossa <doss0032 at umn.edu> wrote:

> Hi All,
>
> I'm looking to pass a vector between a KSP and TS routine. The KSP routine
> must be called before each timestep, and the solution vector is needed for
> the TS routine. Normally, TSSolve() runs over all timesteps, but in my
> case, I'd like to be able to add a routine before each timestep.
>
> Can someone direct me to an example script or briefly explain a case which
> shows how to control time stepping such that one could achieve something
> along the lines of:
>
> while (step < maxsteps+1){
>         KSPSolve(ksp, v, p); /* solves for Vec p and passes this info onto
> TS */
>         TSSolve(ts, u); /* only iterate for 1 timestep */
> }
>
> The function TSSetPreStep() seemed promising, but it can only take TS as
> arguments which may not be sufficient to pass a global vector.
>

Yes, this is the correct thing. You can

  a) Just attach a Vec to the TS using PetscObjectCompose(), but that is
ugly so you can

  b) Make a context structure, and stick it in the TS using


http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/TS/TSSetApplicationContext.html

      That is also where the KSP should go.

  Thanks,

    Matt


> Thank you in advance.
> Scott Dossa
>
>
>


-- 
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20170501/51700639/attachment.html>


More information about the petsc-users mailing list