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. <[email protected]> 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 <[email protected]> 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 >
