Skip to content

Commit 56cb526

Browse files
authored
Merge pull request #1556 from su2code/fix_newton_krylov_dual_time
Fix Newton-Krylov for unsteady problems
2 parents 52f8d89 + 23fcb88 commit 56cb526

4 files changed

Lines changed: 16 additions & 21 deletions

File tree

Common/include/CConfig.hpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ class CConfig {
148148
su2double CL_Target; /*!< \brief Fixed Cl mode Target Cl. */
149149
TIME_MARCHING TimeMarching; /*!< \brief Steady or unsteady (time stepping or dual time stepping) computation. */
150150
unsigned short Dynamic_Analysis; /*!< \brief Static or dynamic structural analysis. */
151-
unsigned short nStartUpIter; /*!< \brief Start up iterations using the fine grid. */
152151
su2double FixAzimuthalLine; /*!< \brief Fix an azimuthal line due to misalignments of the nearfield. */
153152
su2double **DV_Value; /*!< \brief Previous value of the design variable. */
154153
su2double Venkat_LimiterCoeff; /*!< \brief Limiter coefficient */
@@ -1977,12 +1976,6 @@ class CConfig {
19771976
*/
19781977
su2double GetLength_Reynolds(void) const { return Length_Reynolds; }
19791978

1980-
/*!
1981-
* \brief Get the start up iterations using the fine grid, this works only for multigrid problems.
1982-
* \return Start up iterations using the fine grid.
1983-
*/
1984-
unsigned short GetnStartUpIter(void) const { return nStartUpIter; }
1985-
19861979
/*!
19871980
* \brief Get the reference area for non dimensional coefficient computation. If the value from the
19881981
* is 0 then, the code will compute the reference area using the projection of the shape into

Common/src/CConfig.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1810,11 +1810,8 @@ void CConfig::SetConfig_Options() {
18101810
/*!\brief CONV_WINDOW_FIELD
18111811
* \n DESCRIPTION: Output fields for the Cauchy criterium for the TIME iteration. The criterium is applied to the windowed time average of the chosen funcion. */
18121812
addStringListOption("CONV_WINDOW_FIELD",nWndConvField, WndConvField);
1813-
/*!\par CONFIG_CATEGORY: Multi-grid \ingroup Config*/
1814-
/*--- Options related to Multi-grid ---*/
18151813

1816-
/*!\brief START_UP_ITER \n DESCRIPTION: Start up iterations using the fine grid only. DEFAULT: 0 \ingroup Config*/
1817-
addUnsignedShortOption("START_UP_ITER", nStartUpIter, 0);
1814+
/*!\par CONFIG_CATEGORY: Multi-grid \ingroup Config*/
18181815
/*!\brief MGLEVEL\n DESCRIPTION: Multi-grid Levels. DEFAULT: 0 \ingroup Config*/
18191816
addUnsignedShortOption("MGLEVEL", nMGLevels, 0);
18201817
/*!\brief MGCYCLE\n DESCRIPTION: Multi-grid cycle. OPTIONS: See \link MG_Cycle_Map \endlink. Defualt V_CYCLE \ingroup Config*/
@@ -5731,7 +5728,7 @@ void CConfig::SetMarkers(SU2_COMPONENT val_software) {
57315728
break;
57325729
}
57335730
}
5734-
5731+
57355732
if(!found) {
57365733
if (nZone==1)
57375734
SU2_MPI::Error("DV_MARKER contains marker names that do not exist in the lists of BCs in the config file.", CURRENT_FUNCTION);
@@ -6818,7 +6815,6 @@ void CConfig::SetOutput(SU2_COMPONENT val_software, unsigned short val_izone) {
68186815

68196816
if (nMGLevels !=0) {
68206817

6821-
if (nStartUpIter != 0) cout << "A total of " << nStartUpIter << " start up iterations on the fine grid."<< endl;
68226818
if (MGCycle == V_CYCLE) cout << "V Multigrid Cycle, with " << nMGLevels << " multigrid levels."<< endl;
68236819
if (MGCycle == W_CYCLE) cout << "W Multigrid Cycle, with " << nMGLevels << " multigrid levels."<< endl;
68246820
if (MGCycle == FULLMG_CYCLE) cout << "Full Multigrid Cycle, with " << nMGLevels << " multigrid levels."<< endl;

SU2_CFD/include/integration/CNewtonIntegration.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class CNewtonIntegration final : public CIntegration {
6262

6363
private:
6464
/*--- Residual evaluation modes, explicit for products, default to allow preconditioners to be built. ---*/
65-
enum ResEvalType {EXPLICIT, DEFAULT};
65+
enum class ResEvalType {EXPLICIT, DEFAULT};
6666

6767
bool setup = false;
6868
Scalar finDiffStepND = 0.0;

SU2_CFD/src/integration/CNewtonIntegration.cpp

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ void CNewtonIntegration::ComputeResiduals(ResEvalType type) {
120120

121121
/*--- Save the default integration scheme, and force to explicit if required. ---*/
122122
auto TimeIntScheme = config->GetKind_TimeIntScheme();
123-
if (type == EXPLICIT) {
123+
if (type == ResEvalType::EXPLICIT) {
124124
SU2_OMP_MASTER
125125
config->SetKind_TimeIntScheme(EULER_EXPLICIT);
126126
END_SU2_OMP_MASTER
@@ -129,10 +129,14 @@ void CNewtonIntegration::ComputeResiduals(ResEvalType type) {
129129

130130
solvers[FLOW_SOL]->Preprocessing(geometry, solvers, config, MESH_0, NO_RK_ITER, RUNTIME_FLOW_SYS, false);
131131

132+
if (type == ResEvalType::DEFAULT) {
133+
solvers[FLOW_SOL]->SetTime_Step(geometry, solvers, config, MESH_0, config->GetTimeIter());
134+
}
135+
132136
Space_Integration(geometry, solvers, numerics[FLOW_SOL], config, MESH_0, NO_RK_ITER, RUNTIME_FLOW_SYS);
133137

134138
/*--- Restore default. ---*/
135-
if (type == EXPLICIT) {
139+
if (type == ResEvalType::EXPLICIT) {
136140
SU2_OMP_MASTER
137141
config->SetKind_TimeIntScheme(TimeIntScheme);
138142
END_SU2_OMP_MASTER
@@ -187,12 +191,10 @@ void CNewtonIntegration::MultiGrid_Iteration(CGeometry ****geometry_, CSolver **
187191

188192
/*--- Current residual. ---*/
189193

190-
ComputeResiduals(DEFAULT);
194+
ComputeResiduals(ResEvalType::DEFAULT);
191195

192196
/*--- Compute the approximate Jacobian for preconditioning. ---*/
193197

194-
solvers[FLOW_SOL]->SetTime_Step(geometry, solvers, config, MESH_0, config->GetTimeIter());
195-
196198
solvers[FLOW_SOL]->PrepareImplicitIteration(geometry, solvers, config);
197199

198200
if (preconditioner) preconditioner->Build();
@@ -304,7 +306,7 @@ void CNewtonIntegration::MatrixFreeProduct(const CSysVector<Scalar>& u, CSysVect
304306

305307
PerturbSolution(u, factor);
306308

307-
ComputeResiduals(EXPLICIT);
309+
ComputeResiduals(ResEvalType::EXPLICIT);
308310

309311
/*--- Finalize product. ---*/
310312
factor = 1.0 / factor;
@@ -339,9 +341,13 @@ void CNewtonIntegration::Preconditioner(const CSysVector<Scalar>& u, CSysVector<
339341
else {
340342
/*--- Approximate diagonal preconditioner. ---*/
341343

344+
const bool dt1st = (config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_1ST);
345+
const bool dt2nd = (config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_2ND);
346+
const su2double dt = config->GetDelta_UnstTimeND() * (dt1st + 1.5 * dt2nd);
347+
342348
SU2_OMP_FOR_STAT(omp_chunk_size)
343349
for (auto iPoint = 0ul; iPoint < geometry->GetnPointDomain(); ++iPoint) {
344-
su2double delta = solvers[FLOW_SOL]->GetNodes()->GetDelta_Time(iPoint) /
350+
su2double delta = (solvers[FLOW_SOL]->GetNodes()->GetDelta_Time(iPoint) + dt) /
345351
(geometry->nodes->GetVolume(iPoint) + geometry->nodes->GetPeriodicVolume(iPoint));
346352
SU2_OMP_SIMD
347353
for (auto iVar = 0ul; iVar < u.GetNVar(); ++iVar)

0 commit comments

Comments
 (0)