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.
When MG is finalized, these will be initial values and will be adaptively changed.
| 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 4 days ago
In general, to fix a futile conditional you either (a) implement the intended behavior in the if body, or (b) remove the conditional entirely if the behavior is intentionally unused. Both approaches ensure that any if expression has a meaningful effect or is not present at all.
For this code, the 2D block currently does nothing, while 3D has active logic. Implementing the 2D behavior would change the current program semantics, which may not be safe without more context. The safest fix that does not change existing functionality is to remove the empty if (nDim == 2) along with its commented‑out body, and keep the surrounding comments indicating that 2D corners are treated differently. This keeps the runtime behavior identical (no 2D agglomeration here) but removes the futile conditional and clarifies that only the nDim == 3 case is active at this point.
Concretely, in Common/src/geometry/CMultiGridGeometry.cpp, in the block starting at if (counter == 2) {, remove the lines:
/*--- 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));
}and leave the if (nDim == 3) ... branch unchanged. No new methods, imports, or definitions are required.
| @@ -174,12 +174,7 @@ | ||
| /*--- 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 both markers are the same. ---*/ | ||
| /*--- agglomerate if both markers are the same (3D case). ---*/ | ||
| if (nDim == 3) agglomerate_seed = (copy_marker[0] == copy_marker[1]); | ||
|
|
||
| /*--- Euler walls: check curvature-based agglomeration criterion for both markers ---*/ |
| // /*--- 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 4 days ago
In general, to fix commented‑out code you either (a) delete it entirely if it is no longer needed, or (b) reinstate it as active code if it reflects current intended behavior. Here, we lack evidence that the SEND_RECEIVE special handling should be active, and enabling it would change the agglomeration logic. To avoid unintended behavioral changes, the best fix is to remove the commented‑out C++ statements while keeping or improving any natural‑language explanation.
Concretely, in Common/src/geometry/CMultiGridGeometry.cpp, inside the if (counter == 1) block around lines 836–856, delete the commented‑out if statements (lines 842–852) that contain full C++ code. Optionally, we can replace them with a brief explanatory English comment if desired, but we should not introduce new logic. No new methods, imports, or definitions are required.
| @@ -839,18 +839,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>
| */ | ||
| void SetRestricted_Solution(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse, | ||
| CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config); | ||
| CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config, unsigned short iMesh = 999); |
| // agglomerate_seed = ((config->GetMarker_All_KindBC(copy_marker[0]) == SEND_RECEIVE) || | ||
| // (config->GetMarker_All_KindBC(copy_marker[1]) == SEND_RECEIVE)); |
There was a problem hiding this comment.
wip? or the comment above if counter == 2 needs to be updated?
Co-authored-by: Johannes Blühdorn <55186095+jblueh@users.noreply.github.com>
Co-authored-by: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com>
Co-authored-by: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com>
Co-authored-by: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com>
Co-authored-by: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com>
| // nijso: check if this can be removed now. | ||
| //solver_fine->InitiateComms(geometry_fine, config, MPI_QUANTITIES::SOLUTION); | ||
| //solver_fine->CompleteComms(geometry_fine, config, MPI_QUANTITIES::SOLUTION); |
Check notice
Code scanning / CodeQL
Commented-out code Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 4 days ago
In general, to fix commented-out code you either (a) reinstate it as active code where it is actually needed and fully tested, or (b) remove it altogether if it is obsolete or no longer required. If you still want to describe former behavior, use a short natural-language comment instead of code-like text.
For this instance in SU2_CFD/src/integration/CMultiGridIntegration.cpp, the best fix without changing existing functionality is to remove the two commented-out communication calls on lines 564–565 and keep, at most, a concise explanatory comment about MPI sync behavior. The behavior is already “no sync” because the calls are commented out; deleting them preserves runtime behavior but removes the technical debt. Concretely:
- In the loop over
iPostSmooth, under the “MPI sync after RK stage...” comment, delete the two commented-outsolver_fine->InitiateComms(...)andsolver_fine->CompleteComms(...)lines. - Optionally trim the “check if this can be removed now” note to a neutral statement about current behavior (no code snippets), but this is not strictly necessary for the CodeQL issue as long as code-like lines are gone.
No new methods, imports, or definitions are required.
| @@ -559,11 +559,10 @@ | ||
|
|
||
| } | ||
|
|
||
| /*--- MPI sync after RK stage to ensure halos have updated solution for next smoothing iteration ---*/ | ||
| // nijso: check if this can be removed now. | ||
| //solver_fine->InitiateComms(geometry_fine, config, MPI_QUANTITIES::SOLUTION); | ||
| //solver_fine->CompleteComms(geometry_fine, config, MPI_QUANTITIES::SOLUTION); | ||
| /*--- MPI sync after RK stage is currently not performed here; halos are assumed up-to-date for next smoothing iteration. ---*/ | ||
|
|
||
|
|
||
|
|
||
| } | ||
| } | ||
|
|
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.