Skip to content

Commit a928ecb

Browse files
Fix species unsteady restart (#2542)
* fix unsteady restart Co-authored-by: Pedro Gomes <[email protected]>
1 parent 8f0e9b9 commit a928ecb

File tree

5 files changed

+61
-2
lines changed

5 files changed

+61
-2
lines changed

SU2_CFD/include/solvers/CScalarSolver.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,12 @@ class CScalarSolver : public CSolver {
380380
return edgeMassFlux;
381381
}
382382

383+
/*!
384+
* \brief Move solution to previous time levels (for restarts).
385+
*/
386+
void PushSolutionBackInTime(unsigned long TimeIter, bool restart, CSolver*** solver_container,
387+
CGeometry** geometry, CConfig* config);
388+
383389
/*!
384390
* \brief Gradient and Limiter computation.
385391
* \param[in] geometry - Geometrical definition of the problem.

SU2_CFD/include/solvers/CScalarSolver.inl

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -832,3 +832,33 @@ void CScalarSolver<VariableType>::SetResidual_DualTime(CGeometry* geometry, CSol
832832

833833
} // end dynamic grid
834834
}
835+
836+
837+
template <class VariableType>
838+
void CScalarSolver<VariableType>::PushSolutionBackInTime(unsigned long TimeIter, bool
839+
restart,CSolver*** solver_container,
840+
CGeometry** geometry, CConfig* config) {
841+
const bool dual_time = config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_1ST ||
842+
config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_2ND;
843+
const bool isRestartIter = restart && TimeIter == config->GetRestart_Iter();
844+
845+
/*--- The value of the solution for the first iteration of the dual time. ---*/
846+
847+
if (dual_time && (TimeIter == 0 || isRestartIter)) {
848+
/*--- Push back the initial condition to previous solution containers
849+
for a 1st-order restart or when simply initializing to freestream. ---*/
850+
851+
nodes->Set_Solution_time_n();
852+
nodes->Set_Solution_time_n1();
853+
854+
if (isRestartIter && config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_2ND) {
855+
/*--- Load an additional restart file for a 2nd-order restart ---*/
856+
857+
LoadRestart(geometry, solver_container, config, SU2_TYPE::Int(config->GetRestart_Iter()-1), true);
858+
859+
/*--- Push back this new solution to time level N. ---*/
860+
861+
nodes->Set_Solution_time_n();
862+
}
863+
}
864+
}

SU2_CFD/include/solvers/CSpeciesSolver.hpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,18 @@ class CSpeciesSolver : public CScalarSolver<CSpeciesVariable> {
163163
void Source_Residual(CGeometry* geometry, CSolver** solver_container, CNumerics** numerics_container, CConfig* config,
164164
unsigned short iMesh) override;
165165

166+
/*!
167+
* \brief Set the initial condition for the Species transport problem.
168+
* \param[in] geometry - Geometrical definition of the problem.
169+
* \param[in] solver_container - Container with all the solutions.
170+
* \param[in] config - Definition of the particular problem.
171+
* \param[in] TimeIter - Time iteration.
172+
*/
173+
void SetInitialCondition(CGeometry **geometry,
174+
CSolver ***solver_container,
175+
CConfig *config,
176+
unsigned long TimeIter) override;
177+
166178
/*!
167179
* \brief Impose the fluid interface boundary condition using tranfer data.
168180
* \param[in] geometry - Geometrical definition of the problem.

SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,9 @@ void CSpeciesFlameletSolver::Preprocessing(CGeometry* geometry, CSolver** solver
152152

153153
void CSpeciesFlameletSolver::SetInitialCondition(CGeometry** geometry, CSolver*** solver_container, CConfig* config,
154154
unsigned long ExtIter) {
155-
const bool Restart = (config->GetRestart() || config->GetRestart_Flow());
155+
const bool restart = (config->GetRestart() || config->GetRestart_Flow());
156156

157-
if ((!Restart) && ExtIter == 0) {
157+
if ((!restart) && ExtIter == 0) {
158158
if (rank == MASTER_NODE) {
159159
cout << "Initializing progress variable and total enthalpy (using temperature)" << endl;
160160
}
@@ -200,6 +200,7 @@ void CSpeciesFlameletSolver::SetInitialCondition(CGeometry** geometry, CSolver**
200200
default:
201201
break;
202202
}
203+
203204
}
204205

205206
CFluidModel* fluid_model_local;
@@ -311,6 +312,9 @@ void CSpeciesFlameletSolver::SetInitialCondition(CGeometry** geometry, CSolver**
311312
<< n_not_iterated_global << " !!!" << endl;
312313
}
313314
}
315+
316+
/*--- All the unsteady initialization ---*/
317+
PushSolutionBackInTime(ExtIter, restart, solver_container, geometry, config);
314318
}
315319

316320
void CSpeciesFlameletSolver::SetPreconditioner(CGeometry* geometry, CSolver** solver_container, CConfig* config) {

SU2_CFD/src/solvers/CSpeciesSolver.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,3 +570,10 @@ void CSpeciesSolver::Source_Residual(CGeometry *geometry, CSolver **solver_conta
570570
}
571571

572572
}
573+
574+
void CSpeciesSolver::SetInitialCondition(CGeometry **geometry, CSolver ***solver_container, CConfig *config, unsigned long TimeIter) {
575+
576+
const bool restart = config->GetRestart() || config->GetRestart_Flow();
577+
578+
PushSolutionBackInTime(TimeIter, restart, solver_container, geometry, config);
579+
}

0 commit comments

Comments
 (0)