Skip to content

Commit f569cf2

Browse files
committed
Addressing review comments. Adding rotating test. Adding error check for CFL adapt params.
1 parent 9407cb7 commit f569cf2

14 files changed

Lines changed: 93 additions & 93 deletions

Common/include/CConfig.hpp

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -783,8 +783,6 @@ class CConfig {
783783
unsigned short
784784
Console_Output_Verb, /*!< \brief Level of verbosity for console output */
785785
Kind_Average; /*!< \brief Particular average for the marker analyze. */
786-
unsigned short
787-
nPolyCoeffs; /*!< \brief Number of coefficients in temperature polynomial fits for fluid models. */
788786
su2double Gamma, /*!< \brief Ratio of specific heats of the gas. */
789787
Bulk_Modulus, /*!< \brief Value of the bulk modulus for incompressible flows. */
790788
Beta_Factor, /*!< \brief Value of the epsilon^2 multiplier for Beta for the incompressible preconditioner. */
@@ -818,14 +816,14 @@ class CConfig {
818816
Mu_Temperature_Ref, /*!< \brief Reference temperature for Sutherland model. */
819817
Mu_Temperature_RefND, /*!< \brief Non-dimensional reference temperature for Sutherland model. */
820818
Mu_S, /*!< \brief Reference S for Sutherland model. */
821-
Mu_SND, /*!< \brief Non-dimensional reference S for Sutherland model. */
822-
*CpPolyCoefficients, /*!< \brief Definition of the temperature polynomial coefficients for specific heat Cp. */
823-
*MuPolyCoefficients, /*!< \brief Definition of the temperature polynomial coefficients for viscosity. */
824-
*KtPolyCoefficients, /*!< \brief Definition of the temperature polynomial coefficients for thermal conductivity. */
825-
*CpPolyCoefficientsND, /*!< \brief Definition of the non-dimensional temperature polynomial coefficients for specific heat Cp. */
826-
*MuPolyCoefficientsND, /*!< \brief Definition of the non-dimensional temperature polynomial coefficients for viscosity. */
827-
*KtPolyCoefficientsND, /*!< \brief Definition of the non-dimensional temperature polynomial coefficients for thermal conductivity. */
828-
Thermal_Conductivity_Solid, /*!< \brief Thermal conductivity in solids. */
819+
Mu_SND; /*!< \brief Non-dimensional reference S for Sutherland model. */
820+
su2double* CpPolyCoefficients; /*!< \brief Definition of the temperature polynomial coefficients for specific heat Cp. */
821+
su2double* MuPolyCoefficients; /*!< \brief Definition of the temperature polynomial coefficients for viscosity. */
822+
su2double* KtPolyCoefficients; /*!< \brief Definition of the temperature polynomial coefficients for thermal conductivity. */
823+
array<double, N_POLY_COEFFS> CpPolyCoefficientsND{0.0}; /*!< \brief Definition of the non-dimensional temperature polynomial coefficients for specific heat Cp. */
824+
array<double, N_POLY_COEFFS>MuPolyCoefficientsND{0.0}; /*!< \brief Definition of the non-dimensional temperature polynomial coefficients for viscosity. */
825+
array<double, N_POLY_COEFFS>KtPolyCoefficientsND{0.0}; /*!< \brief Definition of the non-dimensional temperature polynomial coefficients for thermal conductivity. */
826+
su2double Thermal_Conductivity_Solid, /*!< \brief Thermal conductivity in solids. */
829827
Thermal_Diffusivity_Solid, /*!< \brief Thermal diffusivity in solids. */
830828
Temperature_Freestream_Solid, /*!< \brief Temperature in solids at freestream conditions. */
831829
Density_Solid, /*!< \brief Total density in solids. */
@@ -1018,9 +1016,9 @@ class CConfig {
10181016
su2double FinalRotation_Rate_Z; /*!< \brief Final rotation rate Z if Ramp rotating frame is activated. */
10191017
su2double FinalOutletPressure; /*!< \brief Final outlet pressure if Ramp outlet pressure is activated. */
10201018
su2double MonitorOutletPressure; /*!< \brief Monitor outlet pressure if Ramp outlet pressure is activated. */
1021-
su2double *default_cp_polycoeffs; /*!< \brief Array for specific heat polynomial coefficients. */
1022-
su2double *default_mu_polycoeffs; /*!< \brief Array for viscosity polynomial coefficients. */
1023-
su2double *default_kt_polycoeffs; /*!< \brief Array for thermal conductivity polynomial coefficients. */
1019+
array<double, N_POLY_COEFFS> default_cp_polycoeffs{0.0}; /*!< \brief Array for specific heat polynomial coefficients. */
1020+
array<double, N_POLY_COEFFS> default_mu_polycoeffs{0.0}; /*!< \brief Array for viscosity polynomial coefficients. */
1021+
array<double, N_POLY_COEFFS> default_kt_polycoeffs{0.0}; /*!< \brief Array for thermal conductivity polynomial coefficients. */
10241022
su2double *ExtraRelFacGiles; /*!< \brief coefficient for extra relaxation factor for Giles BC*/
10251023
bool Body_Force; /*!< \brief Flag to know if a body force is included in the formulation. */
10261024
su2double *Body_Force_Vector; /*!< \brief Values of the prescribed body force vector. */
@@ -3818,7 +3816,7 @@ class CConfig {
38183816
* \brief Get the number of coefficients in the temperature polynomial models.
38193817
* \return The the number of coefficients in the temperature polynomial models.
38203818
*/
3821-
unsigned short GetnPolyCoeffs(void) const { return nPolyCoeffs; }
3819+
unsigned short GetnPolyCoeffs(void) const { return N_POLY_COEFFS; }
38223820

38233821
/*!
38243822
* \brief Get the temperature polynomial coefficient for specific heat Cp.
@@ -3852,7 +3850,7 @@ class CConfig {
38523850
* \brief Get the temperature polynomial coefficients for viscosity.
38533851
* \return Non-dimensional temperature polynomial coefficients for viscosity.
38543852
*/
3855-
su2double* GetMu_PolyCoeffND(void) { return MuPolyCoefficientsND; }
3853+
const su2double* GetMu_PolyCoeffND(void) const { return MuPolyCoefficientsND.data(); }
38563854

38573855
/*!
38583856
* \brief Get the temperature polynomial coefficient for thermal conductivity.
@@ -3872,7 +3870,7 @@ class CConfig {
38723870
* \brief Get the temperature polynomial coefficients for thermal conductivity.
38733871
* \return Non-dimensional temperature polynomial coefficients for thermal conductivity.
38743872
*/
3875-
su2double* GetKt_PolyCoeffND(void) { return KtPolyCoefficientsND; }
3873+
const su2double* GetKt_PolyCoeffND(void) const { return KtPolyCoefficientsND.data(); }
38763874

38773875
/*!
38783876
* \brief Set the value of the non-dimensional constant viscosity.

Common/include/option_structure.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,11 @@ const int SU2_CONN_SKIP = 2; /*!< \brief Offset to skip the globalID and VTK
136136

137137
const su2double COLORING_EFF_THRESH = 0.875; /*!< \brief Below this value fallback strategies are used instead. */
138138

139-
constexpr int N_POLY_COEFFS = 5; /*!< \brief Number of coefficients in temperature polynomial fits for fluid models. */; /*!< \brief Number of coefficients in temperature polynomial fits for fluid models. */
139+
/*--- All temperature polynomial fits for the fluid models currently
140+
assume a quartic form (5 coefficients). For example,
141+
Cp(T) = b0 + b1*T + b2*T^2 + b3*T^3 + b4*T^4. By default, all coeffs
142+
are set to zero and will be properly non-dim. in the solver. ---*/
143+
constexpr int N_POLY_COEFFS = 5; /*!< \brief Number of coefficients in temperature polynomial fits for fluid models. */;
140144

141145
/*!
142146
* \brief Boolean answers

Common/src/CConfig.cpp

Lines changed: 26 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -978,13 +978,6 @@ void CConfig::SetPointersNull(void) {
978978

979979
/*--- Initialize some default arrays to NULL. ---*/
980980

981-
default_cp_polycoeffs = nullptr;
982-
default_mu_polycoeffs = nullptr;
983-
default_kt_polycoeffs = nullptr;
984-
CpPolyCoefficientsND = nullptr;
985-
MuPolyCoefficientsND = nullptr;
986-
KtPolyCoefficientsND = nullptr;
987-
988981
Riemann_FlowDir = nullptr;
989982
Giles_FlowDir = nullptr;
990983
CoordFFDBox = nullptr;
@@ -1076,23 +1069,6 @@ void CConfig::SetRunTime_Options(void) {
10761069

10771070
void CConfig::SetConfig_Options() {
10781071

1079-
1080-
/*--- Allocate some default arrays needed for lists of doubles. ---*/
1081-
1082-
1083-
/*--- All temperature polynomial fits for the fluid models currently
1084-
assume a quartic form (5 coefficients). For example,
1085-
Cp(T) = b0 + b1*T + b2*T^2 + b3*T^3 + b4*T^4. By default, all coeffs
1086-
are set to zero and will be properly non-dim. in the solver. ---*/
1087-
1088-
nPolyCoeffs = N_POLY_COEFFS;
1089-
default_cp_polycoeffs = new su2double[nPolyCoeffs]();
1090-
default_mu_polycoeffs = new su2double[nPolyCoeffs]();
1091-
default_kt_polycoeffs = new su2double[nPolyCoeffs]();
1092-
CpPolyCoefficientsND = new su2double[nPolyCoeffs]();
1093-
MuPolyCoefficientsND = new su2double[nPolyCoeffs]();
1094-
KtPolyCoefficientsND = new su2double[nPolyCoeffs]();
1095-
10961072
// This config file is parsed by a number of programs to make it easy to write SU2
10971073
// wrapper scripts (in python, go, etc.) so please do
10981074
// the best you can to follow the established format. It's very hard to parse c++ code
@@ -1219,11 +1195,11 @@ void CConfig::SetConfig_Options() {
12191195
/*--- Options related to temperature polynomial coefficients for fluid models. ---*/
12201196

12211197
/* DESCRIPTION: Definition of the temperature polynomial coefficients for specific heat Cp. */
1222-
addDoubleArrayOption("CP_POLYCOEFFS", nPolyCoeffs, CpPolyCoefficients, default_cp_polycoeffs);
1198+
addDoubleArrayOption("CP_POLYCOEFFS", N_POLY_COEFFS, CpPolyCoefficients, default_cp_polycoeffs.data());
12231199
/* DESCRIPTION: Definition of the temperature polynomial coefficients for specific heat Cp. */
1224-
addDoubleArrayOption("MU_POLYCOEFFS", nPolyCoeffs, MuPolyCoefficients, default_mu_polycoeffs);
1200+
addDoubleArrayOption("MU_POLYCOEFFS", N_POLY_COEFFS, MuPolyCoefficients, default_mu_polycoeffs.data());
12251201
/* DESCRIPTION: Definition of the temperature polynomial coefficients for specific heat Cp. */
1226-
addDoubleArrayOption("KT_POLYCOEFFS", nPolyCoeffs, KtPolyCoefficients, default_kt_polycoeffs);
1202+
addDoubleArrayOption("KT_POLYCOEFFS", N_POLY_COEFFS, KtPolyCoefficients, default_kt_polycoeffs.data());
12271203

12281204
/*!\brief REYNOLDS_NUMBER \n DESCRIPTION: Reynolds number (non-dimensional, based on the free-stream values). Needed for viscous solvers. For incompressible solvers the Reynolds length will always be 1.0 \n DEFAULT: 0.0 \ingroup Config */
12291205
addDoubleOption("REYNOLDS_NUMBER", Reynolds, 0.0);
@@ -1609,9 +1585,9 @@ void CConfig::SetConfig_Options() {
16091585
addBoolOption("CFL_ADAPT", CFL_Adapt, false);
16101586
/* !\brief CFL_ADAPT_PARAM
16111587
* DESCRIPTION: Parameters of the adaptive CFL number (factor down, factor up, CFL limit (min and max) )
1612-
* Factor down generally >1.0, factor up generally < 1.0 to cause the CFL to increase when residual is decreasing,
1613-
* and decrease when the residual is increasing or stalled. \ingroup Config*/
1614-
default_cfl_adapt[0] = 0.0; default_cfl_adapt[1] = 0.0; default_cfl_adapt[2] = 1.0; default_cfl_adapt[3] = 100.0;
1588+
* Factor down generally <1.0, factor up generally > 1.0 to cause the CFL to increase when the under-relaxation parameter is 1.0
1589+
* and to decrease when the under-relaxation parameter is less than 0.1. Factor is multiplicative. \ingroup Config*/
1590+
default_cfl_adapt[0] = 1.0; default_cfl_adapt[1] = 1.0; default_cfl_adapt[2] = 10.0; default_cfl_adapt[3] = 100.0;
16151591
addDoubleArrayOption("CFL_ADAPT_PARAM", 4, CFL_AdaptParam, default_cfl_adapt);
16161592
/* DESCRIPTION: Reduction factor of the CFL coefficient in the adjoint problem */
16171593
addDoubleOption("CFL_REDUCTION_ADJFLOW", CFLRedCoeff_AdjFlow, 0.8);
@@ -4549,28 +4525,28 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_
45494525

45504526
if ((Kind_Solver == INC_EULER || Kind_Solver == INC_NAVIER_STOKES || Kind_Solver == INC_RANS) && (Kind_FluidModel == INC_IDEAL_GAS_POLY)) {
45514527
su2double sum = 0.0;
4552-
for (unsigned short iVar = 0; iVar < nPolyCoeffs; iVar++) {
4528+
for (unsigned short iVar = 0; iVar < N_POLY_COEFFS; iVar++) {
45534529
sum += GetCp_PolyCoeff(iVar);
45544530
}
4555-
if ((nPolyCoeffs < 1) || (sum == 0.0))
4531+
if ((N_POLY_COEFFS < 1) || (sum == 0.0))
45564532
SU2_MPI::Error(string("CP_POLYCOEFFS not set for fluid model INC_IDEAL_GAS_POLY. \n"), CURRENT_FUNCTION);
45574533
}
45584534

45594535
if (((Kind_Solver == INC_EULER || Kind_Solver == INC_NAVIER_STOKES || Kind_Solver == INC_RANS)) && (Kind_ViscosityModel == POLYNOMIAL_VISCOSITY)) {
45604536
su2double sum = 0.0;
4561-
for (unsigned short iVar = 0; iVar < nPolyCoeffs; iVar++) {
4537+
for (unsigned short iVar = 0; iVar < N_POLY_COEFFS; iVar++) {
45624538
sum += GetMu_PolyCoeff(iVar);
45634539
}
4564-
if ((nPolyCoeffs < 1) || (sum == 0.0))
4540+
if ((N_POLY_COEFFS < 1) || (sum == 0.0))
45654541
SU2_MPI::Error(string("MU_POLYCOEFFS not set for viscosity model POLYNOMIAL_VISCOSITY. \n"), CURRENT_FUNCTION);
45664542
}
45674543

45684544
if ((Kind_Solver == INC_EULER || Kind_Solver == INC_NAVIER_STOKES || Kind_Solver == INC_RANS) && (Kind_ConductivityModel == POLYNOMIAL_CONDUCTIVITY)) {
45694545
su2double sum = 0.0;
4570-
for (unsigned short iVar = 0; iVar < nPolyCoeffs; iVar++) {
4546+
for (unsigned short iVar = 0; iVar < N_POLY_COEFFS; iVar++) {
45714547
sum += GetKt_PolyCoeff(iVar);
45724548
}
4573-
if ((nPolyCoeffs < 1) || (sum == 0.0))
4549+
if ((N_POLY_COEFFS < 1) || (sum == 0.0))
45744550
SU2_MPI::Error(string("KT_POLYCOEFFS not set for conductivity model POLYNOMIAL_CONDUCTIVITY. \n"), CURRENT_FUNCTION);
45754551
}
45764552

@@ -4894,6 +4870,20 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_
48944870
CURRENT_FUNCTION);
48954871
}
48964872

4873+
/* Protect against using incorrect CFL adaption parameters. */
4874+
4875+
if (CFL_Adapt && (CFL_AdaptParam[0] > 1.0)) {
4876+
SU2_MPI::Error(string("CFL adaption factor down should be less than 1.0."), CURRENT_FUNCTION);
4877+
}
4878+
4879+
if (CFL_Adapt && (CFL_AdaptParam[1] < 1.0)) {
4880+
SU2_MPI::Error(string("CFL adaption factor up should be greater than 1.0."), CURRENT_FUNCTION);
4881+
}
4882+
4883+
if (CFL_Adapt && (CFL_AdaptParam[2] > CFL_AdaptParam[3])) {
4884+
SU2_MPI::Error(string("CFL adaption minimum CFL is larger than the maximum CFL."), CURRENT_FUNCTION);
4885+
}
4886+
48974887
/*--- 0 in the config file means "disable" which can be done using a very large group. ---*/
48984888
if (edgeColorGroupSize==0) edgeColorGroupSize = 1<<30;
48994889

@@ -7629,13 +7619,6 @@ CConfig::~CConfig(void) {
76297619

76307620
/*--- Delete some arrays needed just for initializing options. ---*/
76317621

7632-
delete [] default_cp_polycoeffs;
7633-
delete [] default_mu_polycoeffs;
7634-
delete [] default_kt_polycoeffs;
7635-
delete [] CpPolyCoefficientsND;
7636-
delete [] MuPolyCoefficientsND;
7637-
delete [] KtPolyCoefficientsND;
7638-
76397622
delete [] FFDTag;
76407623
delete [] nDV_Value;
76417624
delete [] TagFFDBox;

SU2_CFD/include/thermophysical/CFluidModel.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,17 +207,17 @@ class CFluidModel {
207207
/*!
208208
* \brief Set specific heat Cp model.
209209
*/
210-
virtual void SetCpModel(CConfig* config) {}
210+
virtual void SetCpModel(const CConfig* config) {}
211211

212212
/*!
213213
* \brief Set viscosity model.
214214
*/
215-
void SetLaminarViscosityModel(CConfig* config);
215+
void SetLaminarViscosityModel(const CConfig* config);
216216

217217
/*!
218218
* \brief Set thermal conductivity model.
219219
*/
220-
void SetThermalConductivityModel(CConfig* config);
220+
void SetThermalConductivityModel(const CConfig* config);
221221

222222
/*!
223223
* \brief virtual member that would be different for each gas model implemented

SU2_CFD/include/thermophysical/CIdealGas.hpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,13 @@ class CIdealGas : public CFluidModel {
3939
su2double Gamma{0.0}; /*!< \brief Ratio of Specific Heats. */
4040
su2double Gamma_Minus_One{0.0}; /*!< \brief Ratio of Specific Heats Minus One. */
4141
su2double Gas_Constant{0.0}; /*!< \brief Gas Constant. */
42-
bool ComputeEntropy; /*!< \brief Whether or not to compute entropy. */
42+
bool ComputeEntropy{true}; /*!< \brief Whether or not to compute entropy. */
4343

4444
public:
4545
/*!
4646
* \brief Constructor of the class.
4747
*/
48-
CIdealGas(su2double gamma, su2double R);
49-
50-
/*!
51-
* \brief Constructor of the class.
52-
*/
53-
CIdealGas(su2double gamma, su2double R, bool CompEntropy);
48+
CIdealGas(su2double gamma, su2double R, bool CompEntropy = true);
5449

5550
/*!
5651
* \brief Set the Dimensionless State using Density and Internal Energy

SU2_CFD/include/thermophysical/CIncIdealGasPolynomial.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class CIncIdealGasPolynomial final : public CFluidModel {
5757
* \brief Set the temperature polynomial coefficients for variable Cp.
5858
* \param[in] config - configuration container for the problem.
5959
*/
60-
void SetCpModel(CConfig* config) override {
60+
void SetCpModel(const CConfig* config) override {
6161
for (int i = 0; i < N; ++i) {
6262
coeffs_[i] = config->GetCp_PolyCoeffND(i);
6363
}
@@ -75,7 +75,9 @@ class CIncIdealGasPolynomial final : public CFluidModel {
7575
/* Evaluate the new Cp from the coefficients and temperature. */
7676
Cp = coeffs_[0];
7777
for (int i = 1; i < N; ++i) {
78-
Cp += coeffs_[i] * pow(t, i);
78+
su2double t_i = t;
79+
for (int j = 1; j < i; ++j) t_i *= t;
80+
Cp += coeffs_[i] * t_i;
7981
}
8082
Cv = Cp / Gamma;
8183
}

SU2_CFD/include/thermophysical/CPolynomialConductivity.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ class CPolynomialConductivity final : public CConductivityModel {
6868
/* Evaluate the new kt from the coefficients and temperature. */
6969
kt_ = coeffs_[0];
7070
for (int i = 1; i < N; ++i) {
71-
kt_ += coeffs_[i] * pow(t, i);
71+
su2double t_i = t;
72+
for (int j = 1; j < i; ++j) t_i *= t;
73+
kt_ += coeffs_[i] * t_i;
7274
}
7375
}
7476

SU2_CFD/include/thermophysical/CPolynomialConductivityRANS.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ class CPolynomialConductivityRANS final : public CConductivityModel {
7070
/* Evaluate the new kt from the coefficients and temperature. */
7171
kt_ = coeffs_[0];
7272
for (int i = 1; i < N; ++i) {
73-
kt_ += coeffs_[i] * pow(t, i);
73+
su2double t_i = t;
74+
for (int j = 1; j < i; ++j) t_i *= t;
75+
kt_ += coeffs_[i] * t_i;
7476
}
7577

7678
/* Add the component due to turbulence to compute effective conductivity. */

SU2_CFD/include/thermophysical/CPolynomialViscosity.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ class CPolynomialViscosity final : public CViscosityModel {
7070
/* Evaluate the new mu from the coefficients and temperature. */
7171
mu_ = coeffs_[0];
7272
for (int i = 1; i < N; ++i) {
73-
mu_ += coeffs_[i] * pow(t, i);
73+
su2double t_i = t;
74+
for (int j = 1; j < i; ++j) t_i *= t;
75+
mu_ += coeffs_[i] * t_i;
7476
}
7577
}
7678

SU2_CFD/src/thermophysical/CFluidModel.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
#include "../../include/thermophysical/CPolynomialViscosity.hpp"
3939
#include "../../include/thermophysical/CSutherland.hpp"
4040

41-
void CFluidModel::SetLaminarViscosityModel(CConfig* config) {
41+
void CFluidModel::SetLaminarViscosityModel(const CConfig* config) {
4242
switch (config->GetKind_ViscosityModel()) {
4343
case CONSTANT_VISCOSITY:
4444
LaminarViscosity = unique_ptr<CConstantViscosity>(new CConstantViscosity(config->GetMu_ConstantND()));
@@ -57,7 +57,7 @@ void CFluidModel::SetLaminarViscosityModel(CConfig* config) {
5757
}
5858
}
5959

60-
void CFluidModel::SetThermalConductivityModel(CConfig* config) {
60+
void CFluidModel::SetThermalConductivityModel(const CConfig* config) {
6161
switch (config->GetKind_ConductivityModel()) {
6262
case CONSTANT_CONDUCTIVITY:
6363
if (config->GetKind_ConductivityModel_Turb() == CONSTANT_PRANDTL_TURB) {

0 commit comments

Comments
 (0)