From 5fe2bc0aa9940f59e48f35fe270467f1e4b78eb3 Mon Sep 17 00:00:00 2001 From: Bernd Flemisch Date: Fri, 6 Mar 2020 16:08:39 +0100 Subject: [PATCH] intermediate state of reimplementing the splice functionality --- opm/models/common/multiphasebasemodel.hh | 6 ++++ opm/models/utils/basicproperties.hh | 3 +- opm/models/utils/propertysystem.hh | 40 ++++++++++++++++++++++-- opm/models/utils/propertysystemmacros.hh | 17 +++------- 4 files changed, 50 insertions(+), 16 deletions(-) diff --git a/opm/models/common/multiphasebasemodel.hh b/opm/models/common/multiphasebasemodel.hh index 2b29f0d87..40bd23e3a 100644 --- a/opm/models/common/multiphasebasemodel.hh +++ b/opm/models/common/multiphasebasemodel.hh @@ -54,7 +54,13 @@ BEGIN_PROPERTIES NEW_TYPE_TAG(MultiPhaseBaseModel, INHERITS_FROM(NumericModel, VtkMultiPhase, VtkTemperature)); //! Specify the splices of the MultiPhaseBaseModel type tag +//NEW_PROP_TAG(SpatialDiscretizationSplice); //SET_SPLICES(MultiPhaseBaseModel, SpatialDiscretizationSplice); +template +struct Splices +{ + using tuple = std::tuple>; +}; //! Set the default spatial discretization //! diff --git a/opm/models/utils/basicproperties.hh b/opm/models/utils/basicproperties.hh index 019218ef6..bb77eb677 100644 --- a/opm/models/utils/basicproperties.hh +++ b/opm/models/utils/basicproperties.hh @@ -100,7 +100,7 @@ NEW_PROP_TAG(ThreadManager); NEW_PROP_TAG(NewtonMethod); NEW_PROP_TAG(SolutionVector); NEW_PROP_TAG(GlobalEqVector); -NEW_PROP_TAG(VtkOutputFormat); +//NEW_PROP_TAG(VtkOutputFormat); //! Specifies the type of a solution for a single degee of freedom NEW_PROP_TAG(PrimaryVariables); @@ -261,7 +261,6 @@ NEW_PROP_TAG(EnableExperiments); NEW_PROP_TAG(EnableIntensiveQuantityCache); NEW_PROP_TAG(EnableThermodynamicHints); NEW_PROP_TAG(NonwettingPhase); -NEW_PROP_TAG(SpatialDiscretizationSplice); NEW_PROP_TAG(WettingPhase); NEW_PROP_TAG(OverlappingMatrix); diff --git a/opm/models/utils/propertysystem.hh b/opm/models/utils/propertysystem.hh index c7bb4aaa6..ea6febd0c 100644 --- a/opm/models/utils/propertysystem.hh +++ b/opm/models/utils/propertysystem.hh @@ -36,6 +36,26 @@ namespace Properties { //! a tag to mark properties as undefined struct UndefinedProperty {}; +template +struct SpatialDiscretizationSplice { using type = UndefinedProperty; }; + +namespace TTag { +struct MyTTag {}; +struct MySDTTag {}; +} + +template +struct SpatialDiscretizationSplice +{ using type = TTag::MySDTTag; }; + +template +struct VtkOutputFormat { using type = UndefinedProperty; }; + +template +struct VtkOutputFormat +{ static constexpr auto value = 2; }; + + //! implementation details for template meta programming namespace Detail { @@ -69,7 +89,7 @@ using ConCatTuples = decltype(std::tuple_cat(std::declval()...)); template class Property, class TTagList> struct GetDefined; -//! helper struct to iteratre over the TypeTag hierarchy +//! helper struct to iterate over the TypeTag hierarchy template class Property, class TTagList, class Enable> struct GetNextTypeTag; @@ -129,7 +149,23 @@ struct GetDefined> template class Property> struct GetPropImpl { - using type = typename Detail::GetDefined>::type; + using PType = Properties::SpatialDiscretizationSplice; + using testtype = std::conditional_t(int{}), PType, UndefinedProperty>; + static_assert(!std::is_same::value, "SpatialDiscretizationSplice is undefined in MyTTag!"); + + using QType = Properties::VtkOutputFormat; + using testtype2 = std::conditional_t(int{}), QType, UndefinedProperty>; + static_assert(!std::is_same::value, "VtkOutputFormat is undefined in MySDTTag!"); + +// using testtype = typename Detail::GetDefined +// >::type; + + using type = typename Detail::GetDefined + >::type; static_assert(!std::is_same::value, "Property is undefined!"); }; diff --git a/opm/models/utils/propertysystemmacros.hh b/opm/models/utils/propertysystemmacros.hh index 2a987c5d1..8eb628a16 100644 --- a/opm/models/utils/propertysystemmacros.hh +++ b/opm/models/utils/propertysystemmacros.hh @@ -316,7 +316,7 @@ struct GetTypeTagInheritance> * NEW_TYPE_TAG(ProblemTypeTag, INHERITS_FROM(ModelTypeTag)); * SET_TAG_PROP(ProblemTypeTag, LinearSolver, SuperLUSolver); * \endcode -*/ + */ // template class to revert the order or a std::tuple's arguments. This is required to // make the properties of children defined on the right overwrite the properties of the @@ -345,25 +345,18 @@ struct GetTypeTagInheritance> typedef typename RevertedTupleOuter::template RevertedTupleInner::type type; }; -namespace PTag { -// this class needs to be located in the PTag namespace for reasons -// you don't really want to know... -template +template struct Splices { - typedef typename std::tuple<> tuple; + using tuple = std::tuple<>; }; -} // namespace PTag #define SET_SPLICES(TypeTagName, ...) \ -namespace PTag { \ -template<> \ -struct Splices \ +template \ +struct Splices \ { \ typedef RevertedTuple<__VA_ARGS__>::type tuple; \ }; \ -SPLICE_INFO_(TypeTagName, __VA_ARGS__) \ -} \ extern int semicolonHack_ #define SET_PROP_(EffTypeTagName, PropKind, PropTagName, ...) \