Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
124 commits
Select commit Hold shift + click to select a range
509a608
my changes
Jun 17, 2025
6aeb0a3
my changes
Jun 17, 2025
79e238c
specieschanges
Sep 1, 2025
526b9a1
Remove slurm files from repository
Dec 10, 2025
59979d0
Remove unnecessary blank line in COutput.hpp
tkiymaz Dec 10, 2025
99abfa4
Clean up commented-out density setting code
tkiymaz Dec 10, 2025
bee5a27
Update density retrieval comment for transient handling
tkiymaz Dec 10, 2025
cea69cc
Remove empty line before temperature setter comment
tkiymaz Dec 10, 2025
a721a2e
Clean up whitespace in CIncEulerVariable.hpp
tkiymaz Dec 10, 2025
02c03bb
Clean up blank lines in CVariable.hpp
tkiymaz Dec 10, 2025
0449bb4
Clean up CFlowIncOutput.cpp by removing blank lines
tkiymaz Dec 10, 2025
572291f
Clean up CompleteImplicitIteration and update dRhodT
tkiymaz Dec 10, 2025
c9fd0f6
Revert back the preconditioning to original
tkiymaz Dec 10, 2025
fc33c6a
Remove unnecessary whitespace and debug print statement
tkiymaz Dec 10, 2025
644a543
Clean up blank lines in CIncNSVariable.cpp
tkiymaz Dec 10, 2025
fed4892
Clean up whitespace in CVariable.cpp
tkiymaz Dec 10, 2025
8e09f7f
Fix constructor signature for CSpeciesVariable
tkiymaz Dec 10, 2025
1e5008a
Remove unnecessary blank line in CSpeciesVariable.cpp
tkiymaz Dec 10, 2025
2aebc54
Fix constructor signature for CSpeciesFlameletVariable
tkiymaz Dec 10, 2025
3f19c55
Remove debug output from SetPrimVar method
tkiymaz Dec 10, 2025
f5b3f56
Merge branch 'develop' into fix_inc_unsteady_density
tkiymaz Dec 11, 2025
735c27b
Update SU2_CFD/include/variables/CVariable.hpp
bigfooted Dec 16, 2025
f9f98a0
Update SU2_CFD/include/output/COutput.hpp
bigfooted Dec 16, 2025
adf7581
Update SU2_CFD/include/variables/CIncEulerVariable.hpp
bigfooted Dec 16, 2025
cc06d7e
Update SU2_CFD/include/variables/CEulerVariable.hpp
bigfooted Dec 16, 2025
6f2a8eb
Update SU2_CFD/src/solvers/CIncEulerSolver.cpp
bigfooted Dec 16, 2025
fa318d2
Update SU2_CFD/src/variables/CVariable.cpp
bigfooted Dec 16, 2025
3e1b898
Update SU2_CFD/src/variables/CVariable.cpp
bigfooted Dec 16, 2025
87a3381
Update SU2_CFD/src/variables/CIncNSVariable.cpp
bigfooted Dec 16, 2025
b278ad6
Update SU2_CFD/src/variables/CIncNSVariable.cpp
bigfooted Dec 16, 2025
dda9271
Update SU2_CFD/src/variables/CIncEulerVariable.cpp
bigfooted Dec 16, 2025
ff74a7f
Update SU2_CFD/include/solvers/CFVMFlowSolverBase.inl
bigfooted Dec 16, 2025
c194c4f
Update SU2_CFD/src/variables/CIncEulerVariable.cpp
bigfooted Dec 16, 2025
ac17146
Update SU2_CFD/include/solvers/CFVMFlowSolverBase.inl
bigfooted Dec 16, 2025
35b018f
most of the second order stuff
bigfooted Dec 16, 2025
d14be6e
cleanup for second order method (not tested yet)
bigfooted Dec 16, 2025
6cc4073
merge w. develop
bigfooted Dec 16, 2025
83c3416
Merge branch 'develop' into fix_inc_unsteady_density
Cristopher-Morales Dec 17, 2025
459e3b4
Merge branch 'develop' into fix_inc_unsteady_density
Cristopher-Morales Dec 17, 2025
630856b
Update SU2_CFD/src/solvers/CIncEulerSolver.cpp
tkiymaz Dec 18, 2025
35ad976
Update SU2_CFD/src/solvers/CIncEulerSolver.cpp
tkiymaz Dec 18, 2025
31f8af3
Update SU2_CFD/src/solvers/CIncEulerSolver.cpp
tkiymaz Dec 18, 2025
00ae736
Potential fix for code scanning alert no. 5888: Unused local variable
bigfooted Dec 18, 2025
8a47539
Merge branch 'develop' into fix_inc_unsteady_density
Cristopher-Morales Dec 18, 2025
4f7a656
Merge branch 'develop' into fix_inc_unsteady_density
Cristopher-Morales Dec 18, 2025
df27a84
Update SU2_CFD/src/variables/CIncNSVariable.cpp
bigfooted Dec 24, 2025
51f18af
Merge branch 'develop' into fix_inc_unsteady_density
bigfooted Jan 6, 2026
524fd46
Merge branch 'develop' into fix_inc_unsteady_density
bigfooted Jan 13, 2026
acfe778
Merge branch 'develop' into fix_flame_init
bigfooted Jan 16, 2026
adedf6b
fix mpi and flame init
bigfooted Jan 16, 2026
69833df
Merge remote-tracking branch 'origin/fix_flame_init' into fix_inc_uns…
bigfooted Jan 16, 2026
89661d4
Merge branch 'fix_flame_init' into fix_inc_unsteady_density
bigfooted Jan 16, 2026
df28101
guards
bigfooted Jan 16, 2026
2308622
revert
bigfooted Jan 16, 2026
d529abe
Apply suggestion from @bigfooted
bigfooted Jan 16, 2026
02c3311
Apply suggestion from @bigfooted
bigfooted Jan 16, 2026
2364e90
Merge branch 'develop' into fix_inc_unsteady_density
bigfooted Jan 20, 2026
d4c5d18
Merge branch 'develop' into fix_inc_unsteady_density
bigfooted Mar 15, 2026
7899323
Merge branch 'fix_inc_unsteady_density' of https://github.com/su2code…
bigfooted Mar 15, 2026
b355867
update code
bigfooted Mar 15, 2026
76d652c
fix density registration for AD
bigfooted Mar 15, 2026
100c2cb
Merge branch 'develop' into fix_inc_unsteady_density
bigfooted Mar 17, 2026
1562607
Merge branch 'develop' into fix_inc_unsteady_density
bigfooted Mar 24, 2026
b8e840a
Merge branch 'develop' into fix_inc_unsteady_density
bigfooted Apr 4, 2026
ec308a5
Merge branch 'develop' into fix_inc_unsteady_density
bigfooted Apr 11, 2026
a7ab5b7
Merge branch 'develop' into fix_inc_unsteady_density
bigfooted Apr 21, 2026
4f5cdfa
merge with develop
Apr 21, 2026
0f538ea
update w. develop
bigfooted Apr 24, 2026
d12f7b3
update naming
bigfooted Apr 24, 2026
de4a95b
Merge branch 'develop' into fix_inc_unsteady_density
bigfooted Apr 24, 2026
f7775f0
Merge branch 'develop' into fix_inc_unsteady_density
bigfooted Apr 30, 2026
7905679
fix bounded scalar
bigfooted Apr 30, 2026
b2a9094
fix restart, add regression
bigfooted Apr 30, 2026
f10305e
point github workflow to temporary testcases branch
bigfooted Apr 30, 2026
f5e0e34
Jacobian update for unsteady density
May 1, 2026
b71c7ff
extension of bounded scalar fix to RANS
May 1, 2026
b359140
change OMP call
bigfooted May 3, 2026
5f7e34d
Update SU2_CFD/include/solvers/CSpeciesSolver.hpp
tkiymaz May 13, 2026
3a7553e
Update SU2_CFD/include/solvers/CTurbSolver.hpp
tkiymaz May 13, 2026
663105f
formating and addition of bool functions
May 13, 2026
c25ac53
Merge branch 'develop' into fix_inc_unsteady_density
bigfooted Jun 14, 2026
3573190
Merge branch 'develop' into fix_inc_unsteady_density
bigfooted Jun 24, 2026
110d585
Merge branch 'develop' into fix_inc_unsteady_density
bigfooted Jun 30, 2026
ec56eb3
overload getdensity_time_n
bigfooted Jul 14, 2026
2e5ccec
Merge branch 'develop' into fix_inc_unsteady_density
bigfooted Jul 14, 2026
3ea82e7
overload density
bigfooted Jul 14, 2026
afdc9d5
Merge branch 'fix_inc_unsteady_density' of https://github.com/su2code…
bigfooted Jul 14, 2026
c40865f
registerdensity is part of registersolution
bigfooted Jul 14, 2026
8cc8bbe
Potential fix for pull request finding 'CodeQL / Unused local variable'
bigfooted Jul 14, 2026
879d3ba
update testcase
bigfooted Jul 14, 2026
c9c2c82
Merge branch 'fix_inc_unsteady_density' of https://github.com/su2code…
bigfooted Jul 14, 2026
40c4f72
Apply suggestion from @bigfooted
bigfooted Jul 14, 2026
42eee98
Apply suggestion from @bigfooted
bigfooted Jul 14, 2026
6b9c7ac
update bounded scalar for compressible
bigfooted Jul 14, 2026
cffd048
Merge branch 'fix_inc_unsteady_density' of https://github.com/su2code…
bigfooted Jul 14, 2026
08325f0
Merge branch 'develop' into fix_inc_unsteady_density
bigfooted Jul 15, 2026
dfdba2f
update testcase
bigfooted Jul 15, 2026
e238ab2
Merge branch 'fix_inc_unsteady_density' of https://github.com/su2code…
bigfooted Jul 15, 2026
d406376
update testcase
bigfooted Jul 15, 2026
0a5e693
update regressions
bigfooted Jul 15, 2026
820cb75
fix codi
bigfooted Jul 15, 2026
4be14fd
small cleanup
bigfooted Jul 15, 2026
12fd1f6
drop unused CIncEulerVariable include in CFlowIncOutput
Jul 23, 2026
324d94d
remove dead density adjoint hooks, error out on unsteady adj + variab…
Jul 23, 2026
de8eb53
store bounded_scalar as CScalarSolver member instead of virtual
Jul 23, 2026
abe9e19
recompute dual-time density each step (fixes MG + restart)
Jul 24, 2026
8120bda
remove silent-0 GetDensity_time_n base, cast at scalar-solver call
Jul 24, 2026
f952be0
Update SU2_CFD/include/variables/CIncEulerVariable.hpp
tkiymaz Jul 28, 2026
b3d27b5
Update SU2_CFD/include/solvers/CIncEulerSolver.hpp
tkiymaz Jul 28, 2026
de69cbb
Update SU2_CFD/include/solvers/CScalarSolver.inl
tkiymaz Jul 28, 2026
2cee943
Update SU2_CFD/include/solvers/CScalarSolver.inl
tkiymaz Jul 28, 2026
07a7515
Update SU2_CFD/include/variables/CIncEulerVariable.hpp
tkiymaz Jul 28, 2026
c40ff80
Update SU2_CFD/src/solvers/CIncEulerSolver.cpp
tkiymaz Jul 28, 2026
ea6223b
Update SU2_CFD/src/variables/CIncEulerVariable.cpp
tkiymaz Jul 28, 2026
ac568ba
revert CVariable, make GetDensity_time_n pure virtual with final over…
Jul 28, 2026
ffaa9ac
enable unsteady adjoint with variable density, reject MG + scalar-dep…
Jul 28, 2026
725cc73
Merge branch 'develop' into fix_inc_unsteady_density
tkiymaz Jul 28, 2026
ed698bc
restore develop test_vals for unsteady_naca0012
Jul 29, 2026
1ee51f2
Merge branch 'develop' into fix_inc_unsteady_density
bigfooted Aug 3, 2026
b46633d
update AD regression residuals for variable-density adjoint
Aug 6, 2026
748dbbe
Merge branch 'develop' into fix_inc_unsteady_density
bigfooted Aug 12, 2026
9157de8
Apply suggestion from @bigfooted
bigfooted Aug 12, 2026
96f7a12
Apply suggestions from code review
bigfooted Aug 12, 2026
7610a32
fix periodic regression
bigfooted Aug 12, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Common/src/CConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5764,6 +5764,14 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i
Kind_Solver != MAIN_SOLVER::MULTIPHYSICS)
SU2_MPI::Error("Species transport currently only available for compressible and incompressible flow.", CURRENT_FUNCTION);

