6 #include <dune/common/std/apply.hh> 8 #include <amdis/Operations.hpp> 9 #include <amdis/common/ForEach.hpp> 10 #include <amdis/common/Logical.hpp> 11 #include <amdis/common/Order.hpp> 12 #include <amdis/gridfunctions/Derivative.hpp> 13 #include <amdis/gridfunctions/GridFunction.hpp> 19 template <
class T0,
class... Ts>
22 using type =
typename T0::Domain;
25 template <
class T0,
class... Ts>
28 using type =
typename T0::EntitySet;
35 template <
class Signatur,
class Functor,
class... LocalFunctions>
40 template <
class R,
class D,
class Functor,
class... LocalFunctions>
47 enum { hasDerivative =
true };
49 template <
class LocalFct>
50 struct LocalFunctionWrapper
52 template <
class Gr
idFct>
53 LocalFunctionWrapper(
GridFct const& gridFct)
54 : localFct_{localFunction(gridFct)}
57 LocalFct
const& operator*()
const {
return localFct_; }
58 LocalFct & operator*() {
return localFct_; }
65 template <
class... GridFcts>
68 , localFcts_{FWD(gridFcts)...}
72 template <
class Element>
73 void bind(Element
const& element)
75 Tools::for_each(localFcts_, [&](
auto& localFct) {
76 (*localFct).bind(element);
83 Tools::for_each(localFcts_, [&](
auto& localFct) {
91 return Tools::apply([&](
auto&&... localFct) {
return fct_((*localFct)(x)...); }, localFcts_);
96 Functor
const&
fct()
const 101 auto const& localFcts()
const 108 std::tuple<LocalFunctionWrapper<LocalFunctions>...> localFcts_;
121 template <
class Sig,
class F,
class... LFs,
class Type,
122 REQUIRES(Concepts::HasPartial<F>)>
125 auto index_seq = std::index_sequence_for<LFs...>{};
128 auto term_i = [&](
auto const _i)
130 auto di_f = Tools::apply([&](
auto const&... lgfs) {
131 return makeFunctorGridFunction(partial(lf.fct(), _i), (*lgfs)...);
135 auto const& lgfs_i = *get<VALUE(_i)>(lf.localFcts());
140 auto gridFct = Tools::apply([&](
auto const... _i)
145 return localFunction(gridFct);
157 template <
class Sig,
class F,
class... LFs,
158 REQUIRES(Concepts::HasFunctorOrder<F,
sizeof...(LFs)>
159 && (Concepts::Polynomial<LFs> &&...))>
162 return Tools::apply([&lf](
auto const&... lgfs) {
184 template <
class Functor,
class... GridFunctions>
189 using Range = decltype(std::declval<Functor>()(std::declval<typename GridFunctions::Range>()...));
192 using Domain =
typename Impl::DomainType<GridFunctions...>::type;
195 using EntitySet =
typename Impl::EntitySetType<GridFunctions...>::type;
197 enum { hasDerivative =
false };
200 template <
class Gr
idFct>
201 using LocalFct = TYPEOF( localFunction(std::declval<GridFct>()) );
204 using LocalDomain =
typename EntitySet::LocalCoordinate;
210 template <
class... GridFcts>
213 , gridFcts_{FWD(gridFcts)...}
219 return Tools::apply([&](
auto&&... gridFct) {
return fct_(gridFct(x)...); }, gridFcts_);
225 return std::get<0>(gridFcts_).entitySet();
230 return Tools::apply([&](
auto const&... gridFcts) {
return LocalFunction{fct_, gridFcts...}; }, gridFcts_);
235 std::tuple<GridFunctions...> gridFcts_;
240 template <
class Functor,
class... GridFcts>
241 auto makeFunctorGridFunction(Functor
const& f, GridFcts
const&... gridFcts)
243 static_assert((Concepts::GridFunction<GridFcts> &&...),
244 "All passed parameters must be GridFunctions.");
245 static_assert(Concepts::Callable<Functor, typename GridFcts::Range...>,
246 "Range types of grid functions are not compatible with the functor.");
253 template <
class Functor,
class... PreGridFunctions>
260 template <
class Gr
idView>
261 static auto create(
Self const&
self, GridView
const& gridView)
263 return Tools::apply([&](
auto const&... pgf) {
264 return makeFunctorGridFunction(
self.fct_,
266 },
self.preGridFcts_);
270 template <
class... PreGridFcts>
273 , preGridFcts_{FWD(pgfs)...}
278 std::tuple<PreGridFunctions...> preGridFcts_;
283 template <
class Functor,
class... PreGridFcts>
302 template <
class Functor,
class... PreGridFcts>
FunctorLocalFunction(Functor const &fct, GridFcts &&... gridFcts)
Constructor. Stores copies of the functor and localFunction(gridfunction)s.
Definition: FunctorGridFunction.hpp:66
Definition: GridFunction.hpp:26
constexpr bool Functor
A Functor is a function F with signature Signature.
Definition: Concepts.hpp:134
Definition: FunctorGridFunction.hpp:36
auto invokeAtQP(Functor const &f, PreGridFcts &&... gridFcts)
Generator function for FunctorGridFunction.
Definition: FunctorGridFunction.hpp:303
Definition: FunctorGridFunction.hpp:254
typename Impl::DomainType< GridFunctions... >::type Domain
The argument type that can be applied to the grid-functions.
Definition: FunctorGridFunction.hpp:192
typename remove_cvref< T >::type remove_cvref_t
Helper alias template for remove_cvref.
Definition: TypeTraits.hpp:24
decltype(auto) makeGridFunction(PreGridFct const &preGridFct, GridView const &gridView)
Generator for Gridfunctions from Expressions (PreGridfunctions)
Definition: GridFunction.hpp:154
Contains all classes needed for solving linear and non linear equation systems.
Definition: AdaptBase.hpp:6
Functor const & fct() const
Return the stored functor.
Definition: FunctorGridFunction.hpp:96
Functor that represents A*B.
Definition: Arithmetic.hpp:100
Functor that represents A+B.
Definition: Arithmetic.hpp:19
auto order(F const &f) -> decltype(&F::operator(), f.order())
polynomial order of functions
Definition: Order.hpp:11
void unbind()
Calls unbind for all localFunctions.
Definition: FunctorGridFunction.hpp:81
A Gridfunction that applies a functor to the evaluated Gridfunctions.
Definition: FunctorGridFunction.hpp:185
auto derivativeOf(AnalyticLocalFunction< R(D), LC, F > const &lf, Type const &type)
Definition: AnalyticGridFunction.hpp:103
void bind(Element const &element)
Calls bind for all localFunctions.
Definition: FunctorGridFunction.hpp:73
FunctorGridFunction(Functor const &fct, GridFcts &&... gridFcts)
Constructor. Stores copies of the functor and gridfunctions.
Definition: FunctorGridFunction.hpp:211
Range operator()(Domain const &x) const
Applies the functor to the evaluated gridfunctions.
Definition: FunctorGridFunction.hpp:217
typename Impl::EntitySetType< GridFunctions... >::type EntitySet
The set of entities this grid-function binds to.
Definition: FunctorGridFunction.hpp:195
Range operator()(Domain const &x) const
Applies the functor fct_ to the evaluated localFunctions.
Definition: FunctorGridFunction.hpp:89
EntitySet const & entitySet() const
Return the stored EntitySet of the first GridFunction.
Definition: FunctorGridFunction.hpp:223
Definition: FunctorGridFunction.hpp:258
decltype(std::declval< Functor >()(std::declval< typename GridFunctions::Range >()...)) Range
The result type of the functor when applied to the grid-functions.
Definition: FunctorGridFunction.hpp:189