use constexpr instead of anonymous enums

c++-20 warns for arithmetics using enums
This commit is contained in:
Arne Morten Kvarving
2024-11-06 10:32:30 +01:00
parent 2546d2b181
commit 13b5e23dec
7 changed files with 13 additions and 13 deletions

View File

@@ -212,8 +212,8 @@ class Co2InjectionProblem : public GetPropType<TypeTag, Properties::BaseProblem>
enum { liquidPhaseIdx = FluidSystem::liquidPhaseIdx };
enum { CO2Idx = FluidSystem::CO2Idx };
enum { BrineIdx = FluidSystem::BrineIdx };
enum { conti0EqIdx = Indices::conti0EqIdx };
enum { contiCO2EqIdx = conti0EqIdx + CO2Idx };
static constexpr int conti0EqIdx = Indices::conti0EqIdx;
static constexpr int contiCO2EqIdx = conti0EqIdx + CO2Idx;
using PrimaryVariables = GetPropType<TypeTag, Properties::PrimaryVariables>;
using RateVector = GetPropType<TypeTag, Properties::RateVector>;

View File

@@ -45,7 +45,7 @@ class FlashIndices
: public EnergyIndices<PVOffset + getPropValue<TypeTag, Properties::NumComponents>(),
getPropValue<TypeTag, Properties::EnableEnergy>()>
{
enum { numComponents = getPropValue<TypeTag, Properties::NumComponents>() };
static constexpr int numComponents = getPropValue<TypeTag, Properties::NumComponents>();
enum { enableEnergy = getPropValue<TypeTag, Properties::EnableEnergy>() };
using EnergyIndices = Opm::EnergyIndices<PVOffset + numComponents, enableEnergy>;

View File

@@ -43,7 +43,7 @@ struct ImmiscibleIndices
: public EnergyIndices<PVOffset + getPropValue<TypeTag, Properties::NumPhases>(),
getPropValue<TypeTag, Properties::EnableEnergy>()>
{
enum { numPhases = getPropValue<TypeTag, Properties::NumPhases>() };
static constexpr int numPhases = getPropValue<TypeTag, Properties::NumPhases>();
enum { enableEnergy = getPropValue<TypeTag, Properties::EnableEnergy>() };
using EnergyIndices = Opm::EnergyIndices<PVOffset + numPhases, enableEnergy>;

View File

@@ -48,8 +48,8 @@ struct NcpIndices
{
private:
using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
enum { numPhases = FluidSystem::numPhases };
enum { numComponents = FluidSystem::numComponents };
static constexpr int numPhases = FluidSystem::numPhases;
static constexpr int numComponents = FluidSystem::numComponents;
enum { enableEnergy = getPropValue<TypeTag, Properties::EnableEnergy>() };
using EnergyIndices = Opm::EnergyIndices<PVOffset + numComponents + numPhases, enableEnergy>;

View File

@@ -232,13 +232,13 @@ class NcpModel
using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
using Indices = GetPropType<TypeTag, Properties::Indices>;
enum { numPhases = FluidSystem::numPhases };
enum { numComponents = FluidSystem::numComponents };
enum { fugacity0Idx = Indices::fugacity0Idx };
static constexpr int numPhases = FluidSystem::numPhases;
static constexpr int numComponents = FluidSystem::numComponents;
static constexpr int fugacity0Idx = Indices::fugacity0Idx;
enum { pressure0Idx = Indices::pressure0Idx };
enum { saturation0Idx = Indices::saturation0Idx };
enum { conti0EqIdx = Indices::conti0EqIdx };
enum { ncp0EqIdx = Indices::ncp0EqIdx };
static constexpr int conti0EqIdx = Indices::conti0EqIdx;
static constexpr int ncp0EqIdx = Indices::ncp0EqIdx;
enum { enableDiffusion = getPropValue<TypeTag, Properties::EnableDiffusion>() };
enum { enableEnergy = getPropValue<TypeTag, Properties::EnableEnergy>() };

View File

@@ -46,7 +46,7 @@ class FlashIndices
: public EnergyIndices<PVOffset + getPropValue<TypeTag, Properties::NumComponents>(),
getPropValue<TypeTag, Properties::EnableEnergy>()>
{
enum { numComponents = getPropValue<TypeTag, Properties::NumComponents>() };
static constexpr int numComponents = getPropValue<TypeTag, Properties::NumComponents>();
enum { enableEnergy = getPropValue<TypeTag, Properties::EnableEnergy>() };
using EnergyIndices = Opm::EnergyIndices<PVOffset + numComponents, enableEnergy>;

View File

@@ -46,7 +46,7 @@ class PvsIndices
: public EnergyIndices<PVOffset + getPropValue<TypeTag, Properties::NumComponents>(),
getPropValue<TypeTag, Properties::EnableEnergy>()>
{
enum { numComponents = getPropValue<TypeTag, Properties::NumComponents>() };
static constexpr int numComponents = getPropValue<TypeTag, Properties::NumComponents>();
enum { enableEnergy = getPropValue<TypeTag, Properties::EnableEnergy>() };
using EnergyIndices = Opm::EnergyIndices<PVOffset + numComponents, enableEnergy>;