Skip to content

Commit 236dace

Browse files
committed
fix leaks and missing conservative vars in MSW, #1161
1 parent 4c3dbd4 commit 236dace

4 files changed

Lines changed: 23 additions & 24 deletions

File tree

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,16 @@
3939
class CUpwMSW_Flow final : public CNumerics {
4040
private:
4141
bool implicit;
42-
su2double *Diff_U;
4342
su2double *u_i, *u_j, *ust_i, *ust_j;
4443
su2double *Fc_i, *Fc_j;
4544
su2double *Lambda_i, *Lambda_j;
46-
su2double rhos_i, rhos_j;
47-
su2double *Ust_i, *Ust_j, *Vst_i, *Vst_j, *Velst_i, *Velst_j;
45+
su2double *Vst_i, *Vst_j, *Velst_i, *Velst_j;
4846
su2double **P_Tensor, **invP_Tensor;
49-
unsigned short nPrimVar, nVar, nDim;
5047

5148
su2double** Jacobian_i; /*!< \brief The Jacobian w.r.t. point i after computation. */
5249
su2double** Jacobian_j; /*!< \brief The Jacobian w.r.t. point j after computation. */
5350

5451
public:
55-
5652
/*!
5753
* \brief Constructor of the class.
5854
* \param[in] val_nDim - Number of dimensions of the problem.

SU2_CFD/include/variables/CEulerVariable.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,9 @@ class CEulerVariable : public CVariable {
228228
* \param[in] soundspeed2 - Value of soundspeed^2.
229229
*/
230230
bool SetSoundSpeed(unsigned long iPoint, su2double soundspeed2) final {
231-
su2double radical = soundspeed2;
232-
if (radical < 0.0) return true;
231+
if (soundspeed2 < 0.0) return true;
233232
else {
234-
Primitive(iPoint,nDim+4) = sqrt(radical);
233+
Primitive(iPoint,nDim+4) = sqrt(soundspeed2);
235234
return false;
236235
}
237236
}

SU2_CFD/src/numerics/flow/convection/fvs.cpp

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ CUpwMSW_Flow::CUpwMSW_Flow(unsigned short val_nDim, unsigned short val_nVar, con
3737
implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT);
3838

3939
/*--- Allocate arrays ---*/
40-
Diff_U = new su2double [nVar];
4140
Fc_i = new su2double [nVar];
4241
Fc_j = new su2double [nVar];
4342
Lambda_i = new su2double [nVar];
@@ -47,10 +46,8 @@ CUpwMSW_Flow::CUpwMSW_Flow(unsigned short val_nDim, unsigned short val_nVar, con
4746
u_j = new su2double [nDim];
4847
ust_i = new su2double [nDim];
4948
ust_j = new su2double [nDim];
50-
Vst_i = new su2double [nPrimVar];
51-
Vst_j = new su2double [nPrimVar];
52-
Ust_i = new su2double [nVar];
53-
Ust_j = new su2double [nVar];
49+
Vst_i = new su2double [nDim+5];
50+
Vst_j = new su2double [nDim+5];
5451

5552
Velst_i = new su2double [nDim];
5653
Velst_j = new su2double [nDim];
@@ -70,7 +67,6 @@ CUpwMSW_Flow::CUpwMSW_Flow(unsigned short val_nDim, unsigned short val_nVar, con
7067

7168
CUpwMSW_Flow::~CUpwMSW_Flow(void) {
7269

73-
delete [] Diff_U;
7470
delete [] Fc_i;
7571
delete [] Fc_j;
7672
delete [] Lambda_i;
@@ -80,9 +76,7 @@ CUpwMSW_Flow::~CUpwMSW_Flow(void) {
8076
delete [] u_j;
8177
delete [] ust_i;
8278
delete [] ust_j;
83-
delete [] Ust_i;
8479
delete [] Vst_i;
85-
delete [] Ust_j;
8680
delete [] Vst_j;
8781
delete [] Velst_i;
8882
delete [] Velst_j;
@@ -105,7 +99,7 @@ CNumerics::ResidualType<> CUpwMSW_Flow::ComputeResidual(const CConfig* config) {
10599
implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT);
106100

107101
unsigned short iDim, iVar, jVar, kVar;
108-
su2double P_i, P_j;
102+
su2double rho_i, rho_j, P_i, P_j, H_i, H_j;
109103
su2double ProjVel_i, ProjVel_j, ProjVelst_i, ProjVelst_j;
110104
su2double sqvel_i, sqvel_j;
111105
su2double alpha, w, dp, onemw;
@@ -138,14 +132,28 @@ CNumerics::ResidualType<> CUpwMSW_Flow::ComputeResidual(const CConfig* config) {
138132

139133
/*--- Load variables from nodes i & j ---*/
140134

141-
rhos_i = V_i[0];
142-
rhos_j = V_j[0];
143135
for (iDim = 0; iDim < nDim; iDim++) {
144136
u_i[iDim] = V_i[iDim+1];
145137
u_j[iDim] = V_j[iDim+1];
146138
}
147139
P_i = V_i[nDim+1];
148140
P_j = V_j[nDim+1];
141+
rho_i = V_i[nDim+2];
142+
rho_j = V_j[nDim+2];
143+
H_i = V_i[nDim+3];
144+
H_j = V_j[nDim+3];
145+
146+
/*--- Recompute conservatives ---*/
147+
148+
su2double U_i[5] = {0.0}, U_j[5] = {0.0};
149+
150+
U_i[0] = rho_i; U_j[0] = rho_j;
151+
for (iDim = 0; iDim < nDim; iDim++) {
152+
U_i[iDim+1] = rho_i*u_i[iDim];
153+
U_j[iDim+1] = rho_j*u_j[iDim];
154+
}
155+
U_i[nDim+1] = rho_i*H_i - P_i;
156+
U_j[nDim+1] = rho_j*H_j - P_j;
149157

150158
/*--- Calculate supporting quantities ---*/
151159

@@ -166,10 +174,6 @@ CNumerics::ResidualType<> CUpwMSW_Flow::ComputeResidual(const CConfig* config) {
166174

167175
/*--- Calculate weighted state vector (*) for i & j ---*/
168176

169-
for (iVar = 0; iVar < nVar; iVar++) {
170-
Ust_i[iVar] = onemw*U_i[iVar] + w*U_j[iVar];
171-
Ust_j[iVar] = onemw*U_j[iVar] + w*U_i[iVar];
172-
}
173177
for (iVar = 0; iVar < nDim+5; iVar++) {
174178
Vst_i[iVar] = onemw*V_i[iVar] + w*V_j[iVar];
175179
Vst_j[iVar] = onemw*V_j[iVar] + w*V_i[iVar];

SU2_CFD/src/solvers/CNSSolver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ void CNSSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container, C
110110
CommonPreprocessing(geometry, solver_container, config, iMesh, iRKStep, RunTime_EqSystem, Output);
111111

112112
/*--- Compute gradient for MUSCL reconstruction, for output (i.e. the
113-
turbulence solver) only density and velocity are needed ---*/
113+
turbulence solver, and post) only temperature and velocity are needed ---*/
114114

115115
const auto nPrimVarGrad_bak = nPrimVarGrad;
116116
if (Output) {

0 commit comments

Comments
 (0)