You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TSGetConvergedReason is unusable: out-parameter wrapped as an input #247
TSGetConvergedReason can't be called usefully. The only method takes reason::TSConvergedReason by value and ccalls Ptr{TSConvergedReason} without allocating a Ref, so there's no way to get the value back:
julia>methods(PETSc.LibPETSc.TSGetConvergedReason)
# (petsclib, ts::TS, reason::TSConvergedReason) <- the only one
The same function is wrapped correctly for the sibling solver classes. KSP_wrappers.jl:4066:
SNESGetConvergedReason has both forms, the 2-arg one that allocates the Ref and the 3-arg one that doesn't. TS only got the second. TSGetSolveTime, further down the same file, allocates its Ref correctly, so the generator seems to classify the out-parameter for some signatures and not others.
I hit this writing a TS wrapper and worked around it by deriving convergence from TSGetSolveTime and TSGetStepNumber, which can't tell a diverged step from a step-limit stop.
A crude scan for the same shape (a *Get* function whose last argument is passed as Ptr{T} with no Ref allocated, returning nothing) turns up around 247 candidates, DMGetGlobalSection and DMGetLocalToGlobalMapping among them. I haven't checked those individually, so that's a hint rather than a count.
Is wrapping/ the right place to fix this, or are the generated files edited directly?
I initially used /wrapping to generate the wrappers, but than modified the resulting files directly.
This implies that the two are currently out of sync, which is a non-ideal situation. I'll try fixing this as soon as I have some tokens left. For now, the best way is to edit the files directly.
Fixed by #254: TSGetConvergedReason now allocates the Ref and returns the reason, matching KSPGetConvergedReason. Same thing for TSGetTolerances, since it dropped the caller's vatol/vrtol handles the same way.
Activity
boriskaus commentedon Sep 10, 2026
Thanks for reporting!
I initially used
/wrappingto generate the wrappers, but than modified the resulting files directly.This implies that the two are currently out of sync, which is a non-ideal situation. I'll try fixing this as soon as I have some tokens left. For now, the best way is to edit the files directly.
Return the value from TSGetConvergedReason
Fix two TS wrappers that took output parameters as inputs (#254)
filoferra commentedon Sep 11, 2026
Fixed by #254: TSGetConvergedReason now allocates the Ref and returns the reason, matching KSPGetConvergedReason. Same thing for TSGetTolerances, since it dropped the caller's vatol/vrtol handles the same way.