Skip to content

SNES pseudo-timestepping fixes & improvements - #3492

Open
bendudson wants to merge 4 commits into
nextfrom
snes-ptc
Open

bendudson wants to merge 4 commits into
nextfrom
snes-ptc

Conversation

@bendudson

Copy link
Copy Markdown
Contributor
  • Fix typo in calculating min_neighboring_dt. This is used to cap the cell-to-cell variation of timesteps.
  • Improve handling of failures, to try to prevent the PID controller from becoming saturated.

Copy-paste error in calculation of neighboring timesteps.
Modify dt_vec PETSc Vec, pseudo_timestep Field3D and pseudo_alpha
on SNES failure.

When dt_vec was modified but pseudo_alpha was not, the PID controller
would become saturated so that timestep increases were determined by
caps on increases.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

Comment thread src/solver/impls/snes/snes.cxx
Comment thread src/solver/impls/snes/snes.cxx Outdated
ZedThree
ZedThree previously approved these changes Sep 18, 2026

@ZedThree ZedThree left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, couple of minor suggestions

Comment thread src/solver/impls/snes/snes.cxx Outdated
Comment thread src/solver/impls/snes/snes.cxx Outdated
One cause of solver failure can be very large variation of the
timestep between cells. When SNES repeatedly fails the pseudo timestep
can therefore be "squashed" to reduce variation. This adds options
to tune this process:

- `pseudo_squash_failure_threshold` is an integer (default 5). Once
  the number of snes failures reaches this threshold squashing
  is performed (subsequent failures will be squashed again).
  When snes succeeds the counter is reset to zero.

- `pseudo_squash_method` is an enum, `affine` or `log` to determine
  whether the squashing is linear or logarithmic.

- `pseudo_squash_lambda` is a float between 0 and 1. It determines
  how much of the variation to keep.
Document the new timestep squashing options. Simplify descriptions
of the method and timestep adjustment in the PTC method.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

case BoutPseudoSquashMethod::log:
// Log squash
// dt_vec <- timestep * (dt_vec / timestep)^lambda
PetscInt size;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable 'size' is not initialized [cppcoreguidelines-init-variables]

src/solver/impls/snes/snes.cxx:1066:

- ;
+  = 0;

@bendudson
bendudson requested a review from ZedThree September 19, 2026 20:19
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.

2 participants