-
Notifications
You must be signed in to change notification settings - Fork 918
Fix multigrid agglomeration #2712
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
| MG_PRE_SMOOTH= ( 4, 4, 4, 4 ) | ||
| MG_POST_SMOOTH= ( 4, 4, 4, 4 ) | ||
| MG_CORRECTION_SMOOTH= ( 4, 4, 4, 4 ) | ||
| MG_DAMP_RESTRICTION= 0.5 | ||
| MG_DAMP_PROLONGATION= 0.5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When MG is finalized, these will be initial values and will be adaptively changed.
| /*--- Get current CFL values ---*/ | ||
| su2double CFL_fine = config->GetCFL(iMesh); | ||
| su2double CFL_coarse_current = config->GetCFL(iMesh+1); | ||
| su2double current_coeff = CFL_coarse_current / CFL_fine; | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a simple adaptive CFL for the coarser MG levels (keeping fine mesh CFL fixed). For some meshes and MG levels it prevents divergence, for others it improves convergence. it is not worse than without adaptive CFL.
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
| if (nDim == 2) { | ||
| //agglomerate_seed = ((config->GetMarker_All_KindBC(copy_marker[0]) == SEND_RECEIVE) || | ||
| // (config->GetMarker_All_KindBC(copy_marker[1]) == SEND_RECEIVE)); | ||
|
|
||
| /* --- Euler walls can also not be agglomerated when the point has 2 markers ---*/ | ||
| if ((config->GetMarker_All_KindBC(copy_marker[0]) == EULER_WALL) || | ||
| (config->GetMarker_All_KindBC(copy_marker[1]) == EULER_WALL)) { | ||
| agglomerate_seed = false; | ||
| } |
Check notice
Code scanning / CodeQL
Futile conditional Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 2 days ago
In general, a futile conditional with an empty then-branch and no else-branch should be removed or rewritten so that the condition is either used meaningfully or not evaluated at all. Any explanatory comments should be kept outside of a non-functional if to avoid confusing tools and readers.
For this case in Common/src/geometry/CMultiGridGeometry.cpp, the if (nDim == 2) on line 178 has its logic entirely commented out. The behavior for nDim == 2 is therefore already "do nothing", and the condition serves only as a disabled skeleton. To fix it without changing existing functionality, we should delete the empty if statement (lines 178–181) and retain the commented-out description (or a short note) as plain comments directly in the counter == 2 block. The rest of the logic—especially the if (nDim == 3) agglomerate_seed = (copy_marker[0] == copy_marker[1]); and the curvature-based checks—must remain unchanged.
No new methods, imports, or definitions are needed. The edit is a local cleanup of the empty if block within the shown region.
-
Copy modified lines R177-R180
| @@ -174,11 +174,10 @@ | ||
| /*--- Note that in 2D, this is a corner and we do not agglomerate unless they both are SEND_RECEIVE. ---*/ | ||
| /*--- In 3D, we agglomerate if the 2 markers are the same. ---*/ | ||
| if (counter == 2) { | ||
| /*--- agglomerate if one of the 2 markers are MPI markers. ---*/ | ||
| if (nDim == 2) { | ||
| // agglomerate_seed = ((config->GetMarker_All_KindBC(copy_marker[0]) == SEND_RECEIVE) || | ||
| // (config->GetMarker_All_KindBC(copy_marker[1]) == SEND_RECEIVE)); | ||
| } | ||
| /*--- agglomerate if one of the 2 markers are MPI markers (2D case, currently disabled). ---*/ | ||
| // agglomerate_seed = ((nDim == 2) && | ||
| // ((config->GetMarker_All_KindBC(copy_marker[0]) == SEND_RECEIVE) || | ||
| // (config->GetMarker_All_KindBC(copy_marker[1]) == SEND_RECEIVE))); | ||
| /*--- agglomerate if both markers are the same. ---*/ | ||
| if (nDim == 3) agglomerate_seed = (copy_marker[0] == copy_marker[1]); | ||
|
|
| // /*--- If seed has 2 markers and one is SEND_RECEIVE, do not agglomerate with physical boundary ---*/ | ||
| // if ((marker_seed.size() == 2) && (config->GetMarker_All_KindBC(marker_seed[0]) == SEND_RECEIVE)) { | ||
| // if (copy_marker[0] == marker_seed[1]) { | ||
| // agglomerate_CV = false; | ||
| // } | ||
| // } | ||
| // if ((marker_seed.size() == 2) && (config->GetMarker_All_KindBC(marker_seed[1]) == SEND_RECEIVE)) { | ||
| // if (copy_marker[0] == marker_seed[0]) { | ||
| // agglomerate_CV = false; | ||
| // } | ||
| // } |
Check notice
Code scanning / CodeQL
Commented-out code Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 2 days ago
To fix the problem, we should remove the commented-out code block and, if necessary, replace it with a brief natural-language comment that does not look like code. This avoids confusion, keeps the file clean, and aligns with the recommendation to remove or reinstate commented-out code.
Concretely, in Common/src/geometry/CMultiGridGeometry.cpp, within the if (counter == 1) branch around line 840, delete the commented-out if statements and their bodies (lines 846–856) while leaving the surrounding logic intact. Since this code was already disabled with //, removing it does not alter existing functionality and requires no additional methods, imports, or definitions. If you want to preserve the intent, you can leave or slightly rephrase the existing explanatory comments that are not code-like; in the snippet given, the descriptive comments at 838–843 and 858–860 are already adequate, so we can simply drop the commented-out logic.
| @@ -843,18 +843,6 @@ | ||
| // note that this should be the same marker id, not just the same marker type. | ||
| if ((marker_seed.size() == 1) && (copy_marker[0] == marker_seed[0])) agglomerate_CV = true; | ||
|
|
||
| // /*--- If seed has 2 markers and one is SEND_RECEIVE, do not agglomerate with physical boundary ---*/ | ||
| // if ((marker_seed.size() == 2) && (config->GetMarker_All_KindBC(marker_seed[0]) == SEND_RECEIVE)) { | ||
| // if (copy_marker[0] == marker_seed[1]) { | ||
| // agglomerate_CV = false; | ||
| // } | ||
| // } | ||
| // if ((marker_seed.size() == 2) && (config->GetMarker_All_KindBC(marker_seed[1]) == SEND_RECEIVE)) { | ||
| // if (copy_marker[0] == marker_seed[0]) { | ||
| // agglomerate_CV = false; | ||
| // } | ||
| // } | ||
|
|
||
| /*--- Note: If there is only one marker, but the marker is the SEND_RECEIVE, then the point is actually an | ||
| interior point and we do not agglomerate. ---*/ | ||
| } |
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Proposed Changes
Give a brief overview of your contribution here in a few sentences.
Implement multigrid agglomeration according to Nishikawa and Diskin.
euler walls are working correctly.
mpi still needs to be checked.
I am submitting my contribution to the develop branch.
My contribution generates no new compiler warnings (try with --warnlevel=3 when using meson).
My contribution is commented and consistent with SU2 style (https://su2code.github.io/docs_v7/Style-Guide/).
I used the pre-commit hook to prevent dirty commits and used
pre-commit run --allto format old commits.I have added a test case that demonstrates my contribution, if necessary.
I have updated appropriate documentation (Tutorials, Docs Page, config_template.cpp), if necessary.