diff --git a/src/thermophysicalModels/specie/specie/specieI.H b/src/thermophysicalModels/specie/specie/specieI.H index 780e7328ba..222ed14d8a 100644 --- a/src/thermophysicalModels/specie/specie/specieI.H +++ b/src/thermophysicalModels/specie/specie/specieI.H @@ -161,15 +161,18 @@ inline specie operator==(const specie& st1, const specie& st2) const scalar diffRW = st2.Y_/st2.molWeight_ - st1.Y_/st1.molWeight_; - // if (mag(diffRW) > SMALL) - // { - // molWeight = diffY/diffRW; - // } - + #ifdef __clang__ // Using intermediate volatile bool to prevent compiler optimising out the // if block (above) - CLANG 3.7.1 volatile const bool valid = (mag(diffRW) > SMALL); const scalar molWeight = valid ? diffY/diffRW : GREAT; + #else + scalar molWeight = GREAT; + if (mag(diffRW) > SMALL) + { + molWeight = diffY/diffRW; + } + #endif return specie(diffY, molWeight); } diff --git a/src/thermophysicalModels/specie/thermo/sensibleInternalEnergy/sensibleInternalEnergy.H b/src/thermophysicalModels/specie/thermo/sensibleInternalEnergy/sensibleInternalEnergy.H index 9b2f97b053..04d42aa018 100644 --- a/src/thermophysicalModels/specie/thermo/sensibleInternalEnergy/sensibleInternalEnergy.H +++ b/src/thermophysicalModels/specie/thermo/sensibleInternalEnergy/sensibleInternalEnergy.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2012-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -42,7 +42,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class sensibleInternalEnergy Declaration + Class sensibleInternalEnergy Declaration \*---------------------------------------------------------------------------*/ template @@ -51,11 +51,9 @@ class sensibleInternalEnergy public: - // Constructors - - //- Construct - sensibleInternalEnergy() - {} + //- Constructor + sensibleInternalEnergy() + {} // Member Functions @@ -66,6 +64,7 @@ public: return "sensibleInternalEnergy"; } + // Fundamental properties static word name() @@ -81,10 +80,17 @@ public: const scalar T ) const { + #ifdef __clang__ + // Using volatile to prevent compiler optimisations leading to + // a sigfpe + volatile const scalar cv = thermo.Cv(p, T); + return cv; + #else return thermo.Cv(p, T); + #endif } - //- Cp/Cv [] + //- Ratio of specific heats Cp/Cv [] scalar CpByCpv ( const Thermo& thermo, @@ -92,7 +98,14 @@ public: const scalar T ) const { + #ifdef __clang__ + // Using volatile to prevent compiler optimisations leading to + // a sigfpe + volatile const scalar gamma = thermo.gamma(p, T); + return gamma; + #else return thermo.gamma(p, T); + #endif } //- Sensible internal energy [J/kg] @@ -103,11 +116,18 @@ public: const scalar T ) const { + #ifdef __clang__ + // Using volatile to prevent compiler optimisations leading to + // a sigfpe + volatile const scalar es = thermo.Es(p, T); + return es; + #else return thermo.Es(p, T); + #endif } - //- Temperature from sensible internal energy - // given an initial temperature T0 + //- Temperature from sensible internal energy given an initial + //- temperature T0 [K] scalar THE ( const Thermo& thermo, @@ -116,7 +136,14 @@ public: const scalar T0 ) const { + #ifdef __clang__ + // Using volatile to prevent compiler optimisations leading to + // a sigfpe + volatile const scalar tes = thermo.TEs(e, p, T0); + return tes; + #else return thermo.TEs(e, p, T0); + #endif } };