From 509a608293550637c2b038343865153b7a571314 Mon Sep 17 00:00:00 2001 From: Tahsin Berk Kiymaz Date: Tue, 17 Jun 2025 10:28:16 +0200 Subject: [PATCH 01/39] my changes --- SU2_CFD/include/output/COutput.hpp | 3 +- .../include/solvers/CFVMFlowSolverBase.inl | 7 ++++ SU2_CFD/include/solvers/CScalarSolver.inl | 8 ++-- SU2_CFD/include/variables/CEulerVariable.hpp | 9 ++++ .../include/variables/CIncEulerVariable.hpp | 18 +++++++- SU2_CFD/include/variables/CIncNSVariable.hpp | 2 +- .../variables/CSpeciesFlameletVariable.hpp | 2 +- .../include/variables/CSpeciesVariable.hpp | 2 +- SU2_CFD/include/variables/CVariable.hpp | 41 +++++++++++++++++++ SU2_CFD/src/integration/CIntegration.cpp | 1 + SU2_CFD/src/output/CFlowIncOutput.cpp | 6 +++ SU2_CFD/src/solvers/CIncEulerSolver.cpp | 25 +++++++++-- SU2_CFD/src/variables/CIncEulerVariable.cpp | 17 ++++++-- SU2_CFD/src/variables/CIncNSVariable.cpp | 7 +++- .../variables/CSpeciesFlameletVariable.cpp | 6 ++- SU2_CFD/src/variables/CSpeciesVariable.cpp | 4 +- SU2_CFD/src/variables/CVariable.cpp | 19 +++++++++ Tutorials | 1 + build_su2.slurm | 24 +++++++++++ build_su2_develop.slurm | 24 +++++++++++ 20 files changed, 205 insertions(+), 21 deletions(-) create mode 160000 Tutorials create mode 100644 build_su2.slurm create mode 100644 build_su2_develop.slurm diff --git a/SU2_CFD/include/output/COutput.hpp b/SU2_CFD/include/output/COutput.hpp index 14b0bbec9b6a..90a3e4422fca 100644 --- a/SU2_CFD/include/output/COutput.hpp +++ b/SU2_CFD/include/output/COutput.hpp @@ -300,7 +300,8 @@ class COutput { unsigned short nRequestedVolumeFields; /*! \brief Minimum required volume fields for restart file. */ - const std::vector restartVolumeFields = {"COORDINATES", "SOLUTION", "SENSITIVITY", "GRID_VELOCITY"}; + const std::vector restartVolumeFields = {"COORDINATES", "SOLUTION", "SENSITIVITY", "GRID_VELOCITY","DENSITY_TIME_N"}; + /*----------------------------- Convergence monitoring ----------------------------*/ diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl index 8a99712dc8e0..121987ff0382 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl @@ -882,6 +882,9 @@ void CFVMFlowSolverBase::LoadRestart_impl(CGeometry **geometry, CSolver ** nodes->SetSolution(iPoint_Local, SolutionRestart); } + + // nodes->Set_Density_time_n(iPoint_Local, Restart_Data[index + nVar_Restart]); + /*--- For dynamic meshes, read in and store the grid coordinates and grid velocities for each node. ---*/ @@ -893,6 +896,7 @@ void CFVMFlowSolverBase::LoadRestart_impl(CGeometry **geometry, CSolver ** /*--- Rewind the index to retrieve the Coords. ---*/ index = counter * Restart_Vars[1]; + const auto* Coord = &Restart_Data[index]; su2double GridVel[MAXNDIM] = {0.0}; @@ -914,6 +918,7 @@ void CFVMFlowSolverBase::LoadRestart_impl(CGeometry **geometry, CSolver ** if (static_fsi && update_geo) { /*--- Rewind the index to retrieve the Coords. ---*/ index = counter*Restart_Vars[1]; + const auto* Coord = &Restart_Data[index]; for (auto iDim = 0u; iDim < nDim; iDim++) { @@ -1069,6 +1074,7 @@ void CFVMFlowSolverBase::PushSolutionBackInTime(unsigned long TimeIter, bo for (unsigned short iMesh = 0; iMesh <= config->GetnMGLevels(); iMesh++) { solver_container[iMesh][FLOW_SOL]->GetNodes()->Set_Solution_time_n(); solver_container[iMesh][FLOW_SOL]->GetNodes()->Set_Solution_time_n1(); + solver_container[iMesh][FLOW_SOL]->GetNodes()->Set_Density_time_n(); if (rans) { solver_container[iMesh][TURB_SOL]->GetNodes()->Set_Solution_time_n(); solver_container[iMesh][TURB_SOL]->GetNodes()->Set_Solution_time_n1(); @@ -1099,6 +1105,7 @@ void CFVMFlowSolverBase::PushSolutionBackInTime(unsigned long TimeIter, bo for (unsigned short iMesh = 0; iMesh <= config->GetnMGLevels(); iMesh++) { solver_container[iMesh][FLOW_SOL]->GetNodes()->Set_Solution_time_n(); + solver_container[iMesh][FLOW_SOL]->GetNodes()->Set_Density_time_n(); if (rans) solver_container[iMesh][TURB_SOL]->GetNodes()->Set_Solution_time_n(); geometry[iMesh]->nodes->SetVolume_n(); diff --git a/SU2_CFD/include/solvers/CScalarSolver.inl b/SU2_CFD/include/solvers/CScalarSolver.inl index 1411de2ca787..33812ec035e8 100644 --- a/SU2_CFD/include/solvers/CScalarSolver.inl +++ b/SU2_CFD/include/solvers/CScalarSolver.inl @@ -633,7 +633,7 @@ void CScalarSolver::SetResidual_DualTime(CGeometry* geometry, CSol 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_n = flowNodes->GetDensity_time_n(iPoint); Density_nP1 = flowNodes->GetDensity(iPoint); } else { Density_nM1 = flowNodes->GetSolution_time_n1(iPoint)[0]; @@ -694,7 +694,7 @@ void CScalarSolver::SetResidual_DualTime(CGeometry* geometry, CSol if (Conservative) { if (incompressible) - Density_n = flowNodes->GetDensity(iPoint); // Temporary fix + Density_n = flowNodes->GetDensity_time_n(iPoint); // Temporary fix else Density_n = flowNodes->GetSolution_time_n(iPoint, 0); } @@ -750,7 +750,7 @@ void CScalarSolver::SetResidual_DualTime(CGeometry* geometry, CSol if (Conservative) { if (incompressible) - Density_n = flowNodes->GetDensity(iPoint); // Temporary fix + Density_n = flowNodes->GetDensity_time_n(iPoint); // Temporary fix else Density_n = flowNodes->GetSolution_time_n(iPoint, 0); } @@ -796,7 +796,7 @@ void CScalarSolver::SetResidual_DualTime(CGeometry* geometry, CSol 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_n = flowNodes->GetDensity_time_n(iPoint); Density_nP1 = flowNodes->GetDensity(iPoint); } else { Density_nM1 = flowNodes->GetSolution_time_n1(iPoint)[0]; diff --git a/SU2_CFD/include/variables/CEulerVariable.hpp b/SU2_CFD/include/variables/CEulerVariable.hpp index c1dd2c452393..137f912fabca 100644 --- a/SU2_CFD/include/variables/CEulerVariable.hpp +++ b/SU2_CFD/include/variables/CEulerVariable.hpp @@ -184,6 +184,15 @@ class CEulerVariable : public CFlowVariable { return Primitive(iPoint, indices.Density()) <= 0.0; } + inline void Set_Density_time_n(unsigned long iPoint, su2double val) { + Density_time_n[iPoint] = val; + } + + inline void Set_Density_unsteady(unsigned long iPoint, su2double val) { + Density_unsteady[iPoint] = val; + } + + /*! * \brief Set the value of the temperature. * \param[in] temperature - how agitated the particles are :) diff --git a/SU2_CFD/include/variables/CIncEulerVariable.hpp b/SU2_CFD/include/variables/CIncEulerVariable.hpp index 7f398351f04f..8f846ca0d8ea 100644 --- a/SU2_CFD/include/variables/CIncEulerVariable.hpp +++ b/SU2_CFD/include/variables/CIncEulerVariable.hpp @@ -82,7 +82,7 @@ class CIncEulerVariable : public CFlowVariable { * \param[in] nvar - Number of variables of the problem. * \param[in] config - Definition of the particular problem. */ - CIncEulerVariable(su2double pressure, const su2double *velocity, su2double temperature, + CIncEulerVariable(su2double density, su2double pressure, const su2double *velocity, su2double temperature, unsigned long npoint, unsigned long ndim, unsigned long nvar, const CConfig *config); /*! @@ -99,6 +99,20 @@ class CIncEulerVariable : public CFlowVariable { Primitive(iPoint, indices.Density()) = val_density; return val_density <= 0.0; } + + + inline void Set_Density_time_n(unsigned long iPoint, su2double val) { + Density_time_n[iPoint] = val; + } + + inline void Set_Density_unsteady(unsigned long iPoint, su2double val) { + Density_unsteady[iPoint] = val; + } + + inline su2double GetDensity_time_n(unsigned long iPoint) const { + return Density_time_n[iPoint]; + } + /*! * \brief Set the value of the density for the incompressible flows. @@ -147,6 +161,8 @@ class CIncEulerVariable : public CFlowVariable { */ inline su2double GetDensity(unsigned long iPoint) const final { return Primitive(iPoint, indices.Density()); } + + /*! * \brief Get the temperature of the flow. * \return Value of the temperature of the flow. diff --git a/SU2_CFD/include/variables/CIncNSVariable.hpp b/SU2_CFD/include/variables/CIncNSVariable.hpp index 138026140b5e..475b00e5412c 100644 --- a/SU2_CFD/include/variables/CIncNSVariable.hpp +++ b/SU2_CFD/include/variables/CIncNSVariable.hpp @@ -52,7 +52,7 @@ class CIncNSVariable final : public CIncEulerVariable { * \param[in] nvar - Number of variables of the problem. * \param[in] config - Definition of the particular problem. */ - CIncNSVariable(su2double pressure, const su2double *velocity, su2double temperature, + CIncNSVariable(su2double density, su2double pressure, const su2double *velocity, su2double temperature, unsigned long npoint, unsigned long ndim, unsigned long nvar, const CConfig *config); /*! diff --git a/SU2_CFD/include/variables/CSpeciesFlameletVariable.hpp b/SU2_CFD/include/variables/CSpeciesFlameletVariable.hpp index a1eac80ae48e..7d9cf63e8504 100644 --- a/SU2_CFD/include/variables/CSpeciesFlameletVariable.hpp +++ b/SU2_CFD/include/variables/CSpeciesFlameletVariable.hpp @@ -48,7 +48,7 @@ class CSpeciesFlameletVariable final : public CSpeciesVariable { * \param[in] nvar - Number of variables of the problem. * \param[in] config - Definition of the particular problem. */ - CSpeciesFlameletVariable(const su2double* species_inf, unsigned long npoint, unsigned long ndim, unsigned long nvar, + CSpeciesFlameletVariable(const su2double density, const su2double* species_inf, unsigned long npoint, unsigned long ndim, unsigned long nvar, const CConfig* config); /*! diff --git a/SU2_CFD/include/variables/CSpeciesVariable.hpp b/SU2_CFD/include/variables/CSpeciesVariable.hpp index faeca8fa7194..c6bc9d976124 100644 --- a/SU2_CFD/include/variables/CSpeciesVariable.hpp +++ b/SU2_CFD/include/variables/CSpeciesVariable.hpp @@ -48,7 +48,7 @@ class CSpeciesVariable : public CScalarVariable { * \param[in] nvar - Number of variables of the problem. * \param[in] config - Definition of the particular problem. */ - CSpeciesVariable(const su2double* species_inf, unsigned long npoint, unsigned long ndim, unsigned long nvar, + CSpeciesVariable(su2double density,const su2double* species_inf, unsigned long npoint, unsigned long ndim, unsigned long nvar, const CConfig* config); /*! diff --git a/SU2_CFD/include/variables/CVariable.hpp b/SU2_CFD/include/variables/CVariable.hpp index 98e8c2538196..1931dee89c1c 100644 --- a/SU2_CFD/include/variables/CVariable.hpp +++ b/SU2_CFD/include/variables/CVariable.hpp @@ -68,6 +68,8 @@ class CVariable { MatrixType Solution_time_n; /*!< \brief Solution of the problem at time n for dual-time stepping technique. */ MatrixType Solution_time_n1; /*!< \brief Solution of the problem at time n-1 for dual-time stepping technique. */ VectorType Delta_Time; /*!< \brief Time step. */ + VectorType Density_unsteady; + VectorType Density_time_n; /*!< \brief density at time n for dual-time stepping technique. */ CVectorOfMatrix Gradient; /*!< \brief Gradient of the solution of the problem. */ C3DDoubleMatrix Rmatrix; /*!< \brief Geometry-based matrix for weighted least squares gradient calculations. */ @@ -275,6 +277,12 @@ class CVariable { */ void Set_Solution_time_n1(); + /*! + * \brief Set the density at time n. + */ + void Set_Density_time_n(); + + /*! * \brief Set the variable solution at time n. * \param[in] iPoint - Point index. @@ -308,6 +316,15 @@ class CVariable { Solution_time_n1(iPoint,iVar) = val_sol; } + inline void Set_Density_time_n(unsigned long iPoint, su2double val) { + Density_time_n[iPoint] = val; + } + + inline void Set_Density_unsteady(unsigned long iPoint, su2double val) { + Density_unsteady[iPoint] = val; + } + + /*! * \brief Virtual Member. Specify a vector to set the velocity components of the solution. * Multiplied by density for compressible cases. @@ -502,6 +519,23 @@ class CVariable { inline su2double *GetSolution_time_n1(unsigned long iPoint) { return Solution_time_n1[iPoint]; } inline MatrixType& GetSolution_time_n1() { return Solution_time_n1; } + + /*! + * \brief Get the solution at time n. + * \param[in] iPoint - Point index. + * \return Pointer to the solution (at time n) vector. + */ + inline su2double GetDensity_time_n(unsigned long iPoint) const { return Density_time_n[iPoint]; } + inline VectorType& GetDensity_time_n() { return Density_time_n; } + + /*! + * \brief Get the density. + * \param[in] iPoint - Point index. + * \return Pointer to the solution (at time n) vector. + */ + inline su2double GetDensity_unsteady(unsigned long iPoint) const { return Density_unsteady[iPoint]; } + inline VectorType& GetDensity_unsteady() { return Density_unsteady; } + /*! * \brief Set the value of the old residual. * \param[in] iPoint - Point index. @@ -1869,6 +1903,8 @@ class CVariable { */ inline su2double GetSolution_time_n1(unsigned long iPoint, unsigned long iVar) const { return Solution_time_n1(iPoint,iVar); } + + /*! * \brief Get the velocity (Structural Analysis). * \param[in] iVar - Index of the variable. @@ -2154,6 +2190,11 @@ class CVariable { */ void RegisterSolution_time_n1(); + /*! + * \brief Register the variables in the solution_time_n1 array as input/output variable. + */ + void RegisterDensity_time_n(); + /*! * \brief Set the adjoint values of the solution. * \param[in] adj_sol - The adjoint values of the solution. diff --git a/SU2_CFD/src/integration/CIntegration.cpp b/SU2_CFD/src/integration/CIntegration.cpp index a3af58d572bf..8673ea4d2238 100644 --- a/SU2_CFD/src/integration/CIntegration.cpp +++ b/SU2_CFD/src/integration/CIntegration.cpp @@ -248,6 +248,7 @@ void CIntegration::SetDualTime_Solver(const CGeometry *geometry, CSolver *solver /*--- Store old solution ---*/ solver->GetNodes()->Set_Solution_time_n1(); solver->GetNodes()->Set_Solution_time_n(); + solver->GetNodes()->Set_Density_time_n(); SU2_OMP_SAFE_GLOBAL_ACCESS(solver->ResetCFLAdapt();) diff --git a/SU2_CFD/src/output/CFlowIncOutput.cpp b/SU2_CFD/src/output/CFlowIncOutput.cpp index 7913d84f1300..fe22d2386606 100644 --- a/SU2_CFD/src/output/CFlowIncOutput.cpp +++ b/SU2_CFD/src/output/CFlowIncOutput.cpp @@ -293,6 +293,7 @@ void CFlowIncOutput::SetVolumeOutputFields(CConfig *config){ AddVolumeOutput("PRESSURE", "Pressure", "SOLUTION", "Pressure"); AddVolumeOutput("VELOCITY-X", "Velocity_x", "SOLUTION", "x-component of the velocity vector"); AddVolumeOutput("VELOCITY-Y", "Velocity_y", "SOLUTION", "y-component of the velocity vector"); + if (nDim == 3) AddVolumeOutput("VELOCITY-Z", "Velocity_z", "SOLUTION", "z-component of the velocity vector"); if (heat || weakly_coupled_heat || flamelet) @@ -375,6 +376,9 @@ void CFlowIncOutput::SetVolumeOutputFields(CConfig *config){ AddCommonFVMOutputs(config); + AddVolumeOutput("DENSITY_TIME_N", "Density_time_n", "SOLUTION", "Density at previous time step"); + + if (config->GetTime_Domain()) { SetTimeAveragedFields(); } @@ -418,6 +422,8 @@ void CFlowIncOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSolve const su2double factor = solver[FLOW_SOL]->GetReferenceDynamicPressure(); SetVolumeOutputValue("PRESSURE_COEFF", iPoint, (Node_Flow->GetPressure(iPoint) - solver[FLOW_SOL]->GetPressure_Inf())/factor); SetVolumeOutputValue("DENSITY", iPoint, Node_Flow->GetDensity(iPoint)); + SetVolumeOutputValue("DENSITY_TIME_N", iPoint, Node_Flow->GetDensity_time_n(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)); diff --git a/SU2_CFD/src/solvers/CIncEulerSolver.cpp b/SU2_CFD/src/solvers/CIncEulerSolver.cpp index 6aaf09a51835..16a48ed770ac 100644 --- a/SU2_CFD/src/solvers/CIncEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CIncEulerSolver.cpp @@ -208,9 +208,9 @@ CIncEulerSolver::CIncEulerSolver(CGeometry *geometry, CConfig *config, unsigned /*--- Initialize the solution to the far-field state everywhere. ---*/ if (navier_stokes) { - nodes = new CIncNSVariable(Pressure_Inf, Velocity_Inf, Temperature_Inf, nPoint, nDim, nVar, config); + nodes = new CIncNSVariable(Density_Inf, Pressure_Inf, Velocity_Inf, Temperature_Inf, nPoint, nDim, nVar, config); } else { - nodes = new CIncEulerVariable(Pressure_Inf, Velocity_Inf, Temperature_Inf, nPoint, nDim, nVar, config); + nodes = new CIncEulerVariable(Density_Inf, Pressure_Inf, Velocity_Inf, Temperature_Inf, nPoint, nDim, nVar, config); } SetBaseClassPointerToNodes(); @@ -1927,8 +1927,16 @@ void CIncEulerSolver::PrepareImplicitIteration(CGeometry *geometry, CSolver**, C void CIncEulerSolver::CompleteImplicitIteration(CGeometry *geometry, CSolver**, CConfig *config) { CompleteImplicitIteration_impl(geometry, config); + + //if (config->GetTime_Domain()) { + // for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) { + // nodes->SetDensity_time_n(iPoint, nodes->GetDensity_unsteady(iPoint)); + // } + // } + } + void CIncEulerSolver::SetBeta_Parameter(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh) { static su2double MaxVel2; @@ -2670,7 +2678,7 @@ void CIncEulerSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver su2double U_time_nM1[MAXNVAR], U_time_n[MAXNVAR], U_time_nP1[MAXNVAR]; su2double Volume_nM1, Volume_nP1, TimeStep; const su2double *Normal = nullptr, *GridVel_i = nullptr, *GridVel_j = nullptr; - su2double Density, Cp; + su2double Density, Cp, Density_time_n, Density_unsteady; const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); const bool first_order = (config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_1ST); @@ -2710,15 +2718,24 @@ void CIncEulerSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver /*--- Access the density and Cp at this node (constant for now). ---*/ + Density_time_n = nodes->GetDensity_time_n(iPoint); + Density_unsteady = nodes->GetDensity_unsteady(iPoint); + Density = nodes->GetDensity(iPoint); + + Cp = nodes->GetSpecificHeatCp(iPoint); /*--- Compute the conservative variable vector for all time levels. ---*/ V2U(Density, Cp, V_time_nM1, U_time_nM1); - V2U(Density, Cp, V_time_n, U_time_n); + V2U(Density_time_n, Cp, V_time_n, U_time_n); V2U(Density, Cp, V_time_nP1, U_time_nP1); + if (iPoint==100) + cout <<"density="<GetKind_ConvNumScheme_Flow() == SPACE_CENTERED ? 2 : 4), config), @@ -46,7 +46,7 @@ CIncEulerVariable::CIncEulerVariable(su2double pressure, const su2double *veloci for(unsigned long iPoint=0; iPointGetKind_Streamwise_Periodic() != ENUM_STREAMWISE_PERIODIC::NONE) { @@ -65,7 +66,14 @@ CIncEulerVariable::CIncEulerVariable(su2double pressure, const su2double *veloci } } -bool CIncEulerVariable::SetPrimVar(unsigned long iPoint, CFluidModel *FluidModel) { +bool CIncEulerVariable::SetPrimVar(unsigned long iPoint, CFluidModel *FluidModel) { + + static bool printed = false; + if (!printed) { + std::cout << "[DEBUG] SetPrimVar was called!" << std::endl; + printed = true; + } + bool physical = true; @@ -89,6 +97,8 @@ bool CIncEulerVariable::SetPrimVar(unsigned long iPoint, CFluidModel *FluidModel /*--- Set the value of the density ---*/ const auto check_dens = SetDensity(iPoint, FluidModel->GetDensity()); + Density_unsteady[iPoint] = FluidModel->GetDensity(); + /*--- Non-physical solution found. Revert to old values. ---*/ @@ -106,6 +116,7 @@ bool CIncEulerVariable::SetPrimVar(unsigned long iPoint, CFluidModel *FluidModel FluidModel->SetTDState_T(Temperature); SetDensity(iPoint, FluidModel->GetDensity()); + /*--- Flag this point as non-physical. ---*/ physical = false; diff --git a/SU2_CFD/src/variables/CIncNSVariable.cpp b/SU2_CFD/src/variables/CIncNSVariable.cpp index cbcfa3b0aad6..73412a341b84 100644 --- a/SU2_CFD/src/variables/CIncNSVariable.cpp +++ b/SU2_CFD/src/variables/CIncNSVariable.cpp @@ -28,9 +28,9 @@ #include "../../include/variables/CIncNSVariable.hpp" #include "../../include/fluid/CFluidModel.hpp" -CIncNSVariable::CIncNSVariable(su2double pressure, const su2double *velocity, su2double temperature, +CIncNSVariable::CIncNSVariable(su2double density, su2double pressure, const su2double *velocity, su2double temperature, unsigned long npoint, unsigned long ndim, unsigned long nvar, const CConfig *config) : - CIncEulerVariable(pressure, velocity, temperature, npoint, ndim, nvar, config) { + CIncEulerVariable(density, pressure, velocity, temperature, npoint, ndim, nvar, config) { Vorticity.resize(nPoint,3); StrainMag.resize(nPoint); @@ -52,6 +52,7 @@ bool CIncNSVariable::SetPrimVar(unsigned long iPoint, su2double eddy_visc, su2do bool physical = true; + /*--- Set the value of the pressure ---*/ SetPressure(iPoint); @@ -78,6 +79,8 @@ bool CIncNSVariable::SetPrimVar(unsigned long iPoint, su2double eddy_visc, su2do /*--- Set the value of the density ---*/ const auto check_dens = SetDensity(iPoint, FluidModel->GetDensity()); + Density_unsteady[iPoint] = FluidModel->GetDensity(); + /*--- Non-physical solution found. Revert to old values. ---*/ diff --git a/SU2_CFD/src/variables/CSpeciesFlameletVariable.cpp b/SU2_CFD/src/variables/CSpeciesFlameletVariable.cpp index 9b8d9b562126..960a3dbffee5 100644 --- a/SU2_CFD/src/variables/CSpeciesFlameletVariable.cpp +++ b/SU2_CFD/src/variables/CSpeciesFlameletVariable.cpp @@ -27,13 +27,14 @@ #include "../../include/variables/CSpeciesFlameletVariable.hpp" -CSpeciesFlameletVariable::CSpeciesFlameletVariable(const su2double* species_inf, unsigned long npoint, +CSpeciesFlameletVariable::CSpeciesFlameletVariable(const su2double density, const su2double* species_inf, unsigned long npoint, unsigned long ndim, unsigned long nvar, const CConfig* config) - : CSpeciesVariable(species_inf, npoint, ndim, nvar, config) { + : CSpeciesVariable(density,species_inf, npoint, ndim, nvar, config) { for (unsigned long iPoint = 0; iPoint < nPoint; iPoint++) for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution(iPoint, iVar) = species_inf[iVar]; Solution_Old = Solution; + Density_unsteady = density; /*--- Allocate and initialize solution for the dual time strategy ---*/ bool dual_time = ((config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_1ST) || @@ -42,6 +43,7 @@ CSpeciesFlameletVariable::CSpeciesFlameletVariable(const su2double* species_inf, if (dual_time) { Solution_time_n = Solution; Solution_time_n1 = Solution; + Density_unsteady = density; } /*--- Allocate residual structures ---*/ diff --git a/SU2_CFD/src/variables/CSpeciesVariable.cpp b/SU2_CFD/src/variables/CSpeciesVariable.cpp index 5715ae784cab..964595ba25f1 100644 --- a/SU2_CFD/src/variables/CSpeciesVariable.cpp +++ b/SU2_CFD/src/variables/CSpeciesVariable.cpp @@ -27,7 +27,7 @@ #include "../../include/variables/CSpeciesVariable.hpp" -CSpeciesVariable::CSpeciesVariable(const su2double* species_inf, unsigned long npoint, unsigned long ndim, +CSpeciesVariable::CSpeciesVariable(su2double density, const su2double* species_inf, unsigned long npoint, unsigned long ndim, unsigned long nvar, const CConfig* config) : CScalarVariable(npoint, ndim, nvar, config) { /*--- Allocate space for the mass diffusivity. ---*/ @@ -38,6 +38,7 @@ CSpeciesVariable::CSpeciesVariable(const su2double* species_inf, unsigned long n Solution(iPoint, iVar) = species_inf[iVar]; Solution_Old = Solution; + Density_unsteady = density; /*--- Allocate and initialize solution for the dual time strategy ---*/ bool dual_time = ((config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_1ST) || @@ -46,5 +47,6 @@ CSpeciesVariable::CSpeciesVariable(const su2double* species_inf, unsigned long n if (dual_time) { Solution_time_n = Solution; Solution_time_n1 = Solution; + Density_unsteady = density; } } diff --git a/SU2_CFD/src/variables/CVariable.cpp b/SU2_CFD/src/variables/CVariable.cpp index 98ab867b2e92..3a36316106d7 100644 --- a/SU2_CFD/src/variables/CVariable.cpp +++ b/SU2_CFD/src/variables/CVariable.cpp @@ -39,6 +39,11 @@ CVariable::CVariable(unsigned long npoint, unsigned long nvar, const CConfig *co /*--- Allocate the solution array. ---*/ Solution.resize(nPoint,nVar) = su2double(0.0); + Density_unsteady.resize(nPoint); + Density_time_n.resize(nPoint); + + + if (config->GetMultizone_Problem()) Solution_BGS_k.resize(nPoint,nVar) = su2double(0.0); @@ -56,13 +61,22 @@ CVariable::CVariable(unsigned long npoint, unsigned long ndim, unsigned long nva that are specific to one solver, i.e. not common, in this class. ---*/ Solution.resize(nPoint,nVar) = su2double(0.0); + + + Solution_Old.resize(nPoint,nVar) = su2double(0.0); if (config->GetTime_Domain()) Solution_time_n.resize(nPoint,nVar) = su2double(0.0); + if (config->GetTime_Domain()) { + Density_unsteady.resize(nPoint); + Density_time_n.resize(nPoint); + } + if (config->GetTime_Marching() != TIME_MARCHING::STEADY) Solution_time_n1.resize(nPoint,nVar) = su2double(0.0); + if (config->GetDiscrete_Adjoint()) { if (adjoint && config->GetMultizone_Problem()) @@ -93,6 +107,11 @@ void CVariable::Set_Solution_time_n() { parallelCopy(Solution.size(), Solution.data(), Solution_time_n.data()); } +void CVariable::Set_Density_time_n(){ + assert(Density_time_n.size() == Density_unsteady.size()); + parallelCopy(Density_unsteady.size(),Density_unsteady.data(), Density_time_n.data()); +} + void CVariable::Set_Solution_time_n1() { assert(Solution_time_n1.size() == Solution_time_n.size()); parallelCopy(Solution_time_n.size(), Solution_time_n.data(), Solution_time_n1.data()); diff --git a/Tutorials b/Tutorials new file mode 160000 index 000000000000..e8d5cdbb9609 --- /dev/null +++ b/Tutorials @@ -0,0 +1 @@ +Subproject commit e8d5cdbb96093e659f268b15cfe4a32572335256 diff --git a/build_su2.slurm b/build_su2.slurm new file mode 100644 index 000000000000..5185d7313064 --- /dev/null +++ b/build_su2.slurm @@ -0,0 +1,24 @@ +#!/bin/bash + + +#SBATCH --job-name=build_su2 # Job name +#SBATCH -p genoa +#SBATCH --time=00:10:00 # Maximum runtime (adjust as needed) +#SBATCH --nodes=1 # Number of nodes +#SBATCH --ntasks=1 # Total tasks +#SBATCH --cpus-per-task=16 # CPU cores per task +#SBATCH --output=su2_build_%j.log # Output log file + +# Load required modules +module load 2022 +module load foss/2022a + +# Clone SU2 repository if not done already + + +/home/tberk/SU2/meson.py build -Dwarning_level=2 -Denable-autodiff=true -Denable-directdiff=false -Dwith-mpi=enabled -Denable-cgns=true -Denable-tecio=false -Denable-mlpcpp=true --prefix=/gpfs/home5/tberk/SU2 + +/home/tberk/SU2/ninja -C build install -j16 + + + diff --git a/build_su2_develop.slurm b/build_su2_develop.slurm new file mode 100644 index 000000000000..5185d7313064 --- /dev/null +++ b/build_su2_develop.slurm @@ -0,0 +1,24 @@ +#!/bin/bash + + +#SBATCH --job-name=build_su2 # Job name +#SBATCH -p genoa +#SBATCH --time=00:10:00 # Maximum runtime (adjust as needed) +#SBATCH --nodes=1 # Number of nodes +#SBATCH --ntasks=1 # Total tasks +#SBATCH --cpus-per-task=16 # CPU cores per task +#SBATCH --output=su2_build_%j.log # Output log file + +# Load required modules +module load 2022 +module load foss/2022a + +# Clone SU2 repository if not done already + + +/home/tberk/SU2/meson.py build -Dwarning_level=2 -Denable-autodiff=true -Denable-directdiff=false -Dwith-mpi=enabled -Denable-cgns=true -Denable-tecio=false -Denable-mlpcpp=true --prefix=/gpfs/home5/tberk/SU2 + +/home/tberk/SU2/ninja -C build install -j16 + + + From 6aeb0a3598742447ed8bf49617a3358173c1fa9b Mon Sep 17 00:00:00 2001 From: Tahsin Berk Kiymaz Date: Tue, 17 Jun 2025 11:56:55 +0200 Subject: [PATCH 02/39] my changes --- Tutorials | 1 - 1 file changed, 1 deletion(-) delete mode 160000 Tutorials diff --git a/Tutorials b/Tutorials deleted file mode 160000 index e8d5cdbb9609..000000000000 --- a/Tutorials +++ /dev/null @@ -1 +0,0 @@ -Subproject commit e8d5cdbb96093e659f268b15cfe4a32572335256 From 79e238ccf237f2e288387780279f90ddfc3e9be7 Mon Sep 17 00:00:00 2001 From: Tahsin Berk Kiymaz Date: Tue, 2 Sep 2025 00:12:36 +0200 Subject: [PATCH 03/39] specieschanges --- SU2_CFD/include/variables/CSpeciesFlameletVariable.hpp | 2 +- SU2_CFD/include/variables/CSpeciesVariable.hpp | 2 +- SU2_CFD/src/numerics/flow/convection/fds.cpp | 6 +++--- SU2_CFD/src/solvers/CIncEulerSolver.cpp | 6 +++--- SU2_CFD/src/variables/CSpeciesFlameletVariable.cpp | 8 ++++---- SU2_CFD/src/variables/CSpeciesVariable.cpp | 6 +++--- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/SU2_CFD/include/variables/CSpeciesFlameletVariable.hpp b/SU2_CFD/include/variables/CSpeciesFlameletVariable.hpp index 7d9cf63e8504..a1eac80ae48e 100644 --- a/SU2_CFD/include/variables/CSpeciesFlameletVariable.hpp +++ b/SU2_CFD/include/variables/CSpeciesFlameletVariable.hpp @@ -48,7 +48,7 @@ class CSpeciesFlameletVariable final : public CSpeciesVariable { * \param[in] nvar - Number of variables of the problem. * \param[in] config - Definition of the particular problem. */ - CSpeciesFlameletVariable(const su2double density, const su2double* species_inf, unsigned long npoint, unsigned long ndim, unsigned long nvar, + CSpeciesFlameletVariable(const su2double* species_inf, unsigned long npoint, unsigned long ndim, unsigned long nvar, const CConfig* config); /*! diff --git a/SU2_CFD/include/variables/CSpeciesVariable.hpp b/SU2_CFD/include/variables/CSpeciesVariable.hpp index c6bc9d976124..faeca8fa7194 100644 --- a/SU2_CFD/include/variables/CSpeciesVariable.hpp +++ b/SU2_CFD/include/variables/CSpeciesVariable.hpp @@ -48,7 +48,7 @@ class CSpeciesVariable : public CScalarVariable { * \param[in] nvar - Number of variables of the problem. * \param[in] config - Definition of the particular problem. */ - CSpeciesVariable(su2double density,const su2double* species_inf, unsigned long npoint, unsigned long ndim, unsigned long nvar, + CSpeciesVariable(const su2double* species_inf, unsigned long npoint, unsigned long ndim, unsigned long nvar, const CConfig* config); /*! diff --git a/SU2_CFD/src/numerics/flow/convection/fds.cpp b/SU2_CFD/src/numerics/flow/convection/fds.cpp index ae48e59f3365..6a588ed96704 100644 --- a/SU2_CFD/src/numerics/flow/convection/fds.cpp +++ b/SU2_CFD/src/numerics/flow/convection/fds.cpp @@ -157,9 +157,9 @@ CNumerics::ResidualType<> CUpwFDSInc_Flow::ComputeResidual(const CConfig *config MeandRhodT = 0.0; dRhodT_i = 0.0; dRhodT_j = 0.0; if (variable_density) { - MeandRhodT = -MeanDensity/MeanTemperature; - dRhodT_i = -DensityInc_i/Temperature_i; - dRhodT_j = -DensityInc_j/Temperature_j; + MeandRhodT = 0; + dRhodT_i = 0; + dRhodT_j = 0; } /*--- Compute ProjFlux_i ---*/ diff --git a/SU2_CFD/src/solvers/CIncEulerSolver.cpp b/SU2_CFD/src/solvers/CIncEulerSolver.cpp index 16a48ed770ac..d32c475c5223 100644 --- a/SU2_CFD/src/solvers/CIncEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CIncEulerSolver.cpp @@ -2008,7 +2008,7 @@ void CIncEulerSolver::SetPreconditioner(const CConfig *config, unsigned long iPo law, but in the future, dRhodT should be in the fluid model. ---*/ if (variable_density) { - dRhodT = -Density/Temperature; + dRhodT = 0.0; } else { dRhodT = 0.0; } @@ -2732,8 +2732,8 @@ void CIncEulerSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver V2U(Density_time_n, Cp, V_time_n, U_time_n); V2U(Density, Cp, V_time_nP1, U_time_nP1); - if (iPoint==100) - cout <<"density="<GetTime_Marching() == TIME_MARCHING::DT_STEPPING_1ST) || @@ -43,7 +43,7 @@ CSpeciesFlameletVariable::CSpeciesFlameletVariable(const su2double density, cons if (dual_time) { Solution_time_n = Solution; Solution_time_n1 = Solution; - Density_unsteady = density; + } /*--- Allocate residual structures ---*/ diff --git a/SU2_CFD/src/variables/CSpeciesVariable.cpp b/SU2_CFD/src/variables/CSpeciesVariable.cpp index 964595ba25f1..6f35e5bf9c32 100644 --- a/SU2_CFD/src/variables/CSpeciesVariable.cpp +++ b/SU2_CFD/src/variables/CSpeciesVariable.cpp @@ -27,7 +27,7 @@ #include "../../include/variables/CSpeciesVariable.hpp" -CSpeciesVariable::CSpeciesVariable(su2double density, const su2double* species_inf, unsigned long npoint, unsigned long ndim, +CSpeciesVariable::CSpeciesVariable( const su2double* species_inf, unsigned long npoint, unsigned long ndim, unsigned long nvar, const CConfig* config) : CScalarVariable(npoint, ndim, nvar, config) { /*--- Allocate space for the mass diffusivity. ---*/ @@ -38,7 +38,7 @@ CSpeciesVariable::CSpeciesVariable(su2double density, const su2double* species_i Solution(iPoint, iVar) = species_inf[iVar]; Solution_Old = Solution; - Density_unsteady = density; + /*--- Allocate and initialize solution for the dual time strategy ---*/ bool dual_time = ((config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_1ST) || @@ -47,6 +47,6 @@ CSpeciesVariable::CSpeciesVariable(su2double density, const su2double* species_i if (dual_time) { Solution_time_n = Solution; Solution_time_n1 = Solution; - Density_unsteady = density; + } } From 526b9a142892a8b4996651f328daa66685dd086b Mon Sep 17 00:00:00 2001 From: Tahsin Berk Kiymaz Date: Wed, 10 Dec 2025 14:56:00 +0100 Subject: [PATCH 04/39] Remove slurm files from repository --- build_su2.slurm | 24 ------------------------ build_su2_develop.slurm | 24 ------------------------ 2 files changed, 48 deletions(-) delete mode 100644 build_su2.slurm delete mode 100644 build_su2_develop.slurm diff --git a/build_su2.slurm b/build_su2.slurm deleted file mode 100644 index 5185d7313064..000000000000 --- a/build_su2.slurm +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - - -#SBATCH --job-name=build_su2 # Job name -#SBATCH -p genoa -#SBATCH --time=00:10:00 # Maximum runtime (adjust as needed) -#SBATCH --nodes=1 # Number of nodes -#SBATCH --ntasks=1 # Total tasks -#SBATCH --cpus-per-task=16 # CPU cores per task -#SBATCH --output=su2_build_%j.log # Output log file - -# Load required modules -module load 2022 -module load foss/2022a - -# Clone SU2 repository if not done already - - -/home/tberk/SU2/meson.py build -Dwarning_level=2 -Denable-autodiff=true -Denable-directdiff=false -Dwith-mpi=enabled -Denable-cgns=true -Denable-tecio=false -Denable-mlpcpp=true --prefix=/gpfs/home5/tberk/SU2 - -/home/tberk/SU2/ninja -C build install -j16 - - - diff --git a/build_su2_develop.slurm b/build_su2_develop.slurm deleted file mode 100644 index 5185d7313064..000000000000 --- a/build_su2_develop.slurm +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - - -#SBATCH --job-name=build_su2 # Job name -#SBATCH -p genoa -#SBATCH --time=00:10:00 # Maximum runtime (adjust as needed) -#SBATCH --nodes=1 # Number of nodes -#SBATCH --ntasks=1 # Total tasks -#SBATCH --cpus-per-task=16 # CPU cores per task -#SBATCH --output=su2_build_%j.log # Output log file - -# Load required modules -module load 2022 -module load foss/2022a - -# Clone SU2 repository if not done already - - -/home/tberk/SU2/meson.py build -Dwarning_level=2 -Denable-autodiff=true -Denable-directdiff=false -Dwith-mpi=enabled -Denable-cgns=true -Denable-tecio=false -Denable-mlpcpp=true --prefix=/gpfs/home5/tberk/SU2 - -/home/tberk/SU2/ninja -C build install -j16 - - - From 59979d0897198a54c96974e0a549b5e066250fbc Mon Sep 17 00:00:00 2001 From: tkiymaz <79564236+tkiymaz@users.noreply.github.com> Date: Wed, 10 Dec 2025 18:08:32 +0100 Subject: [PATCH 05/39] Remove unnecessary blank line in COutput.hpp --- SU2_CFD/include/output/COutput.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/SU2_CFD/include/output/COutput.hpp b/SU2_CFD/include/output/COutput.hpp index 90a3e4422fca..67b30394eba9 100644 --- a/SU2_CFD/include/output/COutput.hpp +++ b/SU2_CFD/include/output/COutput.hpp @@ -302,7 +302,6 @@ class COutput { /*! \brief Minimum required volume fields for restart file. */ const std::vector restartVolumeFields = {"COORDINATES", "SOLUTION", "SENSITIVITY", "GRID_VELOCITY","DENSITY_TIME_N"}; - /*----------------------------- Convergence monitoring ----------------------------*/ su2double cauchyValue, /*!< \brief Summed value of the convergence indicator. */ From 99abfa429cf37603fd81b3a003b98657a1e44f18 Mon Sep 17 00:00:00 2001 From: tkiymaz <79564236+tkiymaz@users.noreply.github.com> Date: Wed, 10 Dec 2025 18:13:22 +0100 Subject: [PATCH 06/39] Clean up commented-out density setting code Removed commented-out code for setting density at local point. --- SU2_CFD/include/solvers/CFVMFlowSolverBase.inl | 5 ----- 1 file changed, 5 deletions(-) diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl index 121987ff0382..8ef8e422d185 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl @@ -882,9 +882,6 @@ void CFVMFlowSolverBase::LoadRestart_impl(CGeometry **geometry, CSolver ** nodes->SetSolution(iPoint_Local, SolutionRestart); } - - // nodes->Set_Density_time_n(iPoint_Local, Restart_Data[index + nVar_Restart]); - /*--- For dynamic meshes, read in and store the grid coordinates and grid velocities for each node. ---*/ @@ -896,7 +893,6 @@ void CFVMFlowSolverBase::LoadRestart_impl(CGeometry **geometry, CSolver ** /*--- Rewind the index to retrieve the Coords. ---*/ index = counter * Restart_Vars[1]; - const auto* Coord = &Restart_Data[index]; su2double GridVel[MAXNDIM] = {0.0}; @@ -918,7 +914,6 @@ void CFVMFlowSolverBase::LoadRestart_impl(CGeometry **geometry, CSolver ** if (static_fsi && update_geo) { /*--- Rewind the index to retrieve the Coords. ---*/ index = counter*Restart_Vars[1]; - const auto* Coord = &Restart_Data[index]; for (auto iDim = 0u; iDim < nDim; iDim++) { From bee5a270010f2071d9d28db4437db65304cf7394 Mon Sep 17 00:00:00 2001 From: tkiymaz <79564236+tkiymaz@users.noreply.github.com> Date: Wed, 10 Dec 2025 18:16:13 +0100 Subject: [PATCH 07/39] Update density retrieval comment for transient handling Updated the comment for density retrieval to reflect changes for transient density handling. --- SU2_CFD/include/solvers/CScalarSolver.inl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SU2_CFD/include/solvers/CScalarSolver.inl b/SU2_CFD/include/solvers/CScalarSolver.inl index 33812ec035e8..a023162463aa 100644 --- a/SU2_CFD/include/solvers/CScalarSolver.inl +++ b/SU2_CFD/include/solvers/CScalarSolver.inl @@ -694,7 +694,7 @@ void CScalarSolver::SetResidual_DualTime(CGeometry* geometry, CSol if (Conservative) { if (incompressible) - Density_n = flowNodes->GetDensity_time_n(iPoint); // Temporary fix + Density_n = flowNodes->GetDensity_time_n(iPoint); // Updated for transient density else Density_n = flowNodes->GetSolution_time_n(iPoint, 0); } @@ -750,7 +750,7 @@ void CScalarSolver::SetResidual_DualTime(CGeometry* geometry, CSol if (Conservative) { if (incompressible) - Density_n = flowNodes->GetDensity_time_n(iPoint); // Temporary fix + Density_n = flowNodes->GetDensity_time_n(iPoint); // Updated for transient density else Density_n = flowNodes->GetSolution_time_n(iPoint, 0); } From cea69cc22f6753e5029176a675cfe4a968467afd Mon Sep 17 00:00:00 2001 From: tkiymaz <79564236+tkiymaz@users.noreply.github.com> Date: Wed, 10 Dec 2025 18:17:10 +0100 Subject: [PATCH 08/39] Remove empty line before temperature setter comment --- SU2_CFD/include/variables/CEulerVariable.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/SU2_CFD/include/variables/CEulerVariable.hpp b/SU2_CFD/include/variables/CEulerVariable.hpp index 137f912fabca..44006d9d4fcd 100644 --- a/SU2_CFD/include/variables/CEulerVariable.hpp +++ b/SU2_CFD/include/variables/CEulerVariable.hpp @@ -192,7 +192,6 @@ class CEulerVariable : public CFlowVariable { Density_unsteady[iPoint] = val; } - /*! * \brief Set the value of the temperature. * \param[in] temperature - how agitated the particles are :) From a721a2ec90b8df48778a067f3d87df0a3eb929f0 Mon Sep 17 00:00:00 2001 From: tkiymaz <79564236+tkiymaz@users.noreply.github.com> Date: Wed, 10 Dec 2025 18:20:10 +0100 Subject: [PATCH 09/39] Clean up whitespace in CIncEulerVariable.hpp Removed unnecessary blank lines in CIncEulerVariable.hpp --- SU2_CFD/include/variables/CIncEulerVariable.hpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/SU2_CFD/include/variables/CIncEulerVariable.hpp b/SU2_CFD/include/variables/CIncEulerVariable.hpp index 8f846ca0d8ea..7fe647ce44bc 100644 --- a/SU2_CFD/include/variables/CIncEulerVariable.hpp +++ b/SU2_CFD/include/variables/CIncEulerVariable.hpp @@ -100,7 +100,6 @@ class CIncEulerVariable : public CFlowVariable { return val_density <= 0.0; } - inline void Set_Density_time_n(unsigned long iPoint, su2double val) { Density_time_n[iPoint] = val; } @@ -113,7 +112,6 @@ class CIncEulerVariable : public CFlowVariable { return Density_time_n[iPoint]; } - /*! * \brief Set the value of the density for the incompressible flows. * \param[in] iPoint - Point index. @@ -161,8 +159,6 @@ class CIncEulerVariable : public CFlowVariable { */ inline su2double GetDensity(unsigned long iPoint) const final { return Primitive(iPoint, indices.Density()); } - - /*! * \brief Get the temperature of the flow. * \return Value of the temperature of the flow. From 02c03bbfde11d7d6a0e4891246de92f456e9fedf Mon Sep 17 00:00:00 2001 From: tkiymaz <79564236+tkiymaz@users.noreply.github.com> Date: Wed, 10 Dec 2025 18:22:14 +0100 Subject: [PATCH 10/39] Clean up blank lines in CVariable.hpp Removed unnecessary blank lines in CVariable.hpp --- SU2_CFD/include/variables/CVariable.hpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/SU2_CFD/include/variables/CVariable.hpp b/SU2_CFD/include/variables/CVariable.hpp index 1931dee89c1c..120d01f4cd23 100644 --- a/SU2_CFD/include/variables/CVariable.hpp +++ b/SU2_CFD/include/variables/CVariable.hpp @@ -282,7 +282,6 @@ class CVariable { */ void Set_Density_time_n(); - /*! * \brief Set the variable solution at time n. * \param[in] iPoint - Point index. @@ -324,7 +323,6 @@ class CVariable { Density_unsteady[iPoint] = val; } - /*! * \brief Virtual Member. Specify a vector to set the velocity components of the solution. * Multiplied by density for compressible cases. @@ -519,7 +517,6 @@ class CVariable { inline su2double *GetSolution_time_n1(unsigned long iPoint) { return Solution_time_n1[iPoint]; } inline MatrixType& GetSolution_time_n1() { return Solution_time_n1; } - /*! * \brief Get the solution at time n. * \param[in] iPoint - Point index. @@ -1903,8 +1900,6 @@ class CVariable { */ inline su2double GetSolution_time_n1(unsigned long iPoint, unsigned long iVar) const { return Solution_time_n1(iPoint,iVar); } - - /*! * \brief Get the velocity (Structural Analysis). * \param[in] iVar - Index of the variable. From 0449bb47a3b730b398cb0179f41708f735f457ad Mon Sep 17 00:00:00 2001 From: tkiymaz <79564236+tkiymaz@users.noreply.github.com> Date: Wed, 10 Dec 2025 18:23:56 +0100 Subject: [PATCH 11/39] Clean up CFlowIncOutput.cpp by removing blank lines Removed unnecessary blank lines to improve code readability. --- SU2_CFD/src/output/CFlowIncOutput.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/SU2_CFD/src/output/CFlowIncOutput.cpp b/SU2_CFD/src/output/CFlowIncOutput.cpp index fe22d2386606..0476a1352fe8 100644 --- a/SU2_CFD/src/output/CFlowIncOutput.cpp +++ b/SU2_CFD/src/output/CFlowIncOutput.cpp @@ -293,7 +293,6 @@ void CFlowIncOutput::SetVolumeOutputFields(CConfig *config){ AddVolumeOutput("PRESSURE", "Pressure", "SOLUTION", "Pressure"); AddVolumeOutput("VELOCITY-X", "Velocity_x", "SOLUTION", "x-component of the velocity vector"); AddVolumeOutput("VELOCITY-Y", "Velocity_y", "SOLUTION", "y-component of the velocity vector"); - if (nDim == 3) AddVolumeOutput("VELOCITY-Z", "Velocity_z", "SOLUTION", "z-component of the velocity vector"); if (heat || weakly_coupled_heat || flamelet) @@ -377,8 +376,6 @@ void CFlowIncOutput::SetVolumeOutputFields(CConfig *config){ AddCommonFVMOutputs(config); AddVolumeOutput("DENSITY_TIME_N", "Density_time_n", "SOLUTION", "Density at previous time step"); - - if (config->GetTime_Domain()) { SetTimeAveragedFields(); } @@ -424,7 +421,6 @@ void CFlowIncOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSolve SetVolumeOutputValue("DENSITY", iPoint, Node_Flow->GetDensity(iPoint)); SetVolumeOutputValue("DENSITY_TIME_N", iPoint, Node_Flow->GetDensity_time_n(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)); From 572291f96e62e5669a927a699dd3ceef8068dc8c Mon Sep 17 00:00:00 2001 From: tkiymaz <79564236+tkiymaz@users.noreply.github.com> Date: Wed, 10 Dec 2025 18:28:50 +0100 Subject: [PATCH 12/39] Clean up CompleteImplicitIteration and update dRhodT Removed commented-out code and updated density calculation. --- SU2_CFD/src/solvers/CIncEulerSolver.cpp | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/SU2_CFD/src/solvers/CIncEulerSolver.cpp b/SU2_CFD/src/solvers/CIncEulerSolver.cpp index d32c475c5223..26d93e5e942d 100644 --- a/SU2_CFD/src/solvers/CIncEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CIncEulerSolver.cpp @@ -1927,16 +1927,8 @@ void CIncEulerSolver::PrepareImplicitIteration(CGeometry *geometry, CSolver**, C void CIncEulerSolver::CompleteImplicitIteration(CGeometry *geometry, CSolver**, CConfig *config) { CompleteImplicitIteration_impl(geometry, config); - - //if (config->GetTime_Domain()) { - // for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) { - // nodes->SetDensity_time_n(iPoint, nodes->GetDensity_unsteady(iPoint)); - // } - // } - } - void CIncEulerSolver::SetBeta_Parameter(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh) { static su2double MaxVel2; @@ -2008,7 +2000,7 @@ void CIncEulerSolver::SetPreconditioner(const CConfig *config, unsigned long iPo law, but in the future, dRhodT should be in the fluid model. ---*/ if (variable_density) { - dRhodT = 0.0; + dRhodT = -Density/Temperature; } else { dRhodT = 0.0; } @@ -2720,22 +2712,15 @@ void CIncEulerSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver Density_time_n = nodes->GetDensity_time_n(iPoint); Density_unsteady = nodes->GetDensity_unsteady(iPoint); - Density = nodes->GetDensity(iPoint); - - Cp = nodes->GetSpecificHeatCp(iPoint); - + /*--- Compute the conservative variable vector for all time levels. ---*/ V2U(Density, Cp, V_time_nM1, U_time_nM1); V2U(Density_time_n, Cp, V_time_n, U_time_n); V2U(Density, Cp, V_time_nP1, U_time_nP1); - /*if (iPoint==100) - cout <<"density="<GetDensity()); Density_unsteady[iPoint] = FluidModel->GetDensity(); - /*--- Non-physical solution found. Revert to old values. ---*/ if (check_dens || check_temp) { @@ -116,7 +113,6 @@ bool CIncEulerVariable::SetPrimVar(unsigned long iPoint, CFluidModel *FluidModel FluidModel->SetTDState_T(Temperature); SetDensity(iPoint, FluidModel->GetDensity()); - /*--- Flag this point as non-physical. ---*/ physical = false; From 644a543f37bddb5885be5da80e08b2fe557879fb Mon Sep 17 00:00:00 2001 From: tkiymaz <79564236+tkiymaz@users.noreply.github.com> Date: Wed, 10 Dec 2025 18:37:50 +0100 Subject: [PATCH 15/39] Clean up blank lines in CIncNSVariable.cpp Removed unnecessary blank lines in SetPrimVar function. --- SU2_CFD/src/variables/CIncNSVariable.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/SU2_CFD/src/variables/CIncNSVariable.cpp b/SU2_CFD/src/variables/CIncNSVariable.cpp index 73412a341b84..904d48133355 100644 --- a/SU2_CFD/src/variables/CIncNSVariable.cpp +++ b/SU2_CFD/src/variables/CIncNSVariable.cpp @@ -52,7 +52,6 @@ bool CIncNSVariable::SetPrimVar(unsigned long iPoint, su2double eddy_visc, su2do bool physical = true; - /*--- Set the value of the pressure ---*/ SetPressure(iPoint); @@ -81,7 +80,6 @@ bool CIncNSVariable::SetPrimVar(unsigned long iPoint, su2double eddy_visc, su2do const auto check_dens = SetDensity(iPoint, FluidModel->GetDensity()); Density_unsteady[iPoint] = FluidModel->GetDensity(); - /*--- Non-physical solution found. Revert to old values. ---*/ if (check_dens || check_temp) { From fed4892e122b52e2f13c8c57ed50e4e0955ea099 Mon Sep 17 00:00:00 2001 From: tkiymaz <79564236+tkiymaz@users.noreply.github.com> Date: Wed, 10 Dec 2025 18:40:28 +0100 Subject: [PATCH 16/39] Clean up whitespace in CVariable.cpp Removed unnecessary blank lines in CVariable.cpp. --- SU2_CFD/src/variables/CVariable.cpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/SU2_CFD/src/variables/CVariable.cpp b/SU2_CFD/src/variables/CVariable.cpp index 3a36316106d7..04aa14bb34aa 100644 --- a/SU2_CFD/src/variables/CVariable.cpp +++ b/SU2_CFD/src/variables/CVariable.cpp @@ -42,8 +42,6 @@ CVariable::CVariable(unsigned long npoint, unsigned long nvar, const CConfig *co Density_unsteady.resize(nPoint); Density_time_n.resize(nPoint); - - if (config->GetMultizone_Problem()) Solution_BGS_k.resize(nPoint,nVar) = su2double(0.0); @@ -60,10 +58,6 @@ CVariable::CVariable(unsigned long npoint, unsigned long ndim, unsigned long nva /*--- Allocate fields common to all problems. Do not allocate fields that are specific to one solver, i.e. not common, in this class. ---*/ Solution.resize(nPoint,nVar) = su2double(0.0); - - - - Solution_Old.resize(nPoint,nVar) = su2double(0.0); if (config->GetTime_Domain()) @@ -77,7 +71,6 @@ CVariable::CVariable(unsigned long npoint, unsigned long ndim, unsigned long nva if (config->GetTime_Marching() != TIME_MARCHING::STEADY) Solution_time_n1.resize(nPoint,nVar) = su2double(0.0); - if (config->GetDiscrete_Adjoint()) { if (adjoint && config->GetMultizone_Problem()) External.resize(nPoint,nVar) = su2double(0.0); From 8e09f7f8327ebf79450ac6ef1a34fb4a04d6da2e Mon Sep 17 00:00:00 2001 From: tkiymaz <79564236+tkiymaz@users.noreply.github.com> Date: Wed, 10 Dec 2025 18:43:10 +0100 Subject: [PATCH 17/39] Fix constructor signature for CSpeciesVariable --- SU2_CFD/src/variables/CSpeciesVariable.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/SU2_CFD/src/variables/CSpeciesVariable.cpp b/SU2_CFD/src/variables/CSpeciesVariable.cpp index 6f35e5bf9c32..a670d10f5624 100644 --- a/SU2_CFD/src/variables/CSpeciesVariable.cpp +++ b/SU2_CFD/src/variables/CSpeciesVariable.cpp @@ -27,7 +27,7 @@ #include "../../include/variables/CSpeciesVariable.hpp" -CSpeciesVariable::CSpeciesVariable( const su2double* species_inf, unsigned long npoint, unsigned long ndim, +CSpeciesVariable::CSpeciesVariable(const su2double* species_inf, unsigned long npoint, unsigned long ndim, unsigned long nvar, const CConfig* config) : CScalarVariable(npoint, ndim, nvar, config) { /*--- Allocate space for the mass diffusivity. ---*/ @@ -38,7 +38,6 @@ CSpeciesVariable::CSpeciesVariable( const su2double* species_inf, unsigned long Solution(iPoint, iVar) = species_inf[iVar]; Solution_Old = Solution; - /*--- Allocate and initialize solution for the dual time strategy ---*/ bool dual_time = ((config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_1ST) || From 1e5008a4ff3fdc2eaec8895c0b78ea60072961cd Mon Sep 17 00:00:00 2001 From: tkiymaz <79564236+tkiymaz@users.noreply.github.com> Date: Wed, 10 Dec 2025 18:43:53 +0100 Subject: [PATCH 18/39] Remove unnecessary blank line in CSpeciesVariable.cpp --- SU2_CFD/src/variables/CSpeciesVariable.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/SU2_CFD/src/variables/CSpeciesVariable.cpp b/SU2_CFD/src/variables/CSpeciesVariable.cpp index a670d10f5624..5715ae784cab 100644 --- a/SU2_CFD/src/variables/CSpeciesVariable.cpp +++ b/SU2_CFD/src/variables/CSpeciesVariable.cpp @@ -46,6 +46,5 @@ CSpeciesVariable::CSpeciesVariable(const su2double* species_inf, unsigned long n if (dual_time) { Solution_time_n = Solution; Solution_time_n1 = Solution; - } } From 2aebc5407f870cfda9c7c8ab6ce2201d45b8022c Mon Sep 17 00:00:00 2001 From: tkiymaz <79564236+tkiymaz@users.noreply.github.com> Date: Wed, 10 Dec 2025 18:45:11 +0100 Subject: [PATCH 19/39] Fix constructor signature for CSpeciesFlameletVariable --- SU2_CFD/src/variables/CSpeciesFlameletVariable.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/SU2_CFD/src/variables/CSpeciesFlameletVariable.cpp b/SU2_CFD/src/variables/CSpeciesFlameletVariable.cpp index 424cfc561f27..9b8d9b562126 100644 --- a/SU2_CFD/src/variables/CSpeciesFlameletVariable.cpp +++ b/SU2_CFD/src/variables/CSpeciesFlameletVariable.cpp @@ -27,14 +27,13 @@ #include "../../include/variables/CSpeciesFlameletVariable.hpp" -CSpeciesFlameletVariable::CSpeciesFlameletVariable( const su2double* species_inf, unsigned long npoint, +CSpeciesFlameletVariable::CSpeciesFlameletVariable(const su2double* species_inf, unsigned long npoint, unsigned long ndim, unsigned long nvar, const CConfig* config) : CSpeciesVariable(species_inf, npoint, ndim, nvar, config) { for (unsigned long iPoint = 0; iPoint < nPoint; iPoint++) for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution(iPoint, iVar) = species_inf[iVar]; Solution_Old = Solution; - /*--- Allocate and initialize solution for the dual time strategy ---*/ bool dual_time = ((config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_1ST) || @@ -43,7 +42,6 @@ CSpeciesFlameletVariable::CSpeciesFlameletVariable( const su2double* species_inf if (dual_time) { Solution_time_n = Solution; Solution_time_n1 = Solution; - } /*--- Allocate residual structures ---*/ From 3f19c55fcdac688bd71329ebb7de1751b28b2cc5 Mon Sep 17 00:00:00 2001 From: tkiymaz <79564236+tkiymaz@users.noreply.github.com> Date: Wed, 10 Dec 2025 18:51:32 +0100 Subject: [PATCH 20/39] Remove debug output from SetPrimVar method Removed debug print statement from SetPrimVar function. --- SU2_CFD/src/variables/CIncEulerVariable.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/SU2_CFD/src/variables/CIncEulerVariable.cpp b/SU2_CFD/src/variables/CIncEulerVariable.cpp index 2d8fe1098b81..43c040536658 100644 --- a/SU2_CFD/src/variables/CIncEulerVariable.cpp +++ b/SU2_CFD/src/variables/CIncEulerVariable.cpp @@ -67,12 +67,6 @@ CIncEulerVariable::CIncEulerVariable(su2double density, su2double pressure, cons } bool CIncEulerVariable::SetPrimVar(unsigned long iPoint, CFluidModel *FluidModel) { - static bool printed = false; - if (!printed) { - std::cout << "[DEBUG] SetPrimVar was called!" << std::endl; - printed = true; - } - bool physical = true; /*--- Set the value of the pressure ---*/ From 735c27bd8f9126aba4576bb5e9eb6862b6211993 Mon Sep 17 00:00:00 2001 From: Nijso Date: Tue, 16 Dec 2025 17:13:10 +0100 Subject: [PATCH 21/39] Update SU2_CFD/include/variables/CVariable.hpp Co-authored-by: Cristopher Morales <98025159+Cristopher-Morales@users.noreply.github.com> --- SU2_CFD/include/variables/CVariable.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/include/variables/CVariable.hpp b/SU2_CFD/include/variables/CVariable.hpp index 436125aba78a..ce3d221db76d 100644 --- a/SU2_CFD/include/variables/CVariable.hpp +++ b/SU2_CFD/include/variables/CVariable.hpp @@ -70,7 +70,7 @@ class CVariable { MatrixType Solution_time_n; /*!< \brief Solution of the problem at time n for dual-time stepping technique. */ MatrixType Solution_time_n1; /*!< \brief Solution of the problem at time n-1 for dual-time stepping technique. */ VectorType Delta_Time; /*!< \brief Time step. */ - VectorType Density_unsteady; + VectorType Density_unsteady; /*!< \brief density for unsteady flows. */ VectorType Density_time_n; /*!< \brief density at time n for dual-time stepping technique. */ CVectorOfMatrix Gradient; /*!< \brief Gradient of the solution of the problem. */ From f9f98a08223916f2f2cc033b9f6ddfca89277bde Mon Sep 17 00:00:00 2001 From: Nijso Date: Tue, 16 Dec 2025 17:13:23 +0100 Subject: [PATCH 22/39] Update SU2_CFD/include/output/COutput.hpp Co-authored-by: Cristopher Morales <98025159+Cristopher-Morales@users.noreply.github.com> --- SU2_CFD/include/output/COutput.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/include/output/COutput.hpp b/SU2_CFD/include/output/COutput.hpp index be78782c0af5..7a3e350d4302 100644 --- a/SU2_CFD/include/output/COutput.hpp +++ b/SU2_CFD/include/output/COutput.hpp @@ -302,7 +302,7 @@ class COutput { unsigned short nRequestedVolumeFields; /*! \brief Minimum required volume fields for restart file. */ - const std::vector restartVolumeFields = {"COORDINATES", "SOLUTION", "SENSITIVITY", "GRID_VELOCITY","DENSITY_TIME_N"}; + const std::vector restartVolumeFields = {"COORDINATES", "SOLUTION", "SENSITIVITY", "GRID_VELOCITY", "DENSITY_TIME_N"}; /*----------------------------- Convergence monitoring ----------------------------*/ From adf7581664c4a94f42fe7d01ce4cf79d8e049fc0 Mon Sep 17 00:00:00 2001 From: Nijso Date: Tue, 16 Dec 2025 17:13:44 +0100 Subject: [PATCH 23/39] Update SU2_CFD/include/variables/CIncEulerVariable.hpp Co-authored-by: Cristopher Morales <98025159+Cristopher-Morales@users.noreply.github.com> --- SU2_CFD/include/variables/CIncEulerVariable.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/include/variables/CIncEulerVariable.hpp b/SU2_CFD/include/variables/CIncEulerVariable.hpp index db07e055f5ab..9c68044ebf7b 100644 --- a/SU2_CFD/include/variables/CIncEulerVariable.hpp +++ b/SU2_CFD/include/variables/CIncEulerVariable.hpp @@ -105,7 +105,7 @@ class CIncEulerVariable : public CFlowVariable { Density_time_n[iPoint] = val; } - inline void Set_Density_unsteady(unsigned long iPoint, su2double val) { + inline void SetDensity_Unsteady(unsigned long iPoint, su2double val) { Density_unsteady[iPoint] = val; } From cc06d7e4037194e4a9bad61c415dd5466a46b41d Mon Sep 17 00:00:00 2001 From: Nijso Date: Tue, 16 Dec 2025 17:14:16 +0100 Subject: [PATCH 24/39] Update SU2_CFD/include/variables/CEulerVariable.hpp Co-authored-by: Cristopher Morales <98025159+Cristopher-Morales@users.noreply.github.com> --- SU2_CFD/include/variables/CEulerVariable.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/SU2_CFD/include/variables/CEulerVariable.hpp b/SU2_CFD/include/variables/CEulerVariable.hpp index 3053f1ff6c45..99a2237aa45c 100644 --- a/SU2_CFD/include/variables/CEulerVariable.hpp +++ b/SU2_CFD/include/variables/CEulerVariable.hpp @@ -189,12 +189,12 @@ class CEulerVariable : public CFlowVariable { return Primitive(iPoint, indices.Density()) <= 0.0; } - inline void Set_Density_time_n(unsigned long iPoint, su2double val) { - Density_time_n[iPoint] = val; + inline void SetDensity_Time_n(unsigned long iPoint, su2double val_density_time_n) { + Density_time_n[iPoint] = val_density_time_n; } - inline void Set_Density_unsteady(unsigned long iPoint, su2double val) { - Density_unsteady[iPoint] = val; + inline void SetDensity_Unsteady(unsigned long iPoint, su2double val_density_unsteady) { + Density_unsteady[iPoint] = val_density_unsteady; } /*! From 6f2a8eb32b04e4578e6aed21eac2a614af5bf8bb Mon Sep 17 00:00:00 2001 From: Nijso Date: Tue, 16 Dec 2025 17:16:13 +0100 Subject: [PATCH 25/39] Update SU2_CFD/src/solvers/CIncEulerSolver.cpp Co-authored-by: Cristopher Morales <98025159+Cristopher-Morales@users.noreply.github.com> --- SU2_CFD/src/solvers/CIncEulerSolver.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/SU2_CFD/src/solvers/CIncEulerSolver.cpp b/SU2_CFD/src/solvers/CIncEulerSolver.cpp index 737f1d737f91..10c9df3ac2e4 100644 --- a/SU2_CFD/src/solvers/CIncEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CIncEulerSolver.cpp @@ -2754,7 +2754,6 @@ void CIncEulerSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver /*--- Access the density and Cp at this node (constant for now). ---*/ Density_time_n = nodes->GetDensity_time_n(iPoint); - Density_unsteady = nodes->GetDensity_unsteady(iPoint); Density = nodes->GetDensity(iPoint); Cp = nodes->GetSpecificHeatCp(iPoint); From fa318d2d2d71352b9d92112cba0e71423870444e Mon Sep 17 00:00:00 2001 From: Nijso Date: Tue, 16 Dec 2025 17:16:29 +0100 Subject: [PATCH 26/39] Update SU2_CFD/src/variables/CVariable.cpp Co-authored-by: Cristopher Morales <98025159+Cristopher-Morales@users.noreply.github.com> --- SU2_CFD/src/variables/CVariable.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/src/variables/CVariable.cpp b/SU2_CFD/src/variables/CVariable.cpp index 63251cce304f..64ae679a2ba0 100644 --- a/SU2_CFD/src/variables/CVariable.cpp +++ b/SU2_CFD/src/variables/CVariable.cpp @@ -69,7 +69,7 @@ CVariable::CVariable(unsigned long npoint, unsigned long ndim, unsigned long nva } if (config->GetTime_Marching() != TIME_MARCHING::STEADY) - Solution_time_n1.resize(nPoint,nVar) = su2double(0.0); + Solution_time_n1.resize(nPoint,nVar) = su2double(0.0); /*--- User defined source terms ---*/ if (config->GetPyCustomSource()) UserDefinedSource.resize(nPoint,nVar) = su2double(0.0); From 3e1b898c328847a1dbfbb06018af04751652984d Mon Sep 17 00:00:00 2001 From: Nijso Date: Tue, 16 Dec 2025 17:17:07 +0100 Subject: [PATCH 27/39] Update SU2_CFD/src/variables/CVariable.cpp Co-authored-by: Cristopher Morales <98025159+Cristopher-Morales@users.noreply.github.com> --- SU2_CFD/src/variables/CVariable.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/SU2_CFD/src/variables/CVariable.cpp b/SU2_CFD/src/variables/CVariable.cpp index 64ae679a2ba0..5ef080971da2 100644 --- a/SU2_CFD/src/variables/CVariable.cpp +++ b/SU2_CFD/src/variables/CVariable.cpp @@ -60,10 +60,8 @@ CVariable::CVariable(unsigned long npoint, unsigned long ndim, unsigned long nva Solution.resize(nPoint,nVar) = su2double(0.0); Solution_Old.resize(nPoint,nVar) = su2double(0.0); - if (config->GetTime_Domain()) - Solution_time_n.resize(nPoint,nVar) = su2double(0.0); - if (config->GetTime_Domain()) { + Solution_time_n.resize(nPoint,nVar) = su2double(0.0); Density_unsteady.resize(nPoint); Density_time_n.resize(nPoint); } From 87a33811e872b67684ea757c07906ff71dd46dfe Mon Sep 17 00:00:00 2001 From: Nijso Date: Tue, 16 Dec 2025 17:18:10 +0100 Subject: [PATCH 28/39] Update SU2_CFD/src/variables/CIncNSVariable.cpp Co-authored-by: Cristopher Morales <98025159+Cristopher-Morales@users.noreply.github.com> --- SU2_CFD/src/variables/CIncNSVariable.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/SU2_CFD/src/variables/CIncNSVariable.cpp b/SU2_CFD/src/variables/CIncNSVariable.cpp index d2ecbfad0833..660e9ed56ab1 100644 --- a/SU2_CFD/src/variables/CIncNSVariable.cpp +++ b/SU2_CFD/src/variables/CIncNSVariable.cpp @@ -78,7 +78,6 @@ bool CIncNSVariable::SetPrimVar(unsigned long iPoint, su2double eddy_visc, su2do /*--- Set the value of the density ---*/ const auto check_dens = SetDensity(iPoint, FluidModel->GetDensity()); - Density_unsteady[iPoint] = FluidModel->GetDensity(); /*--- Non-physical solution found. Revert to old values. ---*/ From b278ad68e5c948484eca06750da1374a339b1217 Mon Sep 17 00:00:00 2001 From: Nijso Date: Tue, 16 Dec 2025 17:18:25 +0100 Subject: [PATCH 29/39] Update SU2_CFD/src/variables/CIncNSVariable.cpp Co-authored-by: Cristopher Morales <98025159+Cristopher-Morales@users.noreply.github.com> --- SU2_CFD/src/variables/CIncNSVariable.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/SU2_CFD/src/variables/CIncNSVariable.cpp b/SU2_CFD/src/variables/CIncNSVariable.cpp index 660e9ed56ab1..58b7d8a6fc71 100644 --- a/SU2_CFD/src/variables/CIncNSVariable.cpp +++ b/SU2_CFD/src/variables/CIncNSVariable.cpp @@ -101,6 +101,9 @@ bool CIncNSVariable::SetPrimVar(unsigned long iPoint, su2double eddy_visc, su2do } +/*--- Set density for unsteady problems ---*/ +Density_unsteady[iPoint] = FluidModel->GetDensity(); + /*--- Set the value of the velocity and velocity^2 (requires density) ---*/ SetVelocity(iPoint); From dda9271dba92887807150d2bf716db40465ca198 Mon Sep 17 00:00:00 2001 From: Nijso Date: Tue, 16 Dec 2025 17:18:50 +0100 Subject: [PATCH 30/39] Update SU2_CFD/src/variables/CIncEulerVariable.cpp Co-authored-by: Cristopher Morales <98025159+Cristopher-Morales@users.noreply.github.com> --- SU2_CFD/src/variables/CIncEulerVariable.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/SU2_CFD/src/variables/CIncEulerVariable.cpp b/SU2_CFD/src/variables/CIncEulerVariable.cpp index 7bd87a051adb..ac31a8eaaa4f 100644 --- a/SU2_CFD/src/variables/CIncEulerVariable.cpp +++ b/SU2_CFD/src/variables/CIncEulerVariable.cpp @@ -69,6 +69,7 @@ CIncEulerVariable::CIncEulerVariable(su2double density, su2double pressure, cons } bool CIncEulerVariable::SetPrimVar(unsigned long iPoint, CFluidModel *FluidModel) { + bool physical = true; /*--- Set the value of the pressure ---*/ From ff74a7ff35da1d27f5a86595cbeb0b98df3bf253 Mon Sep 17 00:00:00 2001 From: Nijso Date: Tue, 16 Dec 2025 17:19:06 +0100 Subject: [PATCH 31/39] Update SU2_CFD/include/solvers/CFVMFlowSolverBase.inl --- SU2_CFD/include/solvers/CFVMFlowSolverBase.inl | 1 + 1 file changed, 1 insertion(+) diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl index 25f2a46d10f5..65c6dd8b8a34 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl @@ -1073,6 +1073,7 @@ void CFVMFlowSolverBase::PushSolutionBackInTime(unsigned long TimeIter, bo solver_container[iMesh][FLOW_SOL]->GetNodes()->Set_Solution_time_n(); solver_container[iMesh][FLOW_SOL]->GetNodes()->Set_Solution_time_n1(); solver_container[iMesh][FLOW_SOL]->GetNodes()->Set_Density_time_n(); + solver_container[iMesh][FLOW_SOL]->GetNodes()->Set_Density_time_n1(); if (rans) { solver_container[iMesh][TURB_SOL]->GetNodes()->Set_Solution_time_n(); solver_container[iMesh][TURB_SOL]->GetNodes()->Set_Solution_time_n1(); From c194c4f7d173fc9977f07110a8521facea9247af Mon Sep 17 00:00:00 2001 From: Nijso Date: Tue, 16 Dec 2025 17:19:36 +0100 Subject: [PATCH 32/39] Update SU2_CFD/src/variables/CIncEulerVariable.cpp --- SU2_CFD/src/variables/CIncEulerVariable.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/SU2_CFD/src/variables/CIncEulerVariable.cpp b/SU2_CFD/src/variables/CIncEulerVariable.cpp index ac31a8eaaa4f..cdbea02734e7 100644 --- a/SU2_CFD/src/variables/CIncEulerVariable.cpp +++ b/SU2_CFD/src/variables/CIncEulerVariable.cpp @@ -58,7 +58,8 @@ CIncEulerVariable::CIncEulerVariable(su2double density, su2double pressure, cons if (dual_time) { Solution_time_n = Solution; Solution_time_n1 = Solution; - Density_unsteady = density; + Density_time_n = density; + Density_time_n1 = density; } if (config->GetKind_Streamwise_Periodic() != ENUM_STREAMWISE_PERIODIC::NONE) { From ac17146cd14775ee922c3865a5ff0fb93142aa0d Mon Sep 17 00:00:00 2001 From: Nijso Date: Tue, 16 Dec 2025 17:19:52 +0100 Subject: [PATCH 33/39] Update SU2_CFD/include/solvers/CFVMFlowSolverBase.inl --- SU2_CFD/include/solvers/CFVMFlowSolverBase.inl | 1 + 1 file changed, 1 insertion(+) diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl index 65c6dd8b8a34..2507188def36 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl @@ -1105,6 +1105,7 @@ void CFVMFlowSolverBase::PushSolutionBackInTime(unsigned long TimeIter, bo for (unsigned short iMesh = 0; iMesh <= config->GetnMGLevels(); iMesh++) { solver_container[iMesh][FLOW_SOL]->GetNodes()->Set_Solution_time_n(); solver_container[iMesh][FLOW_SOL]->GetNodes()->Set_Density_time_n(); + solver_container[iMesh][FLOW_SOL]->GetNodes()->Set_Density_time_n1(); if (rans) solver_container[iMesh][TURB_SOL]->GetNodes()->Set_Solution_time_n(); geometry[iMesh]->nodes->SetVolume_n(); From 35b018f7ef5c3594f63de73942a0236485972a70 Mon Sep 17 00:00:00 2001 From: bigfooted Date: Tue, 16 Dec 2025 18:29:13 +0100 Subject: [PATCH 34/39] most of the second order stuff --- SU2_CFD/include/output/COutput.hpp | 2 +- .../include/solvers/CFVMFlowSolverBase.inl | 5 ++++ SU2_CFD/include/solvers/CScalarSolver.inl | 8 ++---- SU2_CFD/include/variables/CEulerVariable.hpp | 4 +++ .../include/variables/CIncEulerVariable.hpp | 10 ++++++- SU2_CFD/include/variables/CVariable.hpp | 26 +++++++++++++++++-- SU2_CFD/src/integration/CIntegration.cpp | 1 + SU2_CFD/src/output/CFlowIncOutput.cpp | 4 ++- SU2_CFD/src/solvers/CIncEulerSolver.cpp | 6 +++-- SU2_CFD/src/variables/CVariable.cpp | 6 +++++ 10 files changed, 59 insertions(+), 13 deletions(-) diff --git a/SU2_CFD/include/output/COutput.hpp b/SU2_CFD/include/output/COutput.hpp index be78782c0af5..ece3f3eb905d 100644 --- a/SU2_CFD/include/output/COutput.hpp +++ b/SU2_CFD/include/output/COutput.hpp @@ -302,7 +302,7 @@ class COutput { unsigned short nRequestedVolumeFields; /*! \brief Minimum required volume fields for restart file. */ - const std::vector restartVolumeFields = {"COORDINATES", "SOLUTION", "SENSITIVITY", "GRID_VELOCITY","DENSITY_TIME_N"}; + const std::vector restartVolumeFields = {"COORDINATES", "SOLUTION", "SENSITIVITY", "GRID_VELOCITY", "DENSITY_TIME_N", "DENSITY_TIME_N1"}; /*----------------------------- Convergence monitoring ----------------------------*/ diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl index 25f2a46d10f5..df66822c3c6f 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl @@ -1071,10 +1071,13 @@ void CFVMFlowSolverBase::PushSolutionBackInTime(unsigned long TimeIter, bo for (unsigned short iMesh = 0; iMesh <= config->GetnMGLevels(); iMesh++) { solver_container[iMesh][FLOW_SOL]->GetNodes()->Set_Solution_time_n(); + // nijso asks: we are in first order here: can this be removed? solver_container[iMesh][FLOW_SOL]->GetNodes()->Set_Solution_time_n1(); solver_container[iMesh][FLOW_SOL]->GetNodes()->Set_Density_time_n(); + if (rans) { solver_container[iMesh][TURB_SOL]->GetNodes()->Set_Solution_time_n(); + // nijso asks: we are in first order here: can this be removed? solver_container[iMesh][TURB_SOL]->GetNodes()->Set_Solution_time_n1(); } @@ -1102,8 +1105,10 @@ void CFVMFlowSolverBase::PushSolutionBackInTime(unsigned long TimeIter, bo /*--- Push back this new solution to time level N. ---*/ for (unsigned short iMesh = 0; iMesh <= config->GetnMGLevels(); iMesh++) { + // nijso asks: now we are at second order, but we push solution to time_n instead of time_n1 ? solver_container[iMesh][FLOW_SOL]->GetNodes()->Set_Solution_time_n(); solver_container[iMesh][FLOW_SOL]->GetNodes()->Set_Density_time_n(); + solver_container[iMesh][FLOW_SOL]->GetNodes()->Set_Density_time_n1(); if (rans) solver_container[iMesh][TURB_SOL]->GetNodes()->Set_Solution_time_n(); geometry[iMesh]->nodes->SetVolume_n(); diff --git a/SU2_CFD/include/solvers/CScalarSolver.inl b/SU2_CFD/include/solvers/CScalarSolver.inl index 189024dfce82..49fc4ea927d5 100644 --- a/SU2_CFD/include/solvers/CScalarSolver.inl +++ b/SU2_CFD/include/solvers/CScalarSolver.inl @@ -634,11 +634,7 @@ void CScalarSolver::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_nM1 = flowNodes->GetDensity_time_n1(iPoint); Density_n = flowNodes->GetDensity_time_n(iPoint); Density_nP1 = flowNodes->GetDensity(iPoint); } else { @@ -801,7 +797,7 @@ void CScalarSolver::SetResidual_DualTime(CGeometry* geometry, CSol 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_nM1 = flowNodes->GetDensity_time_n1(iPoint); Density_n = flowNodes->GetDensity_time_n(iPoint); Density_nP1 = flowNodes->GetDensity(iPoint); } else { diff --git a/SU2_CFD/include/variables/CEulerVariable.hpp b/SU2_CFD/include/variables/CEulerVariable.hpp index 3053f1ff6c45..996134bb6941 100644 --- a/SU2_CFD/include/variables/CEulerVariable.hpp +++ b/SU2_CFD/include/variables/CEulerVariable.hpp @@ -193,6 +193,10 @@ class CEulerVariable : public CFlowVariable { Density_time_n[iPoint] = val; } + inline void Set_Density_time_n1(unsigned long iPoint, su2double val) { + Density_time_n1[iPoint] = val; + } + inline void Set_Density_unsteady(unsigned long iPoint, su2double val) { Density_unsteady[iPoint] = val; } diff --git a/SU2_CFD/include/variables/CIncEulerVariable.hpp b/SU2_CFD/include/variables/CIncEulerVariable.hpp index db07e055f5ab..6b425faeae05 100644 --- a/SU2_CFD/include/variables/CIncEulerVariable.hpp +++ b/SU2_CFD/include/variables/CIncEulerVariable.hpp @@ -105,6 +105,10 @@ class CIncEulerVariable : public CFlowVariable { Density_time_n[iPoint] = val; } + inline void Set_Density_time_n1(unsigned long iPoint, su2double val) { + Density_time_n1[iPoint] = val; + } + inline void Set_Density_unsteady(unsigned long iPoint, su2double val) { Density_unsteady[iPoint] = val; } @@ -112,7 +116,11 @@ class CIncEulerVariable : public CFlowVariable { inline su2double GetDensity_time_n(unsigned long iPoint) const { return Density_time_n[iPoint]; } - + + inline su2double GetDensity_time_n1(unsigned long iPoint) const { + return Density_time_n1[iPoint]; + } + /*! * \brief Set the value of the density for the incompressible flows. * \param[in] iPoint - Point index. diff --git a/SU2_CFD/include/variables/CVariable.hpp b/SU2_CFD/include/variables/CVariable.hpp index 436125aba78a..d6485a98ce6f 100644 --- a/SU2_CFD/include/variables/CVariable.hpp +++ b/SU2_CFD/include/variables/CVariable.hpp @@ -72,6 +72,7 @@ class CVariable { VectorType Delta_Time; /*!< \brief Time step. */ VectorType Density_unsteady; VectorType Density_time_n; /*!< \brief density at time n for dual-time stepping technique. */ + VectorType Density_time_n1; /*!< \brief density at time n for dual-time stepping technique. */ CVectorOfMatrix Gradient; /*!< \brief Gradient of the solution of the problem. */ C3DDoubleMatrix Rmatrix; /*!< \brief Geometry-based matrix for weighted least squares gradient calculations. */ @@ -298,6 +299,11 @@ class CVariable { */ void Set_Density_time_n(); + /*! + * \brief Set the density at time n-1. + */ + void Set_Density_time_n1(); + /*! * \brief Set the variable solution at time n. * \param[in] iPoint - Point index. @@ -334,7 +340,11 @@ class CVariable { inline void Set_Density_time_n(unsigned long iPoint, su2double val) { Density_time_n[iPoint] = val; } - + + inline void Set_Density_time_n1(unsigned long iPoint, su2double val) { + Density_time_n1[iPoint] = val; + } + inline void Set_Density_unsteady(unsigned long iPoint, su2double val) { Density_unsteady[iPoint] = val; } @@ -548,6 +558,14 @@ class CVariable { inline su2double GetDensity_time_n(unsigned long iPoint) const { return Density_time_n[iPoint]; } inline VectorType& GetDensity_time_n() { return Density_time_n; } + /*! + * \brief Get the solution at time n. + * \param[in] iPoint - Point index. + * \return Pointer to the solution (at time n) vector. + */ + inline su2double GetDensity_time_n1(unsigned long iPoint) const { return Density_time_n1[iPoint]; } + inline VectorType& GetDensity_time_n1() { return Density_time_n1; } + /*! * \brief Get the density. * \param[in] iPoint - Point index. @@ -2209,9 +2227,13 @@ class CVariable { void RegisterSolution_time_n1(); /*! - * \brief Register the variables in the solution_time_n1 array as input/output variable. + * \brief Register the variables in the density_time_n array as input/output variable. */ void RegisterDensity_time_n(); + /*! + * \brief Register the variables in the density_time_n1 array as input/output variable. + */ + void RegisterDensity_time_n1(); /*! * \brief Register the variables in the user defined source array as input/output variable. diff --git a/SU2_CFD/src/integration/CIntegration.cpp b/SU2_CFD/src/integration/CIntegration.cpp index fc1e269c7263..199c377f7a06 100644 --- a/SU2_CFD/src/integration/CIntegration.cpp +++ b/SU2_CFD/src/integration/CIntegration.cpp @@ -249,6 +249,7 @@ void CIntegration::SetDualTime_Solver(const CGeometry *geometry, CSolver *solver solver->GetNodes()->Set_Solution_time_n1(); solver->GetNodes()->Set_Solution_time_n(); solver->GetNodes()->Set_Density_time_n(); + solver->GetNodes()->Set_Density_time_n1(); SU2_OMP_SAFE_GLOBAL_ACCESS(solver->ResetCFLAdapt();) diff --git a/SU2_CFD/src/output/CFlowIncOutput.cpp b/SU2_CFD/src/output/CFlowIncOutput.cpp index d1d4257803a5..53fb62b1478f 100644 --- a/SU2_CFD/src/output/CFlowIncOutput.cpp +++ b/SU2_CFD/src/output/CFlowIncOutput.cpp @@ -375,7 +375,8 @@ void CFlowIncOutput::SetVolumeOutputFields(CConfig *config){ AddCommonFVMOutputs(config); - AddVolumeOutput("DENSITY_TIME_N", "Density_time_n", "SOLUTION", "Density at previous time step"); + AddVolumeOutput("DENSITY_TIME_N", "Density_time_n", "SOLUTION", "Density at previous time step n"); + AddVolumeOutput("DENSITY_TIME_N1", "Density_time_n1", "SOLUTION", "Density at previous time step n-1"); if (config->GetTime_Domain()) { SetTimeAveragedFields(); } @@ -420,6 +421,7 @@ 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)); SetVolumeOutputValue("DENSITY_TIME_N", iPoint, Node_Flow->GetDensity_time_n(iPoint)); + SetVolumeOutputValue("DENSITY_TIME_N1", iPoint, Node_Flow->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)); diff --git a/SU2_CFD/src/solvers/CIncEulerSolver.cpp b/SU2_CFD/src/solvers/CIncEulerSolver.cpp index 737f1d737f91..4e875f39e624 100644 --- a/SU2_CFD/src/solvers/CIncEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CIncEulerSolver.cpp @@ -2713,7 +2713,7 @@ void CIncEulerSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver su2double U_time_nM1[MAXNVAR], U_time_n[MAXNVAR], U_time_nP1[MAXNVAR]; su2double Volume_nM1, Volume_nP1, TimeStep; const su2double *Normal = nullptr, *GridVel_i = nullptr, *GridVel_j = nullptr; - su2double Density, Cp, Density_time_n, Density_unsteady; + su2double Density, Cp, Density_time_n, Density_time_nM1, Density_unsteady; const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); const bool first_order = (config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_1ST); @@ -2753,6 +2753,7 @@ void CIncEulerSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver /*--- Access the density and Cp at this node (constant for now). ---*/ + Density_time_nM1 = nodes->GetDensity_time_n1(iPoint); Density_time_n = nodes->GetDensity_time_n(iPoint); Density_unsteady = nodes->GetDensity_unsteady(iPoint); Density = nodes->GetDensity(iPoint); @@ -2760,8 +2761,9 @@ void CIncEulerSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver /*--- Compute the conservative variable vector for all time levels. ---*/ - V2U(Density, Cp, V_time_nM1, U_time_nM1); + V2U(Density_time_nM1, Cp, V_time_nM1, U_time_nM1); V2U(Density_time_n, Cp, V_time_n, U_time_n); + // nijso asks: what is the difference between density_unsteady and density? V2U(Density, Cp, V_time_nP1, U_time_nP1); /*--- CV volume at time n+1. As we are on a static mesh, the volume diff --git a/SU2_CFD/src/variables/CVariable.cpp b/SU2_CFD/src/variables/CVariable.cpp index 63251cce304f..55ee4d007e7d 100644 --- a/SU2_CFD/src/variables/CVariable.cpp +++ b/SU2_CFD/src/variables/CVariable.cpp @@ -41,6 +41,7 @@ CVariable::CVariable(unsigned long npoint, unsigned long nvar, const CConfig *co Density_unsteady.resize(nPoint); Density_time_n.resize(nPoint); + Density_time_n1.resize(nPoint); if (config->GetMultizone_Problem()) Solution_BGS_k.resize(nPoint,nVar) = su2double(0.0); @@ -66,6 +67,7 @@ CVariable::CVariable(unsigned long npoint, unsigned long ndim, unsigned long nva if (config->GetTime_Domain()) { Density_unsteady.resize(nPoint); Density_time_n.resize(nPoint); + Density_time_n1.resize(nPoint); } if (config->GetTime_Marching() != TIME_MARCHING::STEADY) @@ -108,6 +110,10 @@ void CVariable::Set_Density_time_n(){ parallelCopy(Density_unsteady.size(),Density_unsteady.data(), Density_time_n.data()); } +void CVariable::Set_Density_time_n1(){ + assert(Density_time_n.size() == Density_unsteady.size()); + parallelCopy(Density_time_n.size(),Density_time_n.data(), Density_time_n1.data()); +} void CVariable::Set_Solution_time_n1() { assert(Solution_time_n1.size() == Solution_time_n.size()); parallelCopy(Solution_time_n.size(), Solution_time_n.data(), Solution_time_n1.data()); From 630856b0477416e3c62c072c13fadbe2f8de36ac Mon Sep 17 00:00:00 2001 From: tkiymaz <79564236+tkiymaz@users.noreply.github.com> Date: Thu, 18 Dec 2025 12:56:59 +0100 Subject: [PATCH 35/39] Update SU2_CFD/src/solvers/CIncEulerSolver.cpp Co-authored-by: Cristopher Morales <98025159+Cristopher-Morales@users.noreply.github.com> --- SU2_CFD/src/solvers/CIncEulerSolver.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/SU2_CFD/src/solvers/CIncEulerSolver.cpp b/SU2_CFD/src/solvers/CIncEulerSolver.cpp index d62c91ae2f84..3d8ea5dec35d 100644 --- a/SU2_CFD/src/solvers/CIncEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CIncEulerSolver.cpp @@ -2978,6 +2978,8 @@ void CIncEulerSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver /*--- Access the density at this node (constant for now). ---*/ Density = nodes->GetDensity(iPoint); + Density_time_nM1 = nodes->GetDensity_time_n1(iPoint); + Density_time_n = nodes->GetDensity_time_n(iPoint); /*--- Compute the conservative variable vector for all time levels. ---*/ From 35ad9763f190a4e0971bdcee321ae54c995f3467 Mon Sep 17 00:00:00 2001 From: tkiymaz <79564236+tkiymaz@users.noreply.github.com> Date: Thu, 18 Dec 2025 12:57:17 +0100 Subject: [PATCH 36/39] Update SU2_CFD/src/solvers/CIncEulerSolver.cpp Co-authored-by: Cristopher Morales <98025159+Cristopher-Morales@users.noreply.github.com> --- SU2_CFD/src/solvers/CIncEulerSolver.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/SU2_CFD/src/solvers/CIncEulerSolver.cpp b/SU2_CFD/src/solvers/CIncEulerSolver.cpp index 3d8ea5dec35d..a5e69a3c39df 100644 --- a/SU2_CFD/src/solvers/CIncEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CIncEulerSolver.cpp @@ -2985,7 +2985,9 @@ void CIncEulerSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver V2U(Density, V_time_nM1, U_time_nM1); V2U(Density, V_time_n, U_time_n); - V2U(Density, V_time_nP1, U_time_nP1); +V2U(Density_time_nM1, V_time_nM1, U_time_nM1); +V2U(Density_time_n, V_time_n, U_time_n); +V2U(Density, V_time_nP1, U_time_nP1); /*--- CV volume at time n-1 and n+1. In the case of dynamically deforming grids, the volumes will change. On rigidly transforming grids, the From 31f8af3b107e3fd65b2b9c85ef80ccbe74ce786f Mon Sep 17 00:00:00 2001 From: tkiymaz <79564236+tkiymaz@users.noreply.github.com> Date: Thu, 18 Dec 2025 12:57:57 +0100 Subject: [PATCH 37/39] Update SU2_CFD/src/solvers/CIncEulerSolver.cpp Co-authored-by: Cristopher Morales <98025159+Cristopher-Morales@users.noreply.github.com> --- SU2_CFD/src/solvers/CIncEulerSolver.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/SU2_CFD/src/solvers/CIncEulerSolver.cpp b/SU2_CFD/src/solvers/CIncEulerSolver.cpp index a5e69a3c39df..5bf193235498 100644 --- a/SU2_CFD/src/solvers/CIncEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CIncEulerSolver.cpp @@ -2894,7 +2894,8 @@ void CIncEulerSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver V_time_n = nodes->GetSolution_time_n(iPoint); Density = nodes->GetDensity(iPoint); - V2U(Density, V_time_n, U_time_n); +Density_time_n = nodes->GetDensity_time_n(iPoint); +V2U(Density_time_n, V_time_n, U_time_n); GridVel_i = geometry->nodes->GetGridVel(iPoint); From 00ae736b85e0d3265727fbe74d1bc440ebf03a7a Mon Sep 17 00:00:00 2001 From: Nijso Date: Thu, 18 Dec 2025 16:23:23 +0100 Subject: [PATCH 38/39] Potential fix for code scanning alert no. 5888: Unused local variable Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> --- SU2_CFD/src/solvers/CIncEulerSolver.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/src/solvers/CIncEulerSolver.cpp b/SU2_CFD/src/solvers/CIncEulerSolver.cpp index 5bf193235498..6c062b1397ba 100644 --- a/SU2_CFD/src/solvers/CIncEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CIncEulerSolver.cpp @@ -2799,7 +2799,7 @@ void CIncEulerSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver su2double U_time_nM1[MAXNVAR], U_time_n[MAXNVAR], U_time_nP1[MAXNVAR]; su2double Volume_nM1, Volume_nP1, TimeStep; const su2double *Normal = nullptr, *GridVel_i = nullptr, *GridVel_j = nullptr; - su2double Density, Density_time_n, Density_time_nM1, Density_unsteady; + su2double Density, Density_time_n, Density_time_nM1; const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); const bool first_order = (config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_1ST); From df27a844a9f8a7f7f58be57388ae63e0e086b7af Mon Sep 17 00:00:00 2001 From: Nijso Date: Wed, 24 Dec 2025 18:04:41 +0100 Subject: [PATCH 39/39] Update SU2_CFD/src/variables/CIncNSVariable.cpp Co-authored-by: Cristopher Morales <98025159+Cristopher-Morales@users.noreply.github.com> --- SU2_CFD/src/variables/CIncNSVariable.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/SU2_CFD/src/variables/CIncNSVariable.cpp b/SU2_CFD/src/variables/CIncNSVariable.cpp index 0704e65d8358..39c8ad55fa99 100644 --- a/SU2_CFD/src/variables/CIncNSVariable.cpp +++ b/SU2_CFD/src/variables/CIncNSVariable.cpp @@ -103,8 +103,9 @@ bool CIncNSVariable::SetPrimVar(unsigned long iPoint, su2double eddy_visc, su2do } /*--- Set density for unsteady problems ---*/ -Density_unsteady[iPoint] = FluidModel->GetDensity(); - + if (Unsteady) { + SetDensity_unsteady(iPoint, FluidModel->GetDensity();) + } /*--- Set the value of the velocity and velocity^2 (requires density) ---*/ SetVelocity(iPoint);