[petsc-users] TS shallow reset

Zhang, Hong hongzhang at anl.gov
Tue Jan 7 10:06:38 CST 2020


Normally only the initial time and initial stepsize need to be reset (via TSSetTime and TSSetTimeStep) if you need to solve the ODE repeatedly on the same time interval. If you don’t reset these, successive calls to TSSolve will just continue the integration from the previous end point. So if you are solving autonomous ODEs with fixed time steps, resetting the final time may also work.

TSSetMaxTime(ts,1.0)
TSSolve(ts)
TSSetMaxTime(ts,2.0)
TSSolve(ts)

Hong (Mr.)


> On Jan 7, 2020, at 9:14 AM, Smith, Barry F. <bsmith at mcs.anl.gov> wrote:
> 
> 
>  Do you reset the initial tilmestep? Otherwise the second solve thinks it is at the end. Also you may need to reset the iteration number
> 
>  Something like
> 
>  ierr = TSSetTime(appctx->ts, 0);CHKERRQ(ierr);
>  ierr = TSSetStepNumber(appctx->ts, 0);CHKERRQ(ierr);
>  ierr = TSSetTimeStep(appctx->ts, appctx->initial_dt);CHKERRQ(ierr);
> 
> 
> 
>> On Jan 7, 2020, at 8:27 AM, Mark Adams <mfadams at lbl.gov> wrote:
>> 
>> I would like to do a parameters study with a TS solve and want to put TSSolve in a loop. I save the initial conditions in a Vec and copy that into the solution vector after each solve, to get ready for the next one. But, TS does not seem to do anything on the second solve. I guess it thinks it is converged. Is there a way to reset the solver without redoing the whole TS?
>> 
>> Maybe set the step number and TSSetConvergedReason?
>> 
>> Thanks,
>> Mark
> 



More information about the petsc-users mailing list