Skip to content

Avoid recomputing residual norms for MG early exit#2786

Open
pcarruscag wants to merge 54 commits into
developfrom
pedro/use_available_residual
Open

Avoid recomputing residual norms for MG early exit#2786
pcarruscag wants to merge 54 commits into
developfrom
pedro/use_available_residual

Conversation

@pcarruscag

@pcarruscag pcarruscag commented Apr 12, 2026

Copy link
Copy Markdown
Member

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.

@pcarruscag pcarruscag changed the title Test Avoid recomputing residual norms for MG early exit Apr 13, 2026
@pcarruscag pcarruscag requested a review from bigfooted April 13, 2026 04:46
Comment thread SU2_CFD/src/solvers/CSolver.cpp
Comment thread SU2_CFD/src/integration/CMultiGridIntegration.cpp Outdated
Comment thread SU2_CFD/src/integration/CMultiGridIntegration.cpp Outdated
Comment thread SU2_CFD/src/integration/CMultiGridIntegration.cpp
Comment thread TestCases/parallel_regression.py Outdated
Comment thread TestCases/parallel_regression.py Outdated
Comment thread TestCases/hybrid_regression.py Outdated
fix inf

Co-authored-by: Nijso <nijso@hotmail.com>
Comment thread TestCases/parallel_regression.py Outdated
Comment thread TestCases/hybrid_regression.py Outdated
@bigfooted

Copy link
Copy Markdown
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.

@pcarruscag pcarruscag changed the title Avoid recomputing residual norms for MG early exit [WIP] Avoid recomputing residual norms for MG early exit Apr 25, 2026
bigfooted and others added 4 commits May 4, 2026 19:10
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Comment thread SU2_CFD/src/integration/CMultiGridIntegration.cpp Fixed
bigfooted and others added 5 commits May 4, 2026 20:20
@bigfooted

Copy link
Copy Markdown
Contributor

OK, this compiles properly again, and it actually skips smoothing iterations again.

@bigfooted bigfooted changed the title [WIP] Avoid recomputing residual norms for MG early exit Avoid recomputing residual norms for MG early exit Jun 9, 2026
Comment thread Common/src/CConfig.cpp
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);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Can you add a helper to share this between Pre and Post?

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants