Skip to content

Commit 459e3b4

Browse files
Merge branch 'develop' into fix_inc_unsteady_density
2 parents 83c3416 + b4143f1 commit 459e3b4

File tree

3 files changed

+23
-35
lines changed

3 files changed

+23
-35
lines changed

SU2_CFD/src/solvers/CIncEulerSolver.cpp

Lines changed: 20 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2799,18 +2799,17 @@ void CIncEulerSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver
27992799
su2double U_time_nM1[MAXNVAR], U_time_n[MAXNVAR], U_time_nP1[MAXNVAR];
28002800
su2double Volume_nM1, Volume_nP1, TimeStep;
28012801
const su2double *Normal = nullptr, *GridVel_i = nullptr, *GridVel_j = nullptr;
2802-
su2double Density, Cp, Density_time_n, Density_time_nM1, Density_unsteady;
2802+
su2double Density, Density_time_n, Density_time_nM1, Density_unsteady;
28032803

28042804
const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT);
28052805
const bool first_order = (config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_1ST);
28062806
const bool second_order = (config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_2ND);
28072807
const bool energy = config->GetEnergy_Equation();
28082808

2809-
const int ndim = nDim;
2810-
auto V2U = [ndim](su2double Density, su2double Cp, const su2double* V, su2double* U) {
2809+
const int nvar = nVar;
2810+
auto V2U = [nvar](su2double Density, const su2double* V, su2double* U) {
28112811
U[0] = Density;
2812-
for (int iDim = 0; iDim < ndim; iDim++) U[iDim+1] = Density*V[iDim+1];
2813-
U[ndim+1] = Density*Cp*V[ndim+1];
2812+
for (int iVar = 1; iVar < nvar; ++iVar) U[iVar] = Density * V[iVar];
28142813
};
28152814

28162815
/*--- Store the physical time step ---*/
@@ -2837,18 +2836,17 @@ void CIncEulerSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver
28372836
V_time_n = nodes->GetSolution_time_n(iPoint);
28382837
V_time_nP1 = nodes->GetSolution(iPoint);
28392838

2840-
/*--- Access the density and Cp at this node (constant for now). ---*/
2839+
/*--- Access the density at this node (constant for now). ---*/
28412840

28422841
Density_time_nM1 = nodes->GetDensity_time_n1(iPoint);
28432842
Density_time_n = nodes->GetDensity_time_n(iPoint);
28442843
Density = nodes->GetDensity(iPoint);
2845-
Cp = nodes->GetSpecificHeatCp(iPoint);
2846-
2844+
28472845
/*--- Compute the conservative variable vector for all time levels. ---*/
2848-
// nijso: note that we still assume that cp is constant in time.
2849-
V2U(Density_time_nM1, Cp, V_time_nM1, U_time_nM1);
2850-
V2U(Density_time_n, Cp, V_time_n, U_time_n);
2851-
V2U(Density, Cp, V_time_nP1, U_time_nP1);
2846+
2847+
V2U(Density_time_nM1, V_time_nM1, U_time_nM1);
2848+
V2U(Density_time_n, V_time_n, U_time_n);
2849+
V2U(Density, V_time_nP1, U_time_nP1);
28522850

28532851
/*--- CV volume at time n+1. As we are on a static mesh, the volume
28542852
of the CV will remained fixed for all time steps. ---*/
@@ -2869,13 +2867,9 @@ void CIncEulerSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver
28692867
/*--- Compute the Jacobian contribution due to the dual time source term. ---*/
28702868

28712869
if (implicit) {
2872-
su2double delta = (second_order? 1.5 : 1.0) * Volume_nP1 * Density / TimeStep;
2870+
su2double delta = (second_order ? 1.5 : 1.0) * Volume_nP1 * Density / TimeStep;
28732871

2874-
for (iDim = 0; iDim < nDim; iDim++)
2875-
Jacobian.AddVal2Diag(iPoint, iDim+1, delta);
2876-
2877-
if (energy) delta *= Cp;
2878-
Jacobian.AddVal2Diag(iPoint, nDim+1, delta);
2872+
for (iVar = 1; iVar < nVar; ++iVar) Jacobian.AddVal2Diag(iPoint, iVar, delta);
28792873
}
28802874
}
28812875
END_SU2_OMP_FOR
@@ -2900,8 +2894,7 @@ void CIncEulerSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver
29002894

29012895
V_time_n = nodes->GetSolution_time_n(iPoint);
29022896
Density = nodes->GetDensity(iPoint);
2903-
Cp = nodes->GetSpecificHeatCp(iPoint);
2904-
V2U(Density, Cp, V_time_n, U_time_n);
2897+
V2U(Density, V_time_n, U_time_n);
29052898

29062899
GridVel_i = geometry->nodes->GetGridVel(iPoint);
29072900

