diff --git a/exercises/exercise-biomineralization/biominproblem.hh b/exercises/exercise-biomineralization/biominproblem.hh index 0f8d87d5227a9ecf4543a35a952edffee4af771d..1f315088cffc6c94c75c07379f2d440e541f96c5 100644 --- a/exercises/exercise-biomineralization/biominproblem.hh +++ b/exercises/exercise-biomineralization/biominproblem.hh @@ -54,11 +54,8 @@ class BioMinProblem : public PorousMediumFlowProblem<TypeTag> using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView; // Grid dimension - enum - { - dim = GridView::dimension, - dimWorld = GridView::dimensionworld - }; + static constexpr int dim = GridView::dimension; + static constexpr int dimWorld = GridView::dimensionworld; using GlobalPosition = Dune::FieldVector<Scalar, GridView::dimension>; using NumEqVector = Dumux::NumEqVector<PrimaryVariables>; @@ -69,28 +66,24 @@ class BioMinProblem : public PorousMediumFlowProblem<TypeTag> // TODO: dumux-course-task // set the chemistry TypeTag - enum - { - numComponents = FluidSystem::numComponents, - - pressureIdx = Indices::pressureIdx, - switchIdx = Indices::switchIdx, //Saturation + static constexpr int numComponents = FluidSystem::numComponents; + static constexpr int pressureIdx = Indices::pressureIdx; + static constexpr int switchIdx = Indices::switchIdx; //Saturation - //Indices of the components - H2OIdx = FluidSystem::H2OIdx, - CO2Idx = FluidSystem::CO2Idx, - CaIdx = FluidSystem::CaIdx, - UreaIdx = FluidSystem::UreaIdx, + // Indices of the components + static constexpr int H2OIdx = FluidSystem::H2OIdx; + static constexpr int CO2Idx = FluidSystem::CO2Idx; + static constexpr int CaIdx = FluidSystem::CaIdx; + static constexpr int UreaIdx = FluidSystem::UreaIdx; - BiofilmIdx = SolidSystem::BiofilmIdx+numComponents, - CalciteIdx = SolidSystem::CalciteIdx+numComponents, + static constexpr int BiofilmIdx = SolidSystem::BiofilmIdx+numComponents; + static constexpr int CalciteIdx = SolidSystem::CalciteIdx+numComponents; - //Index of the primary component of wetting and nonwetting phase - conti0EqIdx = Indices::conti0EqIdx, + // Index of the primary component of wetting and nonwetting phase + static constexpr int conti0EqIdx = Indices::conti0EqIdx; - // Phase State - liquidPhaseOnly = Indices::firstPhaseOnly, - }; + // Phase State + static constexpr int liquidPhaseOnly = Indices::firstPhaseOnly; /*! * \brief The constructor diff --git a/exercises/exercise-coupling-ff-pm/models/porousmediumsubproblem.hh b/exercises/exercise-coupling-ff-pm/models/porousmediumsubproblem.hh index 6a9a1fa85eded93c86c1e8befad1f13fcf9b889f..01d64fdd8ca7064b080958e04a126dee25c0c5db 100644 --- a/exercises/exercise-coupling-ff-pm/models/porousmediumsubproblem.hh +++ b/exercises/exercise-coupling-ff-pm/models/porousmediumsubproblem.hh @@ -56,19 +56,17 @@ class PorousMediumSubProblem : public PorousMediumFlowProblem<TypeTag> // copy some indices for convenience using Indices = typename GetPropType<TypeTag, Properties::ModelTraits>::Indices; - enum { - // grid and world dimension - dim = GridView::dimension, - dimworld = GridView::dimensionworld, - - // primary variable indices - conti0EqIdx = Indices::conti0EqIdx, - pressureIdx = Indices::pressureIdx, - phaseIdx = 0, - // TODO: dumux-course-task 2.A - // set the `transportCompIdx` to `Indices::switchIdx`. - transportCompIdx = 1 - }; + // grid and world dimension + static constexpr int dim = GridView::dimension; + static constexpr int dimworld = GridView::dimensionworld; + + // primary variable indices + static constexpr int conti0EqIdx = Indices::conti0EqIdx; + static constexpr int pressureIdx = Indices::pressureIdx; + static constexpr int phaseIdx = 0; + // TODO: dumux-course-task 2.A + // set the `transportCompIdx` to `Indices::switchIdx`. + static constexpr int transportCompIdx = 1; using Element = typename GridView::template Codim<0>::Entity; using GlobalPosition = Dune::FieldVector<Scalar, dimworld>; diff --git a/exercises/exercise-fluidsystem/2p2cproblem.hh b/exercises/exercise-fluidsystem/2p2cproblem.hh index c2b105b3e79468495b0f58700a00a131dcb6bb28..4e85ce272ba177bde489c7d4204f72828e588e10 100644 --- a/exercises/exercise-fluidsystem/2p2cproblem.hh +++ b/exercises/exercise-fluidsystem/2p2cproblem.hh @@ -45,9 +45,8 @@ class ExerciseFluidsystemProblemTwoPTwoC : public PorousMediumFlowProblem<TypeTa using Scalar = GetPropType<TypeTag, Properties::Scalar>; // Grid dimension - enum { dim = GridView::dimension, - dimWorld = GridView::dimensionworld - }; + static constexpr int dim = GridView::dimension; + static constexpr int dimWorld = GridView::dimensionworld; using Element = typename GridView::template Codim<0>::Entity; using GlobalPosition = typename Element::Geometry::GlobalCoordinate; diff --git a/exercises/exercise-fluidsystem/2pproblem.hh b/exercises/exercise-fluidsystem/2pproblem.hh index fcfa66fcb11129b35912d3db4077ab8b98963244..c45608c687863c874f1bdd7e6759aa4175279899 100644 --- a/exercises/exercise-fluidsystem/2pproblem.hh +++ b/exercises/exercise-fluidsystem/2pproblem.hh @@ -51,9 +51,8 @@ class ExerciseFluidsystemProblemTwoP : public PorousMediumFlowProblem<TypeTag> using Scalar = GetPropType<TypeTag, Properties::Scalar>; // Grid dimension - enum { dim = GridView::dimension, - dimWorld = GridView::dimensionworld - }; + static constexpr int dim = GridView::dimension; + static constexpr int dimWorld = GridView::dimensionworld; using Element = typename GridView::template Codim<0>::Entity; using GlobalPosition = typename Element::Geometry::GlobalCoordinate; @@ -67,12 +66,10 @@ class ExerciseFluidsystemProblemTwoP : public PorousMediumFlowProblem<TypeTag> using FluidState = GetPropType<TypeTag, Properties::FluidState>; using NumEqVector = Dumux::NumEqVector<PrimaryVariables>; - enum { - waterPressureIdx = Indices::pressureIdx, - naplSaturationIdx = Indices::saturationIdx, - contiWEqIdx = Indices::conti0EqIdx + FluidSystem::comp0Idx, // water transport equation index - contiNEqIdx = Indices::conti0EqIdx + FluidSystem::comp1Idx // napl transport equation index - }; + static constexpr int waterPressureIdx = Indices::pressureIdx; + static constexpr int naplSaturationIdx = Indices::saturationIdx; + static constexpr int contiWEqIdx = Indices::conti0EqIdx + FluidSystem::comp0Idx; // water transport equation index + static constexpr int contiNEqIdx = Indices::conti0EqIdx + FluidSystem::comp1Idx; // napl transport equation index public: ExerciseFluidsystemProblemTwoP(std::shared_ptr<const GridGeometry> gridGeometry) diff --git a/exercises/exercise-fractures/fractureproblem.hh b/exercises/exercise-fractures/fractureproblem.hh index d513ce4f72e55b78d3dce773b373a5e0f253fded..9a750147719d256083549dfa0baebc399c47dc10 100644 --- a/exercises/exercise-fractures/fractureproblem.hh +++ b/exercises/exercise-fractures/fractureproblem.hh @@ -62,11 +62,8 @@ class FractureSubProblem : public PorousMediumFlowProblem<TypeTag> // some indices for convenience using Indices = typename GetPropType<TypeTag, Properties::ModelTraits>::Indices; - enum - { - pressureIdx = Indices::pressureIdx, - saturationIdx = Indices::saturationIdx - }; + static constexpr int pressureIdx = Indices::pressureIdx; + static constexpr int saturationIdx = Indices::saturationIdx; public: //! The constructor diff --git a/exercises/exercise-fractures/matrixproblem.hh b/exercises/exercise-fractures/matrixproblem.hh index eecba0ecab069accdb3a22ae1f9620d52aca613e..469c61ea362ea89f4e2f964fbea7633cf8e32f0c 100644 --- a/exercises/exercise-fractures/matrixproblem.hh +++ b/exercises/exercise-fractures/matrixproblem.hh @@ -66,11 +66,8 @@ class MatrixSubProblem : public PorousMediumFlowProblem<TypeTag> // some indices for convenience using Indices = typename GetPropType<TypeTag, Properties::ModelTraits>::Indices; - enum - { - pressureIdx = Indices::pressureIdx, - saturationIdx = Indices::saturationIdx - }; + static constexpr int pressureIdx = Indices::pressureIdx; + static constexpr int saturationIdx = Indices::saturationIdx; public: //! The constructor diff --git a/exercises/exercise-properties/problem.hh b/exercises/exercise-properties/problem.hh index e91883647a6250893f0ca7a994f28bfb09721193..8e130df74388a19e89c31b2ca3607b82e03167ab 100644 --- a/exercises/exercise-properties/problem.hh +++ b/exercises/exercise-properties/problem.hh @@ -48,13 +48,11 @@ class TwoPTestProblem : public PorousMediumFlowProblem<TypeTag> using GlobalPosition = typename Element::Geometry::GlobalCoordinate; using NumEqVector = Dumux::NumEqVector<PrimaryVariables>; using Indices = typename GetPropType<TypeTag, Properties::ModelTraits>::Indices; - enum { - pressureH2OIdx = Indices::pressureIdx, - saturationDNAPLIdx = Indices::saturationIdx, - contiDNAPLEqIdx = Indices::conti0EqIdx + FluidSystem::comp1Idx, - waterPhaseIdx = FluidSystem::phase0Idx, - dnaplPhaseIdx = FluidSystem::phase1Idx - }; + static constexpr int pressureH2OIdx = Indices::pressureIdx; + static constexpr int saturationDNAPLIdx = Indices::saturationIdx; + static constexpr int contiDNAPLEqIdx = Indices::conti0EqIdx + FluidSystem::comp1Idx; + static constexpr int waterPhaseIdx = FluidSystem::phase0Idx; + static constexpr int dnaplPhaseIdx = FluidSystem::phase1Idx; public: TwoPTestProblem(std::shared_ptr<const GridGeometry> gridGeometry) diff --git a/exercises/solution/exercise-biomineralization/biominproblem.hh b/exercises/solution/exercise-biomineralization/biominproblem.hh index f2f3d626644cf6dbd021bea78b28f58a3a1f96d3..1bad9aeed66da725935084c5abcdaca4fff36c43 100644 --- a/exercises/solution/exercise-biomineralization/biominproblem.hh +++ b/exercises/solution/exercise-biomineralization/biominproblem.hh @@ -56,11 +56,8 @@ class BioMinProblem : public PorousMediumFlowProblem<TypeTag> using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView; // Grid dimension - enum - { - dim = GridView::dimension, - dimWorld = GridView::dimensionworld - }; + static constexpr int dim = GridView::dimension; + static constexpr int dimWorld = GridView::dimensionworld; using GlobalPosition = Dune::FieldVector<Scalar, GridView::dimension>; using NumEqVector = Dumux::NumEqVector<PrimaryVariables>; @@ -72,28 +69,24 @@ class BioMinProblem : public PorousMediumFlowProblem<TypeTag> // set the chemistry TypeTag using Chemistry = typename Dumux::SimpleBiominReactions<NumEqVector, VolumeVariables>; - enum - { - numComponents = FluidSystem::numComponents, - - pressureIdx = Indices::pressureIdx, - switchIdx = Indices::switchIdx, //Saturation + static constexpr int numComponents = FluidSystem::numComponents; + static constexpr int pressureIdx = Indices::pressureIdx; + static constexpr int switchIdx = Indices::switchIdx; //Saturation - //Indices of the components - H2OIdx = FluidSystem::H2OIdx, - CO2Idx = FluidSystem::CO2Idx, - CaIdx = FluidSystem::CaIdx, - UreaIdx = FluidSystem::UreaIdx, + // Indices of the components + static constexpr int H2OIdx = FluidSystem::H2OIdx; + static constexpr int CO2Idx = FluidSystem::CO2Idx; + static constexpr int CaIdx = FluidSystem::CaIdx; + static constexpr int UreaIdx = FluidSystem::UreaIdx; - BiofilmIdx = SolidSystem::BiofilmIdx+numComponents, - CalciteIdx = SolidSystem::CalciteIdx+numComponents, + static constexpr int BiofilmIdx = SolidSystem::BiofilmIdx+numComponents; + static constexpr int CalciteIdx = SolidSystem::CalciteIdx+numComponents; - //Index of the primary component of wetting and nonwetting phase - conti0EqIdx = Indices::conti0EqIdx, + // Index of the primary component of wetting and nonwetting phase + static constexpr int conti0EqIdx = Indices::conti0EqIdx; - // Phase State - liquidPhaseOnly = Indices::firstPhaseOnly, - }; + // Phase State + static constexpr int liquidPhaseOnly = Indices::firstPhaseOnly; /*! * \brief The constructor diff --git a/exercises/solution/exercise-coupling-ff-pm/models/porousmediumsubproblem.hh b/exercises/solution/exercise-coupling-ff-pm/models/porousmediumsubproblem.hh index cfc1e08520f7130537051882defa8e9b34878c68..e49f63bbc13d6e9863b31863fb9b42a5f5390314 100644 --- a/exercises/solution/exercise-coupling-ff-pm/models/porousmediumsubproblem.hh +++ b/exercises/solution/exercise-coupling-ff-pm/models/porousmediumsubproblem.hh @@ -55,24 +55,23 @@ class PorousMediumSubProblem : public PorousMediumFlowProblem<TypeTag> // copy some indices for convenience using Indices = typename GetPropType<TypeTag, Properties::ModelTraits>::Indices; - enum { - // grid and world dimension - dim = GridView::dimension, - dimworld = GridView::dimensionworld, - - // primary variable indices - conti0EqIdx = Indices::conti0EqIdx, - pressureIdx = Indices::pressureIdx, + + // grid and world dimension + static constexpr int dim = GridView::dimension; + static constexpr int dimworld = GridView::dimensionworld; + + // primary variable indices + static constexpr int conti0EqIdx = Indices::conti0EqIdx; + static constexpr int pressureIdx = Indices::pressureIdx; #if EXNUMBER >= 3 - saturationIdx = Indices::switchIdx, - transportCompIdx = Indices::switchIdx + static constexpr int saturationIdx = Indices::switchIdx; + static constexpr int transportCompIdx = Indices::switchIdx; #elif EXNUMBER >= 1 - transportCompIdx = Indices::switchIdx + static constexpr int transportCompIdx = Indices::switchIdx; #else - phaseIdx = 0, - transportCompIdx = 1 + static constexpr int phaseIdx = 0; + static constexpr int transportCompIdx = 1; #endif - }; using Element = typename GridView::template Codim<0>::Entity; using GlobalPosition = Dune::FieldVector<Scalar, dimworld>; diff --git a/exercises/solution/exercise-fluidsystem/2p2cproblem.hh b/exercises/solution/exercise-fluidsystem/2p2cproblem.hh index 8b26c8850f484f274aedb8cefdc0a07f864cc415..5f53e54f14abaafa749bbff45a433a5ffdc5c7c8 100644 --- a/exercises/solution/exercise-fluidsystem/2p2cproblem.hh +++ b/exercises/solution/exercise-fluidsystem/2p2cproblem.hh @@ -45,9 +45,8 @@ class ExerciseFluidsystemProblemTwoPTwoC : public PorousMediumFlowProblem<TypeTa using Scalar = GetPropType<TypeTag, Properties::Scalar>; // Grid dimension - enum { dim = GridView::dimension, - dimWorld = GridView::dimensionworld - }; + static constexpr int dim = GridView::dimension; + static constexpr int dimWorld = GridView::dimensionworld; using Element = typename GridView::template Codim<0>::Entity; using GlobalPosition = typename Element::Geometry::GlobalCoordinate; diff --git a/exercises/solution/exercise-fluidsystem/2pproblem.hh b/exercises/solution/exercise-fluidsystem/2pproblem.hh index ba335303f934200548d23957a51d4bd198dcab2d..1a81df2bdb84d6dfcbcf39207b024790e447809e 100644 --- a/exercises/solution/exercise-fluidsystem/2pproblem.hh +++ b/exercises/solution/exercise-fluidsystem/2pproblem.hh @@ -51,9 +51,8 @@ class ExerciseFluidsystemProblemTwoP : public PorousMediumFlowProblem<TypeTag> using Scalar = GetPropType<TypeTag, Properties::Scalar>; // Grid dimension - enum { dim = GridView::dimension, - dimWorld = GridView::dimensionworld - }; + static constexpr int dim = GridView::dimension; + static constexpr int dimWorld = GridView::dimensionworld; using Element = typename GridView::template Codim<0>::Entity; using GlobalPosition = typename Element::Geometry::GlobalCoordinate; @@ -67,12 +66,10 @@ class ExerciseFluidsystemProblemTwoP : public PorousMediumFlowProblem<TypeTag> using FluidState = GetPropType<TypeTag, Properties::FluidState>; using NumEqVector = Dumux::NumEqVector<PrimaryVariables>; - enum { - waterPressureIdx = Indices::pressureIdx, - naplSaturationIdx = Indices::saturationIdx, - contiWEqIdx = Indices::conti0EqIdx + FluidSystem::comp0Idx, // water transport equation index - contiNEqIdx = Indices::conti0EqIdx + FluidSystem::comp1Idx // napl transport equation index - }; + static constexpr int waterPressureIdx = Indices::pressureIdx; + static constexpr int naplSaturationIdx = Indices::saturationIdx; + static constexpr int contiWEqIdx = Indices::conti0EqIdx + FluidSystem::comp0Idx; // water transport equation index + static constexpr int contiNEqIdx = Indices::conti0EqIdx + FluidSystem::comp1Idx; // napl transport equation index public: ExerciseFluidsystemProblemTwoP(std::shared_ptr<const GridGeometry> gridGeometry) diff --git a/exercises/solution/exercise-fractures/fractureproblem.hh b/exercises/solution/exercise-fractures/fractureproblem.hh index 3284642742aa9fe28e6454c987cbf8fb3e88fc58..e3cb830fd57d644fb97ce20498b6765b3909667b 100644 --- a/exercises/solution/exercise-fractures/fractureproblem.hh +++ b/exercises/solution/exercise-fractures/fractureproblem.hh @@ -62,11 +62,8 @@ class FractureSubProblem : public PorousMediumFlowProblem<TypeTag> // some indices for convenience using Indices = typename GetPropType<TypeTag, Properties::ModelTraits>::Indices; - enum - { - pressureIdx = Indices::pressureIdx, - saturationIdx = Indices::saturationIdx - }; + static constexpr int pressureIdx = Indices::pressureIdx; + static constexpr int saturationIdx = Indices::saturationIdx; public: //! The constructor diff --git a/exercises/solution/exercise-fractures/matrixproblem.hh b/exercises/solution/exercise-fractures/matrixproblem.hh index 606a05ee080c79206b47a8de6de10750695d7b2c..430b3a5628408c10456934810eeada74b6bc2a5f 100644 --- a/exercises/solution/exercise-fractures/matrixproblem.hh +++ b/exercises/solution/exercise-fractures/matrixproblem.hh @@ -66,11 +66,8 @@ class MatrixSubProblem : public PorousMediumFlowProblem<TypeTag> // some indices for convenience using Indices = typename GetPropType<TypeTag, Properties::ModelTraits>::Indices; - enum - { - pressureIdx = Indices::pressureIdx, - saturationIdx = Indices::saturationIdx - }; + static constexpr int pressureIdx = Indices::pressureIdx; + static constexpr int saturationIdx = Indices::saturationIdx; public: //! The constructor diff --git a/exercises/solution/exercise-properties/problem.hh b/exercises/solution/exercise-properties/problem.hh index 8b240ff65f14bcc3ce10a71f870e65b117501db0..d210df125b7e812a7dbe0658144db50d4957669d 100644 --- a/exercises/solution/exercise-properties/problem.hh +++ b/exercises/solution/exercise-properties/problem.hh @@ -49,13 +49,11 @@ class TwoPTestProblem : public PorousMediumFlowProblem<TypeTag> using GlobalPosition = typename Element::Geometry::GlobalCoordinate; using NumEqVector = Dumux::NumEqVector<PrimaryVariables>; using Indices = typename GetPropType<TypeTag, Properties::ModelTraits>::Indices; - enum { - pressureH2OIdx = Indices::pressureIdx, - saturationDNAPLIdx = Indices::saturationIdx, - contiDNAPLEqIdx = Indices::conti0EqIdx + FluidSystem::comp1Idx, - waterPhaseIdx = FluidSystem::phase0Idx, - dnaplPhaseIdx = FluidSystem::phase1Idx - }; + static constexpr int pressureH2OIdx = Indices::pressureIdx; + static constexpr int saturationDNAPLIdx = Indices::saturationIdx; + static constexpr int contiDNAPLEqIdx = Indices::conti0EqIdx + FluidSystem::comp1Idx; + static constexpr int waterPhaseIdx = FluidSystem::phase0Idx; + static constexpr int dnaplPhaseIdx = FluidSystem::phase1Idx; public: TwoPTestProblem(std::shared_ptr<const GridGeometry> gridGeometry)