3#ifndef DUNE_FUNCTIONS_GRIDFUNCTIONS_COMPOSEDGRIDFUNCTION_HH
4#define DUNE_FUNCTIONS_GRIDFUNCTIONS_COMPOSEDGRIDFUNCTION_HH
9#include <dune/common/referencehelper.hh>
10#include <dune/common/typeutilities.hh>
40template<
class OF,
class... IF>
43 using InnerFunctions = std::tuple<IF...>;
44 using InnerLocalFunctions = std::tuple<decltype(localFunction(resolveRef(std::declval<const IF&>())))...>;
46 template<std::
size_t i>
47 using InnerFunction = std::decay_t<ResolveRef_t<std::tuple_element_t<i, InnerFunctions>>>;
49 using OuterFunction = OF;
53 using EntitySet =
typename InnerFunction<0>::EntitySet;
54 using Element =
typename EntitySet::Element;
56 using Domain =
typename EntitySet::GlobalCoordinate;
59 using Range =
decltype(std::declval<OF>()(std::declval<IF>()(std::declval<Domain>())...));
75 globalFunction_(globalFunction),
88 void bind(
const Element& element)
90 std::apply([&](
auto&... innerFunction) {
91 (innerFunction.bind(element),...);
92 }, innerLocalFunctions_);
98 std::apply([&](
auto&... innerFunction) {
99 (innerFunction.unbind(),...);
100 }, innerLocalFunctions_);
107 return std::apply([](
const auto&... innerFunction) {
108 return (innerFunction.bound() && ...);
109 }, innerLocalFunctions_);
123 return std::apply([&](
const auto&... innerFunction) {
124 return globalFunction_.outerFunction_(innerFunction(x)...);
125 }, innerLocalFunctions_);
137 const Element& localContext()
const
139 return std::get<0>(innerLocalFunctions_).localContext();
145 DUNE_THROW(NotImplemented,
"not implemented");
150 InnerLocalFunctions innerLocalFunctions_;
164 template<
class OFT,
class... IFT,
165 disableCopyMove<ComposedGridFunction, OFT> = 0,
166 std::enable_if_t<(
sizeof...(IFT) > 0),
int> = 0>
175 DUNE_THROW(NotImplemented,
"not implemented");
181 DUNE_THROW(NotImplemented,
"not implemented");
192 return LocalFunction(cgf);
214 return std::apply([&](
const auto&... innerFunction) {
247template<
class OF,
class... IF>
251 return ComposedGridFunctionType(std::forward<OF>(outerFunction), std::forward<IF>(innerFunction)...);
auto makeComposedGridFunction(OF &&outerFunction, IF &&... innerFunction)
Create a ComposedGridFunction that composes grid-functions with another function.
Definition: composedgridfunction.hh:248
Definition: polynomial.hh:10
decltype(auto) resolveRef(T &&t)
This is an alias for Dune::resolveRef.
Definition: referencehelper.hh:37
Default implementation for derivative traits.
Definition: defaultderivativetraits.hh:37
Composition of grid functions with another function.
Definition: composedgridfunction.hh:42
OuterFunction outerFunction_
Definition: composedgridfunction.hh:219
InnerFunctions innerFunctions_
Definition: composedgridfunction.hh:220
ComposedGridFunction(OFT &&outerFunction, IFT &&... innerFunctions)
Create ComposedGridFunction.
Definition: composedgridfunction.hh:167
const EntitySet & entitySet() const
Return the EntitySet associated to this composed grid-function.
Definition: composedgridfunction.hh:205
typename InnerFunction< 0 >::EntitySet EntitySet
Definition: composedgridfunction.hh:53
typename EntitySet::LocalCoordinate LocalDomain
Definition: composedgridfunction.hh:57
typename EntitySet::Element Element
Definition: composedgridfunction.hh:54
InnerLocalFunctions innerLocalFunctions() const
Definition: composedgridfunction.hh:212
friend LocalFunction localFunction(const ComposedGridFunction &cgf)
Create a local-function of this composed grid-function.
Definition: composedgridfunction.hh:190
decltype(std::declval< OF >()(std::declval< IF >()(std::declval< Domain >())...)) Range
Definition: composedgridfunction.hh:59
typename EntitySet::GlobalCoordinate Domain
Definition: composedgridfunction.hh:56
Range operator()(const Domain &x) const
Evaluation of the composed grid function in coordinates x
Definition: composedgridfunction.hh:173
friend Traits::DerivativeInterface derivative(const ComposedGridFunction &t)
Not implemented.
Definition: composedgridfunction.hh:179
Definition: gridfunction.hh:32