@@ -2956,8 +2949,7 @@ void CIncEulerSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver
29562949

29572950
V_time_n = nodes->GetSolution_time_n(iPoint);
29582951
Density = nodes->GetDensity(iPoint);
2959-
Cp = nodes->GetSpecificHeatCp(iPoint);
2960-
V2U(Density, Cp, V_time_n, U_time_n);
2952+
V2U(Density, V_time_n, U_time_n);
29612953

29622954
for (iVar = 0; iVar < nVar-!energy; iVar++)
29632955
LinSysRes(iPoint,iVar) += U_time_n[iVar]*Residual_GCL;
@@ -2983,16 +2975,15 @@ void CIncEulerSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver
29832975
V_time_n = nodes->GetSolution_time_n(iPoint);
29842976
V_time_nP1 = nodes->GetSolution(iPoint);
29852977

2986-
/*--- Access the density and Cp at this node (constant for now). ---*/
2978+
/*--- Access the density at this node (constant for now). ---*/
29872979

29882980
Density = nodes->GetDensity(iPoint);
2989-
Cp = nodes->GetSpecificHeatCp(iPoint);
29902981

29912982
/*--- Compute the conservative variable vector for all time levels. ---*/
29922983

2993-
V2U(Density, Cp, V_time_nM1, U_time_nM1);
2994-
V2U(Density, Cp, V_time_n, U_time_n);
2995-
V2U(Density, Cp, V_time_nP1, U_time_nP1);
2984+
V2U(Density, V_time_nM1, U_time_nM1);
2985+
V2U(Density, V_time_n, U_time_n);
2986+
V2U(Density, V_time_nP1, U_time_nP1);
29962987

29972988
/*--- CV volume at time n-1 and n+1. In the case of dynamically deforming
29982989
grids, the volumes will change. On rigidly transforming grids, the
@@ -3018,11 +3009,8 @@ void CIncEulerSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver
30183009
if (implicit) {
30193010
su2double delta = (second_order? 1.5 : 1.0) * Volume_nP1 * Density / TimeStep;
30203011

3021-
for (iDim = 0; iDim < nDim; iDim++)
3022-
Jacobian.AddVal2Diag(iPoint, iDim+1, delta);
3023-
3024-
if (energy) delta *= Cp;
3025-
Jacobian.AddVal2Diag(iPoint, nDim+1, delta);
3012+
for (iVar = 1; iVar < nVar; ++iVar)
3013+
Jacobian.AddVal2Diag(iPoint, iVar, delta);
30263014
}
30273015
}
30283016
END_SU2_OMP_FOR

TestCases/parallel_regression_AD.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,8 @@ def main():
316316
da_unsteadyCHT_cylinder.cfg_dir = "coupled_cht/disc_adj_unsteadyCHT_cylinder"
317317
da_unsteadyCHT_cylinder.cfg_file = "chtMaster.cfg"
318318
da_unsteadyCHT_cylinder.test_iter = 2
319-
da_unsteadyCHT_cylinder.test_vals = [-12.131633, -12.617906, -12.688933, -16.179747, -6.432277, 0.000000, 75.761000, 0.247780]
320-
da_unsteadyCHT_cylinder.test_vals_aarch64 = [-12.131633, -12.617906, -12.688933, -16.179747, -6.432277, 0.000000, 75.761000, 0.247780]
319+
da_unsteadyCHT_cylinder.test_vals = [-8.479629, -9.239920, -9.234868, -15.934511, -13.662012, 0.000000, 89.932000, 0.295190]
320+
da_unsteadyCHT_cylinder.test_vals_aarch64 = [-8.479629, -9.239920, -9.234868, -15.934511, -13.662012, 0.000000, 89.932000, 0.295190]
321321
da_unsteadyCHT_cylinder.unsteady = True
322322
da_unsteadyCHT_cylinder.multizone = True
323323
test_list.append(da_unsteadyCHT_cylinder)

TestCases/tutorials.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def main():
4949
cht_incompressible_unsteady.cfg_dir = "../Tutorials/multiphysics/unsteady_cht/"
5050
cht_incompressible_unsteady.cfg_file = "cht_2d_3cylinders.cfg"
5151
cht_incompressible_unsteady.test_iter = 2
52-
cht_incompressible_unsteady.test_vals = [-2.661443, -2.546289, -0.080399, -0.080399, -0.080399, -12.421980, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 238.240000] #last columns
52+
cht_incompressible_unsteady.test_vals = [-2.661440, -2.534489, -0.080399, -0.080399, -0.080399, -12.421979, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 238.240000] #last columns
5353
cht_incompressible_unsteady.multizone = True
5454
cht_incompressible_unsteady.unsteady = True
5555
test_list.append(cht_incompressible_unsteady)

0 commit comments

Comments
 (0)