Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 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
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
16 changes: 16 additions & 0 deletions Common/src/CConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5792,6 +5792,22 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i
SU2_MPI::Error("Number of initial species incompatible with number of controlling variables and user scalars.", CURRENT_FUNCTION);
/*--- We can have additional user defined transported scalars ---*/
flamelet_ParsedOptions.n_scalars = flamelet_ParsedOptions.n_control_vars + flamelet_ParsedOptions.n_user_scalars;

/*--- Check that spark ignition has required parameters defined ---*/
if (flamelet_ParsedOptions.ignition_method == FLAMELET_INIT_TYPE::SPARK) {
/*--- Check if SPARK_INIT was explicitly set in config file ---*/
if (all_options.find("SPARK_INIT") != all_options.end()) {
SU2_MPI::Error("FLAME_INIT_METHOD=SPARK requires SPARK_INIT to be defined in the config file.", CURRENT_FUNCTION);
}
/*--- Check if SPARK_REACTION_RATES was explicitly set in config file ---*/
if (all_options.find("SPARK_REACTION_RATES") != all_options.end()) {
SU2_MPI::Error("FLAME_INIT_METHOD=SPARK requires SPARK_REACTION_RATES to be defined in the config file.", CURRENT_FUNCTION);
}
if (flamelet_ParsedOptions.nspark < flamelet_ParsedOptions.n_scalars) {
SU2_MPI::Error("SPARK_REACTION_RATES must have at least " + to_string(flamelet_ParsedOptions.n_scalars) +
" values (one for each scalar variable), but only " + to_string(flamelet_ParsedOptions.nspark) + " were provided.", CURRENT_FUNCTION);
}
}
}

