Skip to content

Commit f846cbb

Browse files
committed
update agglomeration
1 parent a47c0f4 commit f846cbb

File tree

4 files changed

+55
-90
lines changed

4 files changed

+55
-90
lines changed

Common/include/geometry/CMultiGridGeometry.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@
3131

3232
/*!
3333
* \class CMultiGridGeometry
34-
* \brief Class for defining the multigrid geometry, the main delicated part is the
34+
* \brief Class for defining the multigrid geometry, the main delegated part is the
3535
* agglomeration stage, which is done in the declaration.
3636
* \author F. Palacios
3737
*/
3838
class CMultiGridGeometry final : public CGeometry {
3939
private:
4040
/*!
41-
* \brief Determine if a CVPoint van be agglomerated, if it have the same marker point as the seed.
41+
* \brief Determine if a CVPoint can be agglomerated, if it has the same marker point as the seed.
4242
* \param[in] CVPoint - Control volume to be agglomerated.
4343
* \param[in] marker_seed - Marker of the seed.
4444
* \param[in] fine_grid - Geometrical definition of the problem.
@@ -49,7 +49,7 @@ class CMultiGridGeometry final : public CGeometry {
4949
const CConfig* config) const;
5050

5151
/*!
52-
* \brief Determine if a can be agglomerated using geometrical criteria.
52+
* \brief Determine if a Point can be agglomerated using geometrical criteria.
5353
* \param[in] iPoint - Seed point.
5454
* \param[in] fine_grid - Geometrical definition of the problem.
5555
* \param[in] config - Definition of the particular problem.

Common/include/geometry/CMultiGridQueue.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class CMultiGridQueue {
9393
void IncrPriorityCV(unsigned long incrPoint);
9494

9595
/*!
96-
* \brief Increase the priority of the CV.
96+
* \brief Reduce the priority of the CV.
9797
* \param[in] redPoint - Index of the control volume.
9898
*/
9999
void RedPriorityCV(unsigned long redPoint);

Common/src/geometry/CMultiGridGeometry.cpp

Lines changed: 50 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,13 @@
3131
#include "../../../Common/include/toolboxes/geometry_toolbox.hpp"
3232

3333
CMultiGridGeometry::CMultiGridGeometry(CGeometry* fine_grid, CConfig* config, unsigned short iMesh) : CGeometry() {
34-
35-
36-
3734
nDim = fine_grid->GetnDim(); // Write the number of dimensions of the coarse grid.
3835

3936
/*--- Create a queue system to do the agglomeration
4037
1st) More than two markers ---> Vertices (never agglomerate)
4138
2nd) Two markers ---> Edges (agglomerate if same BC, never agglomerate if different BC)
42-
3rd) One marker ---> Surface (always agglomarate)
43-
4th) No marker ---> Internal Volume (always agglomarate) ---*/
39+
3rd) One marker ---> Surface (always agglomerate)
40+
4th) No marker ---> Internal Volume (always agglomerate) ---*/
4441

4542
/*--- Set a marker to indicate indirect agglomeration, for quads and hexs,
4643
i.e. consider up to neighbors of neighbors of neighbors.
@@ -100,53 +97,46 @@ CMultiGridGeometry::CMultiGridGeometry(CGeometry* fine_grid, CConfig* config, un
10097

10198
/*--- For a particular point in the fine grid we save all the markers
10299
that are in that point ---*/
103-
//short counter2 = 1;
100+
104101
for (auto jMarker = 0u; jMarker < fine_grid->GetnMarker() && counter < 3; jMarker++) {
105102
if (fine_grid->nodes->GetVertex(iPoint, jMarker) != -1) {
106103
copy_marker[counter] = jMarker;
107104
counter++;
108105

109106
if (jMarker != iMarker) {
110107
marker_seed.push_back(jMarker);
111-
//counter2++;
112108
}
113-
114109
}
115110
}
116111

