Skip to content

Commit

Permalink
Merge branch 'develop' into add_parallel_regions
Browse files Browse the repository at this point in the history
  • Loading branch information
jblueh committed Feb 13, 2024
2 parents 9339f0b + f9f7a01 commit beeda76
Show file tree
Hide file tree
Showing 75 changed files with 7,063 additions and 1,256 deletions.
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ BasedOnStyle: Google
PointerAlignment: Left
DerivePointerAlignment: false
ColumnLimit: 120
SortIncludes: Never
SortIncludes: false
1 change: 1 addition & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ Eduardo Molina
Edwin van der Weide
Ethan Alan Hereth
Florian Dittmann
Filip Hahs
Francesco Poli
Francisco D. Palacios
Gaurav Bansal
Expand Down
35 changes: 31 additions & 4 deletions Common/include/CConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ class CConfig {
unsigned short Kind_PerformanceAverageProcess; /*!< \brief Kind of mixing process.*/
unsigned short Kind_MixingPlaneInterface; /*!< \brief Kind of mixing process.*/
unsigned short Kind_SpanWise; /*!< \brief Kind of span-wise section computation.*/
unsigned short *Kind_TurboMachinery; /*!< \brief Kind of turbomachynery architecture.*/
unsigned short iZone, nZone; /*!< \brief Number of zones in the mesh. */
unsigned short nZoneSpecified; /*!< \brief Number of zones that are specified in config file. */
su2double Highlite_Area; /*!< \brief Highlite area. */
Expand Down Expand Up @@ -435,6 +434,9 @@ class CConfig {
Max_DeltaTime, /*!< \brief Max delta time. */
Unst_CFL; /*!< \brief Unsteady CFL number. */

TURBO_PERF_KIND *Kind_TurboPerf; /*!< \brief Kind of turbomachynery architecture.*/
TURBOMACHINERY_TYPE *Kind_TurboMachinery;

/* Gradient smoothing options */
su2double SmoothingEps1; /*!< \brief Parameter for the identity part in gradient smoothing. */
su2double SmoothingEps2; /*!< \brief Parameter for the Laplace part in gradient smoothing. */
Expand Down Expand Up @@ -1173,6 +1175,7 @@ class CConfig {
string caseName; /*!< \brief Name of the current case */

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

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

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

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

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

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

/*!
* \brief Set the translation rate of the marker.
* \param[in] iDim - spatial component
* \param[in] val - translational velocity
*/
void SetMarkerTranslationRate(unsigned short iMarkerMoving, unsigned short iDim, su2double val) {
MarkerTranslation_Rate[3 * iMarkerMoving + iDim] = val;
}

/*!
* \brief Get the rotation rate of the mesh.
* \param[in] iDim - spatial component
Expand All @@ -5933,6 +5945,16 @@ class CConfig {
*/
su2double GetMarkerRotationRate(unsigned short iMarkerMoving, unsigned short iDim) const { return MarkerRotation_Rate[3*iMarkerMoving + iDim];}

/*!
* \brief Set the rotation rate of the marker.
* \param[in] iMarkerMoving - Index of the moving marker (as specified in Marker_Moving)
* \param[in] iDim - spatial component
* \param[in] val - Rotational velocity
*/
void SetMarkerRotationRate(unsigned short iMarkerMoving, unsigned short iDim, su2double val) {
MarkerRotation_Rate[3 * iMarkerMoving + iDim] = val;
}

/*!
* \brief Get the pitching rate of the mesh.
* \param[in] iDim - spatial component
Expand Down Expand Up @@ -9641,6 +9663,11 @@ class CConfig {
*/
unsigned long GetEdgeColoringGroupSize(void) const { return edgeColorGroupSize; }

/*!
* \brief Check if the discrete adjoint is allowed to relax the coloring, that is, allow smaller edge color group sizes and allow more colors.
*/
bool GetEdgeColoringRelaxDiscAdj() const { return edgeColoringRelaxDiscAdj; }

/*!
* \brief Get the ParMETIS load balancing tolerance.
*/
Expand Down
15 changes: 14 additions & 1 deletion Common/include/geometry/CGeometry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,15 @@ class CGeometry {
*/
inline virtual void GatherInOutAverageValues(CConfig* config, bool allocate) {}

/*!
* \brief Store all the turboperformance in the solver in ZONE_0.
* \param[in] donor_geometry - Solution from the donor mesh.
* \param[in] target_geometry - Solution from the target mesh.
* \param[in] donorZone - counter of the donor solution
*/
inline virtual void SetAvgTurboGeoValues(const CConfig* donor_config, CGeometry* donor_geometry,
unsigned short donorZone){};

/*!
* \brief Set max length.
* \param[in] config - Definition of the particular problem.
Expand Down Expand Up @@ -1720,10 +1729,14 @@ class CGeometry {
/*!
* \brief Get the edge coloring.
* \note This method computes the coloring if that has not been done yet.
* \note Can be instructed to determine and use the maximum edge color group size between 1 and
* CGeometry::edgeColorGroupSize that yields a coloring that is at least as efficient as #COLORING_EFF_THRESH.
* \param[out] efficiency - optional output of the coloring efficiency.
* \param[in] maximizeEdgeColorGroupSize - use the maximum edge color group size that gives an efficient coloring.
* \return Reference to the coloring.
*/
const CCompressedSparsePatternUL& GetEdgeColoring(su2double* efficiency = nullptr);
const CCompressedSparsePatternUL& GetEdgeColoring(su2double* efficiency = nullptr,
bool maximizeEdgeColorGroupSize = false);

/*!
* \brief Force the natural (sequential) edge coloring.
Expand Down
8 changes: 8 additions & 0 deletions Common/include/geometry/CPhysicalGeometry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,14 @@ class CPhysicalGeometry final : public CGeometry {
*/
void GatherInOutAverageValues(CConfig* config, bool allocate) override;

/*!
* \brief Store all the turboperformance in the solver in ZONE_0.
* \param[in] donor_geometry - Solution from the donor mesh.
* \param[in] target_geometry - Solution from the target mesh.
* \param[in] donorZone - counter of the donor solution
*/
void SetAvgTurboGeoValues(const CConfig* donor_config, CGeometry* donor_geometry, unsigned short donorZone) override;

/*!
* \brief Set the edge structure of the control volume.
* \param[in] config - Definition of the particular problem.
Expand Down
36 changes: 25 additions & 11 deletions Common/include/option_structure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1780,19 +1780,33 @@ static const MapType<std::string, SPANWISE_TYPE> SpanWise_Map = {
/*!
* \brief Types of mixing process for averaging quantities at the boundaries.
*/
enum TURBOMACHINERY_TYPE {
AXIAL = 1, /*!< \brief axial turbomachinery. */
CENTRIFUGAL = 2, /*!< \brief centrifugal turbomachinery. */
CENTRIPETAL = 3, /*!< \brief centripetal turbomachinery. */
CENTRIPETAL_AXIAL = 4, /*!< \brief mixed flow turbine. */
AXIAL_CENTRIFUGAL = 5 /*!< \brief mixed flow turbine. */
enum class TURBOMACHINERY_TYPE {
AXIAL, /*!< \brief axial turbomachinery. */
CENTRIFUGAL, /*!< \brief centrifugal turbomachinery. */
CENTRIPETAL, /*!< \brief centripetal turbomachinery. */
CENTRIPETAL_AXIAL, /*!< \brief mixed flow turbine. */
AXIAL_CENTRIFUGAL /*!< \brief mixed flow turbine. */
};
static const MapType<std::string, TURBOMACHINERY_TYPE> TurboMachinery_Map = {
MakePair("AXIAL", AXIAL)
MakePair("CENTRIFUGAL", CENTRIFUGAL)
MakePair("CENTRIPETAL", CENTRIPETAL)
MakePair("CENTRIPETAL_AXIAL", CENTRIPETAL_AXIAL)
MakePair("AXIAL_CENTRIFUGAL", AXIAL_CENTRIFUGAL)
MakePair("AXIAL", TURBOMACHINERY_TYPE::AXIAL)
MakePair("CENTRIFUGAL", TURBOMACHINERY_TYPE::CENTRIFUGAL)
MakePair("CENTRIPETAL", TURBOMACHINERY_TYPE::CENTRIPETAL)
MakePair("CENTRIPETAL_AXIAL", TURBOMACHINERY_TYPE::CENTRIPETAL_AXIAL)
MakePair("AXIAL_CENTRIFUGAL", TURBOMACHINERY_TYPE::AXIAL_CENTRIFUGAL)
};

/*!
* \brief Types of Turbomachinery performance Type.
*/
enum class TURBO_PERF_KIND{
TURBINE, /*!< \brief Turbine Performance. */
COMPRESSOR, /*!< \brief Compressor Performance. */
PROPELLOR /*!< \brief Propellor Performance. */
};
static const MapType<std::string, TURBO_PERF_KIND> TurboPerfKind_Map = {
MakePair("TURBINE", TURBO_PERF_KIND::TURBINE)
MakePair("COMPRESSOR", TURBO_PERF_KIND::COMPRESSOR)
MakePair("PROPELLOR", TURBO_PERF_KIND::PROPELLOR)
};

/*!
Expand Down
2 changes: 1 addition & 1 deletion Common/include/toolboxes/graph_toolbox.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ T createNaturalColoring(Index_t numInnerIndexes) {
* \param[out] indexColor - Optional, vector with colors given to the outer indices.
* \return Coloring in the same type of the input pattern.
*/
template <typename Color_t = char, size_t MaxColors = 64, size_t MaxMB = 128, class T>
template <typename Color_t = unsigned char, size_t MaxColors = 255, size_t MaxMB = 128, class T>
T colorSparsePattern(const T& pattern, size_t groupSize = 1, bool balanceColors = false,
std::vector<Color_t>* indexColor = nullptr) {
static_assert(std::is_integral<Color_t>::value, "");
Expand Down
27 changes: 19 additions & 8 deletions Common/src/CConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1627,6 +1627,9 @@ void CConfig::SetConfig_Options() {
/*!\brief TURBOMACHINERY_KIND \n DESCRIPTION: types of turbomachinery architecture.
\n OPTIONS: see \link TurboMachinery_Map \endlink \n Default: AXIAL */
addEnumListOption("TURBOMACHINERY_KIND",nTurboMachineryKind, Kind_TurboMachinery, TurboMachinery_Map);
/*!\brief TURBOMACHINERY_KIND \n DESCRIPTION: types of turbomachynery Performance Calculations.
\n OPTIONS: see \link TurboPerfKind_Map \endlink \n Default: TURBINE */
addEnumListOption("TURBO_PERF_KIND", nTurboMachineryKind, Kind_TurboPerf, TurboPerfKind_Map);
/*!\brief MARKER_SHROUD \n DESCRIPTION: markers in which velocity is forced to 0.0.
* \n Format: (shroud1, shroud2, ...)*/
addStringListOption("MARKER_SHROUD", nMarker_Shroud, Marker_Shroud);
Expand Down Expand Up @@ -2924,6 +2927,9 @@ void CConfig::SetConfig_Options() {
/* DESCRIPTION: Size of the edge groups colored for thread parallel edge loops (0 forces the reducer strategy). */
addUnsignedLongOption("EDGE_COLORING_GROUP_SIZE", edgeColorGroupSize, 512);

/* DESCRIPTION: Allow fallback to smaller edge color group sizes for the discrete adjoint and allow more colors. */
addBoolOption("EDGE_COLORING_RELAX_DISC_ADJ", edgeColoringRelaxDiscAdj, true);

/*--- options that are used for libROM ---*/
/*!\par CONFIG_CATEGORY:libROM options \ingroup Config*/

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

/*--- Check if turbomachinery performance kind is specified with turbo markers ---*/
if (GetBoolTurbomachinery() && !(nTurboMachineryKind/nZone == 1)){
SU2_MPI::Error("Insufficient TURBO_PERF_KIND options specified with turbomachinery markers", CURRENT_FUNCTION);
}

/*--- Check for Boundary condition available for NICFD ---*/

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

default:
break;
}
}
}
else {
if (Time_Domain) {
cout << "Dynamic structural analysis."<< endl;
cout << "Time step provided by the user for the dynamic analysis(s): "<< Time_Step << "." << endl;
} else {
cout << "Static structural analysis." << endl;
else {
if (Time_Domain) {
cout << "Dynamic structural analysis."<< endl;
cout << "Time step provided by the user for the dynamic analysis(s): "<< Time_Step << "." << endl;
} else {
cout << "Static structural analysis." << endl;
}
}
}

if ((Kind_Solver == MAIN_SOLVER::EULER) || (Kind_Solver == MAIN_SOLVER::NAVIER_STOKES) || (Kind_Solver == MAIN_SOLVER::RANS) ||
(Kind_Solver == MAIN_SOLVER::INC_EULER) || (Kind_Solver == MAIN_SOLVER::INC_NAVIER_STOKES) || (Kind_Solver == MAIN_SOLVER::INC_RANS) ||
Expand Down
57 changes: 55 additions & 2 deletions Common/src/geometry/CGeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3609,7 +3609,7 @@ const su2vector<unsigned long>& CGeometry::GetTransposeSparsePatternMap(Connecti
return pattern.transposePtr();
}

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

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

/*--- Color the edges. ---*/
constexpr bool balanceColors = true;
edgeColoring = colorSparsePattern(pattern, edgeColorGroupSize, balanceColors);

/*--- If requested, find an efficient coloring with maximum color group size (up to edgeColorGroupSize). ---*/
if (maximizeEdgeColorGroupSize) {
auto upperEdgeColorGroupSize = edgeColorGroupSize + 1; /* upper bound that is deemed too large */
auto nextEdgeColorGroupSize = edgeColorGroupSize; /* next value that we are going to try */
auto lowerEdgeColorGroupSize = 1ul; /* lower bound that is known to work */

bool admissibleColoring = false; /* keep track wether the last tested coloring is admissible */

while (true) {
edgeColoring = colorSparsePattern(pattern, nextEdgeColorGroupSize, balanceColors);

/*--- If the coloring fails, reduce the color group size. ---*/
if (edgeColoring.empty()) {
upperEdgeColorGroupSize = nextEdgeColorGroupSize;
admissibleColoring = false;
}
/*--- If the coloring succeeds, check the efficiency. ---*/
else {
const su2double currentEfficiency =
coloringEfficiency(edgeColoring, omp_get_max_threads(), nextEdgeColorGroupSize);

/*--- If the coloring is not efficient, reduce the color group size. ---*/
if (currentEfficiency < COLORING_EFF_THRESH) {
upperEdgeColorGroupSize = nextEdgeColorGroupSize;
admissibleColoring = false;
}
/*--- Otherwise, enlarge the color group size. ---*/
else {
lowerEdgeColorGroupSize = nextEdgeColorGroupSize;
admissibleColoring = true;
}
}

const auto increment = (upperEdgeColorGroupSize - lowerEdgeColorGroupSize) / 2;
nextEdgeColorGroupSize = lowerEdgeColorGroupSize + increment;

/*--- Terminating condition. ---*/
if (increment == 0) {
break;
}
}

edgeColorGroupSize = nextEdgeColorGroupSize;

/*--- If the last tested coloring was not admissible, recompute the final coloring. ---*/
if (!admissibleColoring) {
edgeColoring = colorSparsePattern(pattern, edgeColorGroupSize, balanceColors);
}
}
/*--- No adaptivity. ---*/
else {
edgeColoring = colorSparsePattern(pattern, edgeColorGroupSize, balanceColors);
}

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

0 comments on commit beeda76

Please sign in to comment.