Skip to content
Snippets Groups Projects
Commit 0ea641e4 authored by Bernd Flemisch's avatar Bernd Flemisch
Browse files

Merge branch 'feature/implement-getpropvalue' into 'master'

[properties] Implement getPropValue as free constexpr function

See merge request !1273
parents 13e6b934 6010bf86
No related branches found
No related tags found
Loading
...@@ -123,9 +123,9 @@ using GetProp = typename Properties::Detail::GetPropImpl<TypeTag, Property>::typ ...@@ -123,9 +123,9 @@ using GetProp = typename Properties::Detail::GetPropImpl<TypeTag, Property>::typ
template<class TypeTag, template<class,class> class Property> template<class TypeTag, template<class,class> class Property>
using GetPropType = typename Properties::Detail::GetPropImpl<TypeTag, Property>::type::type; using GetPropType = typename Properties::Detail::GetPropImpl<TypeTag, Property>::type::type;
//! get the value data member of a property (C++17 only, equivalent to old macro GET_PROP_VALUE(...)) //! get the value data member of a property
// template<class TypeTag, template<class,class> class Property> template<class TypeTag, template<class,class> class Property>
// constexpr auto getPropValue = Detail::GetPropImpl<TypeTag, Property>::type::value; constexpr auto getPropValue() { return Properties::Detail::GetPropImpl<TypeTag, Property>::type::value; }
} // end namespace Dumux } // end namespace Dumux
......
...@@ -46,6 +46,9 @@ struct Scalar { using type = UndefinedProperty; }; ...@@ -46,6 +46,9 @@ struct Scalar { using type = UndefinedProperty; };
template<class TypeTag, class MyTypeTag> template<class TypeTag, class MyTypeTag>
struct CoordinateType { using type = UndefinedProperty; }; struct CoordinateType { using type = UndefinedProperty; };
template<class TypeTag, class MyTypeTag>
struct UseTpfaFlux { using type = UndefinedProperty; };
namespace TTag { namespace TTag {
// create some TypeTags (equivalent to old macro NEW_TYPE_TAG(..., INHERITS_FROM(...))) // create some TypeTags (equivalent to old macro NEW_TYPE_TAG(..., INHERITS_FROM(...)))
// the tuple is sorted by precedence, the first one overwriting the following // the tuple is sorted by precedence, the first one overwriting the following
...@@ -71,6 +74,9 @@ struct Scalar<TypeTag, TTag::OnePTest> { using type = int; }; ...@@ -71,6 +74,9 @@ struct Scalar<TypeTag, TTag::OnePTest> { using type = int; };
template<class TypeTag> template<class TypeTag>
struct CoordinateType<TypeTag, TTag::Grid> { using type = GetPropType<TypeTag, Scalar>; }; struct CoordinateType<TypeTag, TTag::Grid> { using type = GetPropType<TypeTag, Scalar>; };
template<class TypeTag>
struct UseTpfaFlux<TypeTag, TTag::CCTpfaDisc> { static constexpr bool value = true; };
} // end namespace Properties } // end namespace Properties
} // end namespace Dumux } // end namespace Dumux
...@@ -105,6 +111,11 @@ int main(int argc, char* argv[]) try ...@@ -105,6 +111,11 @@ int main(int argc, char* argv[]) try
if (!std::is_same<CoordinateType, float>::value) if (!std::is_same<CoordinateType, float>::value)
DUNE_THROW(Dune::InvalidStateException, "Property CoordinateType in TTag::CCTpfaDisc should be float but is " << Dune::className<CoordinateType>()); DUNE_THROW(Dune::InvalidStateException, "Property CoordinateType in TTag::CCTpfaDisc should be float but is " << Dune::className<CoordinateType>());
} }
{
constexpr bool useTpfaFlux = getPropValue<TTag::CCTpfaDisc, UseTpfaFlux>();
if (!useTpfaFlux)
DUNE_THROW(Dune::InvalidStateException, "Property UseTpfaFlux in TTag::CCTpfaDisc should be true!");
}
std::cout << "All tests passed!" << std::endl; std::cout << "All tests passed!" << std::endl;
return 0; return 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment