1#ifndef __DUNE_ACFEM_FUNCTIONS_PLACEHOLDERS_LOCALFUNCTIONHESSIANPLACEHOLDER_HH__
2#define __DUNE_ACFEM_FUNCTIONS_PLACEHOLDERS_LOCALFUNCTIONHESSIANPLACEHOLDER_HH__
5#include "../localfunctiontraits.hh"
6#include "../../tensors/operations/indeterminate.hh"
7#include "../../tensors/operations/placeholder.hh"
8#include "../../tensors/bindings/dune/fieldtensor.hh"
14 namespace GridFunction {
16 using namespace Literals;
17 using Tensor::PlaceholderTensor;
18 using Tensor::FieldVectorTensor;
19 using Tensor::ScalarDecayFieldTensor;
25 template<
class LocalFunction, std::
size_t IndeterminateId = Policy::indeterminateId()>
26 class LocalFunctionHessianPlaceholder
27 :
public PlaceholderTensor<ScalarDecayFieldTensor<typename std::decay_t<LocalFunction>::HessianRangeType>, LocalFunctionHessianPlaceholder<LocalFunction, IndeterminateId> >
29 using ThisType = LocalFunctionHessianPlaceholder;
30 using BaseType = PlaceholderTensor<ScalarDecayFieldTensor<typename std::decay_t<LocalFunction>::HessianRangeType>, ThisType>;
32 using LocalFunctionType = std::decay_t<LocalFunction>;
33 using DomainType =
typename LocalFunctionType::DomainType;
34 using HessianRangeType =
typename LocalFunctionType::HessianRangeType;
35 using TensorType = ScalarDecayFieldTensor<HessianRangeType>;
36 using GridPartType =
typename LocalFunctionType::GridPartType;
37 using EntityType =
typename LocalFunctionType::EntityType;
39 static constexpr std::size_t indeterminateId_ = IndeterminateId;
41 using BaseType::operand;
43 template<class Arg, std::enable_if_t<std::is_constructible<LocalFunction, Arg>::value,
int> = 0>
44 LocalFunctionHessianPlaceholder(Arg&& localFunction)
45 : BaseType(TensorType(), Expressions::Functor<BaseType>{})
46 , localFunction_(std::forward<Arg>(localFunction))
49 constexpr unsigned int order()
const
51 return localFunction_.gridFunction().order() - 2;
55 std::enable_if_t<(IsQuadraturePoint<Point>::value || IsFieldVector<Point>::value),
int> = 0>
56 void setValue(
const Point& point)
58 assert(localFunction_.entity() != EntityType());
59 if constexpr ((TensorTraits<HessianRangeType>::rank - TensorTraits<TensorType>::rank) == 1
60 && TensorTraits<HessianRangeType>::template dim<0>() == 1)
61 operand(0_c) = localFunction_.hessian(point)[0];
63 operand(0_c) = localFunction_.hessian(point);
66 void bind(
const EntityType& entity)
68 localFunction_.bind(entity);
73 localFunction_.unbind();
76 LocalFunction localFunction() &&
78 return localFunction_;
81 auto& localFunction() &
83 return localFunction_;
86 const auto& localFunction() const&
88 return localFunction_;
92 const auto& gridPart()
const
94 return localFunction_.gridFunction().gridPart();
97 static constexpr std::size_t indeterminateId()
99 return indeterminateId_;
102 std::string name()
const
105 return "D2"+localFunction_.gridFunction().name() +
"(X["+toString(indeterminateId_)+
"])";
109 LocalFunction localFunction_;
112 template<
class T,
class SFINAE =
void>
113 struct IsLocalFunctionHessianPlaceholder
118 struct IsLocalFunctionHessianPlaceholder<T, std::enable_if_t<!IsDecay<T>::value> >
119 : IsLocalFunctionHessianPlaceholder<std::decay_t<T> >
122 template<
class LocalFunction, std::
size_t IndeterminateId>
123 struct IsLocalFunctionHessianPlaceholder<LocalFunctionHessianPlaceholder<LocalFunction, IndeterminateId> >
128 std::size_t IndeterminateId = Policy::indeterminateId(),
129 class Closure = Expressions::Closure,
130 std::enable_if_t<IsConstLocalFunction<F>::value,
int> = 0>
131 auto localFunctionHessianPlaceholder(F&& f, IndexConstant<IndeterminateId>
id = IndexConstant<IndeterminateId>{}, Closure closure = Closure{})
133 return closure(LocalFunctionHessianPlaceholder<F, IndeterminateId>(std::forward<F>(f)));
137 std::size_t IndeterminateId = Policy::indeterminateId(),
138 class Closure = Expressions::Closure,
139 std::enable_if_t<IsWrappableByConstLocalFunction<F>::value,
int> = 0>
140 auto localFunctionHessianPlaceholder(F&& f, IndexConstant<IndeterminateId>
id = IndexConstant<IndeterminateId>{}, Closure = Closure{})
142 return localFunctionHessianPlaceholder(ensureConstLocalFunction(std::forward<F>(f)),
id, Closure{});
154 template<
class LocalFunction, std::
size_t IndeterminateId>
155 struct FieldTraits<ACFem::GridFunction::LocalFunctionHessianPlaceholder<LocalFunction, IndeterminateId> >
156 : FieldTraits<ACFem::GridFunction::PlaceholderTensor<ACFem::Tensor::FieldVectorTensor<typename std::decay_t<LocalFunction>::HessianRangeType>, ACFem::GridFunction::LocalFunctionHessianPlaceholder<LocalFunction, IndeterminateId> > >
BoolConstant< false > FalseType
Alias for std::false_type.
Definition: types.hh:110
BoolConstant< true > TrueType
Alias for std::true_type.
Definition: types.hh:107