Open
Conversation
…o feature_MG_adapt
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
…o feature_MG_adapt
pcarruscag
reviewed
Apr 3, 2026
Comment on lines
+1344
to
+1349
| su2double vec[MAXNDIM] = {0.0}; | ||
| su2double len2 = 0.0; | ||
| for (unsigned short d = 0; d < nDim; ++d) { | ||
| vec[d] = fine_grid->nodes->GetCoord(jPoint, d) - fine_grid->nodes->GetCoord(current, d); | ||
| len2 += vec[d] * vec[d]; | ||
| } |
Comment on lines
+1355
to
+1356
| su2double dot = 0.0; | ||
| for (unsigned short d = 0; d < nDim; ++d) dot += vec[d] * prev_dir[d]; |
Member
There was a problem hiding this comment.
Tell Claude about GeometryToolbox please
|
|
||
| int global_any_stagnant = local_any_stagnant; | ||
| int global_all_early = local_all_early; | ||
| #ifdef HAVE_MPI |
Comment on lines
+397
to
+428
| { | ||
| if (SU2_MPI::GetRank() == MASTER_NODE) { | ||
| const unsigned short nMGLevels = config[iZone]->GetnMGLevels(); | ||
| auto printRow = [&](const char* label, | ||
| const unsigned short (&actual)[MAX_MG_LEVELS+1], | ||
| auto getMax, | ||
| const su2double (&rms)[MAX_MG_LEVELS+1][2], | ||
| unsigned short nLevels) { | ||
| cout << label; | ||
| for (unsigned short i = 0; i <= nLevels; ++i) { | ||
| cout << (i == 0 ? "(" : ", ") | ||
| << actual[i] << "/" << getMax(i) | ||
| << " [" << scientific << setprecision(2) | ||
| << rms[i][0] << "->" << rms[i][1] | ||
| << defaultfloat << setprecision(6) << "]"; | ||
| } | ||
| cout << ")\n"; | ||
| }; | ||
| printRow("Pre-smooth : ", lastPreSmoothIters, | ||
| [&](unsigned short i){ return config[iZone]->GetMG_PreSmooth(i); }, | ||
| lastPreSmoothRMS, nMGLevels); | ||
| printRow("Post-smooth : ", lastPostSmoothIters, | ||
| [&](unsigned short i){ return config[iZone]->GetMG_PostSmooth(i); }, | ||
| lastPostSmoothRMS, nMGLevels - 1); | ||
| printRow("Corr.-smooth: ", lastCorrecSmoothIters, | ||
| [&](unsigned short i){ return config[iZone]->GetMG_CorrecSmooth(i); }, | ||
| lastCorrecSmoothRMS, nMGLevels - 1); | ||
| cout << fixed << setprecision(4) | ||
| << "Damp. (restr/prolong): " << config[iZone]->GetDamp_Res_Restric() | ||
| << " / " << config[iZone]->GetDamp_Correc_Prolong() << "\n"; | ||
| cout << defaultfloat << setprecision(6); | ||
| } |
Member
There was a problem hiding this comment.
Can you use the table writer please?
| if (iPreSmooth == 0 && iRKStep == 0) { | ||
| BEGIN_SU2_OMP_SAFE_GLOBAL_ACCESS | ||
| { | ||
| lastPreSmoothRMS[iMesh][0] = ComputeLinSysResRMS(solver_fine, geometry_fine); |
Member
There was a problem hiding this comment.
Don't compute residuals without threads
| if (early_exit && mg_early_exit_flag) { | ||
| /*--- Early exit: RMS threshold was met; the RMS that triggered exit is current_rms | ||
| * but we don't store it — just do a final read for the output. ---*/ | ||
| lastPreSmoothRMS[iMesh][1] = ComputeLinSysResRMS(solver_fine, geometry_fine); |
Member
There was a problem hiding this comment.
Actually, why do you need to recompute residuals? Aren't the solvers computing them already?
Co-authored-by: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com>
Co-authored-by: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com>
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.
Proposed Changes
Give a brief overview of your contribution here in a few sentences.
This PR is an improvement of the multigrid method. The goal is to make it more robust and less sensitive to user-defined settings.
It introduces the following:
This means that the option:
effectively becomes the maximum number of iterations that are being performed. The smoothing threshold is given by:
MG_SMOOTH_RES_THRESHOLD=0.5You can still turn it off using:
MG_SMOOTH_EARLY_EXIT= YESeffectively becomes a starting damping factor.
Limit the number of MG meshes such that the smallest and coarsest mesh always has more than MG_MIN_MESHSIZE points. This means that the option
MGLEVEL=4effectively becomes a maximum number of MG levels.
We also expose the smoothing coefficient for correction smoothing to the user:
MG_SMOOTH_COEFF=1.25fixes multigrid restarts for turbulence problems.
Related Work
Resolve any issues (bug fix or feature request), note any related PRs, or mention interactions with the work of others, if any.
A follow-up to #2712
Will fix #1549
PR Checklist
Put an X by all that apply. You can fill this out after submitting the PR. If you have any questions, don't hesitate to ask! We want to help. These are a guide for you to know what the reviewers will be looking for in your contribution.
pre-commit run --allto format old commits.