From bf6ffb914625087d00e2b36a020880cfcf4e7222 Mon Sep 17 00:00:00 2001 From: Kilian <kilian.weishaupt@iws.uni-stuttgart.de> Date: Wed, 2 Oct 2019 12:06:43 +0200 Subject: [PATCH] Use static constexpr for improved compiler optimization --- dumux/freeflow/compositional/staggered/fluxvariables.hh | 2 +- dumux/porousmediumflow/3p3c/localresidual.hh | 2 +- dumux/porousmediumflow/3pwateroil/localresidual.hh | 2 +- dumux/porousmediumflow/compositional/localresidual.hh | 2 +- dumux/porousmediumflow/tracer/localresidual.hh | 6 +++--- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/dumux/freeflow/compositional/staggered/fluxvariables.hh b/dumux/freeflow/compositional/staggered/fluxvariables.hh index 3eab6b5ab0..e4267068b1 100644 --- a/dumux/freeflow/compositional/staggered/fluxvariables.hh +++ b/dumux/freeflow/compositional/staggered/fluxvariables.hh @@ -75,7 +75,7 @@ public: const auto diffusiveFluxes = MolecularDiffusionType::flux(problem, element, fvGeometry, elemVolVars, scvf); - auto referenceSystemFormulation = MolecularDiffusionType::referenceSystemFormulation(); + static constexpr auto referenceSystemFormulation = MolecularDiffusionType::referenceSystemFormulation(); for (int compIdx = 0; compIdx < numComponents; ++compIdx) { diff --git a/dumux/porousmediumflow/3p3c/localresidual.hh b/dumux/porousmediumflow/3p3c/localresidual.hh index 2f73b36642..32622fcbcd 100644 --- a/dumux/porousmediumflow/3p3c/localresidual.hh +++ b/dumux/porousmediumflow/3p3c/localresidual.hh @@ -135,7 +135,7 @@ public: { FluxVariables fluxVars; fluxVars.init(problem, element, fvGeometry, elemVolVars, scvf, elemFluxVarsCache); - auto referenceSystemFormulation = FluxVariables::MolecularDiffusionType::referenceSystemFormulation(); + static constexpr auto referenceSystemFormulation = FluxVariables::MolecularDiffusionType::referenceSystemFormulation(); // get upwind weights into local scope NumEqVector flux(0.0); diff --git a/dumux/porousmediumflow/3pwateroil/localresidual.hh b/dumux/porousmediumflow/3pwateroil/localresidual.hh index 097be1fd4c..a19c731c5a 100644 --- a/dumux/porousmediumflow/3pwateroil/localresidual.hh +++ b/dumux/porousmediumflow/3pwateroil/localresidual.hh @@ -171,7 +171,7 @@ public: EnergyLocalResidual::heatConductionFlux(flux, fluxVars); // diffusive fluxes - auto referenceSystemFormulation = FluxVariables::MolecularDiffusionType::referenceSystemFormulation(); + static constexpr auto referenceSystemFormulation = FluxVariables::MolecularDiffusionType::referenceSystemFormulation(); const auto diffusionFluxesWPhase = fluxVars.molecularDiffusionFlux(wPhaseIdx); Scalar jNW = diffusionFluxesWPhase[nCompIdx]; // check for the reference system and adapt units of the diffusive flux accordingly. diff --git a/dumux/porousmediumflow/compositional/localresidual.hh b/dumux/porousmediumflow/compositional/localresidual.hh index 9ad1fa80fc..5cb6815bcb 100644 --- a/dumux/porousmediumflow/compositional/localresidual.hh +++ b/dumux/porousmediumflow/compositional/localresidual.hh @@ -143,7 +143,7 @@ public: { FluxVariables fluxVars; fluxVars.init(problem, element, fvGeometry, elemVolVars, scvf, elemFluxVarsCache); - auto referenceSystemFormulation = FluxVariables::MolecularDiffusionType::referenceSystemFormulation(); + static constexpr auto referenceSystemFormulation = FluxVariables::MolecularDiffusionType::referenceSystemFormulation(); // get upwind weights into local scope NumEqVector flux(0.0); diff --git a/dumux/porousmediumflow/tracer/localresidual.hh b/dumux/porousmediumflow/tracer/localresidual.hh index 783a777c36..e4d9a455dd 100644 --- a/dumux/porousmediumflow/tracer/localresidual.hh +++ b/dumux/porousmediumflow/tracer/localresidual.hh @@ -126,7 +126,7 @@ public: NumEqVector flux(0.0); const auto diffusiveFluxes = fluxVars.molecularDiffusionFlux(phaseIdx); - auto referenceSystemFormulation = FluxVariables::MolecularDiffusionType::referenceSystemFormulation(); + static constexpr auto referenceSystemFormulation = FluxVariables::MolecularDiffusionType::referenceSystemFormulation(); // formulation with mole balances if (useMoles) { @@ -248,7 +248,7 @@ public: const auto advDerivIJ = volFlux*rho(outsideVolVars)*outsideWeight; // diffusive term - const auto referenceSystemFormulation = FluxVariables::MolecularDiffusionType::referenceSystemFormulation(); + static constexpr auto referenceSystemFormulation = FluxVariables::MolecularDiffusionType::referenceSystemFormulation(); const auto& fluxCache = elemFluxVarsCache[scvf]; const Scalar rhoInside = massOrMolarDensity(insideVolVars, referenceSystemFormulation, phaseIdx); const Scalar rhoOutside = massOrMolarDensity(outsideVolVars, referenceSystemFormulation, phaseIdx); @@ -307,7 +307,7 @@ public: const auto advDerivIJ = volFlux*rho(outsideVolVars)*outsideWeight; // diffusive term - auto referenceSystemFormulation = FluxVariables::MolecularDiffusionType::referenceSystemFormulation(); + static constexpr auto referenceSystemFormulation = FluxVariables::MolecularDiffusionType::referenceSystemFormulation(); using DiffusionType = GetPropType<T, Properties::MolecularDiffusionType>; const auto ti = DiffusionType::calculateTransmissibilities(problem, element, -- GitLab