Skip to content

Commit 1fd5e04

Browse files
Merge branch 'develop' of https://github.com/su2code/SU2 into chore_cleanup_turbo_functions
2 parents 3abcb98 + f9f7a01 commit 1fd5e04

62 files changed

Lines changed: 1921 additions & 325 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.clang-format

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ BasedOnStyle: Google
22
PointerAlignment: Left
33
DerivePointerAlignment: false
44
ColumnLimit: 120
5-
SortIncludes: Never
5+
SortIncludes: false

AUTHORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ Eduardo Molina
7171
Edwin van der Weide
7272
Ethan Alan Hereth
7373
Florian Dittmann
74+
Filip Hahs
7475
Francesco Poli
7576
Francisco D. Palacios
7677
Gaurav Bansal

Common/include/CConfig.hpp

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ class CConfig {
7171
unsigned short Kind_PerformanceAverageProcess; /*!< \brief Kind of mixing process.*/
7272
unsigned short Kind_MixingPlaneInterface; /*!< \brief Kind of mixing process.*/
7373
unsigned short Kind_SpanWise; /*!< \brief Kind of span-wise section computation.*/
74-
unsigned short *Kind_TurboMachinery; /*!< \brief Kind of turbomachynery architecture.*/
7574
unsigned short iZone, nZone; /*!< \brief Number of zones in the mesh. */
7675
unsigned short nZoneSpecified; /*!< \brief Number of zones that are specified in config file. */
7776
su2double Highlite_Area; /*!< \brief Highlite area. */
@@ -435,6 +434,9 @@ class CConfig {
435434
Max_DeltaTime, /*!< \brief Max delta time. */
436435
Unst_CFL; /*!< \brief Unsteady CFL number. */
437436

437+
TURBO_PERF_KIND *Kind_TurboPerf; /*!< \brief Kind of turbomachynery architecture.*/
438+
TURBOMACHINERY_TYPE *Kind_TurboMachinery;
439+
438440
/* Gradient smoothing options */
439441
su2double SmoothingEps1; /*!< \brief Parameter for the identity part in gradient smoothing. */
440442
su2double SmoothingEps2; /*!< \brief Parameter for the Laplace part in gradient smoothing. */
@@ -1173,6 +1175,7 @@ class CConfig {
11731175
string caseName; /*!< \brief Name of the current case */
11741176

11751177
unsigned long edgeColorGroupSize; /*!< \brief Size of the edge groups colored for OpenMP parallelization of edge loops. */
1178+
bool edgeColoringRelaxDiscAdj; /*!< \brief Allow fallback to smaller edge color group sizes and use more colors for the discrete adjoint. */
11761179

11771180
INLET_SPANWISE_INTERP Kind_InletInterpolationFunction; /*!brief type of spanwise interpolation function to use for the inlet face. */
11781181
INLET_INTERP_TYPE Kind_Inlet_InterpolationType; /*!brief type of spanwise interpolation data to use for the inlet face. */
@@ -5117,7 +5120,7 @@ class CConfig {
51175120
* \brief Get the kind of turbomachinery architecture.
51185121
* \return Kind of turbomachinery architecture.
51195122
*/
5120-
unsigned short GetKind_TurboMachinery(unsigned short val_iZone) const { return Kind_TurboMachinery[val_iZone]; }
5123+
TURBOMACHINERY_TYPE GetKind_TurboMachinery(unsigned short val_iZone) const { return Kind_TurboMachinery[val_iZone]; }
51215124

51225125
/*!
51235126
* \brief Get the kind of turbomachinery architecture.
@@ -5232,7 +5235,7 @@ class CConfig {
52325235
void SetnSpanWiseSections(unsigned short nSpan) { nSpanWiseSections = nSpan;}
52335236

52345237
/*!
5235-
* \brief set number span-wise sections to compute 3D BC and performance for turbomachinery.
5238+
* \brief get number span-wise sections to compute 3D BC and performance for turbomachinery.
52365239
*/
52375240
unsigned short GetnSpan_iZones(unsigned short iZone) const { return nSpan_iZones[iZone];}
52385241

@@ -5257,7 +5260,7 @@ class CConfig {
52575260
* \brief get marker kind for Turbomachinery performance calculation.
52585261
* \return kind index.
52595262
*/
5260-
unsigned short GetKind_TurboPerf(unsigned short index);
5263+
TURBO_PERF_KIND GetKind_TurboPerf(unsigned short val_iZone) const { return Kind_TurboPerf[val_iZone]; };
52615264

52625265
/*!
52635266
* \brief get outlet bounds name for Turbomachinery performance calculation.
@@ -5910,6 +5913,15 @@ class CConfig {
59105913
*/
59115914
su2double GetMarkerTranslationRate(unsigned short iMarkerMoving, unsigned short iDim) const { return MarkerTranslation_Rate[3*iMarkerMoving + iDim];}
59125915

5916+
/*!
5917+
* \brief Set the translation rate of the marker.
5918+
* \param[in] iDim - spatial component
5919+
* \param[in] val - translational velocity
5920+
*/
5921+
void SetMarkerTranslationRate(unsigned short iMarkerMoving, unsigned short iDim, su2double val) {
5922+
MarkerTranslation_Rate[3 * iMarkerMoving + iDim] = val;
5923+
}
5924+
59135925
/*!
59145926
* \brief Get the rotation rate of the mesh.
59155927
* \param[in] iDim - spatial component
@@ -5933,6 +5945,16 @@ class CConfig {
59335945
*/
59345946
su2double GetMarkerRotationRate(unsigned short iMarkerMoving, unsigned short iDim) const { return MarkerRotation_Rate[3*iMarkerMoving + iDim];}
59355947

5948+
/*!
5949+
* \brief Set the rotation rate of the marker.
5950+
* \param[in] iMarkerMoving - Index of the moving marker (as specified in Marker_Moving)
5951+
* \param[in] iDim - spatial component
5952+
* \param[in] val - Rotational velocity
5953+
*/
5954+
void SetMarkerRotationRate(unsigned short iMarkerMoving, unsigned short iDim, su2double val) {
5955+
MarkerRotation_Rate[3 * iMarkerMoving + iDim] = val;
5956+
}
5957+
59365958
/*!
59375959
* \brief Get the pitching rate of the mesh.
59385960
* \param[in] iDim - spatial component
@@ -9641,6 +9663,11 @@ class CConfig {
96419663
*/
96429664
unsigned long GetEdgeColoringGroupSize(void) const { return edgeColorGroupSize; }
96439665

9666+
/*!
9667+
* \brief Check if the discrete adjoint is allowed to relax the coloring, that is, allow smaller edge color group sizes and allow more colors.
9668+
*/
9669+
bool GetEdgeColoringRelaxDiscAdj() const { return edgeColoringRelaxDiscAdj; }
9670+
96449671
/*!
96459672
* \brief Get the ParMETIS load balancing tolerance.
96469673
*/

Common/include/geometry/CGeometry.hpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,15 @@ class CGeometry {
772772
*/
773773
inline virtual void GatherInOutAverageValues(CConfig* config, bool allocate) {}
774774

775+
/*!
776+
* \brief Store all the turboperformance in the solver in ZONE_0.
777+
* \param[in] donor_geometry - Solution from the donor mesh.
778+
* \param[in] target_geometry - Solution from the target mesh.
779+
* \param[in] donorZone - counter of the donor solution
780+
*/
781+
inline virtual void SetAvgTurboGeoValues(const CConfig* donor_config, CGeometry* donor_geometry,
782+
unsigned short donorZone){};
783+
775784
/*!
776785
* \brief Set max length.
777786
* \param[in] config - Definition of the particular problem.
@@ -1720,10 +1729,14 @@ class CGeometry {
17201729
/*!
17211730
* \brief Get the edge coloring.
17221731
* \note This method computes the coloring if that has not been done yet.
1732+
* \note Can be instructed to determine and use the maximum edge color group size between 1 and
1733+
* CGeometry::edgeColorGroupSize that yields a coloring that is at least as efficient as #COLORING_EFF_THRESH.
17231734
* \param[out] efficiency - optional output of the coloring efficiency.
1735+
* \param[in] maximizeEdgeColorGroupSize - use the maximum edge color group size that gives an efficient coloring.
17241736
* \return Reference to the coloring.
17251737
*/
1726-
const CCompressedSparsePatternUL& GetEdgeColoring(su2double* efficiency = nullptr);
1738+
const CCompressedSparsePatternUL& GetEdgeColoring(su2double* efficiency = nullptr,
1739+
bool maximizeEdgeColorGroupSize = false);
17271740

17281741
/*!
17291742
* \brief Force the natural (sequential) edge coloring.

Common/include/geometry/CPhysicalGeometry.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,14 @@ class CPhysicalGeometry final : public CGeometry {
408408
*/
409409
void GatherInOutAverageValues(CConfig* config, bool allocate) override;
410410

411+
/*!
412+
* \brief Store all the turboperformance in the solver in ZONE_0.
413+
* \param[in] donor_geometry - Solution from the donor mesh.
414+
* \param[in] target_geometry - Solution from the target mesh.
415+
* \param[in] donorZone - counter of the donor solution
416+
*/
417+
void SetAvgTurboGeoValues(const CConfig* donor_config, CGeometry* donor_geometry, unsigned short donorZone) override;
418+
411419
/*!
412420
* \brief Set the edge structure of the control volume.
413421
* \param[in] config - Definition of the particular problem.

Common/include/option_structure.hpp

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1780,19 +1780,33 @@ static const MapType<std::string, SPANWISE_TYPE> SpanWise_Map = {
17801780
/*!
17811781
* \brief Types of mixing process for averaging quantities at the boundaries.
17821782
*/
1783-
enum TURBOMACHINERY_TYPE {
1784-
AXIAL = 1, /*!< \brief axial turbomachinery. */
1785-
CENTRIFUGAL = 2, /*!< \brief centrifugal turbomachinery. */
1786-
CENTRIPETAL = 3, /*!< \brief centripetal turbomachinery. */
1787-
CENTRIPETAL_AXIAL = 4, /*!< \brief mixed flow turbine. */
1788-
AXIAL_CENTRIFUGAL = 5 /*!< \brief mixed flow turbine. */
1783+
enum class TURBOMACHINERY_TYPE {
1784+
AXIAL, /*!< \brief axial turbomachinery. */
1785+
CENTRIFUGAL, /*!< \brief centrifugal turbomachinery. */
1786+
CENTRIPETAL, /*!< \brief centripetal turbomachinery. */
1787+
CENTRIPETAL_AXIAL, /*!< \brief mixed flow turbine. */
1788+
AXIAL_CENTRIFUGAL /*!< \brief mixed flow turbine. */
17891789
};
17901790
static const MapType<std::string, TURBOMACHINERY_TYPE> TurboMachinery_Map = {
1791-
MakePair("AXIAL", AXIAL)
1792-
MakePair("CENTRIFUGAL", CENTRIFUGAL)
1793-
MakePair("CENTRIPETAL", CENTRIPETAL)
1794-
MakePair("CENTRIPETAL_AXIAL", CENTRIPETAL_AXIAL)
1795-
MakePair("AXIAL_CENTRIFUGAL", AXIAL_CENTRIFUGAL)
1791+
MakePair("AXIAL", TURBOMACHINERY_TYPE::AXIAL)
1792+
MakePair("CENTRIFUGAL", TURBOMACHINERY_TYPE::CENTRIFUGAL)
1793+
MakePair("CENTRIPETAL", TURBOMACHINERY_TYPE::CENTRIPETAL)
1794+
MakePair("CENTRIPETAL_AXIAL", TURBOMACHINERY_TYPE::CENTRIPETAL_AXIAL)
1795+
MakePair("AXIAL_CENTRIFUGAL", TURBOMACHINERY_TYPE::AXIAL_CENTRIFUGAL)
1796+
};
1797+
1798+
/*!
1799+
* \brief Types of Turbomachinery performance Type.
1800+
*/
1801+
enum class TURBO_PERF_KIND{
1802+
TURBINE, /*!< \brief Turbine Performance. */
1803+
COMPRESSOR, /*!< \brief Compressor Performance. */
1804+
PROPELLOR /*!< \brief Propellor Performance. */
1805+
};
1806+
static const MapType<std::string, TURBO_PERF_KIND> TurboPerfKind_Map = {
1807+
MakePair("TURBINE", TURBO_PERF_KIND::TURBINE)
1808+
MakePair("COMPRESSOR", TURBO_PERF_KIND::COMPRESSOR)
1809+
MakePair("PROPELLOR", TURBO_PERF_KIND::PROPELLOR)
17961810
};
17971811

17981812
/*!

Common/include/toolboxes/graph_toolbox.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ T createNaturalColoring(Index_t numInnerIndexes) {
484484
* \param[out] indexColor - Optional, vector with colors given to the outer indices.
485485
* \return Coloring in the same type of the input pattern.
486486
*/
487-
template <typename Color_t = char, size_t MaxColors = 64, size_t MaxMB = 128, class T>
487+
template <typename Color_t = unsigned char, size_t MaxColors = 255, size_t MaxMB = 128, class T>
488488
T colorSparsePattern(const T& pattern, size_t groupSize = 1, bool balanceColors = false,
489489
std::vector<Color_t>* indexColor = nullptr) {
490490
static_assert(std::is_integral<Color_t>::value, "");

Common/src/CConfig.cpp

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1627,6 +1627,9 @@ void CConfig::SetConfig_Options() {
16271627
/*!\brief TURBOMACHINERY_KIND \n DESCRIPTION: types of turbomachinery architecture.
16281628
\n OPTIONS: see \link TurboMachinery_Map \endlink \n Default: AXIAL */
16291629
addEnumListOption("TURBOMACHINERY_KIND",nTurboMachineryKind, Kind_TurboMachinery, TurboMachinery_Map);
1630+
/*!\brief TURBOMACHINERY_KIND \n DESCRIPTION: types of turbomachynery Performance Calculations.
1631+
\n OPTIONS: see \link TurboPerfKind_Map \endlink \n Default: TURBINE */
1632+
addEnumListOption("TURBO_PERF_KIND", nTurboMachineryKind, Kind_TurboPerf, TurboPerfKind_Map);
16301633
/*!\brief MARKER_SHROUD \n DESCRIPTION: markers in which velocity is forced to 0.0.
16311634
* \n Format: (shroud1, shroud2, ...)*/
16321635
addStringListOption("MARKER_SHROUD", nMarker_Shroud, Marker_Shroud);
@@ -2924,6 +2927,9 @@ void CConfig::SetConfig_Options() {
29242927
/* DESCRIPTION: Size of the edge groups colored for thread parallel edge loops (0 forces the reducer strategy). */
29252928
addUnsignedLongOption("EDGE_COLORING_GROUP_SIZE", edgeColorGroupSize, 512);
29262929

2930+
/* DESCRIPTION: Allow fallback to smaller edge color group sizes for the discrete adjoint and allow more colors. */
2931+
addBoolOption("EDGE_COLORING_RELAX_DISC_ADJ", edgeColoringRelaxDiscAdj, true);
2932+
29272933
/*--- options that are used for libROM ---*/
29282934
/*!\par CONFIG_CATEGORY:libROM options \ingroup Config*/
29292935

@@ -4017,6 +4023,11 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i
40174023
SU2_MPI::Error("Giles Boundary conditions can only be used with turbomachinery markers", CURRENT_FUNCTION);
40184024
}
40194025

4026+
/*--- Check if turbomachinery performance kind is specified with turbo markers ---*/
4027+
if (GetBoolTurbomachinery() && !(nTurboMachineryKind/nZone == 1)){
4028+
SU2_MPI::Error("Insufficient TURBO_PERF_KIND options specified with turbomachinery markers", CURRENT_FUNCTION);
4029+
}
4030+
40204031
/*--- Check for Boundary condition available for NICFD ---*/
40214032

40224033
if ((!ideal_gas) && (!noneq_gas)) {
@@ -6903,16 +6914,16 @@ void CConfig::SetOutput(SU2_COMPONENT val_software, unsigned short val_izone) {
69036914

69046915
default:
69056916
break;
6917+
}
69066918
}
6907-
}
6908-
else {
6909-
if (Time_Domain) {
6910-
cout << "Dynamic structural analysis."<< endl;
6911-
cout << "Time step provided by the user for the dynamic analysis(s): "<< Time_Step << "." << endl;
6912-
} else {
6913-
cout << "Static structural analysis." << endl;
6919+
else {
6920+
if (Time_Domain) {
6921+
cout << "Dynamic structural analysis."<< endl;
6922+
cout << "Time step provided by the user for the dynamic analysis(s): "<< Time_Step << "." << endl;
6923+
} else {
6924+
cout << "Static structural analysis." << endl;
6925+
}
69146926
}
6915-
}
69166927

69176928
if ((Kind_Solver == MAIN_SOLVER::EULER) || (Kind_Solver == MAIN_SOLVER::NAVIER_STOKES) || (Kind_Solver == MAIN_SOLVER::RANS) ||
69186929
(Kind_Solver == MAIN_SOLVER::INC_EULER) || (Kind_Solver == MAIN_SOLVER::INC_NAVIER_STOKES) || (Kind_Solver == MAIN_SOLVER::INC_RANS) ||

Common/src/geometry/CGeometry.cpp

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3609,7 +3609,7 @@ const su2vector<unsigned long>& CGeometry::GetTransposeSparsePatternMap(Connecti
36093609
return pattern.transposePtr();
36103610
}
36113611

3612-
const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficiency) {
3612+
const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficiency, bool maximizeEdgeColorGroupSize) {
36133613
/*--- Check for dry run mode with dummy geometry. ---*/
36143614
if (nEdge == 0) return edgeColoring;
36153615

@@ -3637,7 +3637,60 @@ const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficien
36373637

36383638
/*--- Color the edges. ---*/
36393639
constexpr bool balanceColors = true;
3640-
edgeColoring = colorSparsePattern(pattern, edgeColorGroupSize, balanceColors);
3640+
3641+
/*--- If requested, find an efficient coloring with maximum color group size (up to edgeColorGroupSize). ---*/
3642+
if (maximizeEdgeColorGroupSize) {
3643+
auto upperEdgeColorGroupSize = edgeColorGroupSize + 1; /* upper bound that is deemed too large */
3644+
auto nextEdgeColorGroupSize = edgeColorGroupSize; /* next value that we are going to try */
3645+
auto lowerEdgeColorGroupSize = 1ul; /* lower bound that is known to work */
3646+
3647+
bool admissibleColoring = false; /* keep track wether the last tested coloring is admissible */
3648+
3649+
while (true) {
3650+
edgeColoring = colorSparsePattern(pattern, nextEdgeColorGroupSize, balanceColors);
3651+
3652+
/*--- If the coloring fails, reduce the color group size. ---*/
3653+
if (edgeColoring.empty()) {
3654+
upperEdgeColorGroupSize = nextEdgeColorGroupSize;
3655+
admissibleColoring = false;
3656+
}
3657+
/*--- If the coloring succeeds, check the efficiency. ---*/
3658+
else {
3659+
const su2double currentEfficiency =
3660+
coloringEfficiency(edgeColoring, omp_get_max_threads(), nextEdgeColorGroupSize);
3661+
3662+
/*--- If the coloring is not efficient, reduce the color group size. ---*/
3663+
if (currentEfficiency < COLORING_EFF_THRESH) {
3664+
upperEdgeColorGroupSize = nextEdgeColorGroupSize;
3665+
admissibleColoring = false;
3666+
}
3667+
/*--- Otherwise, enlarge the color group size. ---*/
3668+
else {
3669+
lowerEdgeColorGroupSize = nextEdgeColorGroupSize;
3670+
admissibleColoring = true;
3671+
}
3672+
}
3673+
3674+
const auto increment = (upperEdgeColorGroupSize - lowerEdgeColorGroupSize) / 2;
3675+
nextEdgeColorGroupSize = lowerEdgeColorGroupSize + increment;
3676+
3677+
/*--- Terminating condition. ---*/
3678+
if (increment == 0) {
3679+
break;
3680+
}
3681+
}
3682+
3683+
edgeColorGroupSize = nextEdgeColorGroupSize;
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 {
3692+
edgeColoring = colorSparsePattern(pattern, edgeColorGroupSize, balanceColors);
3693+
}
36413694

36423695
/*--- If the coloring fails use the natural coloring. This is a
36433696
* "soft" failure as this "bad" coloring should be detected

0 commit comments

Comments
 (0)