Skip to content

Commit 45ab051

Browse files
committed
move to scalarsolver
1 parent 81272cc commit 45ab051

File tree

5 files changed

+48
-56
lines changed

5 files changed

+48
-56
lines changed

SU2_CFD/include/solvers/CScalarSolver.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,12 @@ class CScalarSolver : public CSolver {
508508
void LoadRestart(CGeometry** geometry, CSolver*** solver, CConfig* config, int val_iter,
509509
bool val_update_geo) override = 0;
510510

511+
/*!
512+
* \brief Move solution to previous time levels (for restarts).
513+
*/
514+
void PushSolutionBackInTime(unsigned long TimeIter, bool restart,CSolver*** solver_container,
515+
CGeometry** geometry, CConfig* config);
516+
511517
/*!
512518
* \brief Scalar solvers support OpenMP+MPI.
513519
*/

SU2_CFD/include/solvers/CScalarSolver.inl

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -832,3 +832,37 @@ 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 restart,CSolver*** solver_container,
839+
CGeometry** geometry, CConfig* config) {
840+
const bool dual_time = ((config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_1ST) ||
841+
(config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_2ND));
842+
/*--- The value of the solution for the first iteration of the dual time ---*/
843+
844+
if (dual_time && (TimeIter == 0 || (restart && (long)TimeIter == (long)config->GetRestart_Iter()))) {
845+
846+
/*--- Push back the initial condition to previous solution containers
847+
for a 1st-order restart or when simply intitializing to freestream. ---*/
848+
849+
for (auto iMesh = 0u; iMesh <= config->GetnMGLevels(); iMesh++) {
850+
nodes->Set_Solution_time_n();
851+
nodes->Set_Solution_time_n1();
852+
}
853+
854+
if ((restart && (long)TimeIter == (long)config->GetRestart_Iter()) &&
855+
(config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_2ND)) {
856+
857+
/*--- Load an additional restart file for a 2nd-order restart ---*/
858+
859+
LoadRestart(geometry, solver_container, config, SU2_TYPE::Int(config->GetRestart_Iter()-1), true);
860+
861+
/*--- Push back this new solution to time level N. ---*/
862+
863+
for (auto iMesh = 0u; iMesh <= config->GetnMGLevels(); iMesh++) {
864+
nodes->Set_Solution_time_n();
865+
}
866+
}
867+
}
868+
}

SU2_CFD/include/solvers/CSpeciesSolver.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,8 @@ class CSpeciesSolver : public CScalarSolver<CSpeciesVariable> {
178178
/*!
179179
* \brief Move solution to previous time levels (for restarts).
180180
*/
181-
void PushSolutionBackInTime(unsigned long TimeIter, bool restart, CSolver*** solver_container,
182-
CGeometry** geometry, CConfig* config);
181+
//void PushSolutionBackInTime(unsigned long TimeIter, bool restart, CSolver*** solver_container,
182+
// CGeometry** geometry, CConfig* config);
183183

184184
/*!
185185
* \brief Impose the fluid interface boundary condition using tranfer data.

SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
#include "../../include/variables/CFlowVariable.hpp"
3535
#include "../../include/variables/CSpeciesFlameletVariable.hpp"
3636

37+
/*--- Explicit instantiation of the parent class of CSpeciesFlameletSolver. ---*/
38+
//template class CScalarSolver<CSpeciesFlameletVariable>;
3739
CSpeciesFlameletSolver::CSpeciesFlameletSolver(CGeometry* geometry, CConfig* config, unsigned short iMesh)
3840
: CSpeciesSolver(geometry, config, true) {
3941

@@ -314,8 +316,8 @@ void CSpeciesFlameletSolver::SetInitialCondition(CGeometry** geometry, CSolver**
314316
}
315317

316318
/*--- All the unsteady initialization ---*/
317-
CSpeciesSolver::PushSolutionBackInTime(ExtIter, restart, solver_container, geometry, config);
318-
319+
//CScalarSolver<CSpeciesFlameletVariable>::PushSolutionBackInTime(ExtIter, restart, solver_container, geometry, config);
320+
CSpeciesSolver::SetInitialCondition(geometry, solver_container, config, ExtIter);
319321
}
320322

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

SU2_CFD/src/solvers/CSpeciesSolver.cpp

Lines changed: 2 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -571,59 +571,9 @@ void CSpeciesSolver::Source_Residual(CGeometry *geometry, CSolver **solver_conta
571571

572572
}
573573

574-
575574
void CSpeciesSolver::SetInitialCondition(CGeometry **geometry, CSolver ***solver_container, CConfig *config, unsigned long TimeIter) {
576575

577576
const bool restart = (config->GetRestart() || config->GetRestart_Flow());
578577

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-
}
578+
CScalarSolver<CSpeciesVariable>::PushSolutionBackInTime(TimeIter, restart, solver_container, geometry, config);
579+
}

0 commit comments

Comments
 (0)