Skip to content

Install the explicit attempt check only near maxiters - #327

Merged
singhharsh1708 merged 4 commits into
mainfrom
explicit-attempt-check
Oct 24, 2026
Merged

singhharsh1708 merged 4 commits into
mainfrom
explicit-attempt-check

Conversation

@singhharsh1708

Copy link
Copy Markdown
Member

Adaptive explicit solves install a maxiters check through TSSetFunctionDomainError, which PETSc calls at every stage of every step attempt: 7 calls per TSRK("5dp") step, 13 per "8vr" step. The check can only act when the attempts so far are within one of maxiters, and with PETSc's default of at most 10 rejections a single TSStep makes at most 11 attempts. This installs the check only once the remaining attempts drop to 13, armed from the monitor before each TSSolve step and before each integrator TSStep. A -ts_max_reject option keeps the old behaviour of installing it from the start, and reinit! removes it again.

Per step on Lotka-Volterra with save_everystep = false, the time goes from 516 to 497 ns for "3bs", from 833 to 768 ns for "5dp" and from 1546 to 1402 ns for "8vr"; on a 200-state Lorenz-96 problem "5dp" goes from 4252 to 4023 ns. On the Lotka-Volterra work-precision setup every PETSc point is 5 to 12% faster at the same error and step count, while BS3 and DP5, which this does not touch, moved by -3% to +6% between the same runs.

A comparison of 152 solves against main is identical bit for bit in t, u, stats, retcode and dense interpolation. It covers every TSRK subtype with dense output, saveat, Float32, callbacks, tstops and dtmin, and maxiters reached with up to 146 rejected steps, through solve, the integrator, reinit!, a maxiters lowered mid-run, and with -ts_max_reject set. The TSRK, maxiters, statistics, callback and integrator testsets pass (3258 tests), as does PETScAdjoint (4125).

AI Disclosure: Claude assisted with the code. Testing and review by @singhharsh1708.

@singhharsh1708
singhharsh1708 merged commit 4908510 into main Oct 24, 2026
30 of 32 checks passed
singhharsh1708 referenced this pull request Oct 24, 2026
* Read the option names PETSc 3.25 renamed

* Bump to 0.12.3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant