[petsc-users] Call KSP routine before each timestep
Emil Constantinescu
emconsta at mcs.anl.gov
Mon May 1 22:06:27 CDT 2017
On 5/1/17 4:42 PM, Matthew Knepley wrote:
> On Mon, May 1, 2017 at 4:27 PM, Scott Dossa <doss0032 at umn.edu
> <mailto:doss0032 at umn.edu>> wrote:
>
> Hi All,
>
> Matt:
> Thank you! Using the application context is a good approach to pass
> the vector information. Can you also direct me to which command
> allows TSSolve to be only called for one timestep / start at the
> correct timestep? When TSSolve() is called, it always resets to
> timestep 0.
>
>
> You should not need that since PreStep will be called at the beginning
> of each step, but just in case
>
> http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/TS/TSStep.html
>
> although using this is tricky so I do not recommend it.
If it's a projection you may need to set the PostStep and (or) PostStage
if using multistage methods
(http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/TS/TSSetPostStage.html#TSSetPostStage);
otherwise the last step may not be div free.
> Barry:
> Yes, this is a pressure projection method where one needs the
> pressure field at each timestep to solve for the velocity field.
>
>
> If it was me, I would not do it this way, but its somewhat a matter of
> taste. It makes more sense to me to formulate the whole
> system as a DAE, meaning time derivatives on some things (v) and not
> others (p). Then use a DAE timestepper and your
> fluid solver can be formulated as pressure projection using
> PCFIELDSPLIT. This way, if you want to use another kind of fluid
> solver, you can, whereas now you are stuck with the alternation of
> projection of momentum update.
Yes, formulating it as a DAE is desirable; however, if you project it
separately you have access to significantly more time steppers.
Emil
> Thanks,
>
> Matt
>
> I will likely have more follow up questions as I quick write this
> up. Thank you both for your input.
> -Scott Dossa
>
> On Mon, May 1, 2017 at 3:32 PM, Barry Smith <bsmith at mcs.anl.gov
> <mailto:bsmith at mcs.anl.gov>> wrote:
>
>
> Scott - Are you doing some kind of pressure projection method?
>
> PETSc-developers - should this functionality be directly
> added to TS since it comes up fairly often?
>
> Barry
>
>
>
> > On May 1, 2017, at 3:24 PM, Matthew Knepley
> <knepley at gmail.com <mailto:knepley at gmail.com>> wrote:
> >
> > On Mon, May 1, 2017 at 3:13 PM, Scott Dossa <doss0032 at umn.edu
> <mailto: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
> <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
>
>
>
>
>
> --
> 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
More information about the petsc-users
mailing list