Avoid recomputing residual norms for MG early exit#2786
Open
pcarruscag wants to merge 54 commits into
Open
Conversation
bigfooted
reviewed
Apr 13, 2026
bigfooted
reviewed
Apr 13, 2026
bigfooted
reviewed
Apr 13, 2026
bigfooted
reviewed
Apr 13, 2026
bigfooted
reviewed
Apr 14, 2026
bigfooted
reviewed
Apr 14, 2026
bigfooted
reviewed
Apr 14, 2026
fix inf Co-authored-by: Nijso <nijso@hotmail.com>
bigfooted
reviewed
Apr 14, 2026
bigfooted
reviewed
Apr 14, 2026
Co-authored-by: Nijso <nijso@hotmail.com>
Contributor
|
A couple of testcases have very large differences in residuals, and one case is diverging. I will have to check these in more detail to see if they need different settings and produce reasonable results. |
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
…code/su2 into pedro/use_available_residual
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
…code/su2 into pedro/use_available_residual
Contributor
|
OK, this compiles properly again, and it actually skips smoothing iterations again. |
pcarruscag
commented
Jun 14, 2026
Comment on lines
+1992
to
+1993
| /*!\brief MG_SMOOTH_STAGNATION_TOL\n DESCRIPTION: Early exit smoothing when step-to-step RMS ratio >= this value (0 = disabled). DEFAULT: 0.0 \ingroup Config*/ | ||
| addDoubleOption("MG_SMOOTH_STAGNATION_TOL", MGOptions.MG_Smooth_StagnationTol, 0.99); |
Member
Author
There was a problem hiding this comment.
Commented default doesn't match the code
Comment on lines
+607
to
+633
| BEGIN_SU2_OMP_SAFE_GLOBAL_ACCESS { | ||
| const passivedouble defect = ComputeLinSysResRMS(solver_fine); | ||
| if (iPostSmooth == 0) { | ||
| mg_initial_smooth_rms = defect; | ||
| lastPostSmoothRMS[iMesh][0] = defect; | ||
| } else { | ||
| if (mg_prev_smooth_rms > EPS) { | ||
| const passivedouble step_ratio = defect / mg_prev_smooth_rms; | ||
| if (step_ratio > lastPostSmoothWorstStepRatio[iMesh]) { | ||
| lastPostSmoothWorstStepRatio[iMesh] = step_ratio; | ||
| lastPostSmoothWorstStep[iMesh] = iPostSmooth + 1; | ||
| } | ||
| } | ||
|
|
||
| if (early_exit) { | ||
| if (defect < mgOpts.MG_Smooth_Res_Threshold * mg_initial_smooth_rms) { | ||
| lastPostSmoothExitReason[iMesh] = 'T'; | ||
| mg_early_exit_flag = true; | ||
| } else if (defect >= mg_prev_smooth_rms * stag_tol) { | ||
| /*--- 'A' = amplifying-stagnation (defect grew vs previous step). | ||
| * 'S' = clean stagnation (defect is not improving but also not growing). ---*/ | ||
| lastPostSmoothExitReason[iMesh] = (defect > mg_prev_smooth_rms) ? 'A' : 'S'; | ||
| mg_early_exit_flag = true; | ||
| } | ||
| } | ||
| } | ||
| mg_prev_smooth_rms = defect; |
Member
Author
There was a problem hiding this comment.
Can you add a helper to share this between Pre and Post?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I think the norm should include the MG part of the residual, because it is the sum of the 2 that the solver is trying to converge.