From 24cc96c750db56a78d2b6ff9a4545f13e4b37a97 Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Sun, 4 Jan 2026 10:50:18 -0800 Subject: [PATCH 1/4] cleanup --- .../numerics_simd/flow/convection/common.hpp | 47 +++++++++---------- .../numerics_simd/flow/convection/roe.hpp | 4 +- SU2_CFD/include/solvers/CScalarSolver.inl | 9 ++-- SU2_CFD/include/solvers/CSolver.hpp | 5 +- .../src/integration/CNewtonIntegration.cpp | 12 ++--- SU2_CFD/src/solvers/CEulerSolver.cpp | 6 +-- SU2_CFD/src/solvers/CIncEulerSolver.cpp | 10 ++-- SU2_CFD/src/solvers/CNEMOEulerSolver.cpp | 6 +-- TestCases/rans/oneram6/turb_ONERAM6_nk.cfg | 2 - 9 files changed, 46 insertions(+), 55 deletions(-) diff --git a/SU2_CFD/include/numerics_simd/flow/convection/common.hpp b/SU2_CFD/include/numerics_simd/flow/convection/common.hpp index 08c1d67511c0..6d6026bbe8c9 100644 --- a/SU2_CFD/include/numerics_simd/flow/convection/common.hpp +++ b/SU2_CFD/include/numerics_simd/flow/convection/common.hpp @@ -34,12 +34,12 @@ /*! * \brief Blended difference for U-MUSCL reconstruction. - * \param[in] grad_proj - Gradient projection at point i: dot(grad_i, vector_ij). + * \param[in] gradProj - Gradient projection at point i: dot(grad_i, vector_ij). * \param[in] delta - Centered difference: V_j - V_i. * \param[in] kappa - Blending parameter. * \return Blended difference for reconstruction from point i. */ -FORCEINLINE Double umusclProjection(Double grad_proj, +FORCEINLINE Double umusclProjection(Double gradProj, Double delta, Double kappa) { /*-------------------------------------------------------------------*/ @@ -51,7 +51,7 @@ FORCEINLINE Double umusclProjection(Double grad_proj, /*--- To maintain proper scaling for edge limiters, the result of ---*/ /*--- this function is 0.5 * dV_ij^kap. ---*/ /*-------------------------------------------------------------------*/ - return (1.0 - kappa) * grad_proj + kappa * delta; + return (1.0 - kappa) * gradProj + kappa * delta; } /*! @@ -62,7 +62,7 @@ FORCEINLINE Double umusclProjection(Double grad_proj, * \param[in] delta - Centered difference: V_j - V_i. * \param[in] iVar - Variable index. * \param[in] kappa - Blending coefficient. - * \param[in] relax - Newton-Krylov relaxation. + * \param[in] umusclRamp - MUSCL 1st-2nd order ramp times Newton-Krylov relaxation. * \return Variable reconstructed from point i. */ template @@ -71,10 +71,9 @@ FORCEINLINE Double musclReconstruction(const GradType& grad, const Double delta, size_t iVar, Double kappa, - Double relax, - Double ramp_val) { + Double umusclRamp) { const Double proj = dot(grad[iVar], vector_ij); - return ramp_val * relax * umusclProjection(proj, delta, kappa); + return umusclRamp * umusclProjection(proj, delta, kappa); } /*! @@ -87,8 +86,7 @@ FORCEINLINE void musclUnlimited(Int iPoint, const Gradient_t& gradient, CPair& V, Double kappa, - Double relax, - Double ramp_val) { + Double umusclRamp) { constexpr auto nVarGrad = nVarGrad_ > 0 ? nVarGrad_ : VarType::nVar; auto grad_i = gatherVariables(iPoint, gradient); @@ -99,8 +97,8 @@ FORCEINLINE void musclUnlimited(Int iPoint, const Double delta_ij = V.j.all(iVar) - V.i.all(iVar); /*--- U-MUSCL reconstructed variables ---*/ - const Double proj_i = musclReconstruction(grad_i, vector_ij, delta_ij, iVar, kappa, relax, ramp_val); - const Double proj_j = musclReconstruction(grad_j, vector_ij, delta_ij, iVar, kappa, relax, ramp_val); + const Double proj_i = musclReconstruction(grad_i, vector_ij, delta_ij, iVar, kappa, umusclRamp); + const Double proj_j = musclReconstruction(grad_j, vector_ij, delta_ij, iVar, kappa, umusclRamp); /*--- Apply reconstruction: V_L = V_i + 0.5 * dV_ij^kap ---*/ V.i.all(iVar) += 0.5 * proj_i; @@ -119,8 +117,7 @@ FORCEINLINE void musclPointLimited(Int iPoint, const Gradient_t& gradient, CPair& V, Double kappa, - Double relax, - Double ramp_val) { + Double umusclRamp) { constexpr auto nVarGrad = nVarGrad_ > 0 ? nVarGrad_ : VarType::nVar; auto lim_i = gatherVariables(iPoint, limiter); @@ -134,8 +131,8 @@ FORCEINLINE void musclPointLimited(Int iPoint, const Double delta_ij = V.j.all(iVar) - V.i.all(iVar); /*--- U-MUSCL reconstructed variables ---*/ - const Double proj_i = musclReconstruction(grad_i, vector_ij, delta_ij, iVar, kappa, relax, ramp_val); - const Double proj_j = musclReconstruction(grad_j, vector_ij, delta_ij, iVar, kappa, relax, ramp_val); + const Double proj_i = musclReconstruction(grad_i, vector_ij, delta_ij, iVar, kappa, umusclRamp); + const Double proj_j = musclReconstruction(grad_j, vector_ij, delta_ij, iVar, kappa, umusclRamp); /*--- Apply reconstruction: V_L = V_i + 0.5 * lim * dV_ij^kap ---*/ V.i.all(iVar) += 0.5 * lim_i(iVar) * proj_i; @@ -153,8 +150,7 @@ FORCEINLINE void musclEdgeLimited(Int iPoint, const Gradient_t& gradient, CPair& V, Double kappa, - Double relax, - Double ramp_val) { + Double umusclRamp) { constexpr auto nVarGrad = nVarGrad_ > 0 ? nVarGrad_ : VarType::nVar; auto grad_i = gatherVariables(iPoint, gradient); @@ -166,8 +162,8 @@ FORCEINLINE void musclEdgeLimited(Int iPoint, const Double delta_ij_2 = pow(delta_ij, 2) + 1e-6; /*--- U-MUSCL reconstructed variables ---*/ - const Double proj_i = musclReconstruction(grad_i, vector_ij, delta_ij, iVar, kappa, relax, ramp_val); - const Double proj_j = musclReconstruction(grad_j, vector_ij, delta_ij, iVar, kappa, relax, ramp_val); + const Double proj_i = musclReconstruction(grad_i, vector_ij, delta_ij, iVar, kappa, umusclRamp); + const Double proj_j = musclReconstruction(grad_j, vector_ij, delta_ij, iVar, kappa, umusclRamp); /// TODO: Customize the limiter function. const Double lim_i = (delta_ij_2 + proj_i*delta_ij) / (pow(proj_i,2) + delta_ij_2); @@ -187,7 +183,7 @@ FORCEINLINE void musclEdgeLimited(Int iPoint, * \param[in] gasConst - Specific gas constant. * \param[in] muscl - If true, reconstruct, else simply fetch. * \param[in] kappa - Blending coefficient for MUSCL reconstruction. - * \param[in] relax - Newton-Krylov relaxation. + * \param[in] umusclRamp - MUSCL 1st-2nd order ramp times Newton-Krylov relaxation. * \param[in] limiterType - Type of flux limiter. * \param[in] V1st - Pair of compressible flow primitives for nodes i,j. * \param[in] vector_ij - Distance vector from i to j. @@ -200,12 +196,11 @@ FORCEINLINE CPair reconstructPrimitives(Int iEdge, Int iPoint, Int const su2double& gasConst, bool muscl, const su2double& kappa, - const su2double& relax, + const su2double& umusclRamp, LIMITER limiterType, const CPair& V1st, const VectorDbl& vector_ij, - const VariableType& solution, - const su2double& ramp_val) { + const VariableType& solution) { static_assert(ReconVarType::nVar <= PrimVarType::nVar); const auto& gradients = solution.GetGradient_Reconstruction(); @@ -223,13 +218,13 @@ FORCEINLINE CPair reconstructPrimitives(Int iEdge, Int iPoint, Int constexpr auto nVarGrad = ReconVarType::nVar - 2; switch (limiterType) { case LIMITER::NONE: - musclUnlimited(iPoint, jPoint, vector_ij, gradients, V, kappa, relax, ramp_val); + musclUnlimited(iPoint, jPoint, vector_ij, gradients, V, kappa, umusclRamp); break; case LIMITER::VAN_ALBADA_EDGE: - musclEdgeLimited(iPoint, jPoint, vector_ij, gradients, V, kappa, relax, ramp_val); + musclEdgeLimited(iPoint, jPoint, vector_ij, gradients, V, kappa, umusclRamp); break; default: - musclPointLimited(iPoint, jPoint, vector_ij, limiters, gradients, V, kappa, relax, ramp_val); + musclPointLimited(iPoint, jPoint, vector_ij, limiters, gradients, V, kappa, umusclRamp); break; } /*--- Recompute density using the reconstructed pressure and temperature. ---*/ diff --git a/SU2_CFD/include/numerics_simd/flow/convection/roe.hpp b/SU2_CFD/include/numerics_simd/flow/convection/roe.hpp index 597ddc7efedb..92d3e60319d7 100644 --- a/SU2_CFD/include/numerics_simd/flow/convection/roe.hpp +++ b/SU2_CFD/include/numerics_simd/flow/convection/roe.hpp @@ -98,7 +98,7 @@ class CRoeBase : public Base { AD::StartPreacc(); const bool implicit = (config.GetKind_TimeIntScheme() == EULER_IMPLICIT); - const auto nkRelax = config.GetNewtonKrylovRelaxation(); + const auto umusclRamp = config.GetMUSCLRampValue() * config.GetNewtonKrylovRelaxation(); const auto& solution = static_cast(solution_); const auto iPoint = geometry.edges->GetNode(iEdge,0); @@ -123,7 +123,7 @@ class CRoeBase : public Base { /*--- Recompute density and enthalpy instead of reconstructing. ---*/ auto V = reconstructPrimitives >( - iEdge, iPoint, jPoint, gamma, gasConst, muscl, umusclKappa, nkRelax, typeLimiter, V1st, vector_ij, solution, config.GetMUSCLRampValue()); + iEdge, iPoint, jPoint, gamma, gasConst, muscl, umusclKappa, umusclRamp, typeLimiter, V1st, vector_ij, solution); /*--- Compute conservative variables. ---*/ diff --git a/SU2_CFD/include/solvers/CScalarSolver.inl b/SU2_CFD/include/solvers/CScalarSolver.inl index 62029bd26edc..01f05939a2c5 100644 --- a/SU2_CFD/include/solvers/CScalarSolver.inl +++ b/SU2_CFD/include/solvers/CScalarSolver.inl @@ -145,6 +145,7 @@ void CScalarSolver::Upwind_Residual(CGeometry* geometry, CSolver** /*--- U-MUSCL reconstruction ---*/ const su2double kappa = config->GetMUSCL_Kappa(); const su2double kappaFlow = config->GetMUSCL_Kappa_Flow(); + const su2double musclRamp = config->GetMUSCLRampValue(); auto* flowNodes = su2staticcast_p(solver_container[FLOW_SOL]->GetNodes()); const auto& edgeMassFluxes = *(solver_container[FLOW_SOL]->GetEdgeMassFluxes()); @@ -222,8 +223,8 @@ void CScalarSolver::Upwind_Residual(CGeometry* geometry, CSolver** for (auto iVar = 0u; iVar < solver_container[FLOW_SOL]->GetnPrimVarGrad(); iVar++) { const su2double V_ij = V_j[iVar] - V_i[iVar]; - su2double Project_Grad_i = MUSCL_Reconstruction(Gradient_i[iVar], Vector_ij, V_ij, kappaFlow, config->GetMUSCLRampValue()); - su2double Project_Grad_j = MUSCL_Reconstruction(Gradient_j[iVar], Vector_ij, V_ij, kappaFlow, config->GetMUSCLRampValue()); + su2double Project_Grad_i = MUSCL_Reconstruction(Gradient_i[iVar], Vector_ij, V_ij, kappaFlow, musclRamp); + su2double Project_Grad_j = MUSCL_Reconstruction(Gradient_j[iVar], Vector_ij, V_ij, kappaFlow, musclRamp); if (limiterFlow) { Project_Grad_i *= Limiter_i[iVar]; @@ -251,8 +252,8 @@ void CScalarSolver::Upwind_Residual(CGeometry* geometry, CSolver** for (auto iVar = 0u; iVar < nVar; iVar++) { const su2double U_ij = Scalar_j[iVar] - Scalar_i[iVar]; - su2double Project_Grad_i = MUSCL_Reconstruction(Gradient_i[iVar], Vector_ij, U_ij, kappa, config->GetMUSCLRampValue()); - su2double Project_Grad_j = MUSCL_Reconstruction(Gradient_j[iVar], Vector_ij, U_ij, kappa, config->GetMUSCLRampValue()); + su2double Project_Grad_i = MUSCL_Reconstruction(Gradient_i[iVar], Vector_ij, U_ij, kappa, musclRamp); + su2double Project_Grad_j = MUSCL_Reconstruction(Gradient_j[iVar], Vector_ij, U_ij, kappa, musclRamp); if (limiter) { Project_Grad_i *= Limiter_i[iVar]; diff --git a/SU2_CFD/include/solvers/CSolver.hpp b/SU2_CFD/include/solvers/CSolver.hpp index 81fcd074c442..32b7bf43c08e 100644 --- a/SU2_CFD/include/solvers/CSolver.hpp +++ b/SU2_CFD/include/solvers/CSolver.hpp @@ -587,10 +587,11 @@ class CSolver { * \param[in] vector_ij - Distance vector. * \param[in] delta_ij - Centered difference. * \param[in] kappa - Blending coefficient for U-MUSCL reconstruction. - * \param[in] ramp_val - Value of the ramp + * \param[in] ramp_val - Value of the 1st-2nd order MUSCL ramp. * \return - Projected variable. */ - inline su2double MUSCL_Reconstruction(const su2double* grad, const su2double* vector_ij, su2double delta_ij, su2double kappa, su2double ramp_val) { + FORCEINLINE su2double MUSCL_Reconstruction(const su2double* grad, const su2double* vector_ij, su2double delta_ij, + su2double kappa, su2double ramp_val) const { su2double project_grad = GeometryToolbox::DotProduct(nDim, grad, vector_ij); return ramp_val * LimiterHelpers<>::umusclProjection(project_grad, delta_ij, kappa); } diff --git a/SU2_CFD/src/integration/CNewtonIntegration.cpp b/SU2_CFD/src/integration/CNewtonIntegration.cpp index 5424d164b165..a46f52a2f247 100644 --- a/SU2_CFD/src/integration/CNewtonIntegration.cpp +++ b/SU2_CFD/src/integration/CNewtonIntegration.cpp @@ -184,15 +184,11 @@ void CNewtonIntegration::MultiGrid_Iteration(CGeometry ****geometry_, CSolver ** if (!setup) { Setup(); setup = true; } - // Ramp from 1st to 2nd order during the startup. - su2double baseNkRelaxation = 1; - if (startupPeriod && startupIters > 0 && !config->GetRestart()) { - baseNkRelaxation = su2double(startupIters - iter) / startupIters; - } - config->SetNewtonKrylovRelaxation(baseNkRelaxation); + /*--- Remove NK relaxation to compute the current residual. ---*/ + config->SetNewtonKrylovRelaxation(1.0); - // When using NK relaxation (not fully 2nd order Jacobian products) we need an additional - // residual evaluation that is used as the reference for finite differences. + /*--- When using NK relaxation (not fully 2nd order Jacobian products) we need an additional + * residual evaluation that is used as the reference for finite differences. ---*/ LinSysRes0 = (!startupPeriod && nkRelaxation < 1) ? &LinSysResRelax : &LinSysRes; SU2_OMP_PARALLEL_(if(solvers[FLOW_SOL]->GetHasHybridParallel())) { diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index 0ba2b4275964..818ce9d9771b 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -1799,7 +1799,6 @@ void CEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_contain } const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); - const su2double nkRelax = config->GetNewtonKrylovRelaxation(); const bool roe_turkel = (config->GetKind_Upwind_Flow() == UPWIND::TURKEL); const auto kind_dissipation = config->GetKind_RoeLowDiss(); @@ -1809,6 +1808,7 @@ void CEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_contain const bool van_albada = (config->GetKind_SlopeLimit_Flow() == LIMITER::VAN_ALBADA_EDGE); const su2double kappa = config->GetMUSCL_Kappa_Flow(); + const su2double musclRamp = config->GetMUSCLRampValue() * config->GetNewtonKrylovRelaxation(); /*--- Non-physical counter. ---*/ unsigned long counter_local = 0; @@ -1886,8 +1886,8 @@ void CEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_contain for (auto iVar = 0u; iVar < nPrimVarGrad; iVar++) { const su2double V_ij = V_j[iVar] - V_i[iVar]; - const su2double Project_Grad_i = nkRelax * MUSCL_Reconstruction(Gradient_i[iVar], Vector_ij, V_ij, kappa, config->GetMUSCLRampValue()); - const su2double Project_Grad_j = nkRelax * MUSCL_Reconstruction(Gradient_j[iVar], Vector_ij, V_ij, kappa, config->GetMUSCLRampValue()); + const su2double Project_Grad_i = MUSCL_Reconstruction(Gradient_i[iVar], Vector_ij, V_ij, kappa, musclRamp); + const su2double Project_Grad_j = MUSCL_Reconstruction(Gradient_j[iVar], Vector_ij, V_ij, kappa, musclRamp); su2double lim_i = 1.0; su2double lim_j = 1.0; diff --git a/SU2_CFD/src/solvers/CIncEulerSolver.cpp b/SU2_CFD/src/solvers/CIncEulerSolver.cpp index f131740f84d5..01a1017e4bdc 100644 --- a/SU2_CFD/src/solvers/CIncEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CIncEulerSolver.cpp @@ -1239,9 +1239,9 @@ void CIncEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_cont const bool van_albada = (config->GetKind_SlopeLimit_Flow() == LIMITER::VAN_ALBADA_EDGE); const bool bounded_scalar = config->GetBounded_Scalar(); const bool multicomponent = (config->GetKind_FluidModel() == FLUID_MIXTURE); - const su2double nkRelax = config->GetNewtonKrylovRelaxation(); const su2double kappa = config->GetMUSCL_Kappa_Flow(); + const su2double musclRamp = config->GetMUSCLRampValue() * config->GetNewtonKrylovRelaxation(); /*--- For hybrid parallel AD, pause preaccumulation if there is shared reading of * variables, otherwise switch to the faster adjoint evaluation mode. ---*/ @@ -1289,8 +1289,8 @@ void CIncEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_cont for (auto iVar = 0u; iVar < nPrimVarGrad; iVar++) { const su2double V_ij = V_j[iVar] - V_i[iVar]; - const su2double Project_Grad_i = nkRelax * MUSCL_Reconstruction(Gradient_i[iVar], Vector_ij, V_ij, kappa, config->GetMUSCLRampValue()); - const su2double Project_Grad_j = nkRelax * MUSCL_Reconstruction(Gradient_j[iVar], Vector_ij, V_ij, kappa, config->GetMUSCLRampValue()); + const su2double Project_Grad_i = MUSCL_Reconstruction(Gradient_i[iVar], Vector_ij, V_ij, kappa, musclRamp); + const su2double Project_Grad_j = MUSCL_Reconstruction(Gradient_j[iVar], Vector_ij, V_ij, kappa, musclRamp); su2double lim_i = 1.0; su2double lim_j = 1.0; @@ -2150,9 +2150,9 @@ void CIncEulerSolver::SetPreconditioner(const CConfig *config, unsigned long iPo Therefore, we build inv(Precon) here and multiply by the residual later in the R-K and Euler Explicit time integration schemes. ---*/ - + Preconditioner[0][0] = Enthalpy * BetaInc2 * dRhodh / Density + BetaInc2; - + for (iDim = 0; iDim < nDim; iDim++) Preconditioner[iDim + 1][0] = -1.0 * Velocity[iDim] / Density; if (energy) { diff --git a/SU2_CFD/src/solvers/CNEMOEulerSolver.cpp b/SU2_CFD/src/solvers/CNEMOEulerSolver.cpp index e9a720257073..1e91605338ae 100644 --- a/SU2_CFD/src/solvers/CNEMOEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CNEMOEulerSolver.cpp @@ -466,9 +466,9 @@ void CNEMOEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_con const bool muscl = (config->GetMUSCL_Flow() && (iMesh == MESH_0)); const bool limiter = (config->GetKind_SlopeLimit_Flow() != LIMITER::NONE); const bool van_albada = (config->GetKind_SlopeLimit_Flow() == LIMITER::VAN_ALBADA_EDGE); - const su2double nkRelax = config->GetNewtonKrylovRelaxation(); const su2double kappa = config->GetMUSCL_Kappa_Flow(); + const su2double musclRamp = config->GetMUSCLRampValue() * config->GetNewtonKrylovRelaxation(); /*--- Non-physical counter. ---*/ unsigned long counter_local = 0; @@ -542,8 +542,8 @@ void CNEMOEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_con for (auto iVar = 0ul; iVar < nPrimVarGrad; iVar++) { const su2double V_ij = V_j[iVar] - V_i[iVar]; - Project_Grad_i[iVar] = nkRelax * MUSCL_Reconstruction(Gradient_i[iVar], Vector_ij, V_ij, kappa, config->GetMUSCLRampValue()); - Project_Grad_j[iVar] = nkRelax * MUSCL_Reconstruction(Gradient_j[iVar], Vector_ij, V_ij, kappa, config->GetMUSCLRampValue()); + Project_Grad_i[iVar] = MUSCL_Reconstruction(Gradient_i[iVar], Vector_ij, V_ij, kappa, musclRamp); + Project_Grad_j[iVar] = MUSCL_Reconstruction(Gradient_j[iVar], Vector_ij, V_ij, kappa, musclRamp); if (limiter) { if (van_albada) { diff --git a/TestCases/rans/oneram6/turb_ONERAM6_nk.cfg b/TestCases/rans/oneram6/turb_ONERAM6_nk.cfg index dd1f7fdfdbff..d798ac4b2a84 100644 --- a/TestCases/rans/oneram6/turb_ONERAM6_nk.cfg +++ b/TestCases/rans/oneram6/turb_ONERAM6_nk.cfg @@ -33,8 +33,6 @@ LINEAR_SOLVER_ERROR= 0.2 % matrix-free system). 0 is the same as not using NK, 1 is full MUSCL, a negative % values means "automatic", the solver changes the value so that the linear system % can be solved. -% If "n0">0, and RESTART_SOL=NO, the NK relaxation is applied to the residual (not -% just to the NK system) to ramp from MUSCL=OFF to ON during "n0" iterations. NEWTON_KRYLOV_IPARAM= (200, 0, 1) % n0, np, ft NEWTON_KRYLOV_DPARAM= (0, 0, 0, 1e-5, -1) % r0, tp, rf, e, rnk From ad55dc2af3be566215979774a1babba12436d322 Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Sun, 4 Jan 2026 11:00:04 -0800 Subject: [PATCH 2/4] fix windows build --- Common/include/option_structure.hpp | 28 +++++++++++------------ SU2_CFD/src/iteration/CFluidIteration.cpp | 2 +- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Common/include/option_structure.hpp b/Common/include/option_structure.hpp index c97ac30e3415..ac68cecf76c4 100644 --- a/Common/include/option_structure.hpp +++ b/Common/include/option_structure.hpp @@ -91,23 +91,23 @@ const unsigned int ZONE_0 = 0; /*!< \brief Definition of the first grid domain. const unsigned int ZONE_1 = 1; /*!< \brief Definition of the second grid domain. */ const unsigned int INST_0 = 0; /*!< \brief Definition of the first instance per grid level. */ -const su2double STANDARD_GRAVITY = 9.80665; /*!< \brief Acceleration due to gravity at surface of earth. */ -const su2double UNIVERSAL_GAS_CONSTANT = 8.3144598; /*!< \brief Universal gas constant in J/(mol*K) */ -const su2double BOLTZMANN_CONSTANT = 1.3806503E-23; /*!< \brief Boltzmann's constant [J K^-1] */ -const su2double AVOGAD_CONSTANT = 6.0221415E26; /*!< \brief Avogadro's constant, number of particles in one kmole. */ -const su2double FUND_ELEC_CHARGE_CGS = 4.8032047E-10; /*!< \brief Fundamental electric charge in CGS units, cm^(3/2) g^(1/2) s^(-1). */ +static constexpr passivedouble STANDARD_GRAVITY = 9.80665; /*!< \brief Acceleration due to gravity at surface of earth. */ +static constexpr passivedouble UNIVERSAL_GAS_CONSTANT = 8.3144598; /*!< \brief Universal gas constant in J/(mol*K) */ +static constexpr passivedouble BOLTZMANN_CONSTANT = 1.3806503E-23; /*!< \brief Boltzmann's constant [J K^-1] */ +static constexpr passivedouble AVOGAD_CONSTANT = 6.0221415E26; /*!< \brief Avogadro's constant, number of particles in one kmole. */ +static constexpr passivedouble FUND_ELEC_CHARGE_CGS = 4.8032047E-10; /*!< \brief Fundamental electric charge in CGS units, cm^(3/2) g^(1/2) s^(-1). */ -const su2double EPS = 1.0E-16; /*!< \brief Error scale. */ -const su2double TURB_EPS = 1.0E-16; /*!< \brief Turbulent Error scale. */ +static constexpr passivedouble EPS = 1.0E-16; /*!< \brief Error scale. */ +static constexpr passivedouble TURB_EPS = 1.0E-16; /*!< \brief Turbulent Error scale. */ -const su2double ONE2 = 0.5; /*!< \brief One divided by two. */ -const su2double ONE3 = 1.0 / 3.0; /*!< \brief One divided by three. */ -const su2double TWO3 = 2.0 / 3.0; /*!< \brief Two divided by three. */ -const su2double FOUR3 = 4.0 / 3.0; /*!< \brief Four divided by three. */ +static constexpr passivedouble ONE2 = 0.5; /*!< \brief One divided by two. */ +static constexpr passivedouble ONE3 = 1.0 / 3.0; /*!< \brief One divided by three. */ +static constexpr passivedouble TWO3 = 2.0 / 3.0; /*!< \brief Two divided by three. */ +static constexpr passivedouble FOUR3 = 4.0 / 3.0; /*!< \brief Four divided by three. */ -const su2double PI_NUMBER = 4.0 * atan(1.0); /*!< \brief Pi number. */ +static constexpr passivedouble PI_NUMBER = 3.14159265358979323846; /*!< \brief Pi number (not using M_PI to avoid Windows issues). */ -const su2double STEFAN_BOLTZMANN = 5.670367E-08; /*!< \brief Stefan-Boltzmann constant in W/(m^2*K^4). */ +static constexpr passivedouble STEFAN_BOLTZMANN = 5.670367E-08; /*!< \brief Stefan-Boltzmann constant in W/(m^2*K^4). */ const int MASTER_NODE = 0; /*!< \brief Master node for MPI parallelization. */ const int SINGLE_NODE = 1; /*!< \brief There is only a node in the MPI parallelization. */ @@ -195,7 +195,7 @@ const int SU2_CONN_SIZE = 10; /*!< \brief Size of the connectivity array that that we read from a mesh file in the format [[globalID vtkType n0 n1 n2 n3 n4 n5 n6 n7 n8]. */ const int SU2_CONN_SKIP = 2; /*!< \brief Offset to skip the globalID and VTK type at the start of the element connectivity list for each CGNS element. */ -const su2double COLORING_EFF_THRESH = 0.875; /*!< \brief Below this value fallback strategies are used instead. */ +static constexpr passivedouble COLORING_EFF_THRESH = 0.875; /*!< \brief Below this value fallback strategies are used instead. */ /*--- All temperature polynomial fits for the fluid models currently assume a quartic form (5 coefficients). For example, diff --git a/SU2_CFD/src/iteration/CFluidIteration.cpp b/SU2_CFD/src/iteration/CFluidIteration.cpp index fea25ba3b45d..21eaf1615fd3 100644 --- a/SU2_CFD/src/iteration/CFluidIteration.cpp +++ b/SU2_CFD/src/iteration/CFluidIteration.cpp @@ -348,7 +348,7 @@ void CFluidIteration::UpdateRamp(CGeometry**** geometry_container, CConfig** con config->SetMUSCLRampValue(std::pow(std::min(1.0, iterFrac), RampMUSCLParam.RampMUSCLPower)); break; case MUSCL_RAMP_TYPE::SMOOTH_FUNCTION: - config->SetMUSCLRampValue(std::pow((0.5 * (1 - cos(M_PI * std::min(1.0, iterFrac)))), RampMUSCLParam.RampMUSCLPower)); + config->SetMUSCLRampValue(std::pow((0.5 * (1 - cos(PI_NUMBER * std::min(1.0, iterFrac)))), RampMUSCLParam.RampMUSCLPower)); break; default: break; From a058ea30939f16156198e1489d08a8406daf425e Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Sun, 4 Jan 2026 12:13:25 -0800 Subject: [PATCH 3/4] fix AD issues? --- Common/include/option_structure.hpp | 28 ++++++++++++++-------------- TestCases/parallel_regression.py | 2 +- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Common/include/option_structure.hpp b/Common/include/option_structure.hpp index ac68cecf76c4..7035fc5eb6b7 100644 --- a/Common/include/option_structure.hpp +++ b/Common/include/option_structure.hpp @@ -91,23 +91,23 @@ const unsigned int ZONE_0 = 0; /*!< \brief Definition of the first grid domain. const unsigned int ZONE_1 = 1; /*!< \brief Definition of the second grid domain. */ const unsigned int INST_0 = 0; /*!< \brief Definition of the first instance per grid level. */ -static constexpr passivedouble STANDARD_GRAVITY = 9.80665; /*!< \brief Acceleration due to gravity at surface of earth. */ -static constexpr passivedouble UNIVERSAL_GAS_CONSTANT = 8.3144598; /*!< \brief Universal gas constant in J/(mol*K) */ -static constexpr passivedouble BOLTZMANN_CONSTANT = 1.3806503E-23; /*!< \brief Boltzmann's constant [J K^-1] */ -static constexpr passivedouble AVOGAD_CONSTANT = 6.0221415E26; /*!< \brief Avogadro's constant, number of particles in one kmole. */ -static constexpr passivedouble FUND_ELEC_CHARGE_CGS = 4.8032047E-10; /*!< \brief Fundamental electric charge in CGS units, cm^(3/2) g^(1/2) s^(-1). */ +constexpr passivedouble STANDARD_GRAVITY = 9.80665; /*!< \brief Acceleration due to gravity at surface of earth. */ +constexpr passivedouble UNIVERSAL_GAS_CONSTANT = 8.3144598; /*!< \brief Universal gas constant in J/(mol*K) */ +constexpr passivedouble BOLTZMANN_CONSTANT = 1.3806503E-23; /*!< \brief Boltzmann's constant [J K^-1] */ +constexpr passivedouble AVOGAD_CONSTANT = 6.0221415E26; /*!< \brief Avogadro's constant, number of particles in one kmole. */ +constexpr passivedouble FUND_ELEC_CHARGE_CGS = 4.8032047E-10; /*!< \brief Fundamental electric charge in CGS units, cm^(3/2) g^(1/2) s^(-1). */ -static constexpr passivedouble EPS = 1.0E-16; /*!< \brief Error scale. */ -static constexpr passivedouble TURB_EPS = 1.0E-16; /*!< \brief Turbulent Error scale. */ +constexpr passivedouble EPS = 1.0E-16; /*!< \brief Error scale. */ +constexpr passivedouble TURB_EPS = 1.0E-16; /*!< \brief Turbulent Error scale. */ -static constexpr passivedouble ONE2 = 0.5; /*!< \brief One divided by two. */ -static constexpr passivedouble ONE3 = 1.0 / 3.0; /*!< \brief One divided by three. */ -static constexpr passivedouble TWO3 = 2.0 / 3.0; /*!< \brief Two divided by three. */ -static constexpr passivedouble FOUR3 = 4.0 / 3.0; /*!< \brief Four divided by three. */ +constexpr passivedouble ONE2 = 0.5; /*!< \brief One divided by two. */ +constexpr passivedouble ONE3 = 1.0 / 3.0; /*!< \brief One divided by three. */ +constexpr passivedouble TWO3 = 2.0 / 3.0; /*!< \brief Two divided by three. */ +constexpr passivedouble FOUR3 = 4.0 / 3.0; /*!< \brief Four divided by three. */ -static constexpr passivedouble PI_NUMBER = 3.14159265358979323846; /*!< \brief Pi number (not using M_PI to avoid Windows issues). */ +constexpr passivedouble PI_NUMBER = 3.14159265358979323846; /*!< \brief Pi number (not using M_PI to avoid Windows issues). */ -static constexpr passivedouble STEFAN_BOLTZMANN = 5.670367E-08; /*!< \brief Stefan-Boltzmann constant in W/(m^2*K^4). */ +constexpr passivedouble STEFAN_BOLTZMANN = 5.670367E-08; /*!< \brief Stefan-Boltzmann constant in W/(m^2*K^4). */ const int MASTER_NODE = 0; /*!< \brief Master node for MPI parallelization. */ const int SINGLE_NODE = 1; /*!< \brief There is only a node in the MPI parallelization. */ @@ -195,7 +195,7 @@ const int SU2_CONN_SIZE = 10; /*!< \brief Size of the connectivity array that that we read from a mesh file in the format [[globalID vtkType n0 n1 n2 n3 n4 n5 n6 n7 n8]. */ const int SU2_CONN_SKIP = 2; /*!< \brief Offset to skip the globalID and VTK type at the start of the element connectivity list for each CGNS element. */ -static constexpr passivedouble COLORING_EFF_THRESH = 0.875; /*!< \brief Below this value fallback strategies are used instead. */ +constexpr passivedouble COLORING_EFF_THRESH = 0.875; /*!< \brief Below this value fallback strategies are used instead. */ /*--- All temperature polynomial fits for the fluid models currently assume a quartic form (5 coefficients). For example, diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index e980b665df6f..856c5b4e506a 100755 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -447,7 +447,7 @@ def main(): turb_oneram6_nk.cfg_dir = "rans/oneram6" turb_oneram6_nk.cfg_file = "turb_ONERAM6_nk.cfg" turb_oneram6_nk.test_iter = 20 - turb_oneram6_nk.test_vals = [-5.262975, -4.885414, -11.509429, 0.218369, 0.067725, 2, -0.772645, 10] + turb_oneram6_nk.test_vals = [-4.850719, -4.452661, -11.427627, 0.221809, 0.048349, 2, -0.881645, 10] turb_oneram6_nk.timeout = 600 turb_oneram6_nk.tol = 0.0001 test_list.append(turb_oneram6_nk) From 864392975d63595f9c651f9ef7967df24beb6dee Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Sun, 4 Jan 2026 12:54:36 -0800 Subject: [PATCH 4/4] no auto --- SU2_CFD/include/numerics_simd/flow/convection/roe.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/include/numerics_simd/flow/convection/roe.hpp b/SU2_CFD/include/numerics_simd/flow/convection/roe.hpp index 92d3e60319d7..a01c33c0c6e1 100644 --- a/SU2_CFD/include/numerics_simd/flow/convection/roe.hpp +++ b/SU2_CFD/include/numerics_simd/flow/convection/roe.hpp @@ -98,7 +98,7 @@ class CRoeBase : public Base { AD::StartPreacc(); const bool implicit = (config.GetKind_TimeIntScheme() == EULER_IMPLICIT); - const auto umusclRamp = config.GetMUSCLRampValue() * config.GetNewtonKrylovRelaxation(); + const su2double umusclRamp = config.GetMUSCLRampValue() * config.GetNewtonKrylovRelaxation(); const auto& solution = static_cast(solution_); const auto iPoint = geometry.edges->GetNode(iEdge,0);