117112
/*--- To agglomerate a vertex it must have only one physical bc!!
118113
This can be improved. If there is only a marker, it is a good
119114
candidate for agglomeration ---*/
120-
/*--- Valley -> Interior : never
121-
* Valley -> Valley : conditional
122-
* Valley -> Ridge : never ---*/
115+
116+
/*--- Valley -> Valley : conditionally allowed when both points are on the same marker. ---*/
117+
/*--- ! Note that in the case of MPI SEND_RECEIVE markers, we might need other conditions ---*/
123118
if (counter == 1) {
124119
agglomerate_seed = true;
125120

126121
/*--- Euler walls can be curved and agglomerating them leads to difficulties ---*/
127-
//if (config->GetMarker_All_KindBC(marker_seed[0]) == EULER_WALL) agglomerate_seed = false;
122+
//if (config->GetMarker_All_KindBC(marker_seed[0]) == EULER_WALL)
123+
// agglomerate_seed = false;
128124
}
129125

130126
/*--- If there are two markers, we will agglomerate if any of the
131127
markers is SEND_RECEIVE ---*/
132-
/*--- Ridge -> Interior : never
133-
* Ridge -> Valley : never
134-
* Ridge -> Ridge : conditional. Conditional means should be on the same marker. ---*/
128+
135129
if (counter == 2) {
136-
agglomerate_seed = ((config->GetMarker_All_KindBC(copy_marker[0]) == SEND_RECEIVE) ||
137-
(config->GetMarker_All_KindBC(copy_marker[1]) == SEND_RECEIVE)
138-
||
139-
(config->GetMarker_All_KindBC(copy_marker[0]) ==
140-
config->GetMarker_All_KindBC(copy_marker[1])) );
130+
//agglomerate_seed = (config->GetMarker_All_KindBC(copy_marker[0]) == SEND_RECEIVE) ||
131+
// (config->GetMarker_All_KindBC(copy_marker[1]) == SEND_RECEIVE);
141132

142133
/* --- Euler walls can also not be agglomerated when the point has 2 markers ---*/
143134
//if ((config->GetMarker_All_KindBC(copy_marker[0]) == EULER_WALL) ||
144135
// (config->GetMarker_All_KindBC(copy_marker[1]) == EULER_WALL)) {
145-
// agglomerate_seed = false;
136+
agglomerate_seed = true;
146137
//}
147138
}
148139

149-
/*--- Corner -> Any: never agglomerate ---*/
150140
/*--- If there are more than 2 markers, the agglomeration will be discarded ---*/
151141

