[petsc-users] TS: How to implement a simple stopping criterion

Patrick Sanan patrick.sanan at gmail.com
Tue May 28 04:36:25 CDT 2019


I'm working with/on a code which uses TSSUNDIALS, and I'd like to be able
to stop the timestepper based on the value of the solution. In particular,
I wish to enforce that a given concentration has not changed by more than a
specified amount before stopping. Note that this is simpler than general
event detection, as I'm happy stopping before the condition is satisfied
and don't care about finding the point in time when the condition is
satisfied exactly.

As far as I know, PETSc's event handling interface isn't supported with the
SUNDIALS implementation. (As an aside, I'd be happier using TSARKIMEX or
another native timestepper, but so far haven't been able to avoid tiny
timesteps).

My question is whether the following approach has any obvious fatal flaw,
and if any TS gurus have other/better/simpler ideas.

The idea is to add my own logic, say with TSSetPreStep(), to:

1. Maintain the previous step's state (this is a 1d problem, so I'm not too
concerned about the overhead of this)
2. Check my condition, and if it's satisfied, dump the previous step's
data, and use TSSetMaxTime() with the previous step's time, thus ending the
solve.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20190528/be3e5154/attachment.html>


More information about the petsc-users mailing list