-
Notifications
You must be signed in to change notification settings - Fork 910
[WIP] fix multigrid agglomeration #2375
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
| * \return <code>TRUE</code> or <code>FALSE</code> depending if the control volume can be agglomerated. | ||
| */ | ||
| bool SetBoundAgglomeration(unsigned long CVPoint, short marker_seed, const CGeometry* fine_grid, | ||
| bool SetBoundAgglomeration(unsigned long CVPoint, vector<short> marker_seed, const CGeometry* fine_grid, |
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.
We need to pass information about all markers on the seed node (number of markers and index of marker)
| case SUB_SOLVER_TYPE::TURB_SST: | ||
| genericSolver = CreateTurbSolver(kindTurbModel, solver, geometry, config, iMGLevel, false); | ||
| metaData.integrationType = INTEGRATION_TYPE::SINGLEGRID; | ||
| //metaData.integrationType = INTEGRATION_TYPE::MULTIGRID; |
Check notice
Code scanning / CodeQL
Commented-out code Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 1 month ago
The best way to fix this problem is to remove the commented-out code on line 313: //metaData.integrationType = INTEGRATION_TYPE::MULTIGRID;. This line is commented out without justification, and does not serve as documentation or a helpful note. No other changes are required (such as reinstating the code), since there is already a definitive assignment for metaData.integrationType just above this line, and no surrounding commentary suggests ambiguity.
Edit SU2_CFD/src/solvers/CSolverFactory.cpp by deleting line 313 entirely. No import, method, or variable changes are necessary.
| @@ -310,7 +310,6 @@ | ||
| case SUB_SOLVER_TYPE::TURB_SST: | ||
| genericSolver = CreateTurbSolver(kindTurbModel, solver, geometry, config, iMGLevel, false); | ||
| metaData.integrationType = INTEGRATION_TYPE::SINGLEGRID; | ||
| //metaData.integrationType = INTEGRATION_TYPE::MULTIGRID; | ||
| break; | ||
| case SUB_SOLVER_TYPE::TEMPLATE: | ||
| genericSolver = new CTemplateSolver(geometry, config); |
|
In SU2, we overwrite part of the config settings. The nr of pre-smoothing steps for the finest grid is always 1. The nr of post-smoothing steps for the coarsest and finest grid is always 0. I do not know why. |
|
Thank you. We wish to contribute our knowledge about MG for scalar transport equations; if an exciting group is on this topic, we will be happy to collaborate. |
|
Nice to hear there is a larger interest in getting the multigrid method to a higher level. If you would like to enable multigrid for species transport, the first thing to do is change the integration type from SINGLEGRID to MULTIGRID for CreateSpeciesSolver in CSolverFactory.cpp. Then in CMultigridIntegration.cpp, there might be some solver specific things that need to be added. |
|
Thank you for pointing this out. Does the current agglomeration (for the mean-flow equations) consider lines normal to the surface? I think that the Hiroaki paper (MG) considred implicit line? |
|
Hi, No we currently do not do agglomeration along lines. I suspect this is one reason that we do not have good multigrid performance for a number of viscous testcases. @EvertBunschoten was looking into this as well, but he was not yet able to reproduce the good performance reported by the papers of Diskin, Nishikawa and others. |
…ode/su2 into fix_multigrid_agglomeration
| // auto end2 = Suitable_Second_Neighbors.end(); | ||
| // if (find(Suitable_Second_Neighbors.begin(), end2, lPoint) != end2) continue; |
Check notice
Code scanning / CodeQL
Commented-out code Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 9 days ago
The best way to address this issue is to remove the commented-out code block that constitutes code, not documentation, in lines 1151–1168 and the similar block in 1172–1176, while retaining any genuine comments and TODOs. The rationale can be preserved by expanding the existing TODO or explanatory comment, clarifying that the removed block used to attempt further neighbor searches but was deemed redundant, thus future maintainers are pointed towards the issue's context without having to parse dead code. No new imports, methods, or definitions are needed.
-
Copy modified lines R1149-R1151 -
Copy modified lines R1159-R1169 -
Copy modified lines R1173-R1175
| @@ -1146,33 +1146,33 @@ | ||
|
|
||
| /*--- Create a list with the third neighbors, without first, second, and seed neighbors. ---*/ | ||
|
|
||
| /// TODO: This repeats the process above but I doubt it catches any more points. | ||
| /// TODO: Previous code tried to find third neighbors by extending the search beyond second neighbors. | ||
| /// However, this may not be needed, as it likely does not catch more points. | ||
| /// If more sophisticated neighbor discovery is later required, refer to version history. | ||
|
|
||
| // vector<unsigned long> Third_Neighbor_Points, Third_Origin_Points; | ||
|
|
||
| // for (auto kPoint : Suitable_Second_Neighbors) { | ||
| // for (auto lPoint : fine_grid->nodes->GetPoints(kPoint)) { | ||
| // /*--- Check that the third neighbor does not belong to the first neighbors or the seed ---*/ | ||
|
|
||
| // auto end1 = First_Neighbor_Points.end(); | ||
| // if (find(First_Neighbor_Points.begin(), end1, lPoint) != end1) continue; | ||
|
|
||
| // /*--- Check that the third neighbor does not belong to the second neighbors ---*/ | ||
|
|
||
| // auto end2 = Suitable_Second_Neighbors.end(); | ||
| // if (find(Suitable_Second_Neighbors.begin(), end2, lPoint) != end2) continue; | ||
|
|
||
| // Third_Neighbor_Points.push_back(lPoint); | ||
| // Third_Origin_Points.push_back(kPoint); | ||
| // } | ||
| // } | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
| /*--- Identify those third neighbors that are repeated (candidate to be added). ---*/ | ||
|
|
||
| // for (auto iNeighbor = 0ul; iNeighbor < Third_Neighbor_Points.size(); iNeighbor++) { | ||
| // for (auto jNeighbor = iNeighbor + 1; jNeighbor < Third_Neighbor_Points.size(); jNeighbor++) { | ||
| // /*--- Repeated third neighbor with different origin ---*/ | ||
|
|
||
|
|
||
|
|
||
|
|
||
| // if ((Third_Neighbor_Points[iNeighbor] == Third_Neighbor_Points[jNeighbor]) && | ||
| // (Third_Origin_Points[iNeighbor] != Third_Origin_Points[jNeighbor])) { | ||
| // Suitable_Indirect_Neighbors.push_back(Third_Neighbor_Points[iNeighbor]); |
| // Third_Neighbor_Points.push_back(lPoint); | ||
| // Third_Origin_Points.push_back(kPoint); | ||
| // } | ||
| // } |
Check notice
Code scanning / CodeQL
Commented-out code Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 9 days ago
The best and simplest way to address this issue without altering the program's existing behavior is to delete only the commented-out code block that corresponds to the flagged region (lines 1151–1168), as well as any directly connected blocks of commented-out code beneath it (e.g., 1172–1180). All of this is abandoned logic that a reader can recover from version control history if needed. Make sure not to remove regular comments or documentation, just the blocks of commented-out executable code.
No changes to logic, headers, or functionality are necessary—just code removal of the commented-out sections.
| @@ -1148,36 +1148,11 @@ | ||
|
|
||
| /// TODO: This repeats the process above but I doubt it catches any more points. | ||
|
|
||
| // vector<unsigned long> Third_Neighbor_Points, Third_Origin_Points; | ||
|
|
||
| // for (auto kPoint : Suitable_Second_Neighbors) { | ||
| // for (auto lPoint : fine_grid->nodes->GetPoints(kPoint)) { | ||
| // /*--- Check that the third neighbor does not belong to the first neighbors or the seed ---*/ | ||
|
|
||
| // auto end1 = First_Neighbor_Points.end(); | ||
| // if (find(First_Neighbor_Points.begin(), end1, lPoint) != end1) continue; | ||
|
|
||
| // /*--- Check that the third neighbor does not belong to the second neighbors ---*/ | ||
|
|
||
| // auto end2 = Suitable_Second_Neighbors.end(); | ||
| // if (find(Suitable_Second_Neighbors.begin(), end2, lPoint) != end2) continue; | ||
|
|
||
| // Third_Neighbor_Points.push_back(lPoint); | ||
| // Third_Origin_Points.push_back(kPoint); | ||
| // } | ||
| // } | ||
|
|
||
| /*--- Identify those third neighbors that are repeated (candidate to be added). ---*/ | ||
|
|
||
| // for (auto iNeighbor = 0ul; iNeighbor < Third_Neighbor_Points.size(); iNeighbor++) { | ||
| // for (auto jNeighbor = iNeighbor + 1; jNeighbor < Third_Neighbor_Points.size(); jNeighbor++) { | ||
| // /*--- Repeated third neighbor with different origin ---*/ | ||
|
|
||
| // if ((Third_Neighbor_Points[iNeighbor] == Third_Neighbor_Points[jNeighbor]) && | ||
| // (Third_Origin_Points[iNeighbor] != Third_Origin_Points[jNeighbor])) { | ||
| // Suitable_Indirect_Neighbors.push_back(Third_Neighbor_Points[iNeighbor]); | ||
| // } | ||
| // } | ||
| // } | ||
|
|
||
| /*--- Remove duplicates from the final list of Suitable Indirect Neighbors. ---*/ |
| // for (auto iNeighbor = 0ul; iNeighbor < Third_Neighbor_Points.size(); iNeighbor++) { | ||
| // for (auto jNeighbor = iNeighbor + 1; jNeighbor < Third_Neighbor_Points.size(); jNeighbor++) { | ||
| // /*--- Repeated third neighbor with different origin ---*/ |
Check notice
Code scanning / CodeQL
Commented-out code Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 9 days ago
The best way to fix this problem is to remove the block of commented-out code if it is not serving a necessary documentation or illustrative purpose, and is not referenced or required by any surrounding comments. Since the lines in question are straightforward code and not explanatory pseudocode, and the function likely continues appropriately without them, the safe route is to delete the commented-out loop and the associated block. This means lines 1172-1181 (the for-loops for identifying and pushing repeated third neighbors as suitable indirect neighbors) should be cleanly removed.
No additional imports, method definitions, or variable declarations are needed to support this change.
| @@ -1169,17 +1169,7 @@ | ||
|
|
||
| /*--- Identify those third neighbors that are repeated (candidate to be added). ---*/ | ||
|
|
||
| // for (auto iNeighbor = 0ul; iNeighbor < Third_Neighbor_Points.size(); iNeighbor++) { | ||
| // for (auto jNeighbor = iNeighbor + 1; jNeighbor < Third_Neighbor_Points.size(); jNeighbor++) { | ||
| // /*--- Repeated third neighbor with different origin ---*/ | ||
|
|
||
| // if ((Third_Neighbor_Points[iNeighbor] == Third_Neighbor_Points[jNeighbor]) && | ||
| // (Third_Origin_Points[iNeighbor] != Third_Origin_Points[jNeighbor])) { | ||
| // Suitable_Indirect_Neighbors.push_back(Third_Neighbor_Points[iNeighbor]); | ||
| // } | ||
| // } | ||
| // } | ||
|
|
||
| /*--- Remove duplicates from the final list of Suitable Indirect Neighbors. ---*/ | ||
|
|
||
| // sort(Suitable_Indirect_Neighbors.begin(), Suitable_Indirect_Neighbors.end()); |
| // if ((Third_Neighbor_Points[iNeighbor] == Third_Neighbor_Points[jNeighbor]) && | ||
| // (Third_Origin_Points[iNeighbor] != Third_Origin_Points[jNeighbor])) { | ||
| // Suitable_Indirect_Neighbors.push_back(Third_Neighbor_Points[iNeighbor]); | ||
| // } | ||
| // } | ||
| // } |
Check notice
Code scanning / CodeQL
Commented-out code Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 9 days ago
To address the problem, we should remove all blocks of commented-out code, specifically lines 1157 through 1187 (all indented and commented lines) that constitute actual code instead of documentation or meaningful comments. The structural and explanatory comments around the blocks (such as "Identify those third neighbors…", "Remove duplicates…") should be preserved for clarity unless they have become detached from all context, in which case they can also be removed. This edit maintains the clarity of the function while eliminating the confusion and maintenance issues from commented-out code fragments.
| @@ -1154,37 +1154,10 @@ | ||
| // for (auto lPoint : fine_grid->nodes->GetPoints(kPoint)) { | ||
| // /*--- Check that the third neighbor does not belong to the first neighbors or the seed ---*/ | ||
|
|
||
| // auto end1 = First_Neighbor_Points.end(); | ||
| // if (find(First_Neighbor_Points.begin(), end1, lPoint) != end1) continue; | ||
|
|
||
| // /*--- Check that the third neighbor does not belong to the second neighbors ---*/ | ||
|
|
||
| // auto end2 = Suitable_Second_Neighbors.end(); | ||
| // if (find(Suitable_Second_Neighbors.begin(), end2, lPoint) != end2) continue; | ||
|
|
||
| // Third_Neighbor_Points.push_back(lPoint); | ||
| // Third_Origin_Points.push_back(kPoint); | ||
| // } | ||
| // } | ||
|
|
||
| /*--- Identify those third neighbors that are repeated (candidate to be added). ---*/ | ||
|
|
||
| // for (auto iNeighbor = 0ul; iNeighbor < Third_Neighbor_Points.size(); iNeighbor++) { | ||
| // for (auto jNeighbor = iNeighbor + 1; jNeighbor < Third_Neighbor_Points.size(); jNeighbor++) { | ||
| // /*--- Repeated third neighbor with different origin ---*/ | ||
|
|
||
| // if ((Third_Neighbor_Points[iNeighbor] == Third_Neighbor_Points[jNeighbor]) && | ||
| // (Third_Origin_Points[iNeighbor] != Third_Origin_Points[jNeighbor])) { | ||
| // Suitable_Indirect_Neighbors.push_back(Third_Neighbor_Points[iNeighbor]); | ||
| // } | ||
| // } | ||
| // } | ||
|
|
||
| /*--- Remove duplicates from the final list of Suitable Indirect Neighbors. ---*/ | ||
|
|
||
| // sort(Suitable_Indirect_Neighbors.begin(), Suitable_Indirect_Neighbors.end()); | ||
| // auto it2 = unique(Suitable_Indirect_Neighbors.begin(), Suitable_Indirect_Neighbors.end()); | ||
| // Suitable_Indirect_Neighbors.resize(it2 - Suitable_Indirect_Neighbors.begin()); | ||
| } | ||
|
|
||
| void CMultiGridGeometry::AgglomerateImplicitLines(unsigned long& Index_CoarseCV, const CGeometry* fine_grid, |
| // sort(Suitable_Indirect_Neighbors.begin(), Suitable_Indirect_Neighbors.end()); | ||
| // auto it2 = unique(Suitable_Indirect_Neighbors.begin(), Suitable_Indirect_Neighbors.end()); | ||
| // Suitable_Indirect_Neighbors.resize(it2 - Suitable_Indirect_Neighbors.begin()); |
Check notice
Code scanning / CodeQL
Commented-out code Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 9 days ago
The appropriate fix is to remove the commented-out code lines (1185–1187) entirely. This eliminates clutter and reduces confusion for future readers or maintainers. No code functionality is altered, as the code is currently disabled. The region to edit is as follows:
- File:
Common/src/geometry/CMultiGridGeometry.cpp - Lines: 1185, 1186, 1187 (the three commented-out lines)
- Action: Delete these lines.
No imports, definitions, or other code edits aside from removing these lines are necessary.
| @@ -1182,9 +1182,6 @@ | ||
|
|
||
| /*--- Remove duplicates from the final list of Suitable Indirect Neighbors. ---*/ | ||
|
|
||
| // sort(Suitable_Indirect_Neighbors.begin(), Suitable_Indirect_Neighbors.end()); | ||
| // auto it2 = unique(Suitable_Indirect_Neighbors.begin(), Suitable_Indirect_Neighbors.end()); | ||
| // Suitable_Indirect_Neighbors.resize(it2 - Suitable_Indirect_Neighbors.begin()); | ||
| } | ||
|
|
||
| void CMultiGridGeometry::AgglomerateImplicitLines(unsigned long& Index_CoarseCV, const CGeometry* fine_grid, |
|
|
||
| for (auto jMarker = 0u; jMarker < fine_grid->GetnMarker() && counter < 3; jMarker++) { | ||
| for (auto jMarker = 0u; jMarker < fine_grid->GetnMarker(); jMarker++) { | ||
| const string Marker_Tag = config->GetMarker_All_TagBound(iMarker); // fine_grid->GetMarker_Tag(jMarker); |
Check notice
Code scanning / CodeQL
Commented-out code Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 9 days ago
The best way to address this is to remove the commented-out code line // fine_grid->GetMarker_Tag(jMarker);. This clears up the ambiguity for future readers, removes clutter, and doesn't affect the program’s operation, as this code is already not being executed. No additional imports, definitions, or replacements are needed elsewhere, and no code needs to be reinstated.
Change needed:
- File: Common/src/geometry/CMultiGridGeometry.cpp
- Region: Remove line 128, leaving the surrounding comment and functionality unchanged.
-
Copy modified line R128
| @@ -125,7 +125,7 @@ | ||
| that are in that point ---*/ | ||
|
|
||
| for (auto jMarker = 0u; jMarker < fine_grid->GetnMarker(); jMarker++) { | ||
| const string Marker_Tag = config->GetMarker_All_TagBound(iMarker); // fine_grid->GetMarker_Tag(jMarker); | ||
| const string Marker_Tag = config->GetMarker_All_TagBound(iMarker); | ||
| if (fine_grid->nodes->GetVertex(iPoint, jMarker) != -1) { | ||
| copy_marker[counter] = jMarker; | ||
| counter++; |
|
|
||
| /*--- In 2D, corners are not agglomerated, but in 3D counter=2 means we are on the | ||
| edge of a 2D face. In that case, agglomerate if both nodes are the same. ---*/ | ||
| // if (nDim == 2) agglomerate_seed = false; |
Check notice
Code scanning / CodeQL
Commented-out code Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 9 days ago
To fix the issue, the best approach is to simply remove the line // if (nDim == 2) agglomerate_seed = false; altogether. This is because retaining commented-out code only serves to clutter the source and reduce maintainability. Removing the line will not affect the behavior of the code, and no other modifications are necessary. This change involves deleting this single commented line from Common/src/geometry/CMultiGridGeometry.cpp at or near line 217, leaving surrounding comments and logic untouched. No imports, method definitions, or variable adjustments are required.
| @@ -214,7 +214,6 @@ | ||
|
|
||
| /*--- In 2D, corners are not agglomerated, but in 3D counter=2 means we are on the | ||
| edge of a 2D face. In that case, agglomerate if both nodes are the same. ---*/ | ||
| // if (nDim == 2) agglomerate_seed = false; | ||
| } | ||
|
|
||
| /*--- If there are more than 2 markers, the aglomeration will be discarded ---*/ |
| /*--- If the seed (parent) can be agglomerated, we try to agglomerate connected childs to the parent ---*/ | ||
| /*--- Note that in 2D we allow a maximum of 4 nodes to be agglomerated ---*/ | ||
| if (agglomerate_seed) { | ||
| // cout << " seed can be agglomerated to more points." << endl; |
Check notice
Code scanning / CodeQL
Commented-out code Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 9 days ago
The best way to fix this problem is to remove the line of commented-out code entirely. This will declutter the codebase and prevent confusion. Since this code is commented and is non-functional, deleting it does not alter the program's behavior.
Specifically, in Common/src/geometry/CMultiGridGeometry.cpp, locate and delete the line:
// cout << " seed can be agglomerated to more points." << endl;No further changes or imports are necessary. No functional changes are introduced, and no other code comments or lines are affected.
| @@ -226,7 +226,6 @@ | ||
| /*--- If the seed (parent) can be agglomerated, we try to agglomerate connected childs to the parent ---*/ | ||
| /*--- Note that in 2D we allow a maximum of 4 nodes to be agglomerated ---*/ | ||
| if (agglomerate_seed) { | ||
| // cout << " seed can be agglomerated to more points." << endl; | ||
| /*--- Now we do a sweep over all the nodes that surround the seed point ---*/ | ||
|
|
||
| for (auto CVPoint : fine_grid->nodes->GetPoints(iPoint)) { |
|
|
||
| /*--- The new point can be agglomerated ---*/ | ||
| if (SetBoundAgglomeration(CVPoint, marker_seed, fine_grid, config)) { | ||
| // cout << " agglomerate " << CVPoint << " with seed point "<< iPoint << endl; |
Check notice
Code scanning / CodeQL
Commented-out code Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 9 days ago
The best way to fix the problem is to remove the commented-out code entirely, as it is unnecessary and can clutter the codebase. In the provided snippet (Common/src/geometry/CMultiGridGeometry.cpp), the flagged line (243) is a commented-out debug print statement. There are other commented-out debug or print statements in this same function, such as those on lines 229, 233-239, 270-275, and 278. For completeness and clarity, all these commented-out lines should be removed, since they neither document the code nor serve a functional purpose.
The required change is a deletion of those lines. No additional imports, function definitions, or code modifications are needed.
-
Copy modified line R229 -
Copy modified line R234 -
Copy modified line R237 -
Copy modified line R258 -
Copy modified line R261
| @@ -226,21 +226,15 @@ | ||
| /*--- If the seed (parent) can be agglomerated, we try to agglomerate connected childs to the parent ---*/ | ||
| /*--- Note that in 2D we allow a maximum of 4 nodes to be agglomerated ---*/ | ||
| if (agglomerate_seed) { | ||
| // cout << " seed can be agglomerated to more points." << endl; | ||
|
|
||
| /*--- Now we do a sweep over all the nodes that surround the seed point ---*/ | ||
|
|
||
| for (auto CVPoint : fine_grid->nodes->GetPoints(iPoint)) { | ||
| // cout << " checking child CVPoint = " | ||
| // << CVPoint | ||
| // << ", coord = " | ||
| // << fine_grid->nodes->GetCoord(CVPoint, 0) | ||
| // << " " | ||
| // << fine_grid->nodes->GetCoord(CVPoint, 1) | ||
| // << endl; | ||
|
|
||
|
|
||
| /*--- The new point can be agglomerated ---*/ | ||
| if (SetBoundAgglomeration(CVPoint, marker_seed, fine_grid, config)) { | ||
| // cout << " agglomerate " << CVPoint << " with seed point "<< iPoint << endl; | ||
|
|
||
| /*--- We set the value of the parent ---*/ | ||
|
|
||
| fine_grid->nodes->SetParent_CV(CVPoint, Index_CoarseCV); | ||
| @@ -267,15 +255,10 @@ | ||
|
|
||
| /*--- Now we do a sweep over all the indirect nodes that can be added ---*/ | ||
| for (auto CVPoint : Suitable_Indirect_Neighbors) { | ||
| // cout << " Boundary: checking indirect neighbors " << CVPoint | ||
| // << ", coord = " | ||
| // << fine_grid->nodes->GetCoord(CVPoint, 0) | ||
| // << " " | ||
| // << fine_grid->nodes->GetCoord(CVPoint, 1) | ||
| // << endl; | ||
|
|
||
| /*--- The new point can be agglomerated ---*/ | ||
| if (SetBoundAgglomeration(CVPoint, marker_seed, fine_grid, config)) { | ||
| // cout << " Boundary: indirect neighbor " << CVPoint << " can be agglomerated." << endl; | ||
|
|
||
| /*--- We set the value of the parent ---*/ | ||
| fine_grid->nodes->SetParent_CV(CVPoint, Index_CoarseCV); | ||
|
|
| // << endl; | ||
| /*--- The new point can be agglomerated ---*/ | ||
| if (SetBoundAgglomeration(CVPoint, marker_seed, fine_grid, config)) { | ||
| // cout << " Boundary: indirect neighbor " << CVPoint << " can be agglomerated." << endl; |
Check notice
Code scanning / CodeQL
Commented-out code Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 9 days ago
The optimal fix is to remove the commented-out cout line entirely, as it's neither documentation nor active code and is not needed for functionality. Keeping such commented-out debugging code only clutters the source file. If debug output is still occasionally required, a proper debug/logging macro should be used which can be enabled or disabled at compile time, not with block comments. Edit the region in file Common/src/geometry/CMultiGridGeometry.cpp to simply remove line 278, leaving the rest of the code unchanged.
-
Copy modified line R278
| @@ -275,7 +275,7 @@ | ||
| // << endl; | ||
| /*--- The new point can be agglomerated ---*/ | ||
| if (SetBoundAgglomeration(CVPoint, marker_seed, fine_grid, config)) { | ||
| // cout << " Boundary: indirect neighbor " << CVPoint << " can be agglomerated." << endl; | ||
|
|
||
| /*--- We set the value of the parent ---*/ | ||
| fine_grid->nodes->SetParent_CV(CVPoint, Index_CoarseCV); | ||
|
|
| /*--- Compute Forcing Term $P_(k+1) = I^(k+1)_k(P_k+F_k(u_k))-F_(k+1)(I^(k+1)_k u_k)$ and update solution for multigrid ---*/ | ||
|
|
||
| if ( iMesh < config->GetnMGLevels() ) { | ||
| //cout << "imesh =" << iMesh << " " << config->GetnMGLevels() << endl; |
Check notice
Code scanning / CodeQL
Commented-out code Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 12 days ago
The best way to fix the problem is to remove the line containing the commented-out code entirely. Specifically, line 182 in SU2_CFD/src/integration/CMultiGridIntegration.cpp, which reads:
//cout << "imesh =" << iMesh << " " << config->GetnMGLevels() << endl;should be deleted. This will remove the distraction and potential confusion caused by inactive code left in comments, without affecting any functionality of the actual code.
| @@ -179,7 +179,6 @@ | ||
| /*--- Compute Forcing Term $P_(k+1) = I^(k+1)_k(P_k+F_k(u_k))-F_(k+1)(I^(k+1)_k u_k)$ and update solution for multigrid ---*/ | ||
|
|
||
| if ( iMesh < config->GetnMGLevels() ) { | ||
| //cout << "imesh =" << iMesh << " " << config->GetnMGLevels() << endl; | ||
|
|
||
| /*--- Shorter names to refer to coarse grid entities. ---*/ | ||
|
|
| static su2double Damp_Restric_Adapt(const unsigned short *lastPreSmoothIters, | ||
| unsigned short lastPreSmoothCount, | ||
| CConfig *config) { | ||
| //cout << "starting Damp_Restric_Adapt" << endl; |
Check notice
Code scanning / CodeQL
Commented-out code Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 12 days ago
To fix the problem, the line containing the commented-out cout statement should be removed entirely. This involves deleting line 694 (//cout << "starting Damp_Restric_Adapt" << endl;). This is the only required change; no additional code, imports, or functionality needs to be added or modified, as the removal will not affect the logic or function of the surrounding code.
| @@ -691,7 +691,6 @@ | ||
| static su2double Damp_Restric_Adapt(const unsigned short *lastPreSmoothIters, | ||
| unsigned short lastPreSmoothCount, | ||
| CConfig *config) { | ||
| //cout << "starting Damp_Restric_Adapt" << endl; | ||
| if (config == nullptr) return 0.0; | ||
|
|
||
| const unsigned short nMGLevels = config->GetnMGLevels(); |
|
|
||
|
|
||
| const su2double current = config->GetDamp_Res_Restric(); | ||
| //cout << "Current Damp_Res_Restric: " << current << endl; |
Check notice
Code scanning / CodeQL
Commented-out code Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 12 days ago
To fix this problem, simply remove the line //cout << "Current Damp_Res_Restric: " << current << endl; entirely from the file SU2_CFD/src/integration/CMultiGridIntegration.cpp. Do not replace it with anything else unless a meaningful comment is truly needed (which is not the case here). This will clean the code and eliminate unnecessary clutter without affecting any existing functionality, as the line is currently commented-out and has no effect at runtime.
| @@ -745,7 +745,6 @@ | ||
|
|
||
|
|
||
| const su2double current = config->GetDamp_Res_Restric(); | ||
| //cout << "Current Damp_Res_Restric: " << current << endl; | ||
| su2double new_factor = current; | ||
|
|
||
| const su2double scale_down = 0.99; |
| // already made through global MPI reductions, so calling the setter on all | ||
| // ranks yields the same value everywhere. | ||
| config->SetDamp_Res_Restric(new_factor); | ||
| //cout << "ending Damp_Restric_Adapt, damping = " <<config->GetDamp_Res_Restric() << endl; |
Check notice
Code scanning / CodeQL
Commented-out code Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 12 days ago
To fix the problem, we should simply remove the line of commented-out code. This will clean up the code without impacting any functionality, as the code in question is not executed and is redundant due to the presence of proper logging in the preceding code block. Only the single line on or near line 778 (//cout << "ending Damp_Restric_Adapt, damping = " <<config->GetDamp_Res_Restric() << endl;) should be removed, leaving the rest of the code unchanged.
| @@ -775,7 +775,6 @@ | ||
| // already made through global MPI reductions, so calling the setter on all | ||
| // ranks yields the same value everywhere. | ||
| config->SetDamp_Res_Restric(new_factor); | ||
| //cout << "ending Damp_Restric_Adapt, damping = " <<config->GetDamp_Res_Restric() << endl; | ||
| return new_factor; | ||
| } | ||
|
|
…ode/su2 into fix_multigrid_agglomeration
| /*--- First pass: Determine which parents will actually be used (have non-skipped children). | ||
| This prevents creating orphaned halo CVs that have coordinates (0,0,0). ---*/ | ||
| vector<bool> parent_used(Aux_Parent.size(), false); | ||
| vector<unsigned long> parent_local_index(Aux_Parent.size(), ULONG_MAX); | ||
|
|
||
| for (auto iVertex = 0ul; iVertex < nVertexR; iVertex++) { | ||
| /*--- We use the same sorting as in the donor domain, i.e. the local parents | ||
| are numbered according to their order in the remote rank. ---*/ | ||
| const auto iPoint_Fine = fine_grid->vertex[MarkerR][iVertex]->GetNode(); | ||
| auto existing_parent = fine_grid->nodes->GetParent_CV(iPoint_Fine); | ||
|
|
||
| /*--- Skip if already agglomerated (first-wins policy) ---*/ | ||
| if (existing_parent != ULONG_MAX) continue; | ||
|
|
||
| /*--- Find which parent this vertex maps to ---*/ | ||
| for (auto jVertex = 0ul; jVertex < Aux_Parent.size(); jVertex++) { | ||
| if (Parent_Remote[iVertex] == Aux_Parent[jVertex]) { |
Check notice
Code scanning / CodeQL
Commented-out code Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 9 days ago
To fix the problem, the commented-out block of code from line 976 to 990 should be completely removed. This deletion will not affect the current functionality since the code is not compiled or executed (it's within a comment block), and the only effect will be to reduce clutter and potential confusion for future maintainers. No further code, imports, or definitions are necessary elsewhere, and no changes to functionality will occur by removing this block.
-
Copy modified line R977
| @@ -973,22 +973,8 @@ | ||
|
|
||
| bool Stretching = true; | ||
|
|
||
| /* unsigned short iNode, iDim; | ||
| unsigned long jPoint; | ||
| su2double *Coord_i = fine_grid->nodes->GetCoord(iPoint); | ||
| su2double max_dist = 0.0 ; su2double min_dist = 1E20; | ||
| for (iNode = 0; iNode < fine_grid->nodes->GetnPoint(iPoint); iNode ++) { | ||
| jPoint = fine_grid->nodes->GetPoint(iPoint, iNode); | ||
| su2double *Coord_j = fine_grid->nodes->GetCoord(jPoint); | ||
| su2double distance = 0.0; | ||
| for (iDim = 0; iDim < nDim; iDim++) | ||
| distance += (Coord_j[iDim]-Coord_i[iDim])*(Coord_j[iDim]-Coord_i[iDim]); | ||
| distance = sqrt(distance); | ||
| max_dist = max(distance, max_dist); | ||
| min_dist = min(distance, min_dist); | ||
| } | ||
| if ( max_dist/min_dist > 100.0 ) Stretching = false;*/ | ||
|
|
||
|
|
||
| return (Stretching && Volume); | ||
| } | ||
|
|
| /*--- Only increment by the number of parents that will actually be used ---*/ | ||
| Index_CoarseCV += nUsedParents; | ||
|
|
||
| vector<unsigned short> nChildren_MPI(Index_CoarseCV, 0); |
Check notice
Code scanning / CodeQL
Unused local variable Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 9 days ago
To fix this unused variable, simply remove the declaration and initialization of Index_CoarseCV_Before on line 668 from the file Common/src/geometry/CMultiGridGeometry.cpp. No other code depends on this variable, and its removal does not affect any program logic or debugging behavior. No changes to methods, other imports, or additional code are needed.
| @@ -665,7 +665,6 @@ | ||
| } | ||
|
|
||
| /*--- Debug: Track state before updating Index_CoarseCV ---*/ | ||
| auto Index_CoarseCV_Before = Index_CoarseCV; | ||
|
|
||
| /*--- Only increment by the number of parents that will actually be used ---*/ | ||
| Index_CoarseCV += nUsedParents; |
| exponential progression with under-relaxation approach. */ | ||
|
|
||
| const CFLAdaptParams params = InitializeCFLAdaptParams(config); | ||
| //const bool fullComms = (config->GetComm_Level() == COMM_FULL); |
Check notice
Code scanning / CodeQL
Commented-out code Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 9 days ago
The best way to fix this issue is to either remove the commented-out code or to reinstate it if it's still required. Since there is no additional context indicating that this variable is still necessary and its removal does not change existing functionality (as it is inactive), the simplest and recommended action is to delete this line entirely from SU2_CFD/src/solvers/CSolver.cpp, line 2478. No changes to logic or dependencies are needed.
| @@ -2475,7 +2475,6 @@ | ||
| exponential progression with under-relaxation approach. */ | ||
|
|
||
| const CFLAdaptParams params = InitializeCFLAdaptParams(config); | ||
| //const bool fullComms = (config->GetComm_Level() == COMM_FULL); | ||
|
|
||
| bool reduceCFL = false; | ||
| bool resetCFL = false; |

Proposed Changes
Implement multigrid agglomeration rules according to Nishikawa et al paper:
https://www.researchgate.net/publication/267557097_Development_and_Application_of_Parallel_Agglomerated_Multigrid_Method_for_Complex_Geometries
These rules were not consistently implemented. Issues:
current features:
TO DO:
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.