Skip to content

Commit 6a73909

Browse files
authored
Merge pull request #1067 from su2code/fix_inc_rotatingframe
Fixes for incompressible solver - rotating frame and convergence rate for unsteady problems
2 parents e0fafa9 + 35b6fcf commit 6a73909

9 files changed

Lines changed: 69 additions & 61 deletions

File tree

Common/include/CConfig.hpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,8 +600,9 @@ class CConfig {
600600
Kappa_4th_Flow, /*!< \brief JST 4th order dissipation coefficient for flow equations. */
601601
Kappa_2nd_Heat, /*!< \brief 2nd order dissipation coefficient for heat equation. */
602602
Kappa_4th_Heat, /*!< \brief 4th order dissipation coefficient for heat equation. */
603-
Cent_Jac_Fix_Factor; /*!< \brief Multiply the dissipation contribution to the Jacobian of central schemes
603+
Cent_Jac_Fix_Factor, /*!< \brief Multiply the dissipation contribution to the Jacobian of central schemes
604604
by this factor to make the global matrix more diagonal dominant. */
605+
Cent_Inc_Jac_Fix_Factor; /*!< \brief Multiply the dissipation contribution to the Jacobian of incompressible central schemes */
605606
su2double Geo_Waterline_Location; /*!< \brief Location of the waterline. */
606607

607608
su2double Min_Beta_RoeTurkel, /*!< \brief Minimum value of Beta for the Roe-Turkel low Mach preconditioner. */
@@ -4625,6 +4626,12 @@ class CConfig {
46254626
*/
46264627
su2double GetCent_Jac_Fix_Factor(void) const { return Cent_Jac_Fix_Factor; }
46274628

4629+
/*!
4630+
* \brief Factor by which to multiply the dissipation contribution to Jacobians of incompressible central schemes.
4631+
* \return The factor.
4632+
*/
4633+
su2double GetCent_Inc_Jac_Fix_Factor(void) const { return Cent_Inc_Jac_Fix_Factor; }
4634+
46284635
/*!
46294636
* \brief Get the kind of integration scheme (explicit or implicit)
46304637
* for the adjoint flow equations.

Common/src/CConfig.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1819,6 +1819,8 @@ void CConfig::SetConfig_Options() {
18191819
addBoolOption("USE_ACCURATE_FLUX_JACOBIANS", Use_Accurate_Jacobians, false);
18201820
/*!\brief CENTRAL_JACOBIAN_FIX_FACTOR \n DESCRIPTION: Improve the numerical properties (diagonal dominance) of the global Jacobian matrix, 3 to 4 is "optimum" (central schemes) \ingroup Config*/
18211821
addDoubleOption("CENTRAL_JACOBIAN_FIX_FACTOR", Cent_Jac_Fix_Factor, 4.0);
1822+
/*!\brief CENTRAL_JACOBIAN_FIX_FACTOR \n DESCRIPTION: Control numerical properties of the global Jacobian matrix using a multiplication factor for incompressible central schemes \ingroup Config*/
1823+
addDoubleOption("CENTRAL_INC_JACOBIAN_FIX_FACTOR", Cent_Inc_Jac_Fix_Factor, 1.0);
18221824

18231825
/*!\brief CONV_NUM_METHOD_ADJFLOW
18241826
* \n DESCRIPTION: Convective numerical method for the adjoint solver.
@@ -4646,12 +4648,6 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_
46464648
}
46474649
}
46484650

4649-
/*--- Rotating frame is not yet supported with the incompressible solver. ---*/
4650-
4651-
if ((Kind_Solver == INC_EULER || Kind_Solver == INC_NAVIER_STOKES || Kind_Solver == INC_RANS) && (Kind_GridMovement == ROTATING_FRAME)) {
4652-
SU2_MPI::Error("Support for rotating frame simulation not yet implemented for incompressible flows.", CURRENT_FUNCTION);
4653-
}
4654-
46554651
/*--- Assert that there are two markers being analyzed if the
46564652
pressure drop objective function is selected. ---*/
46574653

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,8 @@ class CCentLaxInc_Flow final : public CNumerics {
252252
variable_density, /*!< \brief Variable density incompressible flows. */
253253
energy; /*!< \brief computation with the energy equation. */
254254

255+
su2double fix_factor; /*!< \brief Fix factor for Jacobians. */
256+
255257
su2double** Jacobian_i = nullptr; /*!< \brief The Jacobian w.r.t. point i after computation. */
256258
su2double** Jacobian_j = nullptr; /*!< \brief The Jacobian w.r.t. point j after computation. */
257259

@@ -312,6 +314,8 @@ class CCentJSTInc_Flow final : public CNumerics {
312314
variable_density, /*!< \brief Variable density incompressible flows. */
313315
energy; /*!< \brief computation with the energy equation. */
314316

317+
su2double fix_factor; /*!< \brief Fix factor for Jacobians. */
318+
315319
su2double** Jacobian_i = nullptr; /*!< \brief The Jacobian w.r.t. point i after computation. */
316320
su2double** Jacobian_j = nullptr; /*!< \brief The Jacobian w.r.t. point j after computation. */
317321

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@ CCentLaxInc_Flow::CCentLaxInc_Flow(unsigned short val_nDim, unsigned short val_n
344344
variable_density = (config->GetKind_DensityModel() == VARIABLE);
345345
/* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */
346346
dynamic_grid = config->GetDynamic_Grid();
347+
fix_factor = config->GetCent_Inc_Jac_Fix_Factor();
347348
energy = config->GetEnergy_Equation();
348349

349350
/*--- Artificial dissipation part ---*/
@@ -531,8 +532,8 @@ CNumerics::ResidualType<> CCentLaxInc_Flow::ComputeResidual(const CConfig* confi
531532
for (jVar = 0; jVar < nVar; jVar++) {
532533
ProjFlux[iVar] += Precon[iVar][jVar]*Epsilon_0*Diff_V[jVar]*StretchingFactor*MeanLambda;
533534
if (implicit) {
534-
Jacobian_i[iVar][jVar] += Precon[iVar][jVar]*Epsilon_0*StretchingFactor*MeanLambda;
535-
Jacobian_j[iVar][jVar] -= Precon[iVar][jVar]*Epsilon_0*StretchingFactor*MeanLambda;
535+
Jacobian_i[iVar][jVar] += fix_factor*Precon[iVar][jVar]*Epsilon_0*StretchingFactor*MeanLambda;
536+
Jacobian_j[iVar][jVar] -= fix_factor*Precon[iVar][jVar]*Epsilon_0*StretchingFactor*MeanLambda;
536537
}
537538
}
538539
}
@@ -564,6 +565,7 @@ CCentJSTInc_Flow::CCentJSTInc_Flow(unsigned short val_nDim, unsigned short val_n
564565
energy = config->GetEnergy_Equation();
565566
/* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */
566567
dynamic_grid = config->GetDynamic_Grid();
568+
fix_factor = config->GetCent_Inc_Jac_Fix_Factor();
567569

568570
/*--- Artifical dissipation part ---*/
569571

@@ -759,8 +761,8 @@ CNumerics::ResidualType<> CCentJSTInc_Flow::ComputeResidual(const CConfig* confi
759761
for (jVar = 0; jVar < nVar; jVar++) {
760762
ProjFlux[iVar] += Precon[iVar][jVar]*(Epsilon_2*Diff_V[jVar] - Epsilon_4*Diff_Lapl[jVar])*StretchingFactor*MeanLambda;
761763
if (implicit) {
762-
Jacobian_i[iVar][jVar] += Precon[iVar][jVar]*(Epsilon_2 + Epsilon_4*su2double(Neighbor_i+1))*StretchingFactor*MeanLambda;
763-
Jacobian_j[iVar][jVar] -= Precon[iVar][jVar]*(Epsilon_2 + Epsilon_4*su2double(Neighbor_j+1))*StretchingFactor*MeanLambda;
764+
Jacobian_i[iVar][jVar] += fix_factor*Precon[iVar][jVar]*(Epsilon_2 + Epsilon_4*su2double(Neighbor_i+1))*StretchingFactor*MeanLambda;
765+
Jacobian_j[iVar][jVar] -= fix_factor*Precon[iVar][jVar]*(Epsilon_2 + Epsilon_4*su2double(Neighbor_j+1))*StretchingFactor*MeanLambda;
764766
}
765767
}
766768
}

SU2_CFD/src/solvers/CIncEulerSolver.cpp

Lines changed: 21 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1527,9 +1527,9 @@ void CIncEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_cont
15271527

15281528
for (iPoint = 0; iPoint < nPointDomain; iPoint++) {
15291529

1530-
/*--- Load the conservative variables ---*/
1530+
/*--- Load the primitive variables ---*/
15311531

1532-
numerics->SetConservative(nodes->GetSolution(iPoint), nullptr);
1532+
numerics->SetPrimitive(nodes->GetPrimitive(iPoint), nullptr);
15331533

15341534
/*--- Set incompressible density ---*/
15351535

@@ -3051,33 +3051,19 @@ void CIncEulerSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver
30513051
LinSysRes.AddBlock(iPoint, Residual);
30523052

30533053
if (implicit) {
3054-
3055-
SetPreconditioner(config, iPoint);
3056-
for (iVar = 0; iVar < nVar; iVar++) {
3057-
for (jVar = 0; jVar < nVar; jVar++) {
3058-
Jacobian_i[iVar][jVar] = Preconditioner[iVar][jVar];
3059-
}
3060-
}
3061-
3062-
for (iVar = 0; iVar < nVar; iVar++) {
3063-
for (jVar = 0; jVar < nVar; jVar++) {
3064-
if (config->GetTime_Marching() == DT_STEPPING_1ST)
3065-
Jacobian_i[iVar][jVar] *= Volume_nP1 / TimeStep;
3066-
if (config->GetTime_Marching() == DT_STEPPING_2ND)
3067-
Jacobian_i[iVar][jVar] *= (Volume_nP1*3.0)/(2.0*TimeStep);
3068-
}
3069-
}
3070-
3071-
if (!energy) {
3072-
for (iVar = 0; iVar < nVar; iVar++) {
3073-
Jacobian_i[iVar][nDim+1] = 0.0;
3074-
Jacobian_i[nDim+1][iVar] = 0.0;
3075-
}
3054+
for (iVar = 1; iVar < nVar; iVar++) {
3055+
if (config->GetTime_Marching() == DT_STEPPING_1ST)
3056+
Jacobian_i[iVar][iVar] = Volume_nP1 / TimeStep;
3057+
if (config->GetTime_Marching() == DT_STEPPING_2ND)
3058+
Jacobian_i[iVar][iVar] = (Volume_nP1*3.0)/(2.0*TimeStep);
30763059
}
3060+
for (iDim = 0; iDim < nDim; iDim++)
3061+
Jacobian_i[iDim+1][iDim+1] = Density*Jacobian_i[iDim+1][iDim+1];
3062+
if (energy) Jacobian_i[nDim+1][nDim+1] = Density*Cp*Jacobian_i[nDim+1][nDim+1];
30773063

30783064
Jacobian.AddBlock2Diag(iPoint, Jacobian_i);
3079-
30803065
}
3066+
30813067
}
30823068

30833069
}
@@ -3276,31 +3262,21 @@ void CIncEulerSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver
32763262
to the dual time source term. ---*/
32773263
if (!energy) Residual[nDim+1] = 0.0;
32783264
LinSysRes.AddBlock(iPoint, Residual);
3279-
if (implicit) {
3280-
SetPreconditioner(config, iPoint);
3281-
for (iVar = 0; iVar < nVar; iVar++) {
3282-
for (jVar = 0; jVar < nVar; jVar++) {
3283-
Jacobian_i[iVar][jVar] = Preconditioner[iVar][jVar];
3284-
}
3285-
}
32863265

3287-
for (iVar = 0; iVar < nVar; iVar++) {
3288-
for (jVar = 0; jVar < nVar; jVar++) {
3289-
if (config->GetTime_Marching() == DT_STEPPING_1ST)
3290-
Jacobian_i[iVar][jVar] *= Volume_nP1 / TimeStep;
3291-
if (config->GetTime_Marching() == DT_STEPPING_2ND)
3292-
Jacobian_i[iVar][jVar] *= (Volume_nP1*3.0)/(2.0*TimeStep);
3293-
}
3266+
if (implicit) {
3267+
for (iVar = 1; iVar < nVar; iVar++) {
3268+
if (config->GetTime_Marching() == DT_STEPPING_1ST)
3269+
Jacobian_i[iVar][iVar] = Volume_nP1 / TimeStep;
3270+
if (config->GetTime_Marching() == DT_STEPPING_2ND)
3271+
Jacobian_i[iVar][iVar] = (Volume_nP1*3.0)/(2.0*TimeStep);
32943272
}
3273+
for (iDim = 0; iDim < nDim; iDim++)
3274+
Jacobian_i[iDim+1][iDim+1] = Density*Jacobian_i[iDim+1][iDim+1];
3275+
if (energy) Jacobian_i[nDim+1][nDim+1] = Density*Cp*Jacobian_i[nDim+1][nDim+1];
32953276

3296-
if (!energy) {
3297-
for (iVar = 0; iVar < nVar; iVar++) {
3298-
Jacobian_i[iVar][nDim+1] = 0.0;
3299-
Jacobian_i[nDim+1][iVar] = 0.0;
3300-
}
3301-
}
33023277
Jacobian.AddBlock2Diag(iPoint, Jacobian_i);
33033278
}
3279+
33043280
}
33053281
}
33063282

SU2_PY/SU2/eval/gradients.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,14 @@ def findiff( config, state=None ):
838838
name = su2io.expand_time(name,config)
839839
link.extend(name)
840840

841+
# files: restart solution for dual-time stepping first and second order
842+
if 'RESTART_FILE_1' in files:
843+
name = files['RESTART_FILE_1']
844+
pull.append(name)
845+
if 'RESTART_FILE_2' in files:
846+
name = files['RESTART_FILE_2']
847+
pull.append(name)
848+
841849
# files: target equivarea distribution
842850
if 'EQUIV_AREA' in special_cases and 'TARGET_EA' in files:
843851
pull.append(files['TARGET_EA'])

SU2_PY/finite_differences.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,21 @@ def finite_differences( filename ,
7777
# State
7878
state = SU2.io.State()
7979
state.find_files(config)
80+
81+
# add restart files to state.FILES
82+
if config.get('TIME_DOMAIN', 'NO') == 'YES' and config.get('RESTART_SOL', 'NO') == 'YES':
83+
restart_name = config['RESTART_FILENAME'].split('.')[0]
84+
restart_filename = restart_name + '_' + str(int(config['RESTART_ITER'])-1).zfill(5) + '.dat'
85+
if not os.path.isfile(restart_filename): # throw, if restart files does not exist
86+
sys.exit("Error: Restart file <" + restart_filename + "> not found.")
87+
state['FILES']['RESTART_FILE_1'] = restart_filename
88+
89+
# use only, if time integration is second order
90+
if config.get('TIME_MARCHING', 'NO') == 'DUAL_TIME_STEPPING-2ND_ORDER':
91+
restart_filename = restart_name + '_' + str(int(config['RESTART_ITER'])-2).zfill(5) + '.dat'
92+
if not os.path.isfile(restart_filename): # throw, if restart files does not exist
93+
sys.exit("Error: Restart file <" + restart_filename + "> not found.")
94+
state['FILES']['RESTART_FILE_2'] =restart_filename
8095

8196
# Finite Difference Gradients
8297
SU2.eval.gradients.findiff(config,state)

TestCases/parallel_regression.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,7 @@ def main():
866866
unst_inc_turb_naca0015_sa.cfg_dir = "unsteady/pitching_naca0015_rans_inc"
867867
unst_inc_turb_naca0015_sa.cfg_file = "config_incomp_turb_sa.cfg"
868868
unst_inc_turb_naca0015_sa.test_iter = 1
869-
unst_inc_turb_naca0015_sa.test_vals = [-2.991060, -6.866340, 1.476415, 0.419712]
869+
unst_inc_turb_naca0015_sa.test_vals = [-3.004011, -6.876230, 1.487888, 0.421869]
870870
unst_inc_turb_naca0015_sa.su2_exec = "parallel_computation.py -f"
871871
unst_inc_turb_naca0015_sa.timeout = 1600
872872
unst_inc_turb_naca0015_sa.tol = 0.00001
@@ -1195,8 +1195,8 @@ def main():
11951195
cht_incompressible_unsteady.cfg_dir = "coupled_cht/incomp_2d_unsteady"
11961196
cht_incompressible_unsteady.cfg_file = "cht_2d_3cylinders.cfg"
11971197
cht_incompressible_unsteady.test_iter = 2
1198-
cht_incompressible_unsteady.test_vals = [-1.348104, -0.080392, -0.080391, -0.080391] #last 4 columns
1199-
cht_incompressible_unsteady.su2_exec = "SU2_CFD"
1198+
cht_incompressible_unsteady.test_vals = [-1.305471, -0.080372, -0.080376, -0.080372] #last 4 columns
1199+
cht_incompressible_unsteady.su2_exec = "mpirun -n 2 SU2_CFD"
12001200
cht_incompressible_unsteady.timeout = 1600
12011201
cht_incompressible_unsteady.multizone = True
12021202
cht_incompressible_unsteady.unsteady = True

TestCases/serial_regression.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,7 +1001,7 @@ def main():
10011001
unst_inc_turb_naca0015_sa.cfg_dir = "unsteady/pitching_naca0015_rans_inc"
10021002
unst_inc_turb_naca0015_sa.cfg_file = "config_incomp_turb_sa.cfg"
10031003
unst_inc_turb_naca0015_sa.test_iter = 1
1004-
unst_inc_turb_naca0015_sa.test_vals = [-2.994996, -6.869781, 1.434864, 0.416626] #last 4 columns
1004+
unst_inc_turb_naca0015_sa.test_vals = [-3.007635, -6.879789, 1.445300, 0.419281] #last 4 columns
10051005
unst_inc_turb_naca0015_sa.su2_exec = "SU2_CFD"
10061006
unst_inc_turb_naca0015_sa.timeout = 1600
10071007
unst_inc_turb_naca0015_sa.tol = 0.00001
@@ -1407,7 +1407,7 @@ def main():
14071407
cht_incompressible_unsteady.cfg_dir = "coupled_cht/incomp_2d_unsteady"
14081408
cht_incompressible_unsteady.cfg_file = "cht_2d_3cylinders.cfg"
14091409
cht_incompressible_unsteady.test_iter = 2
1410-
cht_incompressible_unsteady.test_vals = [-1.348104, -0.080392, -0.080391, -0.080391] #last 4 columns
1410+
cht_incompressible_unsteady.test_vals = [-1.303588, -0.080377, -0.080380, -0.080377] #last 4 columns
14111411
cht_incompressible_unsteady.su2_exec = "SU2_CFD"
14121412
cht_incompressible_unsteady.timeout = 1600
14131413
cht_incompressible_unsteady.multizone = True

0 commit comments

Comments
 (0)