if (Kind_Regime == ENUM_REGIME::COMPRESSIBLE && GetBounded_Scalar()) {
Expand Down
24 changes: 8 additions & 16 deletions SU2_CFD/include/solvers/CScalarSolver.inl
Original file line number Diff line number Diff line change
Expand Up @@ -635,12 +635,8 @@ void CScalarSolver<VariableType>::SetResidual_DualTime(CGeometry* geometry, CSol
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_nM1 = flowNodes->GetDensity_time_n1(iPoint);
Density_n = flowNodes->GetDensity_time_n(iPoint);
Density_nP1 = flowNodes->GetDensity(iPoint);
} else {
Density_nM1 = flowNodes->GetSolution_time_n1(iPoint)[0];
Expand Down Expand Up @@ -701,7 +697,7 @@ void CScalarSolver<VariableType>::SetResidual_DualTime(CGeometry* geometry, CSol

if (Conservative) {
if (incompressible)
Density_n = flowNodes->GetDensity(iPoint); // Temporary fix
Density_n = flowNodes->GetDensity_time_n(iPoint);
else
Density_n = flowNodes->GetSolution_time_n(iPoint, 0);
}
Expand Down Expand Up @@ -757,11 +753,11 @@ void CScalarSolver<VariableType>::SetResidual_DualTime(CGeometry* geometry, CSol

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

// nijso: what about second order?
for (iVar = 0; iVar < nVar; iVar++) LinSysRes(iPoint, iVar) += Density_n * U_time_n[iVar] * Residual_GCL;
}
END_SU2_OMP_FOR
Expand Down Expand Up @@ -798,12 +794,8 @@ void CScalarSolver<VariableType>::SetResidual_DualTime(CGeometry* geometry, CSol
/*--- 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_nM1 = flowNodes->GetDensity_time_n1(iPoint);
Density_n = flowNodes->GetDensity_time_n(iPoint);
Density_nP1 = flowNodes->GetDensity(iPoint);
} else {
Density_nM1 = flowNodes->GetSolution_time_n1(iPoint)[0];
Expand Down Expand Up @@ -863,4 +855,4 @@ void CScalarSolver<VariableType>::PushSolutionBackInTime(unsigned long TimeIter,
nodes->Set_Solution_time_n();
}
}
}
}
76 changes: 76 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. */
su2double TemperatureLimits[2]; /*!< \brief Temperature limits [K]. */
public:
/*!
Expand All @@ -87,6 +89,16 @@ class CIncEulerVariable : public CFlowVariable {
CIncEulerVariable(su2double pressure, const su2double *velocity, su2double enthalpy,
unsigned long npoint, unsigned long ndim, unsigned long nvar, const CConfig *config);

/*!
* \brief Set all the solution at time level n to the current solution value (including density).
*/
void Set_Solution_time_n() override;

/*!
* \brief Set all the solution at time level n-1 to the solution at time level n (including density).
*/
void Set_Solution_time_n1() override;

/*!
* \brief Set the value of the pressure.
* \param[in] iPoint - Point index.
Expand Down Expand Up @@ -291,4 +303,68 @@ 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 { return Density_time_n(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 { return Density_time_n1(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; }

/*!
* \brief Register the density at time n as an AD input variable (for discrete adjoint unsteady).
*/
void RegisterDensity_time_n() override;

/*!
* \brief Register the density at time n-1 as an AD input variable (for discrete adjoint unsteady).
*/
void RegisterDensity_time_n1() override;

/*!
* \brief Get the adjoint of density at time n.
* Simplified version: directly extracts the AD derivative of Density_time_n,
* analogous to GetAdjointSolution_time_n for the solution vector.
* The chain-rule contribution d(rho)/d(h) is currently not applied (TODO).
* \param[in] iPoint - Point index.
* \return Adjoint of the density at time n.
*/
inline su2double GetAdjointDensity_time_n(unsigned long iPoint) const override {
AD::Identifier index = AD::GetPassiveIndex();
AD::SetIndex(index, Density_time_n(iPoint));
return AD::GetDerivative(index);
}

/*!
* \brief Get the adjoint of density at time n-1.
* See GetAdjointDensity_time_n.
* \param[in] iPoint - Point index.
* \return Adjoint of the density at time n-1.
*/
inline su2double GetAdjointDensity_time_n1(unsigned long iPoint) const override {
AD::Identifier index = AD::GetPassiveIndex();
AD::SetIndex(index, Density_time_n1(iPoint));
return AD::GetDerivative(index);
}

};
46 changes: 44 additions & 2 deletions SU2_CFD/include/variables/CVariable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,12 +284,12 @@ class CVariable {
/*!
* \brief Set the variable solution at time n.
*/
void Set_Solution_time_n();
virtual void Set_Solution_time_n();

/*!
* \brief Set the variable solution at time n-1.
*/
void Set_Solution_time_n1();
virtual void Set_Solution_time_n1();

/*!
* \brief Set the variable solution at time n.
Expand Down Expand Up @@ -2182,6 +2182,48 @@ class CVariable {
*/
void RegisterUserDefinedSource();

/*!
* \brief Get the stored density at time n (incompressible only).
* \param[in] iPoint - Point index.
* \return Density at time n; 0 for compressible nodes.
*/
inline virtual su2double GetDensity_time_n(unsigned long /*iPoint*/) const { return 0.0; }

/*!
* \brief Get the stored density at time n-1 (incompressible only).
* \param[in] iPoint - Point index.
* \return Density at time n-1; 0 for compressible nodes.
*/
inline virtual su2double GetDensity_time_n1(unsigned long /*iPoint*/) const { return 0.0; }

/*!
* \brief Register the density at time n as an AD input (no-op for non-incompressible nodes).
*/
inline virtual void RegisterDensity_time_n() {}

/*!
* \brief Register the density at time n-1 as an AD input (no-op for non-incompressible nodes).
*/
inline virtual void RegisterDensity_time_n1() {}

/*!
* \brief Get the adjoint values of the density at time n.
* Implemented analogously to GetAdjointSolution_time_n but for a scalar
* (Density_time_n is a VectorType, not a MatrixType).
* Currently ignores the chain-rule d(rho)/d(h) dependence (TODO).
* \param[in] iPoint - Point index.
* \return Adjoint value of the density at time n.
*/
inline virtual su2double GetAdjointDensity_time_n(unsigned long /*iPoint*/) const { return 0.0; }

/*!
* \brief Get the adjoint values of the density at time n-1.
* See GetAdjointDensity_time_n.
* \param[in] iPoint - Point index.
* \return Adjoint value of the density at time n-1.
*/
inline virtual su2double GetAdjointDensity_time_n1(unsigned long /*iPoint*/) const { return 0.0; }

/*!
* \brief Set the adjoint values of the solution.
* \param[in] adj_sol - The adjoint values of the solution.
Expand Down
18 changes: 18 additions & 0 deletions SU2_CFD/src/output/CFlowIncOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

#include "../../../Common/include/geometry/CGeometry.hpp"
#include "../../include/solvers/CSolver.hpp"
#include "../../include/variables/CIncEulerVariable.hpp"

CFlowIncOutput::CFlowIncOutput(CConfig *config, unsigned short nDim) : CFlowOutput(config, nDim, false) {

Expand Down Expand Up @@ -326,6 +327,14 @@ void CFlowIncOutput::SetVolumeOutputFields(CConfig *config){
AddVolumeOutput("PRESSURE_COEFF", "Pressure_Coefficient", "PRIMITIVE", "Pressure coefficient");
AddVolumeOutput("DENSITY", "Density", "PRIMITIVE", "Density");

// Density at previous timesteps for restart (unsteady with non-constant density)
if (config->GetTime_Domain() && config->GetKind_FluidModel() != CONSTANT_DENSITY) {
AddVolumeOutput("DENSITY_TIME_N", "Density_time_n", "SOLUTION", "Density at previous time step n");
if (config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_2ND) {
AddVolumeOutput("DENSITY_TIME_N1", "Density_time_n1", "SOLUTION", "Density at previous time step n-1");
}
}

if (config->GetKind_Solver() == MAIN_SOLVER::INC_RANS || config->GetKind_Solver() == MAIN_SOLVER::INC_NAVIER_STOKES){
AddVolumeOutput("LAMINAR_VISCOSITY", "Laminar_Viscosity", "PRIMITIVE", "Laminar viscosity");
AddVolumeOutput("HEAT_CAPACITY", "Heat_Capacity", "PRIMITIVE", "Heat capacity");
Expand Down Expand Up @@ -399,6 +408,7 @@ void CFlowIncOutput::SetVolumeOutputFields(CConfig *config){
void CFlowIncOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSolver **solver, unsigned long iPoint){

const auto* Node_Flow = solver[FLOW_SOL]->GetNodes();
const auto* Node_Flow_Inc = static_cast<const CIncEulerVariable*>(Node_Flow);
const CVariable* Node_Heat = nullptr;
const CVariable* Node_Rad = nullptr;
auto* Node_Geo = geometry->nodes;
Expand Down Expand Up @@ -437,6 +447,14 @@ void CFlowIncOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSolve
SetVolumeOutputValue("PRESSURE_COEFF", iPoint, (Node_Flow->GetPressure(iPoint) - solver[FLOW_SOL]->GetPressure_Inf())/factor);
SetVolumeOutputValue("DENSITY", iPoint, Node_Flow->GetDensity(iPoint));

// Load density at previous timesteps for restart (unsteady with non-constant density)
if (config->GetTime_Domain() && config->GetKind_FluidModel() != CONSTANT_DENSITY) {
SetVolumeOutputValue("DENSITY_TIME_N", iPoint, Node_Flow_Inc->GetDensity_time_n(iPoint));
if (config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_2ND) {
SetVolumeOutputValue("DENSITY_TIME_N1", iPoint, Node_Flow_Inc->GetDensity_time_n1(iPoint));
}
}

if (config->GetKind_Solver() == MAIN_SOLVER::INC_RANS || config->GetKind_Solver() == MAIN_SOLVER::INC_NAVIER_STOKES){
SetVolumeOutputValue("LAMINAR_VISCOSITY", iPoint, Node_Flow->GetLaminarViscosity(iPoint));
SetVolumeOutputValue("HEAT_CAPACITY", iPoint, Node_Flow->GetSpecificHeatCp(iPoint));
Expand Down
15 changes: 13 additions & 2 deletions SU2_CFD/src/solvers/CDiscAdjSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,18 @@ 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();
/*--- Density is stored separately from the solution vector for incompressible flows. ---*/
if (config->GetKind_Regime() == ENUM_REGIME::INCOMPRESSIBLE)
direct_solver->GetNodes()->RegisterDensity_time_n();
}

if (time_n1_needed)
if (time_n1_needed) {
direct_solver->GetNodes()->RegisterSolution_time_n1();
if (config->GetKind_Regime() == ENUM_REGIME::INCOMPRESSIBLE)
direct_solver->GetNodes()->RegisterDensity_time_n1();
}
}

void CDiscAdjSolver::RegisterVariables(CGeometry *geometry, CConfig *config, bool reset) {
Expand Down Expand Up @@ -367,6 +374,8 @@ void CDiscAdjSolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *confi
for (auto iPoint = 0ul; iPoint < nPoint; iPoint++) {
su2double Solution[MAXNVAR] = {0.0};
direct_solver->GetNodes()->GetAdjointSolution_time_n(iPoint,Solution);
/*--- TODO: For incompressible flow, accumulate GetAdjointDensity_time_n
* into the enthalpy adjoint via d(rho)/d(h) chain rule. ---*/
nodes->Set_Solution_time_n(iPoint,Solution);
}
END_SU2_OMP_FOR
Expand All @@ -382,6 +391,8 @@ void CDiscAdjSolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *confi
for (auto iPoint = 0ul; iPoint < nPoint; iPoint++) {
su2double Solution[MAXNVAR] = {0.0};
direct_solver->GetNodes()->GetAdjointSolution_time_n1(iPoint,Solution);
/*--- TODO: For incompressible flow, accumulate GetAdjointDensity_time_n1
* into the enthalpy adjoint via d(rho)/d(h) chain rule. ---*/
nodes->Set_Solution_time_n1(iPoint,Solution);
}
END_SU2_OMP_FOR
Expand Down
Loading
Loading