From 0111d55f1fa081b9b7bb0837d16c83324aa0db3d Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Sun, 11 Aug 2024 11:14:21 -0700 Subject: [PATCH 1/4] fix hllc kappa --- Common/include/CConfig.hpp | 3 +- .../include/numerics/flow/convection/hllc.hpp | 4 +- SU2_CFD/src/numerics/flow/convection/hllc.cpp | 83 ++++++------------- SU2_CFD/src/numerics/flow/convection/roe.cpp | 4 +- TestCases/parallel_regression.py | 4 +- config_template.cfg | 2 +- 6 files changed, 33 insertions(+), 67 deletions(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index d4f94008ddc..df9a0dba3b7 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -4335,8 +4335,7 @@ class CConfig { array GetNewtonKrylovDblParam(void) const { return NK_DblParam; } /*! - * \brief Get the relaxation coefficient of the linear solver for the implicit formulation. - * \return relaxation coefficient of the linear solver for the implicit formulation. + * \brief Returns the Roe kappa (multipler of the dissipation term). */ su2double GetRoe_Kappa(void) const { return Roe_Kappa; } diff --git a/SU2_CFD/include/numerics/flow/convection/hllc.hpp b/SU2_CFD/include/numerics/flow/convection/hllc.hpp index 5cac798825e..62d46a7d211 100644 --- a/SU2_CFD/include/numerics/flow/convection/hllc.hpp +++ b/SU2_CFD/include/numerics/flow/convection/hllc.hpp @@ -49,7 +49,7 @@ class CUpwHLLC_Flow final : public CNumerics { su2double sq_velRoe, RoeDensity, RoeEnthalpy, RoeSoundSpeed, RoeProjVelocity, ProjInterfaceVel; - su2double sL, sR, sM, pStar, EStar, rhoSL, rhoSR, Rrho, kappa; + su2double sL, sR, sM, pStar, EStar, rhoSL, rhoSR, Rrho; su2double Omega, RHO, OmegaSM; su2double *dSm_dU, *dPI_dU, *drhoStar_dU, *dpStar_dU, *dEStar_dU; @@ -102,7 +102,7 @@ class CUpwGeneralHLLC_Flow final : public CNumerics { su2double sq_velRoe, RoeDensity, RoeEnthalpy, RoeSoundSpeed, RoeProjVelocity, ProjInterfaceVel; su2double Kappa_i, Kappa_j, Chi_i, Chi_j, RoeKappa, RoeChi, RoeKappaStaticEnthalpy; - su2double sL, sR, sM, pStar, EStar, rhoSL, rhoSR, Rrho, kappa; + su2double sL, sR, sM, pStar, EStar, rhoSL, rhoSR, Rrho; su2double Omega, RHO, OmegaSM; su2double *dSm_dU, *dPI_dU, *drhoStar_dU, *dpStar_dU, *dEStar_dU; diff --git a/SU2_CFD/src/numerics/flow/convection/hllc.cpp b/SU2_CFD/src/numerics/flow/convection/hllc.cpp index d574f929b20..d94b44759a7 100644 --- a/SU2_CFD/src/numerics/flow/convection/hllc.cpp +++ b/SU2_CFD/src/numerics/flow/convection/hllc.cpp @@ -31,7 +31,7 @@ CUpwHLLC_Flow::CUpwHLLC_Flow(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config) : CNumerics(val_nDim, val_nVar, config) { implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - kappa = config->GetRoe_Kappa(); + /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ dynamic_grid = config->GetDynamic_Grid(); @@ -114,30 +114,19 @@ CNumerics::ResidualType<> CUpwHLLC_Flow::ComputeResidual(const CConfig* config) Density_j = V_j[nDim+2]; Enthalpy_j = V_j[nDim+3]; - - sq_vel_i = 0.0; - sq_vel_j = 0.0; - - for (iDim = 0; iDim < nDim; iDim++) { - sq_vel_i += Velocity_i[iDim] * Velocity_i[iDim]; - sq_vel_j += Velocity_j[iDim] * Velocity_j[iDim]; - } + sq_vel_i = GeometryToolbox::SquaredNorm(nDim, Velocity_i); + sq_vel_j = GeometryToolbox::SquaredNorm(nDim, Velocity_j); Energy_i = Enthalpy_i - Pressure_i / Density_i; Energy_j = Enthalpy_j - Pressure_j / Density_j; - SoundSpeed_i = sqrt( (Enthalpy_i - 0.5 * sq_vel_i) * Gamma_Minus_One ); - SoundSpeed_j = sqrt( (Enthalpy_j - 0.5 * sq_vel_j) * Gamma_Minus_One ); + SoundSpeed_i = sqrt((Enthalpy_i - 0.5 * sq_vel_i) * Gamma_Minus_One); + SoundSpeed_j = sqrt((Enthalpy_j - 0.5 * sq_vel_j) * Gamma_Minus_One); /*--- Projected velocities ---*/ - ProjVelocity_i = 0; - ProjVelocity_j = 0; - - for (iDim = 0; iDim < nDim; iDim++) { - ProjVelocity_i += Velocity_i[iDim] * UnitNormal[iDim]; - ProjVelocity_j += Velocity_j[iDim] * UnitNormal[iDim]; - } + ProjVelocity_i = GeometryToolbox::DotProduct(nDim, Velocity_i, UnitNormal); + ProjVelocity_j = GeometryToolbox::DotProduct(nDim, Velocity_j, UnitNormal); /*--- Projected Grid Velocity ---*/ @@ -146,7 +135,7 @@ CNumerics::ResidualType<> CUpwHLLC_Flow::ComputeResidual(const CConfig* config) if (dynamic_grid) { for (iDim = 0; iDim < nDim; iDim++) - ProjInterfaceVel += 0.5 * ( GridVel_i[iDim] + GridVel_j[iDim] )*UnitNormal[iDim]; + ProjInterfaceVel += 0.5 * (GridVel_i[iDim] + GridVel_j[iDim]) * UnitNormal[iDim]; SoundSpeed_i -= ProjInterfaceVel; SoundSpeed_j += ProjInterfaceVel; @@ -159,14 +148,11 @@ CNumerics::ResidualType<> CUpwHLLC_Flow::ComputeResidual(const CConfig* config) Rrho = ( sqrt(Density_i) + sqrt(Density_j) ); - sq_velRoe = 0.0; - RoeProjVelocity = - ProjInterfaceVel; - for (iDim = 0; iDim < nDim; iDim++) { RoeVelocity[iDim] = ( Velocity_i[iDim] * sqrt(Density_i) + Velocity_j[iDim] * sqrt(Density_j) ) / Rrho; - sq_velRoe += RoeVelocity[iDim] * RoeVelocity[iDim]; - RoeProjVelocity += RoeVelocity[iDim] * UnitNormal[iDim]; } + sq_velRoe = GeometryToolbox::SquaredNorm(nDim, RoeVelocity); + RoeProjVelocity = GeometryToolbox::DotProduct(nDim, RoeVelocity, UnitNormal) - ProjInterfaceVel; /*--- Mean Roe variables iPoint and jPoint ---*/ @@ -175,10 +161,8 @@ CNumerics::ResidualType<> CUpwHLLC_Flow::ComputeResidual(const CConfig* config) /*--- Roe-averaged speed of sound ---*/ - //RoeSoundSpeed2 = Gamma_Minus_One * ( RoeEnthalpy - 0.5 * sq_velRoe ); RoeSoundSpeed = sqrt( Gamma_Minus_One * ( RoeEnthalpy - 0.5 * sq_velRoe ) ) - ProjInterfaceVel; - /*--- Speed of sound at L and R ---*/ sL = min( RoeProjVelocity - RoeSoundSpeed, ProjVelocity_i - SoundSpeed_i); @@ -214,8 +198,8 @@ CNumerics::ResidualType<> CUpwHLLC_Flow::ComputeResidual(const CConfig* config) IntermediateState[0] = rhoSL * Density_i; for (iDim = 0; iDim < nDim; iDim++) - IntermediateState[iDim+1] = rhoSL * ( Density_i * Velocity_i[iDim] + ( pStar - Pressure_i ) / ( sL - ProjVelocity_i ) * UnitNormal[iDim] ) ; - IntermediateState[nVar-1] = rhoSL * ( Density_i * Energy_i - ( Pressure_i * ProjVelocity_i - pStar * sM) / ( sL - ProjVelocity_i ) ); + IntermediateState[iDim+1] = rhoSL * Density_i * Velocity_i[iDim] + (pStar - Pressure_i) * UnitNormal[iDim] / (sL - sM); + IntermediateState[nVar-1] = rhoSL * Density_i * Energy_i - (Pressure_i * ProjVelocity_i - pStar * sM) / (sL - sM); Flux[0] = sM * IntermediateState[0]; @@ -243,8 +227,8 @@ CNumerics::ResidualType<> CUpwHLLC_Flow::ComputeResidual(const CConfig* config) IntermediateState[0] = rhoSR * Density_j; for (iDim = 0; iDim < nDim; iDim++) - IntermediateState[iDim+1] = rhoSR * ( Density_j * Velocity_j[iDim] + ( pStar - Pressure_j ) / ( sR - ProjVelocity_j ) * UnitNormal[iDim] ) ; - IntermediateState[nVar-1] = rhoSR * ( Density_j * Energy_j - ( Pressure_j * ProjVelocity_j - pStar * sM ) / ( sR - ProjVelocity_j ) ); + IntermediateState[iDim+1] = rhoSR * Density_j * Velocity_j[iDim] + (pStar - Pressure_j) * UnitNormal[iDim] / (sR - sM); + IntermediateState[nVar-1] = rhoSR * Density_j * Energy_j - (Pressure_j * ProjVelocity_j - pStar * sM) / (sR - sM); Flux[0] = sM * IntermediateState[0]; @@ -254,14 +238,12 @@ CNumerics::ResidualType<> CUpwHLLC_Flow::ComputeResidual(const CConfig* config) } } - - for (iVar = 0; iVar < nVar; iVar++) - Flux[iVar] *= Area; + for (iVar = 0; iVar < nVar; iVar++) Flux[iVar] *= Area; /*--- Return early if the Jacobians do not need to be computed. ---*/ - if (implicit) - { + if (!implicit) return ResidualType<>(Flux, Jacobian_i, Jacobian_j); + if (sM > 0.0) { if (sL > 0.0) { @@ -537,27 +519,20 @@ CNumerics::ResidualType<> CUpwHLLC_Flow::ComputeResidual(const CConfig* config) } } - - /*--- Jacobians of the inviscid flux, scale = k because Flux ~ 0.5*(fc_i+fc_j)*Normal ---*/ - - Area *= kappa; - + /*--- Scale Jacobians by area (from Flux *= Area). ---*/ for (iVar = 0; iVar < nVar; iVar++) { for (jVar = 0; jVar < nVar; jVar++) { - Jacobian_i[iVar][jVar] *= Area; - Jacobian_j[iVar][jVar] *= Area; + Jacobian_i[iVar][jVar] *= Area; + Jacobian_j[iVar][jVar] *= Area; } } - } // end if implicit - return ResidualType<>(Flux, Jacobian_i, Jacobian_j); - } CUpwGeneralHLLC_Flow::CUpwGeneralHLLC_Flow(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config) : CNumerics(val_nDim, val_nVar, config) { implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - kappa = config->GetRoe_Kappa(); + /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ dynamic_grid = config->GetDynamic_Grid(); @@ -792,13 +767,12 @@ CNumerics::ResidualType<> CUpwGeneralHLLC_Flow::ComputeResidual(const CConfig* c } } - for (iVar = 0; iVar < nVar; iVar++) - Flux[iVar] *= Area; + for (iVar = 0; iVar < nVar; iVar++) Flux[iVar] *= Area; /*--- Return early if the Jacobians do not need to be computed. ---*/ - if (implicit) - { + if (!implicit) return ResidualType<>(Flux, Jacobian_i, Jacobian_j); + if (sM > 0.0) { if (sL > 0.0) { @@ -1090,21 +1064,14 @@ CNumerics::ResidualType<> CUpwGeneralHLLC_Flow::ComputeResidual(const CConfig* c } } - - /*--- Jacobians of the inviscid flux, scale = kappa because Flux ~ 0.5*(fc_i+fc_j)*Normal ---*/ - - Area *= kappa; - + /*--- Scale Jacobians by area (from Flux *= Area). ---*/ for (iVar = 0; iVar < nVar; iVar++) { for (jVar = 0; jVar < nVar; jVar++) { Jacobian_i[iVar][jVar] *= Area; Jacobian_j[iVar][jVar] *= Area; } } - } // end if implicit - return ResidualType<>(Flux, Jacobian_i, Jacobian_j); - } void CUpwGeneralHLLC_Flow::VinokurMontagne() { diff --git a/SU2_CFD/src/numerics/flow/convection/roe.cpp b/SU2_CFD/src/numerics/flow/convection/roe.cpp index 5f84fc21858..7b122119009 100644 --- a/SU2_CFD/src/numerics/flow/convection/roe.cpp +++ b/SU2_CFD/src/numerics/flow/convection/roe.cpp @@ -34,7 +34,7 @@ CUpwRoeBase_Flow::CUpwRoeBase_Flow(unsigned short val_nDim, unsigned short val_n implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ dynamic_grid = config->GetDynamic_Grid(); - kappa = config->GetRoe_Kappa(); // 1 is unstable + kappa = config->GetRoe_Kappa(); Gamma = config->GetGamma(); Gamma_Minus_One = Gamma - 1.0; @@ -683,7 +683,7 @@ CUpwGeneralRoe_Flow::CUpwGeneralRoe_Flow(unsigned short val_nDim, unsigned short implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ dynamic_grid = config->GetDynamic_Grid(); - kappa = config->GetRoe_Kappa(); // 1 is unstable + kappa = config->GetRoe_Kappa(); Flux = new su2double [nVar]; diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index e8394388bb8..e7184d37783 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -392,7 +392,7 @@ def main(): turb_flatplate_species.test_vals = [-4.120225, -0.634021, -1.706720, 1.363240, -3.250204, 9.000000, -6.697079, 5.000000, -6.978731, 10.000000, -6.013196, 0.996237, 0.996237] test_list.append(turb_flatplate_species) - # Flat plate SST compressibility correction Wilcox + # Flat plate SST compressibility correction Wilcox turb_flatplate_CC_Wilcox = TestCase('turb_flatplate_CC_Wilcox') turb_flatplate_CC_Wilcox.cfg_dir = "rans/flatplate" turb_flatplate_CC_Wilcox.cfg_file = "turb_SST_flatplate_compressibility_Wilcox.cfg" @@ -400,7 +400,7 @@ def main(): turb_flatplate_CC_Wilcox.test_vals = [-1.280875, 1.974212, 1.440458, 5.038402, -4.051125, 8.521136] test_list.append(turb_flatplate_CC_Wilcox) - # Flat plate SST compressibility correction Sarkar + # Flat plate SST compressibility correction Sarkar turb_flatplate_CC_Sarkar = TestCase('turb_flatplate_CC_Sarkar') turb_flatplate_CC_Sarkar.cfg_dir = "rans/flatplate" turb_flatplate_CC_Sarkar.cfg_file = "turb_SST_flatplate_compressibility_Sarkar.cfg" diff --git a/config_template.cfg b/config_template.cfg index ecf00315bd8..00334732b30 100644 --- a/config_template.cfg +++ b/config_template.cfg @@ -1567,7 +1567,7 @@ CONV_NUM_METHOD_FLOW= ROE % Roe Low Dissipation function for Hybrid RANS/LES simulations (FD, NTS, NTS_DUCROS) ROE_LOW_DISSIPATION= FD % -% Roe coefficient +% Roe dissipation coefficient ROE_KAPPA= 0.5 % % Minimum value for beta for the Roe-Turkel preconditioner From f3e7187db240063fd2e94846a904ee1f20cdea03 Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Sun, 11 Aug 2024 11:58:55 -0700 Subject: [PATCH 2/4] checkpoint --- .../include/numerics/flow/convection/hllc.hpp | 14 -- SU2_CFD/src/numerics/flow/convection/hllc.cpp | 218 +++++++++--------- 2 files changed, 103 insertions(+), 129 deletions(-) diff --git a/SU2_CFD/include/numerics/flow/convection/hllc.hpp b/SU2_CFD/include/numerics/flow/convection/hllc.hpp index 62d46a7d211..8f3a64f7f0d 100644 --- a/SU2_CFD/include/numerics/flow/convection/hllc.hpp +++ b/SU2_CFD/include/numerics/flow/convection/hllc.hpp @@ -39,20 +39,6 @@ class CUpwHLLC_Flow final : public CNumerics { private: bool implicit, dynamic_grid; - unsigned short iDim, jDim, iVar, jVar; - - su2double *IntermediateState; - su2double *Velocity_i, *Velocity_j, *RoeVelocity; - - su2double sq_vel_i, Density_i, Energy_i, SoundSpeed_i, Pressure_i, Enthalpy_i, ProjVelocity_i; - su2double sq_vel_j, Density_j, Energy_j, SoundSpeed_j, Pressure_j, Enthalpy_j, ProjVelocity_j; - - su2double sq_velRoe, RoeDensity, RoeEnthalpy, RoeSoundSpeed, RoeProjVelocity, ProjInterfaceVel; - - su2double sL, sR, sM, pStar, EStar, rhoSL, rhoSR, Rrho; - - su2double Omega, RHO, OmegaSM; - su2double *dSm_dU, *dPI_dU, *drhoStar_dU, *dpStar_dU, *dEStar_dU; su2double* Flux; /*!< \brief The flux accross the face. */ su2double** Jacobian_i; /*!< \brief The Jacobian w.r.t. point i after computation. */ diff --git a/SU2_CFD/src/numerics/flow/convection/hllc.cpp b/SU2_CFD/src/numerics/flow/convection/hllc.cpp index d94b44759a7..972c71047c1 100644 --- a/SU2_CFD/src/numerics/flow/convection/hllc.cpp +++ b/SU2_CFD/src/numerics/flow/convection/hllc.cpp @@ -39,17 +39,6 @@ CUpwHLLC_Flow::CUpwHLLC_Flow(unsigned short val_nDim, unsigned short val_nVar, c Gamma_Minus_One = Gamma - 1.0; - IntermediateState = new su2double [nVar]; - dSm_dU = new su2double [nVar]; - dPI_dU = new su2double [nVar]; - drhoStar_dU = new su2double [nVar]; - dpStar_dU = new su2double [nVar]; - dEStar_dU = new su2double [nVar]; - - Velocity_i = new su2double [nDim]; - Velocity_j = new su2double [nDim]; - RoeVelocity = new su2double [nDim]; - Flux = new su2double [nVar]; Jacobian_i = new su2double* [nVar]; Jacobian_j = new su2double* [nVar]; @@ -61,17 +50,6 @@ CUpwHLLC_Flow::CUpwHLLC_Flow(unsigned short val_nDim, unsigned short val_nVar, c CUpwHLLC_Flow::~CUpwHLLC_Flow() { - delete [] IntermediateState; - delete [] dSm_dU; - delete [] dPI_dU; - delete [] drhoStar_dU; - delete [] dpStar_dU; - delete [] dEStar_dU; - - delete [] Velocity_i; - delete [] Velocity_j; - delete [] RoeVelocity; - for (unsigned short iVar = 0; iVar < nVar; iVar++) { delete [] Jacobian_i[iVar]; delete [] Jacobian_j[iVar]; @@ -88,53 +66,53 @@ CNumerics::ResidualType<> CUpwHLLC_Flow::ComputeResidual(const CConfig* config) /*--- Face area (norm or the normal vector) ---*/ - Area = GeometryToolbox::Norm(nDim, Normal); + const su2double Area = GeometryToolbox::Norm(nDim, Normal); /*-- Unit Normal ---*/ - for (iDim = 0; iDim < nDim; iDim++) + for (auto iDim = 0u; iDim < nDim; iDim++) UnitNormal[iDim] = Normal[iDim] / Area; /*-- Fluid velocity at node i,j ---*/ - for (iDim = 0; iDim < nDim; iDim++) { + su2double Velocity_i[MAXNDIM] = {}, Velocity_j[MAXNDIM] = {}; + for (auto iDim = 0u; iDim < nDim; iDim++) { Velocity_i[iDim] = V_i[iDim+1]; Velocity_j[iDim] = V_j[iDim+1]; } /*--- Primitive variables at point i ---*/ - Pressure_i = V_i[nDim+1]; - Density_i = V_i[nDim+2]; - Enthalpy_i = V_i[nDim+3]; + const su2double Pressure_i = V_i[nDim+1]; + const su2double Density_i = V_i[nDim+2]; + const su2double Enthalpy_i = V_i[nDim+3]; /*--- Primitive variables at point j ---*/ - Pressure_j = V_j[nDim+1]; - Density_j = V_j[nDim+2]; - Enthalpy_j = V_j[nDim+3]; + const su2double Pressure_j = V_j[nDim+1]; + const su2double Density_j = V_j[nDim+2]; + const su2double Enthalpy_j = V_j[nDim+3]; - sq_vel_i = GeometryToolbox::SquaredNorm(nDim, Velocity_i); - sq_vel_j = GeometryToolbox::SquaredNorm(nDim, Velocity_j); + const su2double sq_vel_i = GeometryToolbox::SquaredNorm(nDim, Velocity_i); + const su2double sq_vel_j = GeometryToolbox::SquaredNorm(nDim, Velocity_j); - Energy_i = Enthalpy_i - Pressure_i / Density_i; - Energy_j = Enthalpy_j - Pressure_j / Density_j; + const su2double Energy_i = Enthalpy_i - Pressure_i / Density_i; + const su2double Energy_j = Enthalpy_j - Pressure_j / Density_j; - SoundSpeed_i = sqrt((Enthalpy_i - 0.5 * sq_vel_i) * Gamma_Minus_One); - SoundSpeed_j = sqrt((Enthalpy_j - 0.5 * sq_vel_j) * Gamma_Minus_One); + su2double SoundSpeed_i = sqrt((Enthalpy_i - 0.5 * sq_vel_i) * Gamma_Minus_One); + su2double SoundSpeed_j = sqrt((Enthalpy_j - 0.5 * sq_vel_j) * Gamma_Minus_One); /*--- Projected velocities ---*/ - ProjVelocity_i = GeometryToolbox::DotProduct(nDim, Velocity_i, UnitNormal); - ProjVelocity_j = GeometryToolbox::DotProduct(nDim, Velocity_j, UnitNormal); + su2double ProjVelocity_i = GeometryToolbox::DotProduct(nDim, Velocity_i, UnitNormal); + su2double ProjVelocity_j = GeometryToolbox::DotProduct(nDim, Velocity_j, UnitNormal); /*--- Projected Grid Velocity ---*/ - ProjInterfaceVel = 0; + su2double ProjInterfaceVel = 0; if (dynamic_grid) { - - for (iDim = 0; iDim < nDim; iDim++) + for (auto iDim = 0u; iDim < nDim; iDim++) ProjInterfaceVel += 0.5 * (GridVel_i[iDim] + GridVel_j[iDim]) * UnitNormal[iDim]; SoundSpeed_i -= ProjInterfaceVel; @@ -146,37 +124,39 @@ CNumerics::ResidualType<> CUpwHLLC_Flow::ComputeResidual(const CConfig* config) /*--- Roe's averaging ---*/ - Rrho = ( sqrt(Density_i) + sqrt(Density_j) ); + const su2double Rrho = ( sqrt(Density_i) + sqrt(Density_j) ); - for (iDim = 0; iDim < nDim; iDim++) { + su2double RoeVelocity[MAXNDIM] = {}; + for (auto iDim = 0u; iDim < nDim; iDim++) { RoeVelocity[iDim] = ( Velocity_i[iDim] * sqrt(Density_i) + Velocity_j[iDim] * sqrt(Density_j) ) / Rrho; } - sq_velRoe = GeometryToolbox::SquaredNorm(nDim, RoeVelocity); - RoeProjVelocity = GeometryToolbox::DotProduct(nDim, RoeVelocity, UnitNormal) - ProjInterfaceVel; + const su2double sq_velRoe = GeometryToolbox::SquaredNorm(nDim, RoeVelocity); + const su2double RoeProjVelocity = GeometryToolbox::DotProduct(nDim, RoeVelocity, UnitNormal) - ProjInterfaceVel; /*--- Mean Roe variables iPoint and jPoint ---*/ - RoeDensity = sqrt( Density_i * Density_j ); - RoeEnthalpy = ( sqrt(Density_j) * Enthalpy_j + sqrt(Density_i) * Enthalpy_i) / Rrho; + const su2double RoeDensity = sqrt( Density_i * Density_j ); + const su2double RoeEnthalpy = ( sqrt(Density_j) * Enthalpy_j + sqrt(Density_i) * Enthalpy_i) / Rrho; /*--- Roe-averaged speed of sound ---*/ - RoeSoundSpeed = sqrt( Gamma_Minus_One * ( RoeEnthalpy - 0.5 * sq_velRoe ) ) - ProjInterfaceVel; + const su2double RoeSoundSpeed = sqrt( Gamma_Minus_One * ( RoeEnthalpy - 0.5 * sq_velRoe ) ) - ProjInterfaceVel; /*--- Speed of sound at L and R ---*/ - sL = min( RoeProjVelocity - RoeSoundSpeed, ProjVelocity_i - SoundSpeed_i); - sR = max( RoeProjVelocity + RoeSoundSpeed, ProjVelocity_j + SoundSpeed_j); + const su2double sL = min( RoeProjVelocity - RoeSoundSpeed, ProjVelocity_i - SoundSpeed_i); + const su2double sR = max( RoeProjVelocity + RoeSoundSpeed, ProjVelocity_j + SoundSpeed_j); /*--- speed of contact surface ---*/ - RHO = Density_j * (sR - ProjVelocity_j) - Density_i * (sL - ProjVelocity_i); - sM = ( Pressure_i - Pressure_j - Density_i * ProjVelocity_i * ( sL - ProjVelocity_i ) + Density_j * ProjVelocity_j * ( sR - ProjVelocity_j ) ) / RHO; + const su2double RHO = Density_j * (sR - ProjVelocity_j) - Density_i * (sL - ProjVelocity_i); + const su2double sM = ( Pressure_i - Pressure_j - Density_i * ProjVelocity_i * ( sL - ProjVelocity_i ) + Density_j * ProjVelocity_j * ( sR - ProjVelocity_j ) ) / RHO; /*--- Pressure at right and left (Pressure_j=Pressure_i) side of contact surface ---*/ - pStar = Density_j * ( ProjVelocity_j - sR ) * ( ProjVelocity_j - sM ) + Pressure_j; + const su2double pStar = Density_j * ( ProjVelocity_j - sR ) * ( ProjVelocity_j - sM ) + Pressure_j; + su2double IntermediateState[5] = {}; if (sM > 0.0) { @@ -185,7 +165,7 @@ CNumerics::ResidualType<> CUpwHLLC_Flow::ComputeResidual(const CConfig* config) /*--- Compute Left Flux ---*/ Flux[0] = Density_i * ProjVelocity_i; - for (iDim = 0; iDim < nDim; iDim++) + for (auto iDim = 0u; iDim < nDim; iDim++) Flux[iDim+1] = Density_i * Velocity_i[iDim] * ProjVelocity_i + Pressure_i * UnitNormal[iDim]; Flux[nVar-1] = Enthalpy_i * Density_i * ProjVelocity_i; @@ -194,16 +174,15 @@ CNumerics::ResidualType<> CUpwHLLC_Flow::ComputeResidual(const CConfig* config) /*--- Compute Flux Left Star from Left Star State ---*/ - rhoSL = ( sL - ProjVelocity_i ) / ( sL - sM ); + const su2double rhoSL = ( sL - ProjVelocity_i ) / ( sL - sM ); IntermediateState[0] = rhoSL * Density_i; - for (iDim = 0; iDim < nDim; iDim++) + for (auto iDim = 0u; iDim < nDim; iDim++) IntermediateState[iDim+1] = rhoSL * Density_i * Velocity_i[iDim] + (pStar - Pressure_i) * UnitNormal[iDim] / (sL - sM); IntermediateState[nVar-1] = rhoSL * Density_i * Energy_i - (Pressure_i * ProjVelocity_i - pStar * sM) / (sL - sM); - Flux[0] = sM * IntermediateState[0]; - for (iDim = 0; iDim < nDim; iDim++) + for (auto iDim = 0u; iDim < nDim; iDim++) Flux[iDim+1] = sM * IntermediateState[iDim+1] + pStar * UnitNormal[iDim]; Flux[nVar-1] = sM * ( IntermediateState[nVar-1] + pStar ) + pStar * ProjInterfaceVel; } @@ -215,7 +194,7 @@ CNumerics::ResidualType<> CUpwHLLC_Flow::ComputeResidual(const CConfig* config) /*--- Compute Right Flux ---*/ Flux[0] = Density_j * ProjVelocity_j; - for (iDim = 0; iDim < nDim; iDim++) + for (auto iDim = 0u; iDim < nDim; iDim++) Flux[iDim+1] = Density_j * Velocity_j[iDim] * ProjVelocity_j + Pressure_j * UnitNormal[iDim]; Flux[nVar-1] = Enthalpy_j * Density_j * ProjVelocity_j; } @@ -223,22 +202,21 @@ CNumerics::ResidualType<> CUpwHLLC_Flow::ComputeResidual(const CConfig* config) /*--- Compute Flux Right Star from Right Star State ---*/ - rhoSR = ( sR - ProjVelocity_j ) / ( sR - sM ); + const su2double rhoSR = ( sR - ProjVelocity_j ) / ( sR - sM ); IntermediateState[0] = rhoSR * Density_j; - for (iDim = 0; iDim < nDim; iDim++) + for (auto iDim = 0u; iDim < nDim; iDim++) IntermediateState[iDim+1] = rhoSR * Density_j * Velocity_j[iDim] + (pStar - Pressure_j) * UnitNormal[iDim] / (sR - sM); IntermediateState[nVar-1] = rhoSR * Density_j * Energy_j - (Pressure_j * ProjVelocity_j - pStar * sM) / (sR - sM); - Flux[0] = sM * IntermediateState[0]; - for (iDim = 0; iDim < nDim; iDim++) + for (auto iDim = 0u; iDim < nDim; iDim++) Flux[iDim+1] = sM * IntermediateState[iDim+1] + pStar * UnitNormal[iDim]; Flux[nVar-1] = sM * (IntermediateState[nVar-1] + pStar ) + pStar * ProjInterfaceVel; } } - for (iVar = 0; iVar < nVar; iVar++) Flux[iVar] *= Area; + for (auto iVar = 0u; iVar < nVar; iVar++) Flux[iVar] *= Area; /*--- Return early if the Jacobians do not need to be computed. ---*/ @@ -250,8 +228,8 @@ CNumerics::ResidualType<> CUpwHLLC_Flow::ComputeResidual(const CConfig* config) /*--- Compute Jacobian based on Left State ---*/ - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) + for (auto iVar = 0u; iVar < nVar; iVar++) + for (auto jVar = 0u; jVar < nVar; jVar++) Jacobian_j[iVar][jVar] = 0; GetInviscidProjJac(Velocity_i, &Energy_i, UnitNormal, 1.0, Jacobian_i); @@ -260,9 +238,9 @@ CNumerics::ResidualType<> CUpwHLLC_Flow::ComputeResidual(const CConfig* config) else { /*--- Compute Jacobian based on Left Star State ---*/ - EStar = IntermediateState[nVar-1]; - Omega = 1/(sL-sM); - OmegaSM = Omega * sM; + const su2double EStar = IntermediateState[nVar-1]; + const su2double Omega = 1/(sL-sM); + const su2double OmegaSM = Omega * sM; /*--------- Left Jacobian ---------*/ @@ -270,41 +248,46 @@ CNumerics::ResidualType<> CUpwHLLC_Flow::ComputeResidual(const CConfig* config) /*--- Computing pressure derivatives d/dU_L (PI) ---*/ + su2double dPI_dU[5] = {}; dPI_dU[0] = 0.5 * Gamma_Minus_One * sq_vel_i; - for (iDim = 0; iDim < nDim; iDim++) + for (auto iDim = 0u; iDim < nDim; iDim++) dPI_dU[iDim+1] = - Gamma_Minus_One * Velocity_i[iDim]; dPI_dU[nVar-1] = Gamma_Minus_One; /*--- Computing d/dU_L (Sm) ---*/ + su2double dSm_dU[5] = {}; dSm_dU[0] = ( - ProjVelocity_i * ProjVelocity_i + sM * sL + dPI_dU[0] ) / RHO; - for (iDim = 0; iDim < nDim; iDim++) + for (auto iDim = 0u; iDim < nDim; iDim++) dSm_dU[iDim+1] = ( UnitNormal[iDim] * ( 2 * ProjVelocity_i - sL - sM ) + dPI_dU[iDim+1] ) / RHO; dSm_dU[nVar-1] = dPI_dU[nVar-1] / RHO; /*--- Computing d/dU_L (rhoStar) ---*/ + su2double drhoStar_dU[5] = {}; drhoStar_dU[0] = Omega * ( sL + IntermediateState[0] * dSm_dU[0] ); - for (iDim = 0; iDim < nDim; iDim++) + for (auto iDim = 0u; iDim < nDim; iDim++) drhoStar_dU[iDim+1] = Omega * ( - UnitNormal[iDim] + IntermediateState[0] * dSm_dU[iDim+1] ); drhoStar_dU[nVar-1] = Omega * IntermediateState[0] * dSm_dU[nVar-1]; /*--- Computing d/dU_L (pStar) ---*/ - for (iVar = 0; iVar < nVar; iVar++) + su2double dpStar_dU[5] = {}; + for (auto iVar = 0u; iVar < nVar; iVar++) dpStar_dU[iVar] = Density_i * (sR - ProjVelocity_j) * dSm_dU[iVar]; /*--- Computing d/dU_L (EStar) ---*/ - for (iVar = 0; iVar < nVar; iVar++) + su2double dEStar_dU[5] = {}; + for (auto iVar = 0u; iVar < nVar; iVar++) dEStar_dU[iVar] = Omega * ( sM * dpStar_dU[iVar] + ( EStar + pStar ) * dSm_dU[iVar] ); dEStar_dU[0] += Omega * ProjVelocity_i * ( Enthalpy_i - dPI_dU[0] ); - for (iDim = 0; iDim < nDim; iDim++) + for (auto iDim = 0u; iDim < nDim; iDim++) dEStar_dU[iDim+1] += Omega * ( - UnitNormal[iDim] * Enthalpy_i - ProjVelocity_i * dPI_dU[iDim+1] ); dEStar_dU[nVar-1] += Omega * ( sL - ProjVelocity_i - ProjVelocity_i * dPI_dU[nVar-1] ); @@ -312,29 +295,29 @@ CNumerics::ResidualType<> CUpwHLLC_Flow::ComputeResidual(const CConfig* config) /*--- Jacobian First Row ---*/ - for (iVar = 0; iVar < nVar; iVar++) + for (auto iVar = 0u; iVar < nVar; iVar++) Jacobian_i[0][iVar] = sM * drhoStar_dU[iVar] + IntermediateState[0] * dSm_dU[iVar]; /*--- Jacobian Middle Rows ---*/ - for (jDim = 0; jDim < nDim; jDim++) { - for (iVar = 0; iVar < nVar; iVar++) + for (auto jDim = 0u; jDim < nDim; jDim++) { + for (auto iVar = 0u; iVar < nVar; iVar++) Jacobian_i[jDim+1][iVar] = ( OmegaSM + 1 ) * ( UnitNormal[jDim] * dpStar_dU[iVar] + IntermediateState[jDim+1] * dSm_dU[iVar] ); Jacobian_i[jDim+1][0] += OmegaSM * Velocity_i[jDim] * ProjVelocity_i; Jacobian_i[jDim+1][jDim+1] += OmegaSM * (sL - ProjVelocity_i); - for (iDim = 0; iDim < nDim; iDim++) + for (auto iDim = 0u; iDim < nDim; iDim++) Jacobian_i[jDim+1][iDim+1] -= OmegaSM * Velocity_i[jDim] * UnitNormal[iDim]; - for (iVar = 0; iVar < nVar; iVar++) + for (auto iVar = 0u; iVar < nVar; iVar++) Jacobian_i[jDim+1][iVar] -= OmegaSM * dPI_dU[iVar] * UnitNormal[jDim]; } /*--- Jacobian Last Row ---*/ - for (iVar = 0; iVar < nVar; iVar++) + for (auto iVar = 0u; iVar < nVar; iVar++) Jacobian_i[nVar-1][iVar] = sM * ( dEStar_dU[iVar] + dpStar_dU[iVar] ) + ( EStar + pStar ) * dSm_dU[iVar]; @@ -344,39 +327,39 @@ CNumerics::ResidualType<> CUpwHLLC_Flow::ComputeResidual(const CConfig* config) /*--- Computing d/dU_R (Sm) ---*/ dSm_dU[0] = ( ProjVelocity_j * ProjVelocity_j - sM * sR - 0.5 * Gamma_Minus_One * sq_vel_j ) / RHO; - for (iDim = 0; iDim < nDim; iDim++) + for (auto iDim = 0u; iDim < nDim; iDim++) dSm_dU[iDim+1] = - ( UnitNormal[iDim] * ( 2 * ProjVelocity_j - sR - sM) - Gamma_Minus_One * Velocity_j[iDim] ) / RHO; dSm_dU[nVar-1] = - Gamma_Minus_One / RHO; /*--- Computing d/dU_R (pStar) ---*/ - for (iVar = 0; iVar < nVar; iVar++) + for (auto iVar = 0u; iVar < nVar; iVar++) dpStar_dU[iVar] = Density_j * (sL - ProjVelocity_i) * dSm_dU[iVar]; /*--- Computing d/dU_R (EStar) ---*/ - for (iVar = 0; iVar < nVar; iVar++) + for (auto iVar = 0u; iVar < nVar; iVar++) dEStar_dU[iVar] = Omega * ( sM * dpStar_dU[iVar] + ( EStar + pStar ) * dSm_dU[iVar] ); /*--- Jacobian First Row ---*/ - for (iVar = 0; iVar < nVar; iVar++) + for (auto iVar = 0u; iVar < nVar; iVar++) Jacobian_j[0][iVar] = IntermediateState[0] * ( OmegaSM + 1 ) * dSm_dU[iVar]; /*--- Jacobian Middle Rows ---*/ - for (iDim = 0; iDim < nDim; iDim++) { - for (iVar = 0; iVar < nVar; iVar++) + for (auto iDim = 0u; iDim < nDim; iDim++) { + for (auto iVar = 0u; iVar < nVar; iVar++) Jacobian_j[iDim+1][iVar] = ( OmegaSM + 1 ) * ( IntermediateState[iDim+1] * dSm_dU[iVar] + UnitNormal[iDim] * dpStar_dU[iVar] ); } /*--- Jacobian Last Row ---*/ - for (iVar = 0; iVar < nVar; iVar++) + for (auto iVar = 0u; iVar < nVar; iVar++) Jacobian_j[nVar-1][iVar] = sM * (dEStar_dU[iVar] + dpStar_dU[iVar]) + (EStar + pStar) * dSm_dU[iVar]; } } @@ -385,8 +368,8 @@ CNumerics::ResidualType<> CUpwHLLC_Flow::ComputeResidual(const CConfig* config) /*--- Compute Jacobian based on Right State ---*/ - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) + for (auto iVar = 0u; iVar < nVar; iVar++) + for (auto jVar = 0u; jVar < nVar; jVar++) Jacobian_i[iVar][jVar] = 0; GetInviscidProjJac(Velocity_j, &Energy_j, UnitNormal, 1.0, Jacobian_j); @@ -395,9 +378,9 @@ CNumerics::ResidualType<> CUpwHLLC_Flow::ComputeResidual(const CConfig* config) else { /*--- Compute Jacobian based on Right Star State ---*/ - EStar = IntermediateState[nVar-1]; - Omega = 1/(sR-sM); - OmegaSM = Omega * sM; + const su2double EStar = IntermediateState[nVar-1]; + const su2double Omega = 1/(sR-sM); + const su2double OmegaSM = Omega * sM; /*--------- Left Jacobian ---------*/ @@ -405,40 +388,43 @@ CNumerics::ResidualType<> CUpwHLLC_Flow::ComputeResidual(const CConfig* config) /*--- Computing d/dU_L (Sm) ---*/ + su2double dSm_dU[5] = {}; dSm_dU[0] = ( - ProjVelocity_i * ProjVelocity_i + sM * sL + 0.5 * Gamma_Minus_One * sq_vel_i ) / RHO; - for (iDim = 0; iDim < nDim; iDim++) + for (auto iDim = 0u; iDim < nDim; iDim++) dSm_dU[iDim+1] = ( UnitNormal[iDim] * ( 2 * ProjVelocity_i - sL - sM ) - Gamma_Minus_One * Velocity_i[iDim] ) / RHO; dSm_dU[nVar-1] = Gamma_Minus_One / RHO; /*--- Computing d/dU_L (pStar) ---*/ - for (iVar = 0; iVar < nVar; iVar++) + su2double dpStar_dU[5] = {}; + for (auto iVar = 0u; iVar < nVar; iVar++) dpStar_dU[iVar] = Density_i * (sR - ProjVelocity_j) * dSm_dU[iVar]; /*--- Computing d/dU_L (EStar) ---*/ - for (iVar = 0; iVar < nVar; iVar++) + su2double dEStar_dU[5] = {}; + for (auto iVar = 0u; iVar < nVar; iVar++) dEStar_dU[iVar] = Omega * ( sM * dpStar_dU[iVar] + ( EStar + pStar ) * dSm_dU[iVar] ); /*--- Jacobian First Row ---*/ - for (iVar = 0; iVar < nVar; iVar++) + for (auto iVar = 0u; iVar < nVar; iVar++) Jacobian_i[0][iVar] = IntermediateState[0] * ( OmegaSM + 1 ) * dSm_dU[iVar]; /*--- Jacobian Middle Rows ---*/ - for (iDim = 0; iDim < nDim; iDim++) { - for (iVar = 0; iVar < nVar; iVar++) + for (auto iDim = 0u; iDim < nDim; iDim++) { + for (auto iVar = 0u; iVar < nVar; iVar++) Jacobian_i[iDim+1][iVar] = (OmegaSM + 1) * ( IntermediateState[iDim+1] * dSm_dU[iVar] + UnitNormal[iDim] * dpStar_dU[iVar] ); } /*--- Jacobian Last Row ---*/ - for (iVar = 0; iVar < nVar; iVar++) + for (auto iVar = 0u; iVar < nVar; iVar++) Jacobian_i[nVar-1][iVar] = sM * (dEStar_dU[iVar] + dpStar_dU[iVar]) + (EStar + pStar) * dSm_dU[iVar]; @@ -448,8 +434,9 @@ CNumerics::ResidualType<> CUpwHLLC_Flow::ComputeResidual(const CConfig* config) /*--- Computing pressure derivatives d/dU_R (PI) ---*/ + su2double dPI_dU[5] = {}; dPI_dU[0] = 0.5 * Gamma_Minus_One * sq_vel_j; - for (iDim = 0; iDim < nDim; iDim++) + for (auto iDim = 0u; iDim < nDim; iDim++) dPI_dU[iDim+1] = - Gamma_Minus_One * Velocity_j[iDim]; dPI_dU[nVar-1] = Gamma_Minus_One; @@ -458,32 +445,33 @@ CNumerics::ResidualType<> CUpwHLLC_Flow::ComputeResidual(const CConfig* config) /*--- Computing d/dU_R (Sm) ---*/ dSm_dU[0] = - ( - ProjVelocity_j * ProjVelocity_j + sM * sR + dPI_dU[0] ) / RHO; - for (iDim = 0; iDim < nDim; iDim++) + for (auto iDim = 0u; iDim < nDim; iDim++) dSm_dU[iDim+1] = - ( UnitNormal[iDim] * ( 2 * ProjVelocity_j - sR - sM) + dPI_dU[iDim+1] ) / RHO; dSm_dU[nVar-1] = - dPI_dU[nVar-1] / RHO; /*--- Computing d/dU_R (pStar) ---*/ - for (iVar = 0; iVar < nVar; iVar++) + for (auto iVar = 0u; iVar < nVar; iVar++) dpStar_dU[iVar] = Density_j * (sL - ProjVelocity_i) * dSm_dU[iVar]; /*--- Computing d/dU_R (rhoStar) ---*/ + su2double drhoStar_dU[5] = {}; drhoStar_dU[0] = Omega * ( sR + IntermediateState[0] * dSm_dU[0] ); - for (iDim = 0; iDim < nDim; iDim++) + for (auto iDim = 0u; iDim < nDim; iDim++) drhoStar_dU[iDim+1] = Omega * ( - UnitNormal[iDim] + IntermediateState[0] * dSm_dU[iDim+1] ); drhoStar_dU[nVar-1] = Omega * IntermediateState[0] * dSm_dU[nVar-1]; /*--- Computing d/dU_R (EStar) ---*/ - for (iVar = 0; iVar < nVar; iVar++) + for (auto iVar = 0u; iVar < nVar; iVar++) dEStar_dU[iVar] = Omega * ( sM * dpStar_dU[iVar] + ( EStar + pStar ) * dSm_dU[iVar] ); dEStar_dU[0] += Omega * ProjVelocity_j * ( Enthalpy_j - dPI_dU[0] ); - for (iDim = 0; iDim < nDim; iDim++) + for (auto iDim = 0u; iDim < nDim; iDim++) dEStar_dU[iDim+1] += Omega * ( - UnitNormal[iDim] * Enthalpy_j - ProjVelocity_j * dPI_dU[iDim+1] ); dEStar_dU[nVar-1] += Omega * ( sR - ProjVelocity_j - ProjVelocity_j * dPI_dU[nVar-1] ); @@ -491,37 +479,37 @@ CNumerics::ResidualType<> CUpwHLLC_Flow::ComputeResidual(const CConfig* config) /*--- Jacobian First Row ---*/ - for (iVar = 0; iVar < nVar; iVar++) + for (auto iVar = 0u; iVar < nVar; iVar++) Jacobian_j[0][iVar] = sM * drhoStar_dU[iVar] + IntermediateState[0] * dSm_dU[iVar]; /*--- Jacobian Middle Rows ---*/ - for (jDim = 0; jDim < nDim; jDim++) { - for (iVar = 0; iVar < nVar; iVar++) + for (auto jDim = 0u; jDim < nDim; jDim++) { + for (auto iVar = 0u; iVar < nVar; iVar++) Jacobian_j[jDim+1][iVar] = ( OmegaSM + 1 ) * ( UnitNormal[jDim] * dpStar_dU[iVar] + IntermediateState[jDim+1] * dSm_dU[iVar] ); Jacobian_j[jDim+1][0] += OmegaSM * Velocity_j[jDim] * ProjVelocity_j; Jacobian_j[jDim+1][jDim+1] += OmegaSM * (sR - ProjVelocity_j); - for (iDim = 0; iDim < nDim; iDim++) + for (auto iDim = 0u; iDim < nDim; iDim++) Jacobian_j[jDim+1][iDim+1] -= OmegaSM * Velocity_j[jDim] * UnitNormal[iDim]; - for (iVar = 0; iVar < nVar; iVar++) + for (auto iVar = 0u; iVar < nVar; iVar++) Jacobian_j[jDim+1][iVar] -= OmegaSM * dPI_dU[iVar] * UnitNormal[jDim]; } /*--- Jacobian Last Row ---*/ - for (iVar = 0; iVar < nVar; iVar++) + for (auto iVar = 0u; iVar < nVar; iVar++) Jacobian_j[nVar-1][iVar] = sM * ( dEStar_dU[iVar] + dpStar_dU[iVar] ) + ( EStar + pStar ) * dSm_dU[iVar]; } } /*--- Scale Jacobians by area (from Flux *= Area). ---*/ - for (iVar = 0; iVar < nVar; iVar++) { - for (jVar = 0; jVar < nVar; jVar++) { + for (auto iVar = 0u; iVar < nVar; iVar++) { + for (auto jVar = 0u; jVar < nVar; jVar++) { Jacobian_i[iVar][jVar] *= Area; Jacobian_j[iVar][jVar] *= Area; } From dbca37cd3f1f3f8ca635d41bd4c82ac823ed299c Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Sun, 11 Aug 2024 12:36:34 -0700 Subject: [PATCH 3/4] Revert "checkpoint" This reverts commit f3e7187db240063fd2e94846a904ee1f20cdea03. --- .../include/numerics/flow/convection/hllc.hpp | 14 ++ SU2_CFD/src/numerics/flow/convection/hllc.cpp | 218 +++++++++--------- 2 files changed, 129 insertions(+), 103 deletions(-) diff --git a/SU2_CFD/include/numerics/flow/convection/hllc.hpp b/SU2_CFD/include/numerics/flow/convection/hllc.hpp index 8f3a64f7f0d..62d46a7d211 100644 --- a/SU2_CFD/include/numerics/flow/convection/hllc.hpp +++ b/SU2_CFD/include/numerics/flow/convection/hllc.hpp @@ -39,6 +39,20 @@ class CUpwHLLC_Flow final : public CNumerics { private: bool implicit, dynamic_grid; + unsigned short iDim, jDim, iVar, jVar; + + su2double *IntermediateState; + su2double *Velocity_i, *Velocity_j, *RoeVelocity; + + su2double sq_vel_i, Density_i, Energy_i, SoundSpeed_i, Pressure_i, Enthalpy_i, ProjVelocity_i; + su2double sq_vel_j, Density_j, Energy_j, SoundSpeed_j, Pressure_j, Enthalpy_j, ProjVelocity_j; + + su2double sq_velRoe, RoeDensity, RoeEnthalpy, RoeSoundSpeed, RoeProjVelocity, ProjInterfaceVel; + + su2double sL, sR, sM, pStar, EStar, rhoSL, rhoSR, Rrho; + + su2double Omega, RHO, OmegaSM; + su2double *dSm_dU, *dPI_dU, *drhoStar_dU, *dpStar_dU, *dEStar_dU; su2double* Flux; /*!< \brief The flux accross the face. */ su2double** Jacobian_i; /*!< \brief The Jacobian w.r.t. point i after computation. */ diff --git a/SU2_CFD/src/numerics/flow/convection/hllc.cpp b/SU2_CFD/src/numerics/flow/convection/hllc.cpp index 972c71047c1..d94b44759a7 100644 --- a/SU2_CFD/src/numerics/flow/convection/hllc.cpp +++ b/SU2_CFD/src/numerics/flow/convection/hllc.cpp @@ -39,6 +39,17 @@ CUpwHLLC_Flow::CUpwHLLC_Flow(unsigned short val_nDim, unsigned short val_nVar, c Gamma_Minus_One = Gamma - 1.0; + IntermediateState = new su2double [nVar]; + dSm_dU = new su2double [nVar]; + dPI_dU = new su2double [nVar]; + drhoStar_dU = new su2double [nVar]; + dpStar_dU = new su2double [nVar]; + dEStar_dU = new su2double [nVar]; + + Velocity_i = new su2double [nDim]; + Velocity_j = new su2double [nDim]; + RoeVelocity = new su2double [nDim]; + Flux = new su2double [nVar]; Jacobian_i = new su2double* [nVar]; Jacobian_j = new su2double* [nVar]; @@ -50,6 +61,17 @@ CUpwHLLC_Flow::CUpwHLLC_Flow(unsigned short val_nDim, unsigned short val_nVar, c CUpwHLLC_Flow::~CUpwHLLC_Flow() { + delete [] IntermediateState; + delete [] dSm_dU; + delete [] dPI_dU; + delete [] drhoStar_dU; + delete [] dpStar_dU; + delete [] dEStar_dU; + + delete [] Velocity_i; + delete [] Velocity_j; + delete [] RoeVelocity; + for (unsigned short iVar = 0; iVar < nVar; iVar++) { delete [] Jacobian_i[iVar]; delete [] Jacobian_j[iVar]; @@ -66,53 +88,53 @@ CNumerics::ResidualType<> CUpwHLLC_Flow::ComputeResidual(const CConfig* config) /*--- Face area (norm or the normal vector) ---*/ - const su2double Area = GeometryToolbox::Norm(nDim, Normal); + Area = GeometryToolbox::Norm(nDim, Normal); /*-- Unit Normal ---*/ - for (auto iDim = 0u; iDim < nDim; iDim++) + for (iDim = 0; iDim < nDim; iDim++) UnitNormal[iDim] = Normal[iDim] / Area; /*-- Fluid velocity at node i,j ---*/ - su2double Velocity_i[MAXNDIM] = {}, Velocity_j[MAXNDIM] = {}; - for (auto iDim = 0u; iDim < nDim; iDim++) { + for (iDim = 0; iDim < nDim; iDim++) { Velocity_i[iDim] = V_i[iDim+1]; Velocity_j[iDim] = V_j[iDim+1]; } /*--- Primitive variables at point i ---*/ - const su2double Pressure_i = V_i[nDim+1]; - const su2double Density_i = V_i[nDim+2]; - const su2double Enthalpy_i = V_i[nDim+3]; + Pressure_i = V_i[nDim+1]; + Density_i = V_i[nDim+2]; + Enthalpy_i = V_i[nDim+3]; /*--- Primitive variables at point j ---*/ - const su2double Pressure_j = V_j[nDim+1]; - const su2double Density_j = V_j[nDim+2]; - const su2double Enthalpy_j = V_j[nDim+3]; + Pressure_j = V_j[nDim+1]; + Density_j = V_j[nDim+2]; + Enthalpy_j = V_j[nDim+3]; - const su2double sq_vel_i = GeometryToolbox::SquaredNorm(nDim, Velocity_i); - const su2double sq_vel_j = GeometryToolbox::SquaredNorm(nDim, Velocity_j); + sq_vel_i = GeometryToolbox::SquaredNorm(nDim, Velocity_i); + sq_vel_j = GeometryToolbox::SquaredNorm(nDim, Velocity_j); - const su2double Energy_i = Enthalpy_i - Pressure_i / Density_i; - const su2double Energy_j = Enthalpy_j - Pressure_j / Density_j; + Energy_i = Enthalpy_i - Pressure_i / Density_i; + Energy_j = Enthalpy_j - Pressure_j / Density_j; - su2double SoundSpeed_i = sqrt((Enthalpy_i - 0.5 * sq_vel_i) * Gamma_Minus_One); - su2double SoundSpeed_j = sqrt((Enthalpy_j - 0.5 * sq_vel_j) * Gamma_Minus_One); + SoundSpeed_i = sqrt((Enthalpy_i - 0.5 * sq_vel_i) * Gamma_Minus_One); + SoundSpeed_j = sqrt((Enthalpy_j - 0.5 * sq_vel_j) * Gamma_Minus_One); /*--- Projected velocities ---*/ - su2double ProjVelocity_i = GeometryToolbox::DotProduct(nDim, Velocity_i, UnitNormal); - su2double ProjVelocity_j = GeometryToolbox::DotProduct(nDim, Velocity_j, UnitNormal); + ProjVelocity_i = GeometryToolbox::DotProduct(nDim, Velocity_i, UnitNormal); + ProjVelocity_j = GeometryToolbox::DotProduct(nDim, Velocity_j, UnitNormal); /*--- Projected Grid Velocity ---*/ - su2double ProjInterfaceVel = 0; + ProjInterfaceVel = 0; if (dynamic_grid) { - for (auto iDim = 0u; iDim < nDim; iDim++) + + for (iDim = 0; iDim < nDim; iDim++) ProjInterfaceVel += 0.5 * (GridVel_i[iDim] + GridVel_j[iDim]) * UnitNormal[iDim]; SoundSpeed_i -= ProjInterfaceVel; @@ -124,39 +146,37 @@ CNumerics::ResidualType<> CUpwHLLC_Flow::ComputeResidual(const CConfig* config) /*--- Roe's averaging ---*/ - const su2double Rrho = ( sqrt(Density_i) + sqrt(Density_j) ); + Rrho = ( sqrt(Density_i) + sqrt(Density_j) ); - su2double RoeVelocity[MAXNDIM] = {}; - for (auto iDim = 0u; iDim < nDim; iDim++) { + for (iDim = 0; iDim < nDim; iDim++) { RoeVelocity[iDim] = ( Velocity_i[iDim] * sqrt(Density_i) + Velocity_j[iDim] * sqrt(Density_j) ) / Rrho; } - const su2double sq_velRoe = GeometryToolbox::SquaredNorm(nDim, RoeVelocity); - const su2double RoeProjVelocity = GeometryToolbox::DotProduct(nDim, RoeVelocity, UnitNormal) - ProjInterfaceVel; + sq_velRoe = GeometryToolbox::SquaredNorm(nDim, RoeVelocity); + RoeProjVelocity = GeometryToolbox::DotProduct(nDim, RoeVelocity, UnitNormal) - ProjInterfaceVel; /*--- Mean Roe variables iPoint and jPoint ---*/ - const su2double RoeDensity = sqrt( Density_i * Density_j ); - const su2double RoeEnthalpy = ( sqrt(Density_j) * Enthalpy_j + sqrt(Density_i) * Enthalpy_i) / Rrho; + RoeDensity = sqrt( Density_i * Density_j ); + RoeEnthalpy = ( sqrt(Density_j) * Enthalpy_j + sqrt(Density_i) * Enthalpy_i) / Rrho; /*--- Roe-averaged speed of sound ---*/ - const su2double RoeSoundSpeed = sqrt( Gamma_Minus_One * ( RoeEnthalpy - 0.5 * sq_velRoe ) ) - ProjInterfaceVel; + RoeSoundSpeed = sqrt( Gamma_Minus_One * ( RoeEnthalpy - 0.5 * sq_velRoe ) ) - ProjInterfaceVel; /*--- Speed of sound at L and R ---*/ - const su2double sL = min( RoeProjVelocity - RoeSoundSpeed, ProjVelocity_i - SoundSpeed_i); - const su2double sR = max( RoeProjVelocity + RoeSoundSpeed, ProjVelocity_j + SoundSpeed_j); + sL = min( RoeProjVelocity - RoeSoundSpeed, ProjVelocity_i - SoundSpeed_i); + sR = max( RoeProjVelocity + RoeSoundSpeed, ProjVelocity_j + SoundSpeed_j); /*--- speed of contact surface ---*/ - const su2double RHO = Density_j * (sR - ProjVelocity_j) - Density_i * (sL - ProjVelocity_i); - const su2double sM = ( Pressure_i - Pressure_j - Density_i * ProjVelocity_i * ( sL - ProjVelocity_i ) + Density_j * ProjVelocity_j * ( sR - ProjVelocity_j ) ) / RHO; + RHO = Density_j * (sR - ProjVelocity_j) - Density_i * (sL - ProjVelocity_i); + sM = ( Pressure_i - Pressure_j - Density_i * ProjVelocity_i * ( sL - ProjVelocity_i ) + Density_j * ProjVelocity_j * ( sR - ProjVelocity_j ) ) / RHO; /*--- Pressure at right and left (Pressure_j=Pressure_i) side of contact surface ---*/ - const su2double pStar = Density_j * ( ProjVelocity_j - sR ) * ( ProjVelocity_j - sM ) + Pressure_j; + pStar = Density_j * ( ProjVelocity_j - sR ) * ( ProjVelocity_j - sM ) + Pressure_j; - su2double IntermediateState[5] = {}; if (sM > 0.0) { @@ -165,7 +185,7 @@ CNumerics::ResidualType<> CUpwHLLC_Flow::ComputeResidual(const CConfig* config) /*--- Compute Left Flux ---*/ Flux[0] = Density_i * ProjVelocity_i; - for (auto iDim = 0u; iDim < nDim; iDim++) + for (iDim = 0; iDim < nDim; iDim++) Flux[iDim+1] = Density_i * Velocity_i[iDim] * ProjVelocity_i + Pressure_i * UnitNormal[iDim]; Flux[nVar-1] = Enthalpy_i * Density_i * ProjVelocity_i; @@ -174,15 +194,16 @@ CNumerics::ResidualType<> CUpwHLLC_Flow::ComputeResidual(const CConfig* config) /*--- Compute Flux Left Star from Left Star State ---*/ - const su2double rhoSL = ( sL - ProjVelocity_i ) / ( sL - sM ); + rhoSL = ( sL - ProjVelocity_i ) / ( sL - sM ); IntermediateState[0] = rhoSL * Density_i; - for (auto iDim = 0u; iDim < nDim; iDim++) + for (iDim = 0; iDim < nDim; iDim++) IntermediateState[iDim+1] = rhoSL * Density_i * Velocity_i[iDim] + (pStar - Pressure_i) * UnitNormal[iDim] / (sL - sM); IntermediateState[nVar-1] = rhoSL * Density_i * Energy_i - (Pressure_i * ProjVelocity_i - pStar * sM) / (sL - sM); + Flux[0] = sM * IntermediateState[0]; - for (auto iDim = 0u; iDim < nDim; iDim++) + for (iDim = 0; iDim < nDim; iDim++) Flux[iDim+1] = sM * IntermediateState[iDim+1] + pStar * UnitNormal[iDim]; Flux[nVar-1] = sM * ( IntermediateState[nVar-1] + pStar ) + pStar * ProjInterfaceVel; } @@ -194,7 +215,7 @@ CNumerics::ResidualType<> CUpwHLLC_Flow::ComputeResidual(const CConfig* config) /*--- Compute Right Flux ---*/ Flux[0] = Density_j * ProjVelocity_j; - for (auto iDim = 0u; iDim < nDim; iDim++) + for (iDim = 0; iDim < nDim; iDim++) Flux[iDim+1] = Density_j * Velocity_j[iDim] * ProjVelocity_j + Pressure_j * UnitNormal[iDim]; Flux[nVar-1] = Enthalpy_j * Density_j * ProjVelocity_j; } @@ -202,21 +223,22 @@ CNumerics::ResidualType<> CUpwHLLC_Flow::ComputeResidual(const CConfig* config) /*--- Compute Flux Right Star from Right Star State ---*/ - const su2double rhoSR = ( sR - ProjVelocity_j ) / ( sR - sM ); + rhoSR = ( sR - ProjVelocity_j ) / ( sR - sM ); IntermediateState[0] = rhoSR * Density_j; - for (auto iDim = 0u; iDim < nDim; iDim++) + for (iDim = 0; iDim < nDim; iDim++) IntermediateState[iDim+1] = rhoSR * Density_j * Velocity_j[iDim] + (pStar - Pressure_j) * UnitNormal[iDim] / (sR - sM); IntermediateState[nVar-1] = rhoSR * Density_j * Energy_j - (Pressure_j * ProjVelocity_j - pStar * sM) / (sR - sM); + Flux[0] = sM * IntermediateState[0]; - for (auto iDim = 0u; iDim < nDim; iDim++) + for (iDim = 0; iDim < nDim; iDim++) Flux[iDim+1] = sM * IntermediateState[iDim+1] + pStar * UnitNormal[iDim]; Flux[nVar-1] = sM * (IntermediateState[nVar-1] + pStar ) + pStar * ProjInterfaceVel; } } - for (auto iVar = 0u; iVar < nVar; iVar++) Flux[iVar] *= Area; + for (iVar = 0; iVar < nVar; iVar++) Flux[iVar] *= Area; /*--- Return early if the Jacobians do not need to be computed. ---*/ @@ -228,8 +250,8 @@ CNumerics::ResidualType<> CUpwHLLC_Flow::ComputeResidual(const CConfig* config) /*--- Compute Jacobian based on Left State ---*/ - for (auto iVar = 0u; iVar < nVar; iVar++) - for (auto jVar = 0u; jVar < nVar; jVar++) + for (iVar = 0; iVar < nVar; iVar++) + for (jVar = 0; jVar < nVar; jVar++) Jacobian_j[iVar][jVar] = 0; GetInviscidProjJac(Velocity_i, &Energy_i, UnitNormal, 1.0, Jacobian_i); @@ -238,9 +260,9 @@ CNumerics::ResidualType<> CUpwHLLC_Flow::ComputeResidual(const CConfig* config) else { /*--- Compute Jacobian based on Left Star State ---*/ - const su2double EStar = IntermediateState[nVar-1]; - const su2double Omega = 1/(sL-sM); - const su2double OmegaSM = Omega * sM; + EStar = IntermediateState[nVar-1]; + Omega = 1/(sL-sM); + OmegaSM = Omega * sM; /*--------- Left Jacobian ---------*/ @@ -248,46 +270,41 @@ CNumerics::ResidualType<> CUpwHLLC_Flow::ComputeResidual(const CConfig* config) /*--- Computing pressure derivatives d/dU_L (PI) ---*/ - su2double dPI_dU[5] = {}; dPI_dU[0] = 0.5 * Gamma_Minus_One * sq_vel_i; - for (auto iDim = 0u; iDim < nDim; iDim++) + for (iDim = 0; iDim < nDim; iDim++) dPI_dU[iDim+1] = - Gamma_Minus_One * Velocity_i[iDim]; dPI_dU[nVar-1] = Gamma_Minus_One; /*--- Computing d/dU_L (Sm) ---*/ - su2double dSm_dU[5] = {}; dSm_dU[0] = ( - ProjVelocity_i * ProjVelocity_i + sM * sL + dPI_dU[0] ) / RHO; - for (auto iDim = 0u; iDim < nDim; iDim++) + for (iDim = 0; iDim < nDim; iDim++) dSm_dU[iDim+1] = ( UnitNormal[iDim] * ( 2 * ProjVelocity_i - sL - sM ) + dPI_dU[iDim+1] ) / RHO; dSm_dU[nVar-1] = dPI_dU[nVar-1] / RHO; /*--- Computing d/dU_L (rhoStar) ---*/ - su2double drhoStar_dU[5] = {}; drhoStar_dU[0] = Omega * ( sL + IntermediateState[0] * dSm_dU[0] ); - for (auto iDim = 0u; iDim < nDim; iDim++) + for (iDim = 0; iDim < nDim; iDim++) drhoStar_dU[iDim+1] = Omega * ( - UnitNormal[iDim] + IntermediateState[0] * dSm_dU[iDim+1] ); drhoStar_dU[nVar-1] = Omega * IntermediateState[0] * dSm_dU[nVar-1]; /*--- Computing d/dU_L (pStar) ---*/ - su2double dpStar_dU[5] = {}; - for (auto iVar = 0u; iVar < nVar; iVar++) + for (iVar = 0; iVar < nVar; iVar++) dpStar_dU[iVar] = Density_i * (sR - ProjVelocity_j) * dSm_dU[iVar]; /*--- Computing d/dU_L (EStar) ---*/ - su2double dEStar_dU[5] = {}; - for (auto iVar = 0u; iVar < nVar; iVar++) + for (iVar = 0; iVar < nVar; iVar++) dEStar_dU[iVar] = Omega * ( sM * dpStar_dU[iVar] + ( EStar + pStar ) * dSm_dU[iVar] ); dEStar_dU[0] += Omega * ProjVelocity_i * ( Enthalpy_i - dPI_dU[0] ); - for (auto iDim = 0u; iDim < nDim; iDim++) + for (iDim = 0; iDim < nDim; iDim++) dEStar_dU[iDim+1] += Omega * ( - UnitNormal[iDim] * Enthalpy_i - ProjVelocity_i * dPI_dU[iDim+1] ); dEStar_dU[nVar-1] += Omega * ( sL - ProjVelocity_i - ProjVelocity_i * dPI_dU[nVar-1] ); @@ -295,29 +312,29 @@ CNumerics::ResidualType<> CUpwHLLC_Flow::ComputeResidual(const CConfig* config) /*--- Jacobian First Row ---*/ - for (auto iVar = 0u; iVar < nVar; iVar++) + for (iVar = 0; iVar < nVar; iVar++) Jacobian_i[0][iVar] = sM * drhoStar_dU[iVar] + IntermediateState[0] * dSm_dU[iVar]; /*--- Jacobian Middle Rows ---*/ - for (auto jDim = 0u; jDim < nDim; jDim++) { - for (auto iVar = 0u; iVar < nVar; iVar++) + for (jDim = 0; jDim < nDim; jDim++) { + for (iVar = 0; iVar < nVar; iVar++) Jacobian_i[jDim+1][iVar] = ( OmegaSM + 1 ) * ( UnitNormal[jDim] * dpStar_dU[iVar] + IntermediateState[jDim+1] * dSm_dU[iVar] ); Jacobian_i[jDim+1][0] += OmegaSM * Velocity_i[jDim] * ProjVelocity_i; Jacobian_i[jDim+1][jDim+1] += OmegaSM * (sL - ProjVelocity_i); - for (auto iDim = 0u; iDim < nDim; iDim++) + for (iDim = 0; iDim < nDim; iDim++) Jacobian_i[jDim+1][iDim+1] -= OmegaSM * Velocity_i[jDim] * UnitNormal[iDim]; - for (auto iVar = 0u; iVar < nVar; iVar++) + for (iVar = 0; iVar < nVar; iVar++) Jacobian_i[jDim+1][iVar] -= OmegaSM * dPI_dU[iVar] * UnitNormal[jDim]; } /*--- Jacobian Last Row ---*/ - for (auto iVar = 0u; iVar < nVar; iVar++) + for (iVar = 0; iVar < nVar; iVar++) Jacobian_i[nVar-1][iVar] = sM * ( dEStar_dU[iVar] + dpStar_dU[iVar] ) + ( EStar + pStar ) * dSm_dU[iVar]; @@ -327,39 +344,39 @@ CNumerics::ResidualType<> CUpwHLLC_Flow::ComputeResidual(const CConfig* config) /*--- Computing d/dU_R (Sm) ---*/ dSm_dU[0] = ( ProjVelocity_j * ProjVelocity_j - sM * sR - 0.5 * Gamma_Minus_One * sq_vel_j ) / RHO; - for (auto iDim = 0u; iDim < nDim; iDim++) + for (iDim = 0; iDim < nDim; iDim++) dSm_dU[iDim+1] = - ( UnitNormal[iDim] * ( 2 * ProjVelocity_j - sR - sM) - Gamma_Minus_One * Velocity_j[iDim] ) / RHO; dSm_dU[nVar-1] = - Gamma_Minus_One / RHO; /*--- Computing d/dU_R (pStar) ---*/ - for (auto iVar = 0u; iVar < nVar; iVar++) + for (iVar = 0; iVar < nVar; iVar++) dpStar_dU[iVar] = Density_j * (sL - ProjVelocity_i) * dSm_dU[iVar]; /*--- Computing d/dU_R (EStar) ---*/ - for (auto iVar = 0u; iVar < nVar; iVar++) + for (iVar = 0; iVar < nVar; iVar++) dEStar_dU[iVar] = Omega * ( sM * dpStar_dU[iVar] + ( EStar + pStar ) * dSm_dU[iVar] ); /*--- Jacobian First Row ---*/ - for (auto iVar = 0u; iVar < nVar; iVar++) + for (iVar = 0; iVar < nVar; iVar++) Jacobian_j[0][iVar] = IntermediateState[0] * ( OmegaSM + 1 ) * dSm_dU[iVar]; /*--- Jacobian Middle Rows ---*/ - for (auto iDim = 0u; iDim < nDim; iDim++) { - for (auto iVar = 0u; iVar < nVar; iVar++) + for (iDim = 0; iDim < nDim; iDim++) { + for (iVar = 0; iVar < nVar; iVar++) Jacobian_j[iDim+1][iVar] = ( OmegaSM + 1 ) * ( IntermediateState[iDim+1] * dSm_dU[iVar] + UnitNormal[iDim] * dpStar_dU[iVar] ); } /*--- Jacobian Last Row ---*/ - for (auto iVar = 0u; iVar < nVar; iVar++) + for (iVar = 0; iVar < nVar; iVar++) Jacobian_j[nVar-1][iVar] = sM * (dEStar_dU[iVar] + dpStar_dU[iVar]) + (EStar + pStar) * dSm_dU[iVar]; } } @@ -368,8 +385,8 @@ CNumerics::ResidualType<> CUpwHLLC_Flow::ComputeResidual(const CConfig* config) /*--- Compute Jacobian based on Right State ---*/ - for (auto iVar = 0u; iVar < nVar; iVar++) - for (auto jVar = 0u; jVar < nVar; jVar++) + for (iVar = 0; iVar < nVar; iVar++) + for (jVar = 0; jVar < nVar; jVar++) Jacobian_i[iVar][jVar] = 0; GetInviscidProjJac(Velocity_j, &Energy_j, UnitNormal, 1.0, Jacobian_j); @@ -378,9 +395,9 @@ CNumerics::ResidualType<> CUpwHLLC_Flow::ComputeResidual(const CConfig* config) else { /*--- Compute Jacobian based on Right Star State ---*/ - const su2double EStar = IntermediateState[nVar-1]; - const su2double Omega = 1/(sR-sM); - const su2double OmegaSM = Omega * sM; + EStar = IntermediateState[nVar-1]; + Omega = 1/(sR-sM); + OmegaSM = Omega * sM; /*--------- Left Jacobian ---------*/ @@ -388,43 +405,40 @@ CNumerics::ResidualType<> CUpwHLLC_Flow::ComputeResidual(const CConfig* config) /*--- Computing d/dU_L (Sm) ---*/ - su2double dSm_dU[5] = {}; dSm_dU[0] = ( - ProjVelocity_i * ProjVelocity_i + sM * sL + 0.5 * Gamma_Minus_One * sq_vel_i ) / RHO; - for (auto iDim = 0u; iDim < nDim; iDim++) + for (iDim = 0; iDim < nDim; iDim++) dSm_dU[iDim+1] = ( UnitNormal[iDim] * ( 2 * ProjVelocity_i - sL - sM ) - Gamma_Minus_One * Velocity_i[iDim] ) / RHO; dSm_dU[nVar-1] = Gamma_Minus_One / RHO; /*--- Computing d/dU_L (pStar) ---*/ - su2double dpStar_dU[5] = {}; - for (auto iVar = 0u; iVar < nVar; iVar++) + for (iVar = 0; iVar < nVar; iVar++) dpStar_dU[iVar] = Density_i * (sR - ProjVelocity_j) * dSm_dU[iVar]; /*--- Computing d/dU_L (EStar) ---*/ - su2double dEStar_dU[5] = {}; - for (auto iVar = 0u; iVar < nVar; iVar++) + for (iVar = 0; iVar < nVar; iVar++) dEStar_dU[iVar] = Omega * ( sM * dpStar_dU[iVar] + ( EStar + pStar ) * dSm_dU[iVar] ); /*--- Jacobian First Row ---*/ - for (auto iVar = 0u; iVar < nVar; iVar++) + for (iVar = 0; iVar < nVar; iVar++) Jacobian_i[0][iVar] = IntermediateState[0] * ( OmegaSM + 1 ) * dSm_dU[iVar]; /*--- Jacobian Middle Rows ---*/ - for (auto iDim = 0u; iDim < nDim; iDim++) { - for (auto iVar = 0u; iVar < nVar; iVar++) + for (iDim = 0; iDim < nDim; iDim++) { + for (iVar = 0; iVar < nVar; iVar++) Jacobian_i[iDim+1][iVar] = (OmegaSM + 1) * ( IntermediateState[iDim+1] * dSm_dU[iVar] + UnitNormal[iDim] * dpStar_dU[iVar] ); } /*--- Jacobian Last Row ---*/ - for (auto iVar = 0u; iVar < nVar; iVar++) + for (iVar = 0; iVar < nVar; iVar++) Jacobian_i[nVar-1][iVar] = sM * (dEStar_dU[iVar] + dpStar_dU[iVar]) + (EStar + pStar) * dSm_dU[iVar]; @@ -434,9 +448,8 @@ CNumerics::ResidualType<> CUpwHLLC_Flow::ComputeResidual(const CConfig* config) /*--- Computing pressure derivatives d/dU_R (PI) ---*/ - su2double dPI_dU[5] = {}; dPI_dU[0] = 0.5 * Gamma_Minus_One * sq_vel_j; - for (auto iDim = 0u; iDim < nDim; iDim++) + for (iDim = 0; iDim < nDim; iDim++) dPI_dU[iDim+1] = - Gamma_Minus_One * Velocity_j[iDim]; dPI_dU[nVar-1] = Gamma_Minus_One; @@ -445,33 +458,32 @@ CNumerics::ResidualType<> CUpwHLLC_Flow::ComputeResidual(const CConfig* config) /*--- Computing d/dU_R (Sm) ---*/ dSm_dU[0] = - ( - ProjVelocity_j * ProjVelocity_j + sM * sR + dPI_dU[0] ) / RHO; - for (auto iDim = 0u; iDim < nDim; iDim++) + for (iDim = 0; iDim < nDim; iDim++) dSm_dU[iDim+1] = - ( UnitNormal[iDim] * ( 2 * ProjVelocity_j - sR - sM) + dPI_dU[iDim+1] ) / RHO; dSm_dU[nVar-1] = - dPI_dU[nVar-1] / RHO; /*--- Computing d/dU_R (pStar) ---*/ - for (auto iVar = 0u; iVar < nVar; iVar++) + for (iVar = 0; iVar < nVar; iVar++) dpStar_dU[iVar] = Density_j * (sL - ProjVelocity_i) * dSm_dU[iVar]; /*--- Computing d/dU_R (rhoStar) ---*/ - su2double drhoStar_dU[5] = {}; drhoStar_dU[0] = Omega * ( sR + IntermediateState[0] * dSm_dU[0] ); - for (auto iDim = 0u; iDim < nDim; iDim++) + for (iDim = 0; iDim < nDim; iDim++) drhoStar_dU[iDim+1] = Omega * ( - UnitNormal[iDim] + IntermediateState[0] * dSm_dU[iDim+1] ); drhoStar_dU[nVar-1] = Omega * IntermediateState[0] * dSm_dU[nVar-1]; /*--- Computing d/dU_R (EStar) ---*/ - for (auto iVar = 0u; iVar < nVar; iVar++) + for (iVar = 0; iVar < nVar; iVar++) dEStar_dU[iVar] = Omega * ( sM * dpStar_dU[iVar] + ( EStar + pStar ) * dSm_dU[iVar] ); dEStar_dU[0] += Omega * ProjVelocity_j * ( Enthalpy_j - dPI_dU[0] ); - for (auto iDim = 0u; iDim < nDim; iDim++) + for (iDim = 0; iDim < nDim; iDim++) dEStar_dU[iDim+1] += Omega * ( - UnitNormal[iDim] * Enthalpy_j - ProjVelocity_j * dPI_dU[iDim+1] ); dEStar_dU[nVar-1] += Omega * ( sR - ProjVelocity_j - ProjVelocity_j * dPI_dU[nVar-1] ); @@ -479,37 +491,37 @@ CNumerics::ResidualType<> CUpwHLLC_Flow::ComputeResidual(const CConfig* config) /*--- Jacobian First Row ---*/ - for (auto iVar = 0u; iVar < nVar; iVar++) + for (iVar = 0; iVar < nVar; iVar++) Jacobian_j[0][iVar] = sM * drhoStar_dU[iVar] + IntermediateState[0] * dSm_dU[iVar]; /*--- Jacobian Middle Rows ---*/ - for (auto jDim = 0u; jDim < nDim; jDim++) { - for (auto iVar = 0u; iVar < nVar; iVar++) + for (jDim = 0; jDim < nDim; jDim++) { + for (iVar = 0; iVar < nVar; iVar++) Jacobian_j[jDim+1][iVar] = ( OmegaSM + 1 ) * ( UnitNormal[jDim] * dpStar_dU[iVar] + IntermediateState[jDim+1] * dSm_dU[iVar] ); Jacobian_j[jDim+1][0] += OmegaSM * Velocity_j[jDim] * ProjVelocity_j; Jacobian_j[jDim+1][jDim+1] += OmegaSM * (sR - ProjVelocity_j); - for (auto iDim = 0u; iDim < nDim; iDim++) + for (iDim = 0; iDim < nDim; iDim++) Jacobian_j[jDim+1][iDim+1] -= OmegaSM * Velocity_j[jDim] * UnitNormal[iDim]; - for (auto iVar = 0u; iVar < nVar; iVar++) + for (iVar = 0; iVar < nVar; iVar++) Jacobian_j[jDim+1][iVar] -= OmegaSM * dPI_dU[iVar] * UnitNormal[jDim]; } /*--- Jacobian Last Row ---*/ - for (auto iVar = 0u; iVar < nVar; iVar++) + for (iVar = 0; iVar < nVar; iVar++) Jacobian_j[nVar-1][iVar] = sM * ( dEStar_dU[iVar] + dpStar_dU[iVar] ) + ( EStar + pStar ) * dSm_dU[iVar]; } } /*--- Scale Jacobians by area (from Flux *= Area). ---*/ - for (auto iVar = 0u; iVar < nVar; iVar++) { - for (auto jVar = 0u; jVar < nVar; jVar++) { + for (iVar = 0; iVar < nVar; iVar++) { + for (jVar = 0; jVar < nVar; jVar++) { Jacobian_i[iVar][jVar] *= Area; Jacobian_j[iVar][jVar] *= Area; } From e5386aaf515bb3594eec9c13f9ee102aff4584a1 Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Sun, 11 Aug 2024 12:36:52 -0700 Subject: [PATCH 4/4] update tests --- TestCases/hybrid_regression.py | 6 +++--- TestCases/parallel_regression.py | 6 +++--- TestCases/parallel_regression_AD.py | 2 +- TestCases/serial_regression.py | 4 ++-- TestCases/tutorials.py | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/TestCases/hybrid_regression.py b/TestCases/hybrid_regression.py index 686bef7e367..c893649c1dd 100644 --- a/TestCases/hybrid_regression.py +++ b/TestCases/hybrid_regression.py @@ -67,7 +67,7 @@ def main(): wedge.cfg_dir = "euler/wedge" wedge.cfg_file = "inv_wedge_HLLC.cfg" wedge.test_iter = 20 - wedge.test_vals = [-1.396962, 4.262003, -0.244219, 0.043052] + wedge.test_vals = [-1.368091, 4.302736, -0.243433, 0.042906] test_list.append(wedge) # ONERA M6 Wing @@ -121,8 +121,8 @@ def main(): cylinder_lowmach.cfg_dir = "navierstokes/cylinder" cylinder_lowmach.cfg_file = "cylinder_lowmach.cfg" cylinder_lowmach.test_iter = 25 - cylinder_lowmach.test_vals = [-6.850130, -1.388096, -0.056036, 108.140809, 0.007988] - cylinder_lowmach.test_vals_aarch64 = [-6.850130, -1.388096, -0.056036, 108.140813, 0.007988] + cylinder_lowmach.test_vals = [-6.830996, -1.368850, -0.143956, 73.963354, 0.002457] + cylinder_lowmach.test_vals_aarch64 = [-6.830996, -1.368850, -0.143956, 73.963354, 0.002457] test_list.append(cylinder_lowmach) # 2D Poiseuille flow (body force driven with periodic inlet / outlet) diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index e7184d37783..03e6fbaef47 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -236,7 +236,7 @@ def main(): wedge.cfg_dir = "euler/wedge" wedge.cfg_file = "inv_wedge_HLLC.cfg" wedge.test_iter = 20 - wedge.test_vals = [-1.406716, 4.253025, -0.244411, 0.043089] + wedge.test_vals = [-1.377543, 4.293870, -0.243566, 0.042930] test_list.append(wedge) # ONERA M6 Wing @@ -282,7 +282,7 @@ def main(): ea_naca64206.cfg_dir = "optimization_euler/equivalentarea_naca64206" ea_naca64206.cfg_file = "NACA64206.cfg" ea_naca64206.test_iter = 10 - ea_naca64206.test_vals = [-1.151334, -0.455927, -0.003879, 67775.000000] + ea_naca64206.test_vals = [-1.188459, -0.522783, -0.003147, 67775.000000] test_list.append(ea_naca64206) # SUPERSONIC FLOW PAST A RAMP IN A CHANNEL @@ -327,7 +327,7 @@ def main(): cylinder_lowmach.cfg_dir = "navierstokes/cylinder" cylinder_lowmach.cfg_file = "cylinder_lowmach.cfg" cylinder_lowmach.test_iter = 25 - cylinder_lowmach.test_vals = [-6.858484, -1.396528, -1.854558, 110.033249, 0.001951] + cylinder_lowmach.test_vals = [-6.841604, -1.379532, -1.266739, 76.118218, 0.000274] test_list.append(cylinder_lowmach) # 2D Poiseuille flow (body force driven with periodic inlet / outlet) diff --git a/TestCases/parallel_regression_AD.py b/TestCases/parallel_regression_AD.py index b62fed781a3..a4aa0f57252 100644 --- a/TestCases/parallel_regression_AD.py +++ b/TestCases/parallel_regression_AD.py @@ -71,7 +71,7 @@ def main(): ea_naca64206.cfg_dir = "optimization_euler/equivalentarea_naca64206" ea_naca64206.cfg_file = "NACA64206.cfg" ea_naca64206.test_iter = 10 - ea_naca64206.test_vals = [3.182170, 2.473052, -5509000.000000, 5.551800] + ea_naca64206.test_vals = [3.127605, 2.411805, -5505700.000000, 10.591000] test_list.append(ea_naca64206) #################################### diff --git a/TestCases/serial_regression.py b/TestCases/serial_regression.py index eeabe7de0ef..080b41053b7 100644 --- a/TestCases/serial_regression.py +++ b/TestCases/serial_regression.py @@ -109,7 +109,7 @@ def main(): wedge.cfg_dir = "euler/wedge" wedge.cfg_file = "inv_wedge_HLLC.cfg" wedge.test_iter = 20 - wedge.test_vals = [-1.396962, 4.262003, -0.244219, 0.043052] + wedge.test_vals = [-1.368091, 4.302736, -0.243433, 0.042906] test_list.append(wedge) # ONERA M6 Wing @@ -182,7 +182,7 @@ def main(): cylinder_lowmach.cfg_dir = "navierstokes/cylinder" cylinder_lowmach.cfg_file = "cylinder_lowmach.cfg" cylinder_lowmach.test_iter = 25 - cylinder_lowmach.test_vals = [-6.850123, -1.388088, -0.056090, 108.140176, 0.007983] + cylinder_lowmach.test_vals = [-6.830989, -1.368842, -0.143838, 73.962440, 0.002454] test_list.append(cylinder_lowmach) # 2D Poiseuille flow (body force driven with periodic inlet / outlet) diff --git a/TestCases/tutorials.py b/TestCases/tutorials.py index e2cac1f32d0..5d987f8cd9a 100644 --- a/TestCases/tutorials.py +++ b/TestCases/tutorials.py @@ -145,7 +145,7 @@ def main(): tutorial_inv_wedge.cfg_dir = "../Tutorials/compressible_flow/Inviscid_Wedge" tutorial_inv_wedge.cfg_file = "inv_wedge_HLLC.cfg" tutorial_inv_wedge.test_iter = 0 - tutorial_inv_wedge.test_vals = [-0.864206, 4.850246, -0.259185, 0.045567] + tutorial_inv_wedge.test_vals = [-0.864206, 4.850246, -0.245674, 0.043209] tutorial_inv_wedge.no_restart = True test_list.append(tutorial_inv_wedge)