/*--- The dual-time density history is recomputed via the fluid model, which needs the species
solution; the species solver only exists on the finest grid. ---*/
if ((Kind_Regime == ENUM_REGIME::INCOMPRESSIBLE) && (Kind_DensityModel != INC_DENSITYMODEL::CONSTANT) &&
(TimeMarching == TIME_MARCHING::DT_STEPPING_1ST || TimeMarching == TIME_MARCHING::DT_STEPPING_2ND) &&
(nMGLevels > 0))
SU2_MPI::Error("Dual-time stepping with species-dependent variable density does not support MGLEVEL > 0.",
CURRENT_FUNCTION);

/*--- Species specific OF currently can only handle one entry in Marker_Analyze. ---*/
for (unsigned short iObj = 0; iObj < nObj; iObj++) {
if ((Kind_ObjFunc[iObj] == SURFACE_SPECIES_0 ||
Expand Down
12 changes: 12 additions & 0 deletions SU2_CFD/include/solvers/CIncEulerSolver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,18 @@ class CIncEulerSolver : public CFVMFlowSolverBase<CIncEulerVariable, ENUM_REGIME
*/
virtual unsigned long SetPrimitive_Variables(CSolver **solver_container, const CConfig *config);

/*!
* \brief Recompute the dual-time density history (rho_n, rho_n-1) from the stored
* solution histories (Solution_time_n[,1], and the species histories for
* flamelet/variable-density) via the fluid model.
* \details Called once per physical time step (InnerIter == 0), after the solution
* push-back. This keeps the density history consistent with the primitive
* state at time n (also after restart).
* \param[in] solver_container - Container vector with all the solutions.
* \param[in] config - Definition of the particular problem.
*/
void RecomputeDensity_time_n(CSolver **solver_container, const CConfig *config);

/*!
* \brief Update the Beta parameter for the incompressible preconditioner.
* \param[in] geometry - Geometrical definition of the problem.
Expand Down
3 changes: 2 additions & 1 deletion SU2_CFD/include/solvers/CScalarSolver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class CScalarSolver : public CSolver {
su2double Solution_Inf[MAXNVAR]; /*!< \brief Far-field solution. */

const bool Conservative; /*!< \brief Transported Variable is conservative. Solution has to be multiplied with rho. */
const bool BoundedScalar; /*!< \brief Whether the derived solver uses the bounded-scalar convective scheme. */

const CPrimitiveIndices<unsigned short> prim_idx; /*!< \brief Indices of the primitive flow variables. */

Expand Down Expand Up @@ -440,7 +441,7 @@ class CScalarSolver : public CSolver {
* \param[in] geometry - Geometrical definition of the problem.
* \param[in] config - Definition of the particular problem.
*/
CScalarSolver(CGeometry* geometry, CConfig* config, bool conservative);
CScalarSolver(CGeometry* geometry, CConfig* config, bool conservative, bool bounded_scalar);

/*!
* \brief Compute the spatial integration using a upwind scheme.
Expand Down
96 changes: 46 additions & 50 deletions SU2_CFD/include/solvers/CScalarSolver.inl
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
#include "../../include/variables/CFlowVariable.hpp"

template <class VariableType>
CScalarSolver<VariableType>::CScalarSolver(CGeometry* geometry, CConfig* config, bool conservative)
: CSolver(), Conservative(conservative),
CScalarSolver<VariableType>::CScalarSolver(CGeometry* geometry, CConfig* config, bool conservative, bool bounded_scalar)
: CSolver(), Conservative(conservative), BoundedScalar(bounded_scalar),
prim_idx(config->GetKind_Regime() == ENUM_REGIME::INCOMPRESSIBLE,
config->GetNEMOProblem(), geometry->GetnDim(), config->GetnSpecies()) {
SU2_ZONE_SCOPED
Expand Down Expand Up @@ -639,11 +639,11 @@ void CScalarSolver<VariableType>::SetResidual_DualTime(CGeometry* geometry, CSol
const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT);
const bool first_order = (config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_1ST);
const bool second_order = (config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_2ND);
const bool incompressible = (config->GetKind_Regime() == ENUM_REGIME::INCOMPRESSIBLE);

/*--- Flow solution, needed to get density. ---*/
const bool bounded_scalar = BoundedScalar;

CVariable* flowNodes = solver_container[FLOW_SOL]->GetNodes();
/*--- Flow solution, needed to get density. ---*/
auto* flowNodes = su2staticcast_p<CFlowVariable*>(solver_container[FLOW_SOL]->GetNodes());

/*--- Store the physical time step ---*/

Expand Down Expand Up @@ -671,19 +671,9 @@ void CScalarSolver<VariableType>::SetResidual_DualTime(CGeometry* geometry, CSol
SU2_OMP_FOR_STAT(omp_chunk_size)
for (iPoint = 0; iPoint < nPointDomain; iPoint++) {
if (Conservative) {
if (incompressible) {
/*--- This is temporary and only valid for constant-density problems:
density could also be temperature dependent, but as it is not a part
of the solution vector it's neither stored for previous time steps
nor updated with the solution at the end of each iteration. */
Density_nM1 = flowNodes->GetDensity(iPoint);
Density_n = flowNodes->GetDensity(iPoint);
Density_nP1 = flowNodes->GetDensity(iPoint);
} else {
Density_nM1 = flowNodes->GetSolution_time_n1(iPoint)[0];
Density_n = flowNodes->GetSolution_time_n(iPoint, 0);
Density_nP1 = flowNodes->GetSolution(iPoint, 0);
}
Density_nM1 = flowNodes->GetDensity_time_n1(iPoint);
Density_n = flowNodes->GetDensity_time_n(iPoint);
Density_nP1 = flowNodes->GetDensity(iPoint);
}

/*--- Retrieve the solution at time levels n-1, n, and n+1. Note that
Expand All @@ -703,13 +693,20 @@ void CScalarSolver<VariableType>::SetResidual_DualTime(CGeometry* geometry, CSol
time discretization scheme (1st- or 2nd-order).---*/

for (iVar = 0; iVar < nVar; iVar++) {
su2double unsteady_term = 0.0;
if (first_order)
LinSysRes(iPoint, iVar) +=
(Density_nP1 * U_time_nP1[iVar] - Density_n * U_time_n[iVar]) * Volume_nP1 / TimeStep;
unsteady_term = (Density_nP1 * U_time_nP1[iVar] - Density_n * U_time_n[iVar]) * Volume_nP1 / TimeStep;
if (second_order)
LinSysRes(iPoint, iVar) += (3.0 * Density_nP1 * U_time_nP1[iVar] - 4.0 * Density_n * U_time_n[iVar] +
unsteady_term = (3.0 * Density_nP1 * U_time_nP1[iVar] - 4.0 * Density_n * U_time_n[iVar] +
1.0 * Density_nM1 * U_time_nM1[iVar]) *
Volume_nP1 / (2.0 * TimeStep);

if (bounded_scalar) {
if (first_order) unsteady_term -= U_time_nP1[iVar] * (Density_nP1 - Density_n) * Volume_nP1 / TimeStep;
Comment thread
bigfooted marked this conversation as resolved.
if (second_order) unsteady_term -= U_time_nP1[iVar] * (3.0 * Density_nP1 - 4.0 * Density_n + 1.0 * Density_nM1) * Volume_nP1 / (2.0 * TimeStep);
}

LinSysRes(iPoint, iVar) += unsteady_term;
}

/*--- Compute the Jacobian contribution due to the dual time source term. ---*/
Expand Down Expand Up @@ -737,10 +734,7 @@ void CScalarSolver<VariableType>::SetResidual_DualTime(CGeometry* geometry, CSol
U_time_n = nodes->GetSolution_time_n(iPoint);

if (Conservative) {
if (incompressible)
Density_n = flowNodes->GetDensity(iPoint); // Temporary fix
else
Density_n = flowNodes->GetSolution_time_n(iPoint, 0);
Density_n = flowNodes->GetDensity_time_n(iPoint);
}

for (iNeigh = 0; iNeigh < geometry->nodes->GetnPoint(iPoint); iNeigh++) {
Expand Down Expand Up @@ -793,10 +787,7 @@ void CScalarSolver<VariableType>::SetResidual_DualTime(CGeometry* geometry, CSol
/*--- Multiply by density at node i for the SST model ---*/

if (Conservative) {
if (incompressible)
Density_n = flowNodes->GetDensity(iPoint); // Temporary fix
else
Density_n = flowNodes->GetSolution_time_n(iPoint, 0);
Density_n = flowNodes->GetDensity_time_n(iPoint);
}

for (iVar = 0; iVar < nVar; iVar++) LinSysRes(iPoint, iVar) += Density_n * U_time_n[iVar] * Residual_GCL;
Expand Down Expand Up @@ -832,37 +823,42 @@ void CScalarSolver<VariableType>::SetResidual_DualTime(CGeometry* geometry, CSol
due to the time discretization has a new form.---*/

if (Conservative) {
/*--- If this is the SST model, we need to multiply by the density
in order to get the conservative variables ---*/
if (incompressible) {
/*--- This is temporary and only valid for constant-density problems:
density could also be temperature dependent, but as it is not a part
of the solution vector it's neither stored for previous time steps
nor updated with the solution at the end of each iteration. */
Density_nM1 = flowNodes->GetDensity(iPoint);
Density_n = flowNodes->GetDensity(iPoint);
Density_nP1 = flowNodes->GetDensity(iPoint);
} else {
Density_nM1 = flowNodes->GetSolution_time_n1(iPoint)[0];
Density_n = flowNodes->GetSolution_time_n(iPoint, 0);
Density_nP1 = flowNodes->GetSolution(iPoint, 0);
}
/*--- Get density at different time levels via virtual methods ---*/
Density_nM1 = flowNodes->GetDensity_time_n1(iPoint);
Density_n = flowNodes->GetDensity_time_n(iPoint);
Density_nP1 = flowNodes->GetDensity(iPoint);
}

for (iVar = 0; iVar < nVar; iVar++) {
su2double unsteady_term = 0.0;
if (first_order)
LinSysRes(iPoint, iVar) +=
(Density_nP1 * U_time_nP1[iVar] - Density_n * U_time_n[iVar]) * (Volume_nP1 / TimeStep);
unsteady_term = (Density_nP1 * U_time_nP1[iVar] - Density_n * U_time_n[iVar]) * (Volume_nP1 / TimeStep);
if (second_order)
LinSysRes(iPoint, iVar) +=
(Density_nP1 * U_time_nP1[iVar] - Density_n * U_time_n[iVar]) * (3.0 * Volume_nP1 / (2.0 * TimeStep)) +
unsteady_term = (Density_nP1 * U_time_nP1[iVar] - Density_n * U_time_n[iVar]) * (3.0 * Volume_nP1 / (2.0 * TimeStep)) +
(Density_nM1 * U_time_nM1[iVar] - Density_n * U_time_n[iVar]) * (Volume_nM1 / (2.0 * TimeStep));

if (bounded_scalar) {
if (first_order) unsteady_term -= U_time_nP1[iVar] * (Density_nP1 - Density_n) * (Volume_nP1 / TimeStep);
if (second_order) unsteady_term -= U_time_nP1[iVar] * ((Density_nP1 - Density_n) * (3.0 * Volume_nP1 / (2.0 * TimeStep)) +
(Density_nM1 - Density_n) * (Volume_nM1 / (2.0 * TimeStep)));
}

LinSysRes(iPoint, iVar) += unsteady_term;
}

/*--- Compute the Jacobian contribution due to the dual time source term. ---*/
if (implicit) {
if (first_order) Jacobian.AddVal2Diag(iPoint, Volume_nP1 / TimeStep);
if (second_order) Jacobian.AddVal2Diag(iPoint, (Volume_nP1 * 3.0) / (2.0 * TimeStep));
su2double diag_factor = 1.0;
if (Conservative) {
if (bounded_scalar) {
if (first_order) diag_factor = Density_n;
if (second_order) diag_factor = (4.0 * Density_n - Density_nM1) / 3.0;
} else {
diag_factor = Density_nP1;
}
}
if (first_order) Jacobian.AddVal2Diag(iPoint, diag_factor * Volume_nP1 / TimeStep);
if (second_order) Jacobian.AddVal2Diag(iPoint, diag_factor * 3.0 * Volume_nP1 / (2.0 * TimeStep));
}
}
END_SU2_OMP_FOR
Expand Down
2 changes: 1 addition & 1 deletion SU2_CFD/include/solvers/CTurbSolver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class CTurbSolver : public CScalarSolver<CTurbVariable> {
* \returns The number of extra variables.
*/
unsigned long RegisterSolutionExtra(bool input, const CConfig* config) final;

/*!
* \brief Compute a suitable under-relaxation parameter to limit the change in the solution variables over
* a nonlinear iteration for stability.
Expand Down
14 changes: 14 additions & 0 deletions SU2_CFD/include/variables/CEulerVariable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,20 @@ class CEulerVariable : public CFlowVariable {
CEulerVariable(su2double density, const su2double *velocity, su2double energy,
unsigned long npoint, unsigned long ndim, unsigned long nvar, const CConfig *config);

/*!
* \brief Get the density at time level n for dual-time stepping.
* \param[in] iPoint - Point index.
* \return Density at time level n.
*/
inline su2double GetDensity_time_n(unsigned long iPoint) const final { return GetSolution_time_n(iPoint, 0); }

/*!
* \brief Get the density at time level n-1 for dual-time stepping.
* \param[in] iPoint - Point index.
* \return Density at time level n-1.
*/
inline su2double GetDensity_time_n1(unsigned long iPoint) const final { return GetSolution_time_n1(iPoint, 0); }

/*!
* \brief A virtual member.
*/
Expand Down
14 changes: 14 additions & 0 deletions SU2_CFD/include/variables/CFlowVariable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,4 +270,18 @@ class CFlowVariable : public CVariable {
* \return Vector of magnitudes.
*/
inline su2activevector& GetStrainMag() { return StrainMag; }

/*!
* \brief Get the density at time level n for dual-time stepping.
* \param[in] iPoint - Point index.
* \return Density at time level n.
*/
virtual su2double GetDensity_time_n(unsigned long iPoint) const = 0;

/*!
* \brief Get the density at time level n-1 for dual-time stepping.
* \param[in] iPoint - Point index.
* \return Density at time level n-1.
*/
virtual su2double GetDensity_time_n1(unsigned long iPoint) const = 0;
};
34 changes: 34 additions & 0 deletions SU2_CFD/include/variables/CIncEulerVariable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ class CIncEulerVariable : public CFlowVariable {

VectorType Streamwise_Periodic_RecoveredPressure, /*!< \brief Recovered/Physical pressure [Pa] for streamwise periodic flow. */
Streamwise_Periodic_RecoveredTemperature; /*!< \brief Recovered/Physical temperature [K] for streamwise periodic flow. */
VectorType Density_time_n, /*!< \brief Density at time n for dual-time stepping. */
Density_time_n1; /*!< \brief Density at time n-1 for dual-time stepping. */
Comment thread
pcarruscag marked this conversation as resolved.
su2double TemperatureLimits[2]; /*!< \brief Temperature limits [K]. */
public:
/*!
Expand Down Expand Up @@ -291,4 +293,36 @@ class CIncEulerVariable : public CFlowVariable {
for (unsigned long iDim = 0; iDim < nDim; iDim++) Solution(iPoint, iDim+1) = val_vector[iDim];
}

/*!
* \brief Get the density at time level n for dual-time stepping.
* \param[in] iPoint - Point index.
* \return Density at time level n.
*/
inline su2double GetDensity_time_n(unsigned long iPoint) const final {
return Density_time_n.size() > 0 ? Density_time_n(iPoint) : GetDensity(iPoint);
}

/*!
* \brief Get the density at time level n-1 for dual-time stepping.
* \param[in] iPoint - Point index.
* \return Density at time level n-1.
*/
inline su2double GetDensity_time_n1(unsigned long iPoint) const final {
return Density_time_n1.size() > 0 ? Density_time_n1(iPoint) : GetDensity(iPoint);
}

/*!
* \brief Set the density at time level n for dual-time stepping.
* \param[in] iPoint - Point index.
* \param[in] val_density - Density value.
*/
inline void SetDensity_time_n(unsigned long iPoint, su2double val_density) { Density_time_n(iPoint) = val_density; }

/*!
* \brief Set the density at time level n-1 for dual-time stepping.
* \param[in] iPoint - Point index.
* \param[in] val_density - Density value.
*/
inline void SetDensity_time_n1(unsigned long iPoint, su2double val_density) { Density_time_n1(iPoint) = val_density; }

};
14 changes: 14 additions & 0 deletions SU2_CFD/include/variables/CNEMOEulerVariable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,20 @@ class CNEMOEulerVariable : public CFlowVariable {
unsigned long nvar, unsigned long nvalprim,
unsigned long nvarprimgrad, const CConfig *config, CNEMOGas *fluidmodel);

/*!
* \brief Get the density at time level n for dual-time stepping.
* \param[in] iPoint - Point index.
* \return Density at time level n.
*/
inline su2double GetDensity_time_n(unsigned long iPoint) const final { return GetSolution_time_n(iPoint, 0); }

/*!
* \brief Get the density at time level n-1 for dual-time stepping.
* \param[in] iPoint - Point index.
* \return Density at time level n-1.
*/
inline su2double GetDensity_time_n1(unsigned long iPoint) const final { return GetSolution_time_n1(iPoint, 0); }

/*---------------------------------------*/
/*--- U,V,S Routines ---*/
/*---------------------------------------*/
Expand Down
6 changes: 4 additions & 2 deletions SU2_CFD/src/solvers/CDiscAdjSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,13 @@ void CDiscAdjSolver::RegisterSolution(CGeometry *geometry, CConfig *config) {
/*--- Register quantities that are no solver variables but further inputs/outputs of the (outer) iteration. ---*/
direct_solver->RegisterSolutionExtra(true, config);

if (time_n_needed)
if (time_n_needed) {
direct_solver->GetNodes()->RegisterSolution_time_n();
}
Comment thread
bigfooted marked this conversation as resolved.

if (time_n1_needed)
if (time_n1_needed) {
direct_solver->GetNodes()->RegisterSolution_time_n1();
}
}

void CDiscAdjSolver::RegisterVariables(CGeometry *geometry, CConfig *config, bool reset) {
Expand Down
2 changes: 1 addition & 1 deletion SU2_CFD/src/solvers/CHeatSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
template class CScalarSolver<CHeatVariable>;

CHeatSolver::CHeatSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh)
: CScalarSolver<CHeatVariable>(geometry, config, false),
: CScalarSolver<CHeatVariable>(geometry, config, false, false),
flow(config->GetFluidProblem()) {
SU2_ZONE_SCOPED

Expand Down
Loading
Loading