Skip to content

Conversation

@bigfooted
Copy link
Contributor

@bigfooted bigfooted commented Jan 18, 2026

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 --all to 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.

Comment on lines +60 to +64
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
Copy link
Contributor Author

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.

Comment on lines +333 to +337
/*--- 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;

Copy link
Contributor Author

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.

bigfooted and others added 5 commits January 26, 2026 14:02
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>
Comment on lines 179 to 183
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

If-statement with an empty then-branch and no else-branch.

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.

Suggested changeset 1
Common/src/geometry/CMultiGridGeometry.cpp

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/Common/src/geometry/CMultiGridGeometry.cpp b/Common/src/geometry/CMultiGridGeometry.cpp
--- a/Common/src/geometry/CMultiGridGeometry.cpp
+++ b/Common/src/geometry/CMultiGridGeometry.cpp
@@ -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]);
 
EOF
@@ -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]);

Copilot is powered by AI and may make mistakes. Always verify output.
Comment on lines +848 to +858
// /*--- 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

This comment appears to contain commented-out code.

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.

Suggested changeset 1
Common/src/geometry/CMultiGridGeometry.cpp

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/Common/src/geometry/CMultiGridGeometry.cpp b/Common/src/geometry/CMultiGridGeometry.cpp
--- a/Common/src/geometry/CMultiGridGeometry.cpp
+++ b/Common/src/geometry/CMultiGridGeometry.cpp
@@ -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.  ---*/
       }
EOF
@@ -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. ---*/
}
Copilot is powered by AI and may make mistakes. Always verify output.
bigfooted and others added 4 commits January 28, 2026 17:06
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>
@bigfooted bigfooted changed the title [WIP] Fix multigrid agglomeration Fix multigrid agglomeration Jan 28, 2026
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.

2 participants