1#ifndef __DUNE_ACFEM_FUNCTIONS_OPERANDPROMOTION_HH__
2#define __DUNE_ACFEM_FUNCTIONS_OPERANDPROMOTION_HH__
4#include "../common/literals.hh"
5#include "../mpl/compare.hh"
6#include "../expressions/interface.hh"
7#include "../tensors/tensorbase.hh"
10#include "localfunctiontraits.hh"
11#include "functiontraits.hh"
12#include "placeholders/localfunctionplaceholder.hh"
18 namespace GridFunction
20 using namespace Literals;
21 using Expressions::IsClosure;
22 using Expressions::IsPromotedTopLevel;
30 !AnyIs<IsPromotedTopLevel, T...>::value
32 && !AllAre<IsTensorFunction, T...>::value
34 && AnyIs<IsTensorFunction, T...>::value
36 && AllAre<OrPredicate<
37 IsTensorOperand, IsTensorFunction>::template Predicate, T...>::value
45 template<std::size_t N,
class... T,
51 return std::forward<TypePackElement<N, T...> >(
52 get<N>(std::forward_as_tuple(std::forward<T>(t)...))
61 template<std::size_t N,
class... T,
62 std::enable_if_t<(PromoteTensorOperands<T...>::value
71 tensor(std::forward<TypePackElement<N, T...> >(
72 get<N>(std::forward_as_tuple(std::forward<T>(t)...))
88 !AllAre<IsTensorFunction, T...>::value
90 && AnyIs<IsTensorFunction, T...>::value
92 && AllAre<OrPredicate<
93 IsConstLocalFunctionOperand, IsTensorFunction>::template Predicate, T...>::value
101 template<std::size_t N,
class... T,
107 return std::forward<
TupleElement<N, std::tuple<T...> > >(
108 get<N>(std::forward_as_tuple(std::forward<T>(t)...))
117 template<std::size_t N,
class... T,
118 std::enable_if_t<(PromoteFunctionOperands<T...>::value
129 get<N>(std::forward_as_tuple(std::forward<T>(t)...))
132 fct.indeterminateId()
143 template<std::size_t N,
class... T>
146 !AnyIs<IsClosure, T...>::value
148 && !AnyIs<IsTensorFunction, T...>::value
150 && AnyIs<IsConstLocalFunctionOperand, T...>::value
152 && AllAre<OrPredicate<
153 IsTensorOperand, IsConstLocalFunctionOperand>::template Predicate, T...>::value
160 template<std::size_t N,
class... T,
169 get<N>(std::forward_as_tuple(std::forward<T>(t)...))
171 Policy::IndeterminateId{}
180 template<std::size_t N,
class... T,
181 std::enable_if_t<(PromoteAllFunctionOperands<N, T...>::value
182 && !
NthIs<N, IsConstLocalFunctionOperand, T...>::value
186 const auto& fct =
get<
IndexOfMatching<IsConstLocalFunctionOperand, T...>::value>(std::forward_as_tuple(std::forward<T>(t)...));
190 tensor(std::forward<
TupleElement<N, std::tuple<T...> > >(
191 get<N>(std::forward_as_tuple(std::forward<T>(t)...))
193 Policy::IndeterminateId{}
199 std::enable_if_t<(sizeof(derivative(operandPromotion<0>(std::declval<T>()))) >= 0),
int> = 0>
200 constexpr decltype(
auto) derivative(T&& t)
202 return derivative(operandPromotion<0>(std::forward<T>(t)));
206 std::size_t N,
class T,
207 std::enable_if_t<(sizeof(derivative<N>(operandPromotion<0>(std::declval<T>()))) >= 0),
int> = 0>
208 constexpr decltype(
auto) derivative(T&& t)
210 return derivative<N>(operandPromotion<0>(std::forward<T>(t)));
215 std::enable_if_t<(sizeof(ternary(operandPromotion<0>(std::declval<T>()))) >= 0),
int> = 0>
216 constexpr decltype(
auto) ternary(T&& t)
218 return ternary(operandPromotion<0>(std::forward<T>(t)));
223 using GridFunction::derivative;
constexpr decltype(auto) operandPromotion(T &&... t)
The purpose of this function is to promote operands to other types, e.g.
Definition: interface.hh:154
auto gridFunction(const GridPart &gridPart, T &&t, IndexConstant< MaxOrder > maxOrder=IndexConstant< MaxOrder >{}, IndexConstant< IndeterminateId > id=IndexConstant< IndeterminateId >{})
Generate a BindableGridFunction which wraps a copy of T.
Definition: gridfunction.hh:23
auto localFunctionPlaceholder(F &&f, IndexConstant< IndeterminateId > id=IndexConstant< IndeterminateId >{}, Closure closure=Closure{})
Generate a LocalFunctionPlaceholder for a Fem::ConstLocalFunction.
Definition: localfunctionplaceholder.hh:192
constexpr decltype(auto) get(T &&t, IndexConstant< I >=IndexConstant< I >{})
Access to the i-the element.
Definition: access.hh:129
std::tuple_element_t< N, std::decay_t< TupleLike > > TupleElement
Forward to std::tuple_element<N, std::decay_t<T> >
Definition: access.hh:125
Predicate< TypePackElement< N, T... > > NthIs
Instantiates to Predicate applied to the N-th element of T...
Definition: compare.hh:470
IndexConstant< PredicateMatch< std::tuple< T... >, Predicate >::index_ > IndexOfMatching
Obtain the index of the first matching tuple type.
Definition: compare.hh:458
Constant< bool, V > BoolConstant
Short-cut for integral constant of type bool.
Definition: types.hh:48
TrueType if T can be passed through constLocalFunction().
Definition: localfunctiontraits.hh:112
Definition: functiontraits.hh:34