diff --git a/examples/problems/co2injectionproblem.hh b/examples/problems/co2injectionproblem.hh index 6a2ae04c4..46a9ed998 100644 --- a/examples/problems/co2injectionproblem.hh +++ b/examples/problems/co2injectionproblem.hh @@ -212,8 +212,8 @@ class Co2InjectionProblem : public GetPropType 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; using RateVector = GetPropType; diff --git a/opm/models/blackoil/blackoilpolymermodules.hh b/opm/models/blackoil/blackoilpolymermodules.hh index 7ebd31acf..dc80c5ab4 100644 --- a/opm/models/blackoil/blackoilpolymermodules.hh +++ b/opm/models/blackoil/blackoilpolymermodules.hh @@ -591,7 +591,9 @@ public: const Scalar& maxAdsorbtion = PolymerModule::plyrockMaxAdsorbtion(elemCtx, dofIdx, timeIdx); const auto& plyadsAdsorbedPolymer = PolymerModule::plyadsAdsorbedPolymer(elemCtx, dofIdx, timeIdx); polymerAdsorption_ = plyadsAdsorbedPolymer.eval(polymerConcentration_, /*extrapolate=*/true); - if (PolymerModule::plyrockAdsorbtionIndex(elemCtx, dofIdx, timeIdx) == BlackOilPolymerParams::NoDesorption) { + if (static_cast(PolymerModule::plyrockAdsorbtionIndex(elemCtx, dofIdx, timeIdx)) == + BlackOilPolymerParams::NoDesorption) + { const Scalar& maxPolymerAdsorption = elemCtx.problem().maxPolymerAdsorption(elemCtx, dofIdx, timeIdx); polymerAdsorption_ = std::max(Evaluation(maxPolymerAdsorption) , polymerAdsorption_); } diff --git a/opm/models/flash/flashindices.hh b/opm/models/flash/flashindices.hh index ead04c224..642bfd5c2 100644 --- a/opm/models/flash/flashindices.hh +++ b/opm/models/flash/flashindices.hh @@ -45,7 +45,7 @@ class FlashIndices : public EnergyIndices(), getPropValue()> { - enum { numComponents = getPropValue() }; + static constexpr int numComponents = getPropValue(); enum { enableEnergy = getPropValue() }; using EnergyIndices = Opm::EnergyIndices; diff --git a/opm/models/immiscible/immiscibleindices.hh b/opm/models/immiscible/immiscibleindices.hh index 15f659941..8d3c8165f 100644 --- a/opm/models/immiscible/immiscibleindices.hh +++ b/opm/models/immiscible/immiscibleindices.hh @@ -43,7 +43,7 @@ struct ImmiscibleIndices : public EnergyIndices(), getPropValue()> { - enum { numPhases = getPropValue() }; + static constexpr int numPhases = getPropValue(); enum { enableEnergy = getPropValue() }; using EnergyIndices = Opm::EnergyIndices; diff --git a/opm/models/ncp/ncpindices.hh b/opm/models/ncp/ncpindices.hh index cd9bbdc43..049b433b7 100644 --- a/opm/models/ncp/ncpindices.hh +++ b/opm/models/ncp/ncpindices.hh @@ -48,8 +48,8 @@ struct NcpIndices { private: using FluidSystem = GetPropType; - enum { numPhases = FluidSystem::numPhases }; - enum { numComponents = FluidSystem::numComponents }; + static constexpr int numPhases = FluidSystem::numPhases; + static constexpr int numComponents = FluidSystem::numComponents; enum { enableEnergy = getPropValue() }; using EnergyIndices = Opm::EnergyIndices; diff --git a/opm/models/ncp/ncpmodel.hh b/opm/models/ncp/ncpmodel.hh index d0459ecdb..ec02ca373 100644 --- a/opm/models/ncp/ncpmodel.hh +++ b/opm/models/ncp/ncpmodel.hh @@ -232,13 +232,13 @@ class NcpModel using FluidSystem = GetPropType; using Indices = GetPropType; - 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() }; enum { enableEnergy = getPropValue() }; diff --git a/opm/models/ptflash/flashindices.hh b/opm/models/ptflash/flashindices.hh index 7b60cb3e2..578b62d76 100644 --- a/opm/models/ptflash/flashindices.hh +++ b/opm/models/ptflash/flashindices.hh @@ -46,7 +46,7 @@ class FlashIndices : public EnergyIndices(), getPropValue()> { - enum { numComponents = getPropValue() }; + static constexpr int numComponents = getPropValue(); enum { enableEnergy = getPropValue() }; using EnergyIndices = Opm::EnergyIndices; diff --git a/opm/models/pvs/pvsindices.hh b/opm/models/pvs/pvsindices.hh index 801f7935e..ef044bea1 100644 --- a/opm/models/pvs/pvsindices.hh +++ b/opm/models/pvs/pvsindices.hh @@ -46,7 +46,7 @@ class PvsIndices : public EnergyIndices(), getPropValue()> { - enum { numComponents = getPropValue() }; + static constexpr int numComponents = getPropValue(); enum { enableEnergy = getPropValue() }; using EnergyIndices = Opm::EnergyIndices; diff --git a/opm/simulators/flow/RegionPhasePVAverage.cpp b/opm/simulators/flow/RegionPhasePVAverage.cpp index d7e9a04f3..e2b10473f 100644 --- a/opm/simulators/flow/RegionPhasePVAverage.cpp +++ b/opm/simulators/flow/RegionPhasePVAverage.cpp @@ -212,5 +212,6 @@ Opm::RegionPhasePoreVolAverage::valueArrayIndex(const Ix start, const AvgType type, const Element element) const { - return start + type*Element::NumElem + element; + return start + static_cast(type) * static_cast(Element::NumElem) + + static_cast(element); } diff --git a/opm/simulators/timestepping/AdaptiveTimeStepping.hpp b/opm/simulators/timestepping/AdaptiveTimeStepping.hpp index 485afca1b..d3166a252 100644 --- a/opm/simulators/timestepping/AdaptiveTimeStepping.hpp +++ b/opm/simulators/timestepping/AdaptiveTimeStepping.hpp @@ -553,7 +553,7 @@ void registerAdaptiveParameters(); return serializationTestObject_(); } - bool operator==(const AdaptiveTimeStepping& rhs) + bool operator==(const AdaptiveTimeStepping& rhs) const { if (timeStepControlType_ != rhs.timeStepControlType_ || (timeStepControl_ && !rhs.timeStepControl_) || diff --git a/opm/simulators/utils/MPIPacker.hpp b/opm/simulators/utils/MPIPacker.hpp index fdf92d88e..25e91bdb8 100644 --- a/opm/simulators/utils/MPIPacker.hpp +++ b/opm/simulators/utils/MPIPacker.hpp @@ -34,6 +34,9 @@ namespace Opm::Mpi { namespace detail { +template +constexpr bool is_pod_v = std::is_standard_layout_v && std::is_trivial_v; + std::size_t mpi_buffer_size(const std::size_t bufsize, const std::size_t position); //! \brief Abstract struct for packing which is (partially) specialized for specific types. @@ -199,7 +202,7 @@ struct Packer template std::size_t packSize(const T& data) const { - return detail::Packing,T>::packSize(data, m_comm); + return detail::Packing,T>::packSize(data, m_comm); } //! \brief Calculates the pack size for an array. @@ -209,7 +212,7 @@ struct Packer template std::size_t packSize(const T* data, std::size_t n) const { - static_assert(std::is_pod_v, "Array packing not supported for non-pod data"); + static_assert(detail::is_pod_v, "Array packing not supported for non-pod data"); return detail::Packing::packSize(data, n, m_comm); } @@ -223,7 +226,7 @@ struct Packer std::vector& buffer, std::size_t& position) const { - detail::Packing,T>::pack(data, buffer, position, m_comm); + detail::Packing,T>::pack(data, buffer, position, m_comm); } //! \brief Pack an array. @@ -238,7 +241,7 @@ struct Packer std::vector& buffer, std::size_t& position) const { - static_assert(std::is_pod_v, "Array packing not supported for non-pod data"); + static_assert(detail::is_pod_v, "Array packing not supported for non-pod data"); detail::Packing::pack(data, n, buffer, position, m_comm); } @@ -252,7 +255,7 @@ struct Packer const std::vector& buffer, std::size_t& position) const { - detail::Packing,T>::unpack(data, buffer, position, m_comm); + detail::Packing,T>::unpack(data, buffer, position, m_comm); } //! \brief Unpack an array. @@ -267,7 +270,7 @@ struct Packer const std::vector& buffer, std::size_t& position) const { - static_assert(std::is_pod_v, "Array packing not supported for non-pod data"); + static_assert(detail::is_pod_v, "Array packing not supported for non-pod data"); detail::Packing::unpack(data, n, buffer, position, m_comm); }