dune-functions 2.9.0
gridfunction.hh
Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3#ifndef DUNE_FUNCTIONS_GRIDFUNCTIONS_GRID_FUNCTION_HH
4#define DUNE_FUNCTIONS_GRIDFUNCTIONS_GRID_FUNCTION_HH
5
6#include <type_traits>
7
8#include <dune/common/typeutilities.hh>
9
17
18
19
20namespace Dune {
21namespace Functions {
22
23
24
25/*
26 * Default implementation is empty
27 * The actual implementation is only given if Signature is an type
28 * describing a function signature as Range(Domain).
29 */
30template<class Signature, class EntitySet, template<class> class DerivativeTraits=DefaultDerivativeTraits, size_t bufferSize=56>
32{};
33
34
35
36namespace Imp
37{
38
40 template<class S, class ES, template<class> class DerivativeTraits, size_t bufferSize>
41 struct GridFunctionTraits :
42 DifferentiableFunctionTraits<S, DerivativeTraits, bufferSize>
43 {
44 protected:
45 using Base=DifferentiableFunctionTraits<S, DerivativeTraits, bufferSize>;
46
47 public:
49 using EntitySet = ES;
50
52 using Element = typename EntitySet::Element;
53
55 using DerivativeSignature = typename Base::DerivativeSignature;
56
59
61 using LocalSignature = typename Base::Range(typename EntitySet::LocalCoordinate);
62
64 template<class R>
66
68 using LocalFunctionTraits = typename Dune::Functions::Imp::LocalFunctionTraits<LocalSignature, Element, LocalDerivativeTraits, bufferSize>;
69
72
74 using Concept = GridFunctionWrapperInterface<S, DerivativeInterface, LocalFunctionInterface, ES>;
75
77 template<class B>
78 using Model = GridFunctionWrapperImplementation<S, DerivativeInterface, LocalFunctionInterface, ES, B>;
79 };
80}
81
82
83
95template<class Range, class Domain, class ES, template<class> class DerivativeTraits, size_t bufferSize>
96class GridFunction<Range(Domain), ES, DerivativeTraits, bufferSize> :
97 public TypeErasureBase<
98 typename Imp::GridFunctionTraits<Range(Domain), ES, DerivativeTraits, bufferSize>::Concept,
99 Imp::GridFunctionTraits<Range(Domain), ES, DerivativeTraits, bufferSize>::template Model>
100{
101 using Traits = Imp::GridFunctionTraits<Range(Domain), ES, DerivativeTraits, bufferSize>;
102
104
105 using DerivativeInterface = typename Traits::DerivativeInterface;
106
107 using LocalFunctionInterface = typename Traits::LocalFunctionInterface;
108
109 using EntitySet = typename Traits::EntitySet;
110
111public:
112
124 template<class F, disableCopyMove<GridFunction, F> = 0 >
126 Base(std::forward<F>(f))
127 {
128 static_assert(Dune::Functions::Concept::isGridFunction<F, Range(Domain), EntitySet>(), "Trying to construct a GridFunction from type that does not model the GridFunction concept");
129 }
130
131 GridFunction() = default;
132
138 Range operator() (const Domain& x) const
139 {
140 return this->asInterface().operator()(x);
141 }
142
151 friend DerivativeInterface derivative(const GridFunction& t)
152 {
153 return t.asInterface().derivative();
154 }
155
165 friend LocalFunctionInterface localFunction(const GridFunction& t)
166 {
167 return t.asInterface().wrappedLocalFunction();
168 }
169
176 const EntitySet& entitySet() const
177 {
178 return this->asInterface().wrappedEntitySet();
179 }
180};
181
182
183
184}} // namespace Dune::Functions
185
186
187
188#endif // DUNE_FUNCTIONS_GRIDFUNCTIONS_GRID_FUNCTION_HH
Definition: polynomial.hh:10
Definition: localfunction.hh:30
Base class for type-erased interface wrapper.
Definition: typeerasure.hh:165
Definition: gridfunction.hh:32
friend DerivativeInterface derivative(const GridFunction &t)
Get derivative of wrapped function.
Definition: gridfunction.hh:151
const EntitySet & entitySet() const
Get associated EntitySet.
Definition: gridfunction.hh:176
GridFunction(F &&f)
Construct from function.
Definition: gridfunction.hh:125
friend LocalFunctionInterface localFunction(const GridFunction &t)
Get local function of wrapped function.
Definition: gridfunction.hh:165
Derivative traits for local functions.
Definition: localderivativetraits.hh:28