Skip to content

Commit b4143f1

Browse files
Cristopher-MoralespcarruscagCristopher-Morales
authored
Updating SetResidual_DualTime needed for unsteady flows (#2647)
* initial commit * Update SU2_CFD/src/solvers/CIncEulerSolver.cpp Co-authored-by: Pedro Gomes <[email protected]> * addressing comment * updating residuals --------- Co-authored-by: Pedro Gomes <[email protected]> Co-authored-by: Cristopher-Morales <[email protected]>
1 parent 3261fef commit b4143f1

File tree

3 files changed

+21
-33
lines changed

3 files changed

+21
-33
lines changed

SU2_CFD/src/solvers/CIncEulerSolver.cpp

Lines changed: 18 additions & 30 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;
2802+
su2double Density;
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,16 +2836,15 @@ 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 = nodes->GetDensity(iPoint);
2843-
Cp = nodes->GetSpecificHeatCp(iPoint);
28442842

28452843
/*--- Compute the conservative variable vector for all time levels. ---*/
28462844

2847-
V2U(Density, Cp, V_time_nM1, U_time_nM1);
2848-
V2U(Density, Cp, V_time_n, U_time_n);
2849-
V2U(Density, Cp, V_time_nP1, U_time_nP1);
2845+
V2U(Density, V_time_nM1, U_time_nM1);
2846+
V2U(Density, V_time_n, U_time_n);
2847+
V2U(Density, V_time_nP1, U_time_nP1);
28502848

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

28692867
if (implicit) {
2870-
su2double delta = (second_order? 1.5 : 1.0) * Volume_nP1 * Density / TimeStep;
2871-
2872-
for (iDim = 0; iDim < nDim; iDim++)
2873-
Jacobian.AddVal2Diag(iPoint, iDim+1, delta);
2868+
su2double delta = (second_order ? 1.5 : 1.0) * Volume_nP1 * Density / TimeStep;
28742869

2875-
if (energy) delta *= Cp;
2876-
Jacobian.AddVal2Diag(iPoint, nDim+1, delta);
2870+
for (iVar = 1; iVar < nVar; ++iVar) Jacobian.AddVal2Diag(iPoint, iVar, delta);
28772871
}
28782872
}
28792873
END_SU2_OMP_FOR
@@ -2898,8 +2892,7 @@ void CIncEulerSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver
28982892

28992893
V_time_n = nodes->GetSolution_time_n(iPoint);
29002894
Density = nodes->GetDensity(iPoint);
2901-
Cp = nodes->GetSpecificHeatCp(iPoint);
2902-
V2U(Density, Cp, V_time_n, U_time_n);
2895+
V2U(Density, V_time_n, U_time_n);
29032896

29042897
GridVel_i = geometry->nodes->GetGridVel(iPoint);
29052898

@@ -2954,8 +2947,7 @@ void CIncEulerSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver
29542947

29552948
V_time_n = nodes->GetSolution_time_n(iPoint);
29562949
Density = nodes->GetDensity(iPoint);
2957-
Cp = nodes->GetSpecificHeatCp(iPoint);
2958-
V2U(Density, Cp, V_time_n, U_time_n);
2950+
V2U(Density, V_time_n, U_time_n);
29592951

29602952
for (iVar = 0; iVar < nVar-!energy; iVar++)
29612953
LinSysRes(iPoint,iVar) += U_time_n[iVar]*Residual_GCL;
@@ -2981,16 +2973,15 @@ void CIncEulerSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver
29812973
V_time_n = nodes->GetSolution_time_n(iPoint);
29822974
V_time_nP1 = nodes->GetSolution(iPoint);
29832975

2984-
/*--- Access the density and Cp at this node (constant for now). ---*/
2976+
/*--- Access the density at this node (constant for now). ---*/
29852977

29862978
Density = nodes->GetDensity(iPoint);
2987-
Cp = nodes->GetSpecificHeatCp(iPoint);
29882979

29892980
/*--- Compute the conservative variable vector for all time levels. ---*/
29902981

2991-
V2U(Density, Cp, V_time_nM1, U_time_nM1);
2992-
V2U(Density, Cp, V_time_n, U_time_n);
2993-
V2U(Density, Cp, V_time_nP1, U_time_nP1);
2982+
V2U(Density, V_time_nM1, U_time_nM1);
2983+
V2U(Density, V_time_n, U_time_n);
2984+
V2U(Density, V_time_nP1, U_time_nP1);
29942985

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

3019-
for (iDim = 0; iDim < nDim; iDim++)
3020-
Jacobian.AddVal2Diag(iPoint, iDim+1, delta);
3021-
3022-
if (energy) delta *= Cp;
3023-
Jacobian.AddVal2Diag(iPoint, nDim+1, delta);
3010+
for (iVar = 1; iVar < nVar; ++iVar)
3011+
Jacobian.AddVal2Diag(iPoint, iVar, delta);
30243012
}
30253013
}
30263014
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)