Skip to content

Commit 0928593

Browse files
Merge branch 'develop' into fix/lm-transition-model-adjoint-2606
2 parents a2758c9 + d136052 commit 0928593

21 files changed

Lines changed: 408 additions & 397 deletions

File tree

Common/include/CConfig.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,7 @@ class CConfig {
651651
unsigned long Linear_Solver_Prec_Threads; /*!< \brief Number of threads per rank for ILU and LU_SGS preconditioners. */
652652
unsigned short Linear_Solver_ILU_n; /*!< \brief ILU fill=in level. */
653653
su2double SemiSpan; /*!< \brief Wing Semi span. */
654+
su2double MSW_Alpha; /*!< \brief Coefficient for blending states in the MSW scheme. */
654655
su2double Roe_Kappa; /*!< \brief Relaxation of the Roe scheme. */
655656
su2double Relaxation_Factor_Adjoint; /*!< \brief Relaxation coefficient for variable updates of adjoint solvers. */
656657
su2double Relaxation_Factor_CHT; /*!< \brief Relaxation coefficient for the update of conjugate heat variables. */
@@ -4432,6 +4433,11 @@ class CConfig {
44324433
*/
44334434
void SetNewtonKrylovRelaxation(const su2double& relaxation) { NK_Relaxation = relaxation; }
44344435

4436+
/*!
4437+
* \brief Returns the MSW alpha (coefficient of the state blending weight).
4438+
*/
4439+
su2double GetMSW_Alpha(void) const { return MSW_Alpha; }
4440+
44354441
/*!
44364442
* \brief Returns the Roe kappa (multipler of the dissipation term).
44374443
*/

Common/src/CConfig.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1916,6 +1916,8 @@ void CConfig::SetConfig_Options() {
19161916
addDoubleOption("RELAXATION_FACTOR_ADJOINT", Relaxation_Factor_Adjoint, 1.0);
19171917
/* DESCRIPTION: Relaxation of the CHT coupling */
19181918
addDoubleOption("RELAXATION_FACTOR_CHT", Relaxation_Factor_CHT, 1.0);
1919+
/* DESCRIPTION: MSW alpha coefficient */
1920+
addDoubleOption("MSW_ALPHA", MSW_Alpha, 5.0);
19191921
/* DESCRIPTION: Roe coefficient */
19201922
addDoubleOption("ROE_KAPPA", Roe_Kappa, 0.5);
19211923
/* DESCRIPTION: Roe-Turkel preconditioning for low Mach number flows */

SU2_CFD/include/numerics/CNumerics.hpp

Lines changed: 150 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535

3636
#include "../../../Common/include/CConfig.hpp"
3737
#include "../../../Common/include/linear_algebra/blas_structure.hpp"
38+
#include "../../../Common/include/toolboxes/geometry_toolbox.hpp"
3839

3940
class CElement;
4041
class CFluidModel;
@@ -46,7 +47,7 @@ class CFluidModel;
4647
*/
4748
class CNumerics {
4849
protected:
49-
enum : size_t {MAXNDIM = 3}; /*!< \brief Max number of space dimensions, used in some static arrays. */
50+
static constexpr size_t MAXNDIM = 3; /*!< \brief Max number of space dimensions, used in some static arrays. */
5051

5152
unsigned short nDim, nVar; /*!< \brief Number of dimensions and variables. */
5253
su2double Gamma; /*!< \brief Fluid's Gamma constant (ratio of specific heats). */
@@ -1146,15 +1147,77 @@ class CNumerics {
11461147
/*!
11471148
* \brief Computation of the matrix P, this matrix diagonalize the conservative Jacobians in
11481149
* the form $P^{-1}(A.Normal)P=Lambda$.
1149-
* \param[in] val_density - Value of the density.
1150-
* \param[in] val_velocity - Value of the velocity.
1151-
* \param[in] val_soundspeed - Value of the sound speed.
1152-
* \param[in] val_normal - Normal vector, the norm of the vector is the area of the face.
1153-
* \param[out] val_p_tensor - Pointer to the P matrix.
1154-
*/
1155-
void GetPMatrix(const su2double *val_density, const su2double *val_velocity,
1156-
const su2double *val_soundspeed, const su2double *val_normal,
1157-
su2double **val_p_tensor) const;
1150+
* \param[in] density - Value of the density.
1151+
* \param[in] velocity - Velocity vector.
1152+
* \param[in] soundspeed - Value of the sound speed.
1153+
* \param[in] normal - Normal vector, the norm of the vector is the area of the face.
1154+
* \param[out] p_tensor - P matrix.
1155+
*/
1156+
template <typename Matrix>
1157+
void GetPMatrix(const su2double& density, const su2double* velocity,
1158+
const su2double& soundspeed, const su2double* normal,
1159+
Matrix& p_tensor) const {
1160+
const su2double rhooc = density / soundspeed;
1161+
const su2double rhoxc = density * soundspeed;
1162+
1163+
if (nDim == 2) {
1164+
const su2double ke = 0.5 * GeometryToolbox::SquaredNorm(2, velocity);
1165+
const su2double projvel = GeometryToolbox::DotProduct(2, velocity, normal);
1166+
1167+
p_tensor[0][0] = 1.0;
1168+
p_tensor[0][1] = 0.0;
1169+
p_tensor[0][2] = 0.5 * rhooc;
1170+
p_tensor[0][3] = 0.5 * rhooc;
1171+
1172+
p_tensor[1][0] = velocity[0];
1173+
p_tensor[1][1] = density * normal[1];
1174+
p_tensor[1][2] = 0.5 * (velocity[0] * rhooc + normal[0] * density);
1175+
p_tensor[1][3] = 0.5 * (velocity[0] * rhooc - normal[0] * density);
1176+
1177+
p_tensor[2][0] = velocity[1];
1178+
p_tensor[2][1] = -density * normal[0];
1179+
p_tensor[2][2] = 0.5 * (velocity[1] * rhooc + normal[1] * density);
1180+
p_tensor[2][3] = 0.5 * (velocity[1] * rhooc - normal[1] * density);
1181+
1182+
p_tensor[3][0] = ke;
1183+
p_tensor[3][1] = density * (velocity[0] * normal[1] - velocity[1] * normal[0]);
1184+
p_tensor[3][2] = 0.5 * (ke * rhooc + density * projvel + rhoxc / Gamma_Minus_One);
1185+
p_tensor[3][3] = 0.5 * (ke * rhooc - density * projvel + rhoxc / Gamma_Minus_One);
1186+
} else {
1187+
const su2double ke = 0.5 * GeometryToolbox::SquaredNorm(3, velocity);
1188+
const su2double projvel = GeometryToolbox::DotProduct(3, velocity, normal);
1189+
1190+
p_tensor[0][0] = normal[0];
1191+
p_tensor[0][1] = normal[1];
1192+
p_tensor[0][2] = normal[2];
1193+
p_tensor[0][3] = 0.5 * rhooc;
1194+
p_tensor[0][4] = 0.5 * rhooc;
1195+
1196+
p_tensor[1][0] = velocity[0] * normal[0];
1197+
p_tensor[1][1] = velocity[0] * normal[1] - density * normal[2];
1198+
p_tensor[1][2] = velocity[0] * normal[2] + density * normal[1];
1199+
p_tensor[1][3] = 0.5 * (velocity[0] * rhooc + density * normal[0]);
1200+
p_tensor[1][4] = 0.5 * (velocity[0] * rhooc - density * normal[0]);
1201+
1202+
p_tensor[2][0] = velocity[1] * normal[0] + density * normal[2];
1203+
p_tensor[2][1] = velocity[1] * normal[1];
1204+
p_tensor[2][2] = velocity[1] * normal[2] - density * normal[0];
1205+
p_tensor[2][3] = 0.5 * (velocity[1] * rhooc + density * normal[1]);
1206+
p_tensor[2][4] = 0.5 * (velocity[1] * rhooc - density * normal[1]);
1207+
1208+
p_tensor[3][0] = velocity[2] * normal[0] - density * normal[1];
1209+
p_tensor[3][1] = velocity[2] * normal[1] + density * normal[0];
1210+
p_tensor[3][2] = velocity[2] * normal[2];
1211+
p_tensor[3][3] = 0.5 * (velocity[2] * rhooc + density * normal[2]);
1212+
p_tensor[3][4] = 0.5 * (velocity[2] * rhooc - density * normal[2]);
1213+
1214+
p_tensor[4][0] = ke * normal[0] + density * (velocity[1] * normal[2] - velocity[2] * normal[1]);
1215+
p_tensor[4][1] = ke * normal[1] + density * (velocity[2] * normal[0] - velocity[0] * normal[2]);
1216+
p_tensor[4][2] = ke * normal[2] + density * (velocity[0] * normal[1] - velocity[1] * normal[0]);
1217+
p_tensor[4][3] = 0.5 * (ke * rhooc + density * projvel + rhoxc / Gamma_Minus_One);
1218+
p_tensor[4][4] = 0.5 * (ke * rhooc - density * projvel + rhoxc / Gamma_Minus_One);
1219+
}
1220+
}
11581221

11591222
/*!
11601223
* \brief Computation of the matrix Rinv*Pe.
@@ -1261,15 +1324,83 @@ class CNumerics {
12611324
/*!
12621325
* \brief Computation of the matrix P^{-1}, this matrix diagonalize the conservative Jacobians
12631326
* in the form $P^{-1}(A.Normal)P=Lambda$.
1264-
* \param[in] val_density - Value of the density.
1265-
* \param[in] val_velocity - Value of the velocity.
1266-
* \param[in] val_soundspeed - Value of the sound speed.
1267-
* \param[in] val_normal - Normal vector, the norm of the vector is the area of the face.
1268-
* \param[out] val_invp_tensor - Pointer to inverse of the P matrix.
1269-
*/
1270-
void GetPMatrix_inv(const su2double *val_density, const su2double *val_velocity,
1271-
const su2double *val_soundspeed, const su2double *val_normal,
1272-
su2double **val_invp_tensor) const;
1327+
* \param[in] density - Value of the density.
1328+
* \param[in] velocity - Velocity vector.
1329+
* \param[in] soundspeed - Value of the sound speed.
1330+
* \param[in] normal - Normal vector, the norm of the vector is the area of the face.
1331+
* \param[out] inv_p_tensor - Pointer to inverse of the P matrix.
1332+
*/
1333+
template <typename Matrix>
1334+
void GetPMatrix_inv(const su2double& density, const su2double* velocity,
1335+
const su2double& soundspeed, const su2double* normal,
1336+
Matrix& inv_p_tensor) const {
1337+
const su2double rhoxc = density * soundspeed;
1338+
const su2double c2 = pow(soundspeed, 2);
1339+
const su2double gm1 = Gamma_Minus_One;
1340+
const su2double k0orho = normal[0] / density;
1341+
const su2double k1orho = normal[1] / density;
1342+
const su2double gm1_o_c2 = gm1 / c2;
1343+
const su2double gm1_o_rhoxc = gm1 / rhoxc;
1344+
1345+
if (nDim == 3) {
1346+
const su2double k2orho = normal[2] / density;
1347+
const su2double ke = 0.5 * GeometryToolbox::SquaredNorm(3, velocity);
1348+
const su2double projvel_o_rho = GeometryToolbox::DotProduct(3, velocity, normal) / density;
1349+
1350+
inv_p_tensor[0][0] = normal[0] + k1orho * velocity[2] - k2orho * velocity[1] - normal[0] * gm1_o_c2 * ke;
1351+
inv_p_tensor[0][1] = normal[0] * gm1_o_c2 * velocity[0];
1352+
inv_p_tensor[0][2] = k2orho + normal[0] * gm1_o_c2 * velocity[1];
1353+
inv_p_tensor[0][3] = -k1orho + normal[0] * gm1_o_c2 * velocity[2];
1354+
inv_p_tensor[0][4] = -normal[0] * gm1_o_c2;
1355+
1356+
inv_p_tensor[1][0] = normal[1] + k2orho * velocity[0] - k0orho * velocity[2] - normal[1] * gm1_o_c2 * ke;
1357+
inv_p_tensor[1][1] = -k2orho + normal[1] * gm1_o_c2 * velocity[0];
1358+
inv_p_tensor[1][2] = normal[1] * gm1_o_c2 * velocity[1];
1359+
inv_p_tensor[1][3] = k0orho + normal[1] * gm1_o_c2 * velocity[2];
1360+
inv_p_tensor[1][4] = -normal[1] * gm1_o_c2;
1361+
1362+
inv_p_tensor[2][0] = normal[2] + k0orho * velocity[1] - k1orho * velocity[0] - normal[2] * gm1_o_c2 * ke;
1363+
inv_p_tensor[2][1] = k1orho + normal[2] * gm1_o_c2 * velocity[0];
1364+
inv_p_tensor[2][2] = -k0orho + normal[2] * gm1_o_c2 * velocity[1];
1365+
inv_p_tensor[2][3] = normal[2] * gm1_o_c2 * velocity[2];
1366+
inv_p_tensor[2][4] = -normal[2] * gm1_o_c2;
1367+
1368+
inv_p_tensor[3][0] = -projvel_o_rho + gm1_o_rhoxc * ke;
1369+
inv_p_tensor[3][1] = k0orho - gm1_o_rhoxc * velocity[0];
1370+
inv_p_tensor[3][2] = k1orho - gm1_o_rhoxc * velocity[1];
1371+
inv_p_tensor[3][3] = k2orho - gm1_o_rhoxc * velocity[2];
1372+
inv_p_tensor[3][4] = gm1_o_rhoxc;
1373+
1374+
inv_p_tensor[4][0] = projvel_o_rho + gm1_o_rhoxc * ke;
1375+
inv_p_tensor[4][1] = -k0orho - gm1_o_rhoxc * velocity[0];
1376+
inv_p_tensor[4][2] = -k1orho - gm1_o_rhoxc * velocity[1];
1377+
inv_p_tensor[4][3] = -k2orho - gm1_o_rhoxc * velocity[2];
1378+
inv_p_tensor[4][4] = gm1_o_rhoxc;
1379+
} else {
1380+
const su2double ke = 0.5 * GeometryToolbox::SquaredNorm(2, velocity);
1381+
const su2double projvel_o_rho = GeometryToolbox::DotProduct(2, velocity, normal) / density;
1382+
1383+
inv_p_tensor[0][0] = 1 - gm1_o_c2 * ke;
1384+
inv_p_tensor[0][1] = gm1_o_c2 * velocity[0];
1385+
inv_p_tensor[0][2] = gm1_o_c2 * velocity[1];
1386+
inv_p_tensor[0][3] = -gm1_o_c2;
1387+
1388+
inv_p_tensor[1][0] = -k1orho * velocity[0] + k0orho * velocity[1];
1389+
inv_p_tensor[1][1] = k1orho;
1390+
inv_p_tensor[1][2] = -k0orho;
1391+
inv_p_tensor[1][3] = 0;
1392+
1393+
inv_p_tensor[2][0] = -projvel_o_rho + gm1_o_rhoxc * ke;
1394+
inv_p_tensor[2][1] = k0orho - gm1_o_rhoxc * velocity[0];
1395+
inv_p_tensor[2][2] = k1orho - gm1_o_rhoxc * velocity[1];
1396+
inv_p_tensor[2][3] = gm1_o_rhoxc;
1397+
1398+
inv_p_tensor[3][0] = projvel_o_rho + gm1_o_rhoxc * ke;
1399+
inv_p_tensor[3][1] = -k0orho - gm1_o_rhoxc * velocity[0];
1400+
inv_p_tensor[3][2] = -k1orho - gm1_o_rhoxc * velocity[1];
1401+
inv_p_tensor[3][3] = gm1_o_rhoxc;
1402+
}
1403+
}
12731404

12741405
/*!
12751406
* \brief Compute viscous residual and jacobian.

SU2_CFD/include/numerics/NEMO/convection/msw.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
*/
3939
class CUpwMSW_NEMO : public CNEMONumerics {
4040
private:
41+
const su2double alpha;
42+
4143
su2double *Diff_U;
4244
su2double *ust_i, *ust_j;
4345
su2double *Fc_i, *Fc_j;

SU2_CFD/include/numerics/flow/convection/fvs.hpp

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,16 @@
3838
*/
3939
class CUpwMSW_Flow final : public CNumerics {
4040
private:
41-
bool implicit;
42-
su2double *u_i, *u_j, *ust_i, *ust_j;
43-
su2double *Fc_i, *Fc_j;
44-
su2double *Lambda_i, *Lambda_j;
45-
su2double *Vst_i, *Vst_j, *Velst_i, *Velst_j;
46-
su2double **P_Tensor, **invP_Tensor;
41+
static constexpr auto MAXNVAR = MAXNDIM + 2;
4742

48-
su2double** Jacobian_i; /*!< \brief The Jacobian w.r.t. point i after computation. */
49-
su2double** Jacobian_j; /*!< \brief The Jacobian w.r.t. point j after computation. */
43+
const su2double alpha;
44+
const bool dynamic_grid;
45+
46+
su2double buf_Jacobian_i[MAXNVAR * MAXNVAR], buf_Jacobian_j[MAXNVAR * MAXNVAR];
47+
su2double* Jacobian_i[MAXNVAR]; /*!< \brief The Jacobian w.r.t. point i after computation. */
48+
su2double* Jacobian_j[MAXNVAR]; /*!< \brief The Jacobian w.r.t. point j after computation. */
49+
50+
su2double Fc[MAXNVAR];
5051

5152
public:
5253
/*!
@@ -57,11 +58,6 @@ class CUpwMSW_Flow final : public CNumerics {
5758
*/
5859
CUpwMSW_Flow(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config);
5960

60-
/*!
61-
* \brief Destructor of the class.
62-
*/
63-
~CUpwMSW_Flow(void) override;
64-
6561
/*!
6662
* \brief Compute the Roe's flux between two nodes i and j.
6763
* \param[in] config - Definition of the particular problem.

SU2_CFD/src/iteration/CFluidIteration.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,11 @@ void CFluidIteration::UpdateRamp(CGeometry**** geometry_container, CConfig** con
340340
const long unsigned updateFreq = RampMUSCLParam.rampMUSCLCoeff[RAMP_COEFF::UPDATE_FREQ];
341341
const long unsigned rampLength = RampMUSCLParam.rampMUSCLCoeff[RAMP_COEFF::FINAL_ITER];
342342
auto iterFrac = (static_cast<double>(iter - startIter)/static_cast<double>((rampLength + startIter) - startIter));
343-
if (iter < startIter) return;
344-
if ((iter == startIter) && (rank == MASTER_NODE)) cout << "Beginning to ramp MUSCL scheme..." << endl;
343+
if (iter < startIter) {
344+
config->SetMUSCLRampValue(0);
345+
return;
346+
}
347+
if (iter == startIter && rank == MASTER_NODE) cout << "Beginning to ramp MUSCL scheme..." << endl;
345348
if ((iter % updateFreq == 0 && iter < (rampLength + startIter)) || (iter == (rampLength + startIter))) {
346349
switch (RampMUSCLParam.Kind_MUSCLRamp) {
347350
case MUSCL_RAMP_TYPE::ITERATION:

0 commit comments

Comments
 (0)