> On Feb 2, 2020, at 11:24 AM, Mohammed Ashour <[email protected]> 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
> 
> -- 

Reply via email to