DUNE-FUNCTIONS (2.8)

gridfunction.hh
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
10#include <dune/functions/common/typeerasure.hh>
11#include <dune/functions/common/defaultderivativetraits.hh>
12#include <dune/functions/common/differentiablefunction.hh>
13#include <dune/functions/common/localfunction.hh>
14#include <dune/functions/common/functionconcepts.hh>
15#include <dune/functions/gridfunctions/localderivativetraits.hh>
16#include <dune/functions/gridfunctions/gridfunction_imp.hh>
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>
31class GridFunction
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
58 using DerivativeInterface = GridFunction<DerivativeSignature, ES, DerivativeTraits, bufferSize>;
59
61 using LocalSignature = typename Base::Range(typename EntitySet::LocalCoordinate);
62
63 template<class R>
64 using LocalDerivativeTraits = typename Dune::Functions::LocalDerivativeTraits<EntitySet, DerivativeTraits>::template Traits<R>;
65
67 using LocalFunctionTraits = typename Dune::Functions::Imp::LocalFunctionTraits<LocalSignature, Element, LocalDerivativeTraits, bufferSize>;
68
70 using LocalFunctionInterface = LocalFunction<LocalSignature, Element, LocalDerivativeTraits, bufferSize>;
71
73 using Concept = GridFunctionWrapperInterface<S, DerivativeInterface, LocalFunctionInterface, ES>;
74
76 template<class B>
77 using Model = GridFunctionWrapperImplementation<S, DerivativeInterface, LocalFunctionInterface, ES, B>;
78 };
79}
80
81
82
94template<class Range, class Domain, class ES, template<class> class DerivativeTraits, size_t bufferSize>
95class GridFunction<Range(Domain), ES, DerivativeTraits, bufferSize> :
96 public TypeErasureBase<
97 typename Imp::GridFunctionTraits<Range(Domain), ES, DerivativeTraits, bufferSize>::Concept,
98 Imp::GridFunctionTraits<Range(Domain), ES, DerivativeTraits, bufferSize>::template Model>
99{
100 using Traits = Imp::GridFunctionTraits<Range(Domain), ES, DerivativeTraits, bufferSize>;
101
103
104 using DerivativeInterface = typename Traits::DerivativeInterface;
105
106 using LocalFunctionInterface = typename Traits::LocalFunctionInterface;
107
108 using EntitySet = typename Traits::EntitySet;
109
110public:
111
123 template<class F, disableCopyMove<GridFunction, F> = 0 >
125 Base(std::forward<F>(f))
126 {
127 static_assert(Dune::Functions::Concept::isGridFunction<F, Range(Domain), EntitySet>(), "Trying to construct a GridFunction from type that does not model the GridFunction concept");
128 }
129
130 GridFunction() = default;
131
135 Range operator() (const Domain& x) const
136 {
137 return this->asInterface().operator()(x);
138 }
139
143 friend DerivativeInterface derivative(const GridFunction& t)
144 {
145 return t.asInterface().derivative();
146 }
147
157 friend LocalFunctionInterface localFunction(const GridFunction& t)
158 {
159 return t.asInterface().wrappedLocalFunction();
160 }
161
167 const EntitySet& entitySet() const
168 {
169 return this->asInterface().wrappedEntitySet();
170 }
171};
172
173
174
175}} // namespace Dune::Functions
176
177
178
179#endif // DUNE_FUNCTIONS_GRIDFUNCTIONS_GRID_FUNCTION_HH
friend DerivativeInterface derivative(const GridFunction &t)
Definition: gridfunction.hh:143
const EntitySet & entitySet() const
Get associated EntitySet.
Definition: gridfunction.hh:167
GridFunction(F &&f)
Construct from function.
Definition: gridfunction.hh:124
friend LocalFunctionInterface localFunction(const GridFunction &t)
Get local function of wrapped function.
Definition: gridfunction.hh:157
Base class for type-erased interface wrapper.
Definition: typeerasure.hh:165
Definition: polynomial.hh:10
Derivative traits for local functions.
Definition: localderivativetraits.hh:28
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 15, 22:36, 2024)