[petsc-users] Flagging the solver to restart
Abhyankar, Shrirang G
shrirang.abhyankar at pnnl.gov
Sat Feb 15 12:20:14 CST 2020
if the criteria are met, it'll move forward, if not, it'll engaged the routine TSRollBack(), which based on my understanding is the proper way yo flag the solver to recalculate n+1.
Are you trying to do some kind of zero crossing event or root-finding here? If so, using TSSetEventHandler<https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/TS/TSSetEventHandler.html> would be a better way than to write your own code. You merely have to define the criteria/condition in an event function and how to handle it in a posteventfunction. PETSc will manage the event location and rollback part for you. See an example here https://www.mcs.anl.gov/petsc/petsc-current/src/ts/examples/tutorials/ex40.c.html.
Thanks,
Shri
From: petsc-users <petsc-users-bounces at mcs.anl.gov> on behalf of "Zhang, Hong via petsc-users" <petsc-users at mcs.anl.gov>
Reply-To: "Zhang, Hong" <hongzhang at anl.gov>
Date: Saturday, February 15, 2020 at 11:14 AM
To: Mohammed Ashour <ashour.msc at gmail.com>
Cc: PETSc users list <petsc-users at mcs.anl.gov>
Subject: Re: [petsc-users] Flagging the solver to restart
Please make sure your replies go to the maillist.
On Feb 15, 2020, at 4:35 AM, Mohammed Ashour <ashour.msc at gmail.com<mailto:ashour.msc at gmail.com>> wrote:
Dear Mr. Hong,
Thanks for your reply and clarification.
I have a follow-up question. If TSRollBack() is to be called within a TSPostStep, that would set the ts->steprollback to PETSC_TRUE. And since there is a falsity test on TSPreStep in TSSolve, that would prevent TSPreStep from being engaged as long as ts->steprollback is PETSC_TRUE, which it is after being set so in the TSPostStep. So I'm wondering, why is there a falsity test on TSPreStep knowing that it would not be accessible if TSRollBack is called within TSPostStep.
This guarantees TSPreStep is called only once before each successful step.
Hong
Thanks in advance.
Yours sincerely
On Tue, Feb 4, 2020 at 5:32 PM Zhang, Hong <hongzhang at anl.gov<mailto:hongzhang at anl.gov>> wrote:
> On Feb 2, 2020, at 11:24 AM, Mohammed Ashour <ashour.msc at gmail.com<mailto:ashour.msc at gmail.com>> wrote:
>
> Dear All,
> I'm solving a constraint phase-field problem using PetIGA. This question i'm having is more relevant to PETSc, so I'm posting here.
>
> I have an algorithm involving iterating on the solution vector until certain criteria are met before moving forward for the next time step. The sequence inside the TSSolve is to call TSMonitor first, to print a user-defined set of values and the move to solve at TSStep and then call TSPostEvaluate.
>
> So I'm using the TSMonitor to update some variables at time n , those variables are used the in the residual and jacobian calculations at time n+1, and then solving and then check if those criteria are met or not in a function assigned to TS via TSSetPostEvaluate, if the criteria are met, it'll move forward, if not, it'll engaged the routine TSRollBack(), which based on my understanding is the proper way yo flag the solver to recalculate n+1. My question is, is this the proper way to do it? what is the difference between TSRollBack and TSRestart?
You are right that TSRollBack() recalculates the current time step. But I would not suggest to use TSPostEvaluate in your case. Presumably you are not using the PETSc adaptor (e.g. via -ts_adapt_type none) and want to control the stepsize yourself. You can check the criteria in TSPostStep, call TSRollBack() if the criteria are not met and update the variables accordingly. The variables can also be updated in TSPreStep(), but TSMonitor should not be used since it is designed for read-only operations.
TSRestart may be needed when you are using non-self-starting integration methods such as multiple step methods and FSAL RK methods (-ts_rk_type <3bs,5dp,5bs,6vr,7vr,8vr>). These methods rely on solutions or residuals from previous time steps, thus need a flag to hard restart the time integration whenever discontinuity is introduced (e.g. a parameter in the RHS function is changed). So TSRestart sets the flag to tell the integrator to treat the next time step like the first time step in a time integration.
Hong (Mr.)
> Thanks a lot
>
> --
--
Mohammed Ashour, M.Sc.
PhD Scholar
Bauhaus-Universität Weimar
Institute of Structural Mechanics (ISM)
Marienstraße 7
99423 Weimar, Germany
Mobile: +(49) 176 58834667
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20200215/2cbea7c9/attachment.html>
More information about the petsc-users
mailing list