From e013e43983ac98bdbd7a784bc2b27757b5e60e4b Mon Sep 17 00:00:00 2001 From: KRGulaj Date: Wed, 7 Oct 2026 16:20:13 +0200 Subject: [PATCH 1/4] Use the passive value in std::isnan of the turbo averaging and output With the MSVC STL, std::isnan on su2double resolves to the UCRT's generic template, which does not compile. A NaN check only needs the value. --- SU2_CFD/src/output/CFlowCompOutput.cpp | 8 ++++---- SU2_CFD/src/solvers/CEulerSolver.cpp | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/SU2_CFD/src/output/CFlowCompOutput.cpp b/SU2_CFD/src/output/CFlowCompOutput.cpp index 4c895674e299..2a47b32e68a9 100644 --- a/SU2_CFD/src/output/CFlowCompOutput.cpp +++ b/SU2_CFD/src/output/CFlowCompOutput.cpp @@ -787,13 +787,13 @@ void CFlowCompOutput::WriteTurboSpanwisePerformance(su2vectorGetInletState().GetVelocityValue()*config[ZONE_0]->GetVelocity_Ref(); // This captures NaNs - if(std::isnan(BladePerf->GetInletState().GetAbsFlowAngle())){ + if(std::isnan(SU2_TYPE::GetValue(BladePerf->GetInletState().GetAbsFlowAngle()))){ file.width(30); file << "0.0000"; } else { file.width(30); file << BladePerf->GetInletState().GetAbsFlowAngle()*180.0/PI_NUMBER; } - if(std::isnan(BladePerf->GetInletState().GetFlowAngle())){ + if(std::isnan(SU2_TYPE::GetValue(BladePerf->GetInletState().GetFlowAngle()))){ file.width(30); file << "0.0000"; } else{ @@ -850,13 +850,13 @@ void CFlowCompOutput::WriteTurboSpanwisePerformance(su2vectorGetOutletState().GetVelocity()[iDim]*config[ZONE_0]->GetVelocity_Ref(); } file.width(30); file << BladePerf->GetInletState().GetVelocityValue()*config[ZONE_0]->GetVelocity_Ref(); - if(std::isnan(BladePerf->GetInletState().GetAbsFlowAngle())){ + if(std::isnan(SU2_TYPE::GetValue(BladePerf->GetInletState().GetAbsFlowAngle()))){ file.width(30); file << "0.0000"; } else { file.width(30); file << BladePerf->GetOutletState().GetAbsFlowAngle()*180.0/PI_NUMBER; } - if(std::isnan(BladePerf->GetInletState().GetAbsFlowAngle())){ + if(std::isnan(SU2_TYPE::GetValue(BladePerf->GetInletState().GetAbsFlowAngle()))){ file.width(30); file << "0.0000"; } else{ diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index 2b1e021883b3..ef880886e3ad 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -9555,7 +9555,7 @@ void CEulerSolver::TurboAverageProcess(CSolver **solver, CGeometry *geometry, CC for (auto iDim = 2; iDim < nDim +1;iDim++) avgVelocity[iDim-1] = AverageFlux[iMarker][iSpan][iDim] / AverageFlux[iMarker][iSpan][0]; - if (std::isnan(avgDensity) || std::isnan(avgPressure) || avgPressure < 0.0 || avgDensity < 0.0 ){ + if (std::isnan(SU2_TYPE::GetValue(avgDensity)) || std::isnan(SU2_TYPE::GetValue(avgPressure)) || avgPressure < 0.0 || avgDensity < 0.0 ){ val_init_pressure = TotalAreaPressure / TotalArea; MixedOut_Average (config, val_init_pressure, AverageFlux[iMarker][iSpan], AverageTurboNormal, avgPressure, avgDensity); avgVelocity[0] = ( AverageFlux[iMarker][iSpan][1] - avgPressure) / AverageFlux[iMarker][iSpan][0]; @@ -9595,7 +9595,7 @@ void CEulerSolver::TurboAverageProcess(CSolver **solver, CGeometry *geometry, CC AverageRelTangVelocity[iMarker][iSpan] = avgRelTangVel; /* --- check if averaged quantities are correct otherwise reset the old quantities ---*/ - const bool nanSolution = (std::isnan(AverageDensity[iMarker][iSpan]) || std::isnan(AveragePressure[iMarker][iSpan])); + const bool nanSolution = (std::isnan(SU2_TYPE::GetValue(AverageDensity[iMarker][iSpan])) || std::isnan(SU2_TYPE::GetValue(AveragePressure[iMarker][iSpan]))); const bool negSolution = (AverageDensity[iMarker][iSpan] < 0.0 || AveragePressure[iMarker][iSpan] < 0.0); if (nanSolution || negSolution){ if (nanSolution) From f1d7325f5e19fa427b6bfd94d238d109ff119777 Mon Sep 17 00:00:00 2001 From: KRGulaj Date: Wed, 7 Oct 2026 16:26:15 +0200 Subject: [PATCH 2/4] Enable the complex overloads for MSVC AD builds The generic complex division and abs of the MSVC STL convert to double. --- Common/include/basic_types/ad_structure.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Common/include/basic_types/ad_structure.hpp b/Common/include/basic_types/ad_structure.hpp index a155465ba68f..36eafccc37a8 100644 --- a/Common/include/basic_types/ad_structure.hpp +++ b/Common/include/basic_types/ad_structure.hpp @@ -937,9 +937,10 @@ void Finalize(); /*--- If we compile under OSX we have to overload some of the operators for * complex numbers to avoid the use of the standard operators - * (they use a lot of functions that are only defined for doubles) ---*/ + * (they use a lot of functions that are only defined for doubles). + * The MSVC STL needs the same overloads when su2double is an AD type. ---*/ -#ifdef __APPLE__ +#if defined(__APPLE__) || (defined(_MSC_VER) && (defined(CODI_REVERSE_TYPE) || defined(CODI_FORWARD_TYPE))) namespace std { From 907101008b9e95b995ab2ce8359f86d7cff615ce Mon Sep 17 00:00:00 2001 From: Nijso Date: Mon, 30 Nov 2026 19:16:16 +0100 Subject: [PATCH 3/4] Update SU2_CFD/src/output/CFlowCompOutput.cpp --- SU2_CFD/src/output/CFlowCompOutput.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/src/output/CFlowCompOutput.cpp b/SU2_CFD/src/output/CFlowCompOutput.cpp index 2a47b32e68a9..259f62a03cb4 100644 --- a/SU2_CFD/src/output/CFlowCompOutput.cpp +++ b/SU2_CFD/src/output/CFlowCompOutput.cpp @@ -850,7 +850,7 @@ void CFlowCompOutput::WriteTurboSpanwisePerformance(su2vectorGetOutletState().GetVelocity()[iDim]*config[ZONE_0]->GetVelocity_Ref(); } file.width(30); file << BladePerf->GetInletState().GetVelocityValue()*config[ZONE_0]->GetVelocity_Ref(); - if(std::isnan(SU2_TYPE::GetValue(BladePerf->GetInletState().GetAbsFlowAngle()))){ + if(std::isnan(SU2_TYPE::GetValue(BladePerf->GetOutletState().GetAbsFlowAngle()))){ file.width(30); file << "0.0000"; } else { From e0a29eff35f46fc5f5d9d5d537d5a082e2512b8a Mon Sep 17 00:00:00 2001 From: Nijso Date: Mon, 30 Nov 2026 19:16:27 +0100 Subject: [PATCH 4/4] Update SU2_CFD/src/output/CFlowCompOutput.cpp --- SU2_CFD/src/output/CFlowCompOutput.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/src/output/CFlowCompOutput.cpp b/SU2_CFD/src/output/CFlowCompOutput.cpp index 259f62a03cb4..4514576aa254 100644 --- a/SU2_CFD/src/output/CFlowCompOutput.cpp +++ b/SU2_CFD/src/output/CFlowCompOutput.cpp @@ -856,7 +856,7 @@ void CFlowCompOutput::WriteTurboSpanwisePerformance(su2vectorGetOutletState().GetAbsFlowAngle()*180.0/PI_NUMBER; } - if(std::isnan(SU2_TYPE::GetValue(BladePerf->GetInletState().GetAbsFlowAngle()))){ + if(std::isnan(SU2_TYPE::GetValue(BladePerf->GetOutletState().GetFlowAngle()))){ file.width(30); file << "0.0000"; } else{