Skip to content

Commit aec3aab

Browse files
committed
Avoid recomputation if last coloring was admissible.
1 parent 84354e3 commit aec3aab

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

Common/src/geometry/CGeometry.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3644,12 +3644,15 @@ const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficien
36443644
auto nextEdgeColorGroupSize = edgeColorGroupSize; /* next value that we are going to try */
36453645
auto lowerEdgeColorGroupSize = 1ul; /* lower bound that is known to work */
36463646

3647+
bool admissibleColoring = false; /* keep track wether the last tested coloring is admissible */
3648+
36473649
while (true) {
36483650
edgeColoring = colorSparsePattern(pattern, nextEdgeColorGroupSize, balanceColors);
36493651

36503652
/*--- If the coloring fails, reduce the color group size. ---*/
36513653
if (edgeColoring.empty()) {
36523654
upperEdgeColorGroupSize = nextEdgeColorGroupSize;
3655+
admissibleColoring = false;
36533656
}
36543657
/*--- If the coloring succeeds, check the efficiency. ---*/
36553658
else {
@@ -3659,10 +3662,12 @@ const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficien
36593662
/*--- If the coloring is not efficient, reduce the color group size. ---*/
36603663
if (currentEfficiency < COLORING_EFF_THRESH) {
36613664
upperEdgeColorGroupSize = nextEdgeColorGroupSize;
3665+
admissibleColoring = false;
36623666
}
36633667
/*--- Otherwise, enlarge the color group size. ---*/
36643668
else {
36653669
lowerEdgeColorGroupSize = nextEdgeColorGroupSize;
3670+
admissibleColoring = true;
36663671
}
36673672
}
36683673

@@ -3676,7 +3681,14 @@ const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficien
36763681
}
36773682

36783683
edgeColorGroupSize = nextEdgeColorGroupSize;
3679-
} else {
3684+
3685+
/*--- If the last tested coloring was not admissible, recompute the final coloring. ---*/
3686+
if (!admissibleColoring) {
3687+
edgeColoring = colorSparsePattern(pattern, edgeColorGroupSize, balanceColors);
3688+
}
3689+
}
3690+
/*--- No adaptivity. ---*/
3691+
else {
36803692
edgeColoring = colorSparsePattern(pattern, edgeColorGroupSize, balanceColors);
36813693
}
36823694

0 commit comments

Comments
 (0)