Skip to content

Commit

Permalink
Merge pull request #1646 from su2code/sa_options
Browse files Browse the repository at this point in the history
New SA version/correction combinations and new way of specifying them in the config (SA_OPTIONS=...)
  • Loading branch information
pcarruscag authored May 27, 2022
2 parents 0e7844e + 3fa7b8a commit ead83fe
Show file tree
Hide file tree
Showing 27 changed files with 383 additions and 344 deletions.
25 changes: 14 additions & 11 deletions Common/include/CConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -699,10 +699,12 @@ class CConfig {
*Marker_WallFunctions, /*!< \brief Markers for which wall functions must be applied. */
*Marker_SobolevBC; /*!< \brief Markers in the gradient solver */

unsigned short nConfig_Files; /*!< \brief Number of config files for multiphysics problems. */
string *Config_Filenames; /*!< \brief List of names for configuration files. */
SST_OPTIONS *SST_Options; /*!< \brief List of modifications/corrections/versions of SST turbulence model.*/
unsigned short nSST_Options; /*!< \brief number of SST options specified. */
unsigned short nConfig_Files; /*!< \brief Number of config files for multiphysics problems. */
string *Config_Filenames; /*!< \brief List of names for configuration files. */
SST_OPTIONS *SST_Options; /*!< \brief List of modifications/corrections/versions of SST turbulence model.*/
SA_OPTIONS *SA_Options; /*!< \brief List of modifications/corrections/versions of SA turbulence model.*/
unsigned short nSST_Options; /*!< \brief Number of SST options specified. */
unsigned short nSA_Options; /*!< \brief Number of SA options specified. */
WALL_FUNCTIONS *Kind_WallFunctions; /*!< \brief The kind of wall function to use for the corresponding markers. */
unsigned short **IntInfo_WallFunctions; /*!< \brief Additional integer information for the wall function markers. */
su2double **DoubleInfo_WallFunctions; /*!< \brief Additional double information for the wall function markers. */
Expand Down Expand Up @@ -1015,7 +1017,6 @@ class CConfig {
WINDOW_FUNCTION Kind_WindowFct; /*!< \brief Type of window (weight) function for objective functional. */
unsigned short Kind_HybridRANSLES; /*!< \brief Kind of Hybrid RANS/LES. */
unsigned short Kind_RoeLowDiss; /*!< \brief Kind of Roe scheme with low dissipation for unsteady flows. */
bool QCR; /*!< \brief Spalart-Allmaras with Quadratic Constitutive Relation, 2000 version (SA-QCR2000) . */

unsigned short nSpanWiseSections; /*!< \brief number of span-wise sections */
unsigned short nSpanMaxAllZones; /*!< \brief number of maximum span-wise sections for all zones */
Expand Down Expand Up @@ -1137,7 +1138,8 @@ class CConfig {
unsigned short nScreenOutput, /*!< \brief Number of screen output variables (max: 6). */
nHistoryOutput, nVolumeOutput; /*!< \brief Number of variables printed to the history file. */
bool Multizone_Residual; /*!< \brief Determines if memory should be allocated for the multizone residual. */
SST_ParsedOptions sstParsedOptions; /*!< \brief additional parameters for the SST turbulence model */
SST_ParsedOptions sstParsedOptions; /*!< \brief Additional parameters for the SST turbulence model. */
SA_ParsedOptions saParsedOptions; /*!< \brief Additional parameters for the SA turbulence model. */
su2double uq_delta_b; /*!< \brief Parameter used to perturb eigenvalues of Reynolds Stress Matrix */
unsigned short eig_val_comp; /*!< \brief Parameter used to determine type of eigenvalue perturbation */
su2double uq_urlx; /*!< \brief Under-relaxation factor */
Expand Down Expand Up @@ -9058,11 +9060,6 @@ class CConfig {
*/
su2double GetConst_DES(void) const { return Const_DES; }

/*!
* \brief Get QCR (SA-QCR2000).
*/
bool GetQCR(void) const { return QCR;}

/*!
* \brief Get if AD preaccumulation should be performed.
*/
Expand Down Expand Up @@ -9629,4 +9626,10 @@ class CConfig {
*/
SST_ParsedOptions GetSSTParsedOptions() const { return sstParsedOptions; }

/*!
* \brief Get parsed SA option data structure.
* \return SA option data structure.
*/
SA_ParsedOptions GetSAParsedOptions() const { return saParsedOptions; }

};
114 changes: 100 additions & 14 deletions Common/include/option_structure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -912,19 +912,11 @@ static const MapType<std::string, LIMITER> Limiter_Map = {
enum class TURB_MODEL {
NONE, /*!< \brief No turbulence model. */
SA, /*!< \brief Kind of Turbulent model (Spalart-Allmaras). */
SA_NEG, /*!< \brief Kind of Turbulent model (Negative Spalart-Allmaras). */
SA_E, /*!< \brief Kind of Turbulent model (Spalart-Allmaras Edwards). */
SA_COMP, /*!< \brief Kind of Turbulent model (Spalart-Allmaras Compressibility Correction). */
SA_E_COMP, /*!< \brief Kind of Turbulent model (Spalart-Allmaras Edwards with Compressibility Correction). */
SST, /*!< \brief Kind of Turbulence model (Menter SST). */
};
static const MapType<std::string, TURB_MODEL> Turb_Model_Map = {
MakePair("NONE", TURB_MODEL::NONE)
MakePair("SA", TURB_MODEL::SA)
MakePair("SA_NEG", TURB_MODEL::SA_NEG)
MakePair("SA_E", TURB_MODEL::SA_E)
MakePair("SA_COMP", TURB_MODEL::SA_COMP)
MakePair("SA_E_COMP", TURB_MODEL::SA_E_COMP)
MakePair("SST", TURB_MODEL::SST)
};

Expand All @@ -944,10 +936,6 @@ inline TURB_FAMILY TurbModelFamily(TURB_MODEL model) {
case TURB_MODEL::NONE:
return TURB_FAMILY::NONE;
case TURB_MODEL::SA:
case TURB_MODEL::SA_NEG:
case TURB_MODEL::SA_E:
case TURB_MODEL::SA_COMP:
case TURB_MODEL::SA_E_COMP:
return TURB_FAMILY::SA;
case TURB_MODEL::SST:
return TURB_FAMILY::KW;
Expand Down Expand Up @@ -998,6 +986,7 @@ struct SST_ParsedOptions {
* \param[in] SST_Options - Selected SST option from config.
* \param[in] nSST_Options - Number of options selected.
* \param[in] rank - MPI rank.
* \return Struct with SST options.
*/
inline SST_ParsedOptions ParseSSTOptions(const SST_OPTIONS *SST_Options, unsigned short nSST_Options, int rank) {
SST_ParsedOptions SSTParsedOptions;
Expand Down Expand Up @@ -1056,18 +1045,115 @@ inline SST_ParsedOptions ParseSSTOptions(const SST_OPTIONS *SST_Options, unsigne
return SSTParsedOptions;
}

/*!
* \brief SA Options
*/
enum class SA_OPTIONS {
NONE, /*!< \brief No option / default. */
NEG, /*!< \brief Negative SA. */
EDW, /*!< \brief Edwards version. */
FT2, /*!< \brief Use FT2 term. */
QCR2000, /*!< \brief Quadratic constitutive relation. */
COMP, /*!< \brief Compressibility correction. */
ROT, /*!< \brief Rotation correction. */
BC, /*!< \brief Bas-Cakmakcioclu transition. */
EXP, /*!< \brief Allow experimental combinations of options (according to TMR). */
};
static const MapType<std::string, SA_OPTIONS> SA_Options_Map = {
MakePair("NONE", SA_OPTIONS::NONE)
MakePair("NEGATIVE", SA_OPTIONS::NEG)
MakePair("EDWARDS", SA_OPTIONS::EDW)
MakePair("WITHFT2", SA_OPTIONS::FT2)
MakePair("QCR2000", SA_OPTIONS::QCR2000)
MakePair("COMPRESSIBILITY", SA_OPTIONS::COMP)
MakePair("ROTATION", SA_OPTIONS::ROT)
MakePair("BCM", SA_OPTIONS::BC)
MakePair("EXPERIMENTAL", SA_OPTIONS::EXP)
};

/*!
* \brief Structure containing parsed SA options.
*/
struct SA_ParsedOptions {
SA_OPTIONS version = SA_OPTIONS::NONE; /*!< \brief SA base model. */
bool ft2 = false; /*!< \brief Use ft2 term. */
bool qcr2000 = false; /*!< \brief Use QCR-2000. */
bool comp = false; /*!< \brief Use compressibility correction. */
bool rot = false; /*!< \brief Use rotation correction. */
bool bc = false; /*!< \brief BC transition. */
};

/*!
* \brief Function to parse SA options.
* \param[in] SA_Options - Selected SA option from config.
* \param[in] nSA_Options - Number of options selected.
* \param[in] rank - MPI rank.
* \return Struct with SA options.
*/
inline SA_ParsedOptions ParseSAOptions(const SA_OPTIONS *SA_Options, unsigned short nSA_Options, int rank) {
SA_ParsedOptions SAParsedOptions;

auto IsPresent = [&](SA_OPTIONS option) {
const auto sa_options_end = SA_Options + nSA_Options;
return std::find(SA_Options, sa_options_end, option) != sa_options_end;
};

const bool found_neg = IsPresent(SA_OPTIONS::NEG);
const bool found_edw = IsPresent(SA_OPTIONS::EDW);
const bool found_bsl = !found_neg && !found_edw;

if (found_neg && found_edw) {
SU2_MPI::Error("Two versions (Negative and Edwards) selected for SA_OPTIONS. Please choose only one.", CURRENT_FUNCTION);
}

if (found_bsl) {
SAParsedOptions.version = SA_OPTIONS::NONE;
} else if (found_neg) {
SAParsedOptions.version = SA_OPTIONS::NEG;
} else {
SAParsedOptions.version = SA_OPTIONS::EDW;
}
SAParsedOptions.ft2 = IsPresent(SA_OPTIONS::FT2);
SAParsedOptions.qcr2000 = IsPresent(SA_OPTIONS::QCR2000);
SAParsedOptions.comp = IsPresent(SA_OPTIONS::COMP);
SAParsedOptions.rot = IsPresent(SA_OPTIONS::ROT);
SAParsedOptions.bc = IsPresent(SA_OPTIONS::BC);

/*--- Validate user settings when not in experimental mode. ---*/
if (!IsPresent(SA_OPTIONS::EXP)) {
const bool any_but_bc = SAParsedOptions.ft2 || SAParsedOptions.qcr2000 || SAParsedOptions.comp || SAParsedOptions.rot;

switch (SAParsedOptions.version) {
case SA_OPTIONS::NEG:
if (!SAParsedOptions.ft2 || SAParsedOptions.bc)
SU2_MPI::Error("A non-standard version of SA-neg was requested (see https://turbmodels.larc.nasa.gov/spalart.html).\n"
"If you want to continue, add EXPERIMENTAL to SA_OPTIONS.", CURRENT_FUNCTION);
break;
case SA_OPTIONS::EDW:
if (any_but_bc || SAParsedOptions.bc)
SU2_MPI::Error("A non-standard version of SA-noft2-Edwards was requested (see https://turbmodels.larc.nasa.gov/spalart.html).\n"
"If you want to continue, add EXPERIMENTAL to SA_OPTIONS.", CURRENT_FUNCTION);
break;
default:
if (SAParsedOptions.bc && any_but_bc)
SU2_MPI::Error("A non-standard version of SA-BCM was requested (see https://turbmodels.larc.nasa.gov/spalart.html).\n"
"If you want to continue, add EXPERIMENTAL to SA_OPTIONS.", CURRENT_FUNCTION);
break;
}
}
return SAParsedOptions;
}

/*!
* \brief Types of transition models
*/
enum class TURB_TRANS_MODEL {
NONE, /*!< \brief No transition model. */
LM, /*!< \brief Kind of transition model (Langtry-Menter (LM) for SST and Spalart-Allmaras). */
BC /*!< \brief Kind of transition model (BAS-CAKMAKCIOGLU (BC) for Spalart-Allmaras). */
};
static const MapType<std::string, TURB_TRANS_MODEL> Trans_Model_Map = {
MakePair("NONE", TURB_TRANS_MODEL::NONE)
MakePair("LM", TURB_TRANS_MODEL::LM)
MakePair("BC", TURB_TRANS_MODEL::BC)
};

/*!
Expand Down
64 changes: 44 additions & 20 deletions Common/src/CConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1091,6 +1091,8 @@ void CConfig::SetConfig_Options() {
addEnumOption("KIND_TURB_MODEL", Kind_Turb_Model, Turb_Model_Map, TURB_MODEL::NONE);
/*!\brief SST_OPTIONS \n DESCRIPTION: Specify SST turbulence model options/corrections. \n Options: see \link SST_Options_Map \endlink \n DEFAULT: NONE \ingroup Config*/
addEnumListOption("SST_OPTIONS", nSST_Options, SST_Options, SST_Options_Map);
/*!\brief SST_OPTIONS \n DESCRIPTION: Specify SA turbulence model options/corrections. \n Options: see \link SA_Options_Map \endlink \n DEFAULT: NONE \ingroup Config*/
addEnumListOption("SA_OPTIONS", nSA_Options, SA_Options, SA_Options_Map);

/*!\brief KIND_TRANS_MODEL \n DESCRIPTION: Specify transition model OPTIONS: see \link Trans_Model_Map \endlink \n DEFAULT: NONE \ingroup Config*/
addEnumOption("KIND_TRANS_MODEL", Kind_Trans_Model, Trans_Model_Map, TURB_TRANS_MODEL::NONE);
Expand Down Expand Up @@ -2767,9 +2769,6 @@ void CConfig::SetConfig_Options() {
/* DESCRIPTION: Roe with low dissipation for unsteady flows */
addEnumOption("ROE_LOW_DISSIPATION", Kind_RoeLowDiss, RoeLowDiss_Map, NO_ROELOWDISS);

/* DESCRIPTION: Activate SA Quadratic Constitutive Relation, 2000 version */
addBoolOption("SA_QCR", QCR, false);

/* DESCRIPTION: Compute Average for unsteady simulations */
addBoolOption("COMPUTE_AVERAGE", Compute_Average, false);

Expand Down Expand Up @@ -2996,6 +2995,8 @@ void CConfig::SetConfig_Parsing(istream& config_buffer){
newString.append("SOLID_DENSITY is deprecated. Use MATERIAL_DENSITY instead.\n\n");
else if (!option_name.compare("SOLID_TEMPERATURE_INIT"))
newString.append("SOLID_TEMPERATURE_INIT is deprecated. Use FREESTREAM_TEMPERATURE instead.\n\n");
else if (!option_name.compare("SA_QCR"))
newString.append("SA_QCR is deprecated. Use SA_OPTIONS=QCR2000 instead.\n\n");
else {
/*--- Find the most likely candidate for the unrecognized option, based on the length
of start and end character sequences shared by candidates and the option. ---*/
Expand Down Expand Up @@ -3054,9 +3055,21 @@ void CConfig::SetConfig_Parsing(istream& config_buffer){
string out = option_map[option_name]->SetValue(option_value);
if (out.compare("") != 0) {
/*--- valid option, but deprecated value ---*/
if ((!option_name.compare("KIND_TURB_MODEL")) && (option_value[0]=="SST_SUST"))
errorString.append("Option KIND_TURB_MODEL=SST_SUST is deprecated. Use KIND_TURB_MODEL=SST, SST_OPTIONS=SUSTAINING instead.\n");

if (!option_name.compare("KIND_TURB_MODEL")) {
if (option_value[0] == "SST_SUST")
errorString.append("Option KIND_TURB_MODEL=SST_SUST is deprecated. Use KIND_TURB_MODEL=SST, SST_OPTIONS=SUSTAINING instead.\n");
else if (option_value[0] == "SA_NEG")
errorString.append("Option KIND_TURB_MODEL=SA_NEG is deprecated. Use KIND_TURB_MODEL=SA, SA_OPTIONS=NEGATIVE instead.\n");
else if (option_value[0] == "SA_E")
errorString.append("Option KIND_TURB_MODEL=SA_E is deprecated. Use KIND_TURB_MODEL=SA, SA_OPTIONS=EDWARDS instead.\n");
else if (option_value[0] == "SA_COMP")
errorString.append("Option KIND_TURB_MODEL=SA_COMP is deprecated. Use KIND_TURB_MODEL=SA, SA_OPTIONS=COMPRESSIBILITY instead.\n");
else if (option_value[0] == "SA_E_COMP")
errorString.append("Option KIND_TURB_MODEL=SA_E_COMP is deprecated. Use KIND_TURB_MODEL=SA, SA_OPTIONS=EDWARDS,COMPRESSIBILITY instead.\n");
} else if (!option_name.compare("KIND_TRANS_MODEL")) {
if (option_value[0] == "BC")
errorString.append("Option KIND_TRANS_MODEL=BC is deprecated. Use KIND_TURB_MODEL=SA, SA_OPTIONS=BCM instead.\n");
}
errorString.append(out);
errorString.append("\n");
err_count++;
Expand Down Expand Up @@ -3399,8 +3412,10 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i
}

/*--- Postprocess SST_OPTIONS into structure. ---*/
if (Kind_Turb_Model==TURB_MODEL::SST) {
if (Kind_Turb_Model == TURB_MODEL::SST) {
sstParsedOptions = ParseSSTOptions(SST_Options, nSST_Options, rank);
} else if (Kind_Turb_Model == TURB_MODEL::SA) {
saParsedOptions = ParseSAOptions(SA_Options, nSA_Options, rank);
}

/*--- Check if turbulence model can be used for AXISYMMETRIC case---*/
Expand Down Expand Up @@ -4588,10 +4603,6 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i
for (int i=0; i<7; ++i) eng_cyl[i] /= 12.0;
}

if ((Kind_Turb_Model != TURB_MODEL::SA) && (Kind_Trans_Model == TURB_TRANS_MODEL::BC)){
SU2_MPI::Error("BC transition model currently only available in combination with SA turbulence model!", CURRENT_FUNCTION);
}

if (Kind_Trans_Model == TURB_TRANS_MODEL::LM) {
SU2_MPI::Error("The LM transition model is under maintenance.", CURRENT_FUNCTION);
}
Expand Down Expand Up @@ -5861,11 +5872,26 @@ void CConfig::SetOutput(SU2_COMPONENT val_software, unsigned short val_izone) {
cout << "Turbulence model: ";
switch (Kind_Turb_Model) {
case TURB_MODEL::NONE: break;
case TURB_MODEL::SA: cout << "Spalart Allmaras" << endl; break;
case TURB_MODEL::SA_NEG: cout << "Negative Spalart Allmaras" << endl; break;
case TURB_MODEL::SA_E: cout << "Edwards Spalart Allmaras" << endl; break;
case TURB_MODEL::SA_COMP: cout << "Compressibility Correction Spalart Allmaras" << endl; break;
case TURB_MODEL::SA_E_COMP: cout << "Compressibility Correction Edwards Spalart Allmaras" << endl; break;
case TURB_MODEL::SA:
switch (saParsedOptions.version) {
case SA_OPTIONS::NEG:
cout << "Negative-";
break;
case SA_OPTIONS::EDW:
cout << "Edwards-";
break;
default:
break;
}
cout << "Spalart-Allmaras";

if (!saParsedOptions.ft2) cout << "-noft2";
if (saParsedOptions.rot) cout << "-R";
if (saParsedOptions.comp) cout << "-comp";
if (saParsedOptions.qcr2000) cout << "-QCR2000";
if (saParsedOptions.bc) cout << "-BCM";
cout << endl;
break;
case TURB_MODEL::SST:
cout << "Menter's k-omega SST";
if (sstParsedOptions.version == SST_OPTIONS::V1994) cout << "-1994";
Expand All @@ -5891,11 +5917,9 @@ void CConfig::SetOutput(SU2_COMPONENT val_software, unsigned short val_izone) {
cout << "." << endl;
break;
}
if (QCR) cout << "Using Quadratic Constitutive Relation, 2000 version (QCR2000)" << endl;
if (Kind_Trans_Model == TURB_TRANS_MODEL::BC) cout << "Using the revised BC transition model (2020)" << endl;
cout << "Hybrid RANS/LES: ";
switch (Kind_HybridRANSLES){
case NO_HYBRIDRANSLES: cout << "No Hybrid RANS/LES" << endl; break;
switch (Kind_HybridRANSLES) {
case NO_HYBRIDRANSLES: cout << "No Hybrid RANS/LES" << endl; break;
case SA_DES: cout << "Detached Eddy Simulation (DES97) " << endl; break;
case SA_DDES: cout << "Delayed Detached Eddy Simulation (DDES) with Standard SGS" << endl; break;
case SA_ZDES: cout << "Delayed Detached Eddy Simulation (DDES) with Vorticity-based SGS" << endl; break;
Expand Down
Loading

0 comments on commit ead83fe

Please sign in to comment.