diff --git a/dumux/discretization/method.hh b/dumux/discretization/method.hh index 255c0061fa880b582f57651f0c377c836dd5c59e..8da080bdd7691c7cf1771c2231f21ecf79ef8fbd 100644 --- a/dumux/discretization/method.hh +++ b/dumux/discretization/method.hh @@ -27,6 +27,8 @@ #include <ostream> #include <string> +#include <dumux/common/tag.hh> + namespace Dumux { /*! @@ -41,10 +43,112 @@ enum class DiscretizationMethod none, box, cctpfa, ccmpfa, staggered, fem, fcstaggered }; + +namespace DiscretizationMethods { + +struct CCTpfa : public Utility::Tag<CCTpfa> { + static std::string name() { return "cctpfa"; } + + //conversion operator + [[deprecated("Conversion to enum is deprecated. Will be removed after 3.5. Use tags.")]] + constexpr operator DiscretizationMethod() const + { + return DiscretizationMethod::cctpfa; + } +}; + + +struct CCMpfa : public Utility::Tag<CCMpfa> { + static std::string name() { return "ccmpfa"; } + + //conversion operator + [[deprecated("Conversion to enum is deprecated. Will be removed after 3.5. Use tags.")]] + constexpr operator DiscretizationMethod() const + { + return DiscretizationMethod::ccmpfa; + } +}; + + +struct Box : public Utility::Tag<Box> { + static std::string name() { return "box"; } + + //conversion operator + [[deprecated("Conversion to enum is deprecated. Will be removed after 3.5. Use tags.")]] + constexpr operator DiscretizationMethod() const + { + return DiscretizationMethod::box; + } +}; + + + +struct Staggered : public Utility::Tag<Staggered> { + static std::string name() { return "staggered"; } + + //conversion operator + [[deprecated("Conversion to enum is deprecated. Will be removed after 3.5. Use tags.")]] + constexpr operator DiscretizationMethod() const + { + return DiscretizationMethod::staggered; + } +}; + + + +struct FEM : public Utility::Tag<FEM> { + static std::string name() { return "fem"; } + + //conversion operator + [[deprecated("Conversion to enum is deprecated. Will be removed after 3.5. Use tags.")]] + constexpr operator DiscretizationMethod() const + { + return DiscretizationMethod::fem; + } +}; + + + +struct FCStaggered : public Utility::Tag<FCStaggered> { + static std::string name() { return "fcstaggered"; } + + //conversion operator + [[deprecated("Conversion to enum is deprecated. Will be removed after 3.5. Use tags.")]] + constexpr operator DiscretizationMethod() const + { + return DiscretizationMethod::fcstaggered; + } +}; + + + +struct None : public Utility::Tag<None> { + static std::string name() { return "none"; } + + //conversion operator + [[deprecated("Conversion to enum is deprecated. Will be removed after 3.5. Use tags.")]] + constexpr operator DiscretizationMethod() const + { + return DiscretizationMethod::none; + } +}; + + +inline constexpr CCTpfa cctpfa{}; +inline constexpr CCMpfa ccmpfa{}; +inline constexpr Box box{}; +inline constexpr Staggered staggered{}; +inline constexpr FEM fem{}; +inline constexpr FCStaggered fcstaggered{}; +inline constexpr None none{}; + +} // end namespace DiscretizationMethods + /*! * \brief Convert discretization method to string * \ingroup Discretization */ +[[deprecated("Use discretization tags and their name attribute. Will be removed after 3.5")]] inline std::string toString(DiscretizationMethod m) { switch (m) @@ -63,8 +167,24 @@ inline std::string toString(DiscretizationMethod m) * \brief Write discretization method to stream * \ingroup Discretization */ +[[deprecated("Use discretization tags which also support operator <<. Will be removed after 3.5")]] inline std::ostream& operator<<(std::ostream& stream, DiscretizationMethod m) -{ stream << toString(m); return stream; } +{ + // get rid of deprecation warning in the transition period + const auto toStringImpl = [](DiscretizationMethod m){ + switch (m) + { + case DiscretizationMethod::box: return "box"; + case DiscretizationMethod::cctpfa: return "cctpfa"; + case DiscretizationMethod::ccmpfa: return "ccmpfa"; + case DiscretizationMethod::fcstaggered: return "fcstaggered"; + case DiscretizationMethod::fem: return "fem"; + case DiscretizationMethod::staggered: return "staggered"; + default: return "none"; + } + }; + stream << toStringImpl(m); return stream; +} } // end namespace Dumux