[properties] recover splice mechanism

This commit is contained in:
Bernd Flemisch 2020-03-13 16:08:49 +01:00
parent 4f890ed379
commit 54d665a532
5 changed files with 38 additions and 39 deletions

View File

@ -56,16 +56,10 @@ struct FiniteDifferenceLocalLinearizer;
}
//! The generic type tag for problems using the immiscible multi-phase model
NEW_TYPE_TAG(MultiPhaseBaseModel, INHERITS_FROM(NumericModel, VtkMultiPhase, VtkTemperature));
NEW_TYPE_TAG(MultiPhaseBaseModel, INHERITS_FROM(VtkMultiPhase, VtkTemperature));
//! Specify the splices of the MultiPhaseBaseModel type tag
//NEW_PROP_TAG(SpatialDiscretizationSplice);
//SET_SPLICES(MultiPhaseBaseModel, SpatialDiscretizationSplice);
template<class TypeTag>
struct Splices<TypeTag, TTag::MultiPhaseBaseModel>
{
using type = std::tuple<GetSplicePropType<TypeTag, Properties::SpatialDiscretizationSplice>>;
};
SET_SPLICE(MultiPhaseBaseModel, SpatialDiscretizationSplice);
//! Set the default spatial discretization
//!

View File

@ -48,17 +48,7 @@ NEW_TYPE_TAG(FvBaseDiscretization,
//! set the splices for the finite volume discretizations
//SET_SPLICES(FvBaseDiscretization, LinearSolverSplice, LocalLinearizerSplice);
template<class TypeTag>
struct Splices<TypeTag, TTag::FvBaseDiscretization>
{
// using type = std::tuple<GetSplicePropType<TypeTag, Properties::LinearSolverSplice>,
// GetSplicePropType<TypeTag, Properties::LocalLinearizerSplice>>;
using type = std::tuple<TTag::ParallelBiCGStabLinearSolver,
TTag::FiniteDifferenceLocalLinearizer>;
};
SET_SPLICES(FvBaseDiscretization, LinearSolverSplice, LocalLinearizerSplice);
//! use a parallel BiCGStab linear solver by default
SET_TAG_PROP(FvBaseDiscretization, LinearSolverSplice, ParallelBiCGStabLinearSolver);
@ -66,6 +56,7 @@ SET_TAG_PROP(FvBaseDiscretization, LinearSolverSplice, ParallelBiCGStabLinearSol
//! by default, use finite differences to linearize the system of PDEs
SET_TAG_PROP(FvBaseDiscretization, LocalLinearizerSplice, FiniteDifferenceLocalLinearizer);
/*!
* \brief Representation of a function evaluation and all necessary derivatives with
* regard to the intensive quantities of the primary variables.

View File

@ -126,10 +126,6 @@ private:
static int numThreads_;
};
namespace Properties {
SET_TYPE_PROP(NumericModel, ThreadManager, Opm::ThreadManager<TypeTag>);
}
template <class TypeTag>
int ThreadManager<TypeTag>::numThreads_ = 1;
} // namespace Opm

View File

@ -41,7 +41,6 @@ struct Splices
{
using type = std::tuple<>;
};
//! implementation details for template meta programming
namespace Detail {
@ -171,7 +170,12 @@ template<class TypeTag, class LastTypeTag>
struct GetDefinedSplice<TypeTag, std::tuple<LastTypeTag>>
{
using LastSplice = Splices<TypeTag, LastTypeTag>;
using nexttuple = typename GetNextSpliceTypeTag<TypeTag, std::tuple<LastTypeTag>, void>::type;
using nexttuple = typename GetNextSpliceTypeTag<TypeTag,
ConCatTuples<
std::tuple<LastTypeTag>,
typename LastSplice::type
>,
void>::type;
using type = std::conditional_t<isDefinedSplice<LastSplice>(int{}),
ConCatTuples<nexttuple, typename LastSplice::type>,
@ -182,7 +186,12 @@ template<class TypeTag, class FirstTypeTag, class ...Args>
struct GetDefinedSplice<TypeTag, std::tuple<FirstTypeTag, Args...>>
{
using FirstSplice = Splices<TypeTag, FirstTypeTag>;
using nexttuple = typename GetNextSpliceTypeTag<TypeTag, std::tuple<FirstTypeTag, Args...>, void>::type;
using nexttuple = typename GetNextSpliceTypeTag<TypeTag,
ConCatTuples<
std::tuple<FirstTypeTag, Args...>,
typename FirstSplice::type
>,
void>::type;
using type = std::conditional_t<isDefinedSplice<FirstSplice>(int{}),
ConCatTuples<typename FirstSplice::type, nexttuple>,
@ -193,8 +202,7 @@ struct GetDefinedSplice<TypeTag, std::tuple<FirstTypeTag, Args...>>
template<class TypeTag, template<class,class> class Property>
struct GetPropImpl
{
using splice = typename Detail::GetDefinedSplice<TypeTag, std::tuple<TypeTag>>::type;
using tuple = std::conditional_t<std::is_same<splice, std::tuple<>>::value, std::tuple<>, splice>;
using tuple = typename Detail::GetDefinedSplice<TypeTag, std::tuple<TypeTag>>::type;
using type = typename Detail::GetDefined<TypeTag,
Property,
ConCatTuples<std::tuple<TypeTag>, tuple>
@ -202,10 +210,10 @@ struct GetPropImpl
static_assert(!std::is_same<type, UndefinedProperty>::value, "Property is undefined!");
};
template<class TypeTag, template<class,class> class Property>
template<class TypeTag, class SpliceTypeTag, template<class,class> class Property>
struct GetSplicePropImpl
{
using type = typename Detail::GetDefined<TypeTag, Property, std::tuple<TypeTag>>::type;
using type = typename Detail::GetDefined<TypeTag, Property, std::tuple<TypeTag, SpliceTypeTag>>::type;
static_assert(!std::is_same<type, std::tuple<>>::value, "Splice is undefined!");
};
@ -225,8 +233,8 @@ using GetProp = typename Properties::Detail::GetPropImpl<TypeTag, Property>::typ
template<class TypeTag, template<class,class> class Property>
using GetPropType = typename Properties::Detail::GetPropImpl<TypeTag, Property>::type::type;
template<class TypeTag, template<class,class> class Property>
using GetSplicePropType = typename Properties::Detail::GetSplicePropImpl<TypeTag, Property>::type::type;
template<class TypeTag, class SpliceTypeTag, template<class,class> class Property>
using GetSplicePropType = typename Properties::Detail::GetSplicePropImpl<TypeTag, SpliceTypeTag, Property>::type::type;
//! get the value data member of a property
template<class TypeTag, template<class,class> class Property>

View File

@ -345,14 +345,24 @@ struct GetTypeTagInheritance<std::tuple<FirstTypeTag, OtherTypeTags...>>
typedef typename RevertedTupleOuter<sizeof...(Args)>::template RevertedTupleInner<Args...>::type type;
};
#define SET_SPLICES(TypeTagName, ...) \
template<class TypeTag> \
struct Splices<TypeTag, TTAG(TypeTagName)> \
{ \
typedef RevertedTuple<__VA_ARGS__>::type tuple; \
}; \
#define SET_SPLICE(TypeTagName, SpliceName) \
template<class TypeTag> \
struct Splices<TypeTag, TTag::TypeTagName> \
{ \
using type = std::tuple<GetSplicePropType<TypeTag, TTag::TypeTagName, Properties::SpliceName>>; \
}; \
extern int semicolonHack_
#define SET_SPLICES(TypeTagName, SpliceName1, SpliceName2) \
template<class TypeTag> \
struct Splices<TypeTag, TTag::TypeTagName> \
{ \
using type = std::tuple<GetSplicePropType<TypeTag, TTag::TypeTagName, Properties::SpliceName1>, \
GetSplicePropType<TypeTag, TTag::TypeTagName, Properties::SpliceName2>>; \
}; \
extern int semicolonHack_
#define SET_PROP_(EffTypeTagName, PropKind, PropTagName, ...) \
template <class TypeTag> \
struct PropTagName<TypeTag, TTAG(EffTypeTagName)>