Skip to content

Commit 81272cc

Browse files
committed
fix unsteady restart
1 parent 764b3be commit 81272cc

File tree

3 files changed

+82
-2
lines changed

3 files changed

+82
-2
lines changed

SU2_CFD/include/solvers/CSpeciesSolver.hpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,24 @@ 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 FEM structural 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] ExtIter - External iteration.
172+
*/
173+
void SetInitialCondition(CGeometry **geometry,
174+
CSolver ***solver_container,
175+
CConfig *config,
176+
unsigned long TimeIter) override;
177+
178+
/*!
179+
* \brief Move solution to previous time levels (for restarts).
180+
*/
181+
void PushSolutionBackInTime(unsigned long TimeIter, bool restart, CSolver*** solver_container,
182+
CGeometry** geometry, CConfig* config);
183+
166184
/*!
167185
* \brief Impose the fluid interface boundary condition using tranfer data.
168186
* \param[in] geometry - Geometrical definition of the problem.

SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp

Lines changed: 7 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,10 @@ void CSpeciesFlameletSolver::SetInitialCondition(CGeometry** geometry, CSolver**
311312
<< n_not_iterated_global << " !!!" << endl;
312313
}
313314
}
315+
316+
/*--- All the unsteady initialization ---*/
317+
CSpeciesSolver::PushSolutionBackInTime(ExtIter, restart, solver_container, geometry, config);
318+
314319
}
315320

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

SU2_CFD/src/solvers/CSpeciesSolver.cpp

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

572572
}
573+
574+
575+
void CSpeciesSolver::SetInitialCondition(CGeometry **geometry, CSolver ***solver_container, CConfig *config, unsigned long TimeIter) {
576+
577+
const bool restart = (config->GetRestart() || config->GetRestart_Flow());
578+
579+
PushSolutionBackInTime(TimeIter, restart, solver_container, geometry,config);
580+
}
581+
582+
void CSpeciesSolver::PushSolutionBackInTime(unsigned long TimeIter, bool restart, CSolver*** solver_container,
583+
CGeometry** geometry, CConfig* config) {
584+
585+
586+
const bool dual_time = ((config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_1ST) ||
587+
(config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_2ND));
588+
589+
590+
/*--- If restart solution, then interpolate the flow solution to
591+
all the multigrid levels, this is important with the dual time strategy ---*/
592+
593+
if (restart && (TimeIter == 0)) {
594+
595+
for (auto iMesh = 1u; iMesh <= config->GetnMGLevels(); iMesh++) {
596+
MultigridRestriction(*geometry[iMesh - 1], solver_container[iMesh - 1][SPECIES_SOL]->GetNodes()->GetSolution(),
597+
*geometry[iMesh], solver_container[iMesh][SPECIES_SOL]->GetNodes()->GetSolution());
598+
solver_container[iMesh][SPECIES_SOL]->InitiateComms(geometry[iMesh], config, MPI_QUANTITIES::SOLUTION);
599+
solver_container[iMesh][SPECIES_SOL]->CompleteComms(geometry[iMesh], config, MPI_QUANTITIES::SOLUTION);
600+
}
601+
}
602+
603+
/*--- The value of the solution for the first iteration of the dual time ---*/
604+
605+
if (dual_time && (TimeIter == 0 || (restart && (long)TimeIter == (long)config->GetRestart_Iter()))) {
606+
607+
/*--- Push back the initial condition to previous solution containers
608+
for a 1st-order restart or when simply intitializing to freestream. ---*/
609+
610+
for (auto iMesh = 0u; iMesh <= config->GetnMGLevels(); iMesh++) {
611+
solver_container[iMesh][SPECIES_SOL]->GetNodes()->Set_Solution_time_n();
612+
solver_container[iMesh][SPECIES_SOL]->GetNodes()->Set_Solution_time_n1();
613+
}
614+
615+
if ((restart && (long)TimeIter == (long)config->GetRestart_Iter()) &&
616+
(config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_2ND)) {
617+
618+
/*--- Load an additional restart file for a 2nd-order restart ---*/
619+
620+
solver_container[MESH_0][SPECIES_SOL]->LoadRestart(geometry, solver_container, config, SU2_TYPE::Int(config->GetRestart_Iter()-1), true);
621+
622+
/*--- Push back this new solution to time level N. ---*/
623+
624+
for (auto iMesh = 0u; iMesh <= config->GetnMGLevels(); iMesh++) {
625+
solver_container[iMesh][SPECIES_SOL]->GetNodes()->Set_Solution_time_n();
626+
}
627+
}
628+
}
629+
}

0 commit comments

Comments
 (0)