@@ -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