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
| 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]; | ||
| } |
There was a problem hiding this comment.
this one? GeometryToolbox::Distance
| if (iPreSmooth == 0 && iRKStep == 0) { | ||
| BEGIN_SU2_OMP_SAFE_GLOBAL_ACCESS | ||
| { | ||
| lastPreSmoothRMS[iMesh][0] = ComputeLinSysResRMS(solver_fine, geometry_fine); |
There was a problem hiding this comment.
Don't compute residuals without threads
There was a problem hiding this comment.
ok, so computelinsysres outside of the omp loop?
| 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); |
There was a problem hiding this comment.
Actually, why do you need to recompute residuals? Aren't the solvers computing them already?
There was a problem hiding this comment.
getRes_RMS only has the fine grid values, this one computes it on all grid levels.
Co-authored-by: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com>
Co-authored-by: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com>
Common/include/CConfig.hpp
Outdated
| bool GetMG_Smooth_EarlyExit() const { return MG_Smooth_EarlyExit; } | ||
| bool GetMG_Smooth_EarlyExit() const { return MGOptions.MG_Smooth_EarlyExit; } | ||
|
|
There was a problem hiding this comment.
So the idea is to return a reference to the struct as well, replacing the individual accessors, so that there is just one clean interface for all MG settings.
There was a problem hiding this comment.
ok, so we get rid of the individual GetMG_* functions?
There was a problem hiding this comment.
@pcarruscag mmm, like this?
const CMGOptions& GetMGOptions() const { return MGOptions; }
and then we can do this for example:
config[iZone]->GetMGOptions().MG_Smooth_EarlyExit)
There was a problem hiding this comment.
I looked at sstparsedoptions, and copying that instead, it then looks like this:
const auto& mgOptsZone = config[iZone]->GetMGOptions();
if (mgOptsZone.MG_Smooth_EarlyExit) {
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.