152142
if (counter > 2) agglomerate_seed = false;
@@ -157,7 +147,6 @@ CMultiGridGeometry::CMultiGridGeometry(CGeometry* fine_grid, CConfig* config, un
157147
/*--- Now we do a sweep over all the nodes that surround the seed point ---*/
158148

159149
for (auto CVPoint : fine_grid->nodes->GetPoints(iPoint)) {
160-
161150
/*--- The new point can be agglomerated ---*/
162151

163152
if (SetBoundAgglomeration(CVPoint, marker_seed, fine_grid, config)) {
@@ -493,15 +482,18 @@ CMultiGridGeometry::CMultiGridGeometry(CGeometry* fine_grid, CConfig* config, un
493482
SetGlobal_nPointDomain(Global_nPointCoarse);
494483

495484
if (iMesh != MESH_0) {
496-
const su2double factor = 1.5;
485+
//const su2double factor = 1.5; //nijso: too high
486+
const su2double factor = 1.0;
497487
const su2double Coeff = pow(su2double(Global_nPointFine) / Global_nPointCoarse, 1.0 / nDim);
498488
const su2double CFL = factor * config->GetCFL(iMesh - 1) / Coeff;
499489
config->SetCFL(iMesh, CFL);
500490
}
501491

502492
const su2double ratio = su2double(Global_nPointFine) / su2double(Global_nPointCoarse);
503493

504-
if (((nDim == 2) && (ratio < 2.5)) || ((nDim == 3) && (ratio < 2.5))) {
494+
//if (((nDim == 2) && (ratio < 2.5)) || ((nDim == 3) && (ratio < 2.5))) {
495+
// nijso: too high for very small test meshes.
496+
if (((nDim == 2) && (ratio < 2.0)) || ((nDim == 3) && (ratio < 2.0))) {
505497
config->SetMGLevels(iMesh - 1);
506498
} else if (rank == MASTER_NODE) {
507499
PrintingToolbox::CTablePrinter MGTable(&std::cout);
@@ -535,11 +527,9 @@ bool CMultiGridGeometry::SetBoundAgglomeration(unsigned long CVPoint, vector<sho
535527

536528
if ((!fine_grid->nodes->GetAgglomerate(CVPoint)) && (fine_grid->nodes->GetDomain(CVPoint)) &&
537529
(GeometricalCheck(CVPoint, fine_grid, config))) {
538-
539530
/*--- If the point belongs to a boundary, its type must be compatible with the seed marker. ---*/
540531

541532
if (fine_grid->nodes->GetBoundary(CVPoint)) {
542-
543533
/*--- Identify the markers of the vertex that we want to agglomerate ---*/
544534

545535
// count number of markers on the agglomeration candidate
@@ -552,87 +542,61 @@ bool CMultiGridGeometry::SetBoundAgglomeration(unsigned long CVPoint, vector<sho
552542
}
553543
}
554544

555-
//count again the markers on the seed
556-
// for (auto jMarker = 0u; jMarker < fine_grid->GetnMarker() && counter < 3; jMarker++) {
557-
// if (fine_grid->nodes->GetVertex(iPoint, jMarker) != -1) {
558-
// copy_marker[counter] = jMarker;
559-
// counter++;
560-
// }
561-
// }
562-
563545
/*--- The basic condition is that the agglomerated vertex must have the same physical marker,
564546
but eventually a send-receive condition ---*/
565547

566548
/*--- Only one marker in the vertex that is going to be agglomerated ---*/
567-
/*--- Ridge(2) -> Valley(1) : never
568-
* Valley -> Valley(1) : conditional (should be same marker) ---*/
569-
if ((counter == 1) && (marker_seed.size() == 1)) {
549+
550+
/*--- Valley -> Valley: only if of the same type---*/
551+
if (counter == 1) {
570552
/*--- We agglomerate if there is only one marker and it is the same marker as the seed marker ---*/
571553
// note that this should be the same marker id, not just the same marker type
572-
// !!!! note that when the seed has 2 markers, we have a problem.
573-
if (copy_marker[0] == marker_seed[0]) agglomerate_CV = true;
574-
554+
if ((marker_seed.size()==1) && (copy_marker[0] == marker_seed[0])) agglomerate_CV = true;
575555

576556
/*--- If there is only one marker, but the marker is the SEND_RECEIVE ---*/
577-
// Nijso: that means the child is an mpi interface in the interior -> do NOT agglomerate unless the
578-
// marker of the seed is also SEND_RECEIVE
579-
else if (config->GetMarker_All_KindBC(copy_marker[0]) == SEND_RECEIVE) {
580-
//agglomerate_CV = true;
581-
agglomerate_CV = false;
582-
}
557+
558+
//if (config->GetMarker_All_KindBC(copy_marker[0]) == SEND_RECEIVE) {
559+
// agglomerate_CV = true;
560+
//}
583561

584562
//if ((config->GetMarker_All_KindBC(marker_seed[0]) == SYMMETRY_PLANE) ||
585563
// (config->GetMarker_All_KindBC(marker_seed[0]) == EULER_WALL)) {
586-
// if (config->GetMarker_All_KindBC(copy_marker[0]) == SEND_RECEIVE) {
587-
// agglomerate_CV = false;
588-
// }
564+
// if (config->GetMarker_All_KindBC(copy_marker[0]) == SEND_RECEIVE) {
565+
// agglomerate_CV = false;
566+
// }
589567
//}
590568
}
591569

592570
/*--- If there are two markers in the vertex that is going to be agglomerated ---*/
593-
/*--- ridge(2) -> ridge(2): conditionally allow (same marker)
594-
* ridge -> valley : never (seed has 1 marker)
595-
* ridge -> corner : never (seed has >2 marker )
596-
*---*/
597-
if ((counter == 2) && (marker_seed.size() == 2)) {
571+
/*--- Ridge -> Ridge: only if of the same type (same marker ID) ---*/
572+
if (counter == 2) {
573+
574+
// check if the seed also has 2 markers
575+
if (marker_seed.size() == 2) {
576+
// now check if the seed is on the same 2 marker ID's (note that if we allow that they are of the same
577+
// marker type, we need to check that the alignement of the markers is correct as well. better not go there.)
578+
if ( ((marker_seed[0] = copy_marker[0]) && (marker_seed[1] = copy_marker[1])) ||
579+
((marker_seed[0] = copy_marker[1]) && (marker_seed[1] = copy_marker[0])) ) {
580+
agglomerate_CV = true;
581+
}
582+
}
598583
/*--- First we verify that the seed is a physical boundary ---*/
599584

600-
if (config->GetMarker_All_KindBC(marker_seed[0]) != SEND_RECEIVE) {
585+
// if (config->GetMarker_All_KindBC(marker_seed[0]) != SEND_RECEIVE) {
586+
// /*--- Then we check that one of the markers is equal to the seed marker, and the other is send/receive ---*/
601587

602-
/*--- Then we check that one of the markers is equal to the seed marker, and the other is send/receive ---*/
603-
604-
if (((copy_marker[0] == marker_seed[0]) && (config->GetMarker_All_KindBC(copy_marker[1]) == SEND_RECEIVE)) ||
605-
((config->GetMarker_All_KindBC(copy_marker[0]) == SEND_RECEIVE) && (copy_marker[1] == marker_seed[0]))) {
606-
agglomerate_CV = true;
607-
}
608-
else
609-
/*--- check that ridges are equal on seed and on child ---*/
610-
if ((config->GetMarker_All_KindBC(copy_marker[0]) == config->GetMarker_All_KindBC(copy_marker[1]))
611-
&&
612-
(config->GetMarker_All_KindBC(marker_seed[0]) == config->GetMarker_All_KindBC(marker_seed[1]))
613-
) {
614-
cout << "ridges can be agglomerated" << endl;
615-
agglomerate_CV = true;
616-
}
617-
}
588+
// if (((copy_marker[0] == marker_seed[0]) && (config->GetMarker_All_KindBC(copy_marker[1]) == SEND_RECEIVE)) ||
589+
// ((config->GetMarker_All_KindBC(copy_marker[0]) == SEND_RECEIVE) && (copy_marker[1] == marker_seed[0]))) {
590+
agglomerate_CV = false;
591+
// agglomerate_CV = true;
592+
// }
593+
// }
618594
}
619595
}
620-
/*--- If the element belongs to the domain, it is always agglomerated. ---*/
621-
/*--- any marker -> interior : never agglomerate ---*/
596+
/*--- If the element belongs to the domain, it is never agglomerated. ---*/
597+
/*--- Any -> Interior : disallowed ---*/
622598
else {
623-
624-
// only agglomerate internal nodes with mpi nodes
625-
//if (config->GetMarker_All_KindBC(marker_seed[0]) == SEND_RECEIVE)
626-
// agglomerate_CV = true;
627-
//else
628599
agglomerate_CV = false;
629-
630-
// actually, for symmetry (and possibly other cells) we only agglomerate cells that are on the marker
631-
// at this point, the seed was on the boundary and the CV was not. so we check if the seed is a symmetry
632-
//if ((config->GetMarker_All_KindBC(marker_seed[0]) == SYMMETRY_PLANE) ||
633-
// (config->GetMarker_All_KindBC(marker_seed[0]) == EULER_WALL)) {
634-
// agglomerate_CV = false;
635-
//}
636600
}
637601
}
638602

SU2_CFD/src/solvers/CSolverFactory.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ CSolver* CSolverFactory::CreateSubSolver(SUB_SOLVER_TYPE kindSolver, CSolver **s
307307
case SUB_SOLVER_TYPE::TURB_SST:
308308
genericSolver = CreateTurbSolver(kindTurbModel, solver, geometry, config, iMGLevel, false);
309309
metaData.integrationType = INTEGRATION_TYPE::SINGLEGRID;
310+
//metaData.integrationType = INTEGRATION_TYPE::MULTIGRID;
310311
break;
311312
case SUB_SOLVER_TYPE::TEMPLATE:
312313
genericSolver = new CTemplateSolver(geometry, config);

0 commit comments

Comments
 (0)