DUNE PDELab (git)

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
4// SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file AUTHORS.md
5// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception OR LGPL-3.0-or-later
6
7#ifndef DUNE_FUNCTIONS_GRIDFUNCTIONS_GRID_FUNCTION_HH
8#define DUNE_FUNCTIONS_GRIDFUNCTIONS_GRID_FUNCTION_HH
9
10#include <type_traits>
11
13
14#include <dune/functions/common/typeerasure.hh>
15#include <dune/functions/common/defaultderivativetraits.hh>
16#include <dune/functions/common/differentiablefunction.hh>
17#include <dune/functions/common/localfunction.hh>
18#include <dune/functions/common/functionconcepts.hh>
19#include <dune/functions/gridfunctions/localderivativetraits.hh>
20#include <dune/functions/gridfunctions/gridfunction_imp.hh>
21
22
23
24namespace Dune {
25namespace Functions {
26
27
28
29/*
30 * Default implementation is empty
31 * The actual implementation is only given if Signature is an type
32 * describing a function signature as Range(Domain).
33 */
34template<class Signature, class EntitySet, template<class> class DerivativeTraits=DefaultDerivativeTraits, size_t bufferSize=56>
35class GridFunction
36{};
37
38
39
40namespace Imp
41{
42
44 template<class S, class ES, template<class> class DerivativeTraits, size_t bufferSize>
45 struct GridFunctionTraits :
46 DifferentiableFunctionTraits<S, DerivativeTraits, bufferSize>
47 {
48 protected:
49 using Base=DifferentiableFunctionTraits<S, DerivativeTraits, bufferSize>;
50
51 public:
53 using EntitySet = ES;
54
56 using Element = typename EntitySet::Element;
57
59 using DerivativeSignature = typename Base::DerivativeSignature;
60
62 using DerivativeInterface = GridFunction<DerivativeSignature, ES, DerivativeTraits, bufferSize>;
63
65 using LocalSignature = typename Base::Range(typename EntitySet::LocalCoordinate);
66
68 template<class R>
69 using LocalDerivativeTraits = typename Dune::Functions::LocalDerivativeTraits<EntitySet, DerivativeTraits>::template Traits<R>;
70
72 using LocalFunctionTraits = typename Dune::Functions::Imp::LocalFunctionTraits<LocalSignature, Element, LocalDerivativeTraits, bufferSize>;
73
75 using LocalFunctionInterface = LocalFunction<LocalSignature, Element, LocalDerivativeTraits, bufferSize>;
76
78 using Concept = GridFunctionWrapperInterface<S, DerivativeInterface, LocalFunctionInterface, ES>;
79
81 template<class B>
82 using Model = GridFunctionWrapperImplementation<S, DerivativeInterface, LocalFunctionInterface, ES, B>;
83 };
84}
85
86
87
99template<class Range, class Domain, class ES, template<class> class DerivativeTraits, size_t bufferSize>
100class GridFunction<Range(Domain), ES, DerivativeTraits, bufferSize> :
101 public TypeErasureBase<
102 typename Imp::GridFunctionTraits<Range(Domain), ES, DerivativeTraits, bufferSize>::Concept,
103 Imp::GridFunctionTraits<Range(Domain), ES, DerivativeTraits, bufferSize>::template Model>
104{
105 using Traits = Imp::GridFunctionTraits<Range(Domain), ES, DerivativeTraits, bufferSize>;
106
108
109 using DerivativeInterface = typename Traits::DerivativeInterface;
110
111 using LocalFunctionInterface = typename Traits::LocalFunctionInterface;
112
113 using EntitySet = typename Traits::EntitySet;
114
115public:
116
128 template<class F, disableCopyMove<GridFunction, F> = 0 >
130 Base(std::forward<F>(f))
131 {
132 static_assert(Dune::Functions::Concept::isGridFunction<F, Range(Domain), EntitySet>(), "Trying to construct a GridFunction from type that does not model the GridFunction concept");
133 }
134
135 GridFunction() = default;
136
142 Range operator() (const Domain& x) const
143 {
144 return this->asInterface().operator()(x);
145 }
146
155 friend DerivativeInterface derivative(const GridFunction& t)
156 {
157 return t.asInterface().derivative();
158 }
159
169 friend LocalFunctionInterface localFunction(const GridFunction& t)
170 {
171 return t.asInterface().wrappedLocalFunction();
172 }
173
180 const EntitySet& entitySet() const
181 {
182 return this->asInterface().wrappedEntitySet();
183 }
184};
185
186
187
188}} // namespace Dune::Functions
189
190
191
192#endif // DUNE_FUNCTIONS_GRIDFUNCTIONS_GRID_FUNCTION_HH
friend DerivativeInterface derivative(const GridFunction &t)
Get derivative of wrapped function.
Definition: gridfunction.hh:155
const EntitySet & entitySet() const
Get associated EntitySet.
Definition: gridfunction.hh:180
GridFunction(F &&f)
Construct from function.
Definition: gridfunction.hh:129
friend LocalFunctionInterface localFunction(const GridFunction &t)
Get local function of wrapped function.
Definition: gridfunction.hh:169
Base class for type-erased interface wrapper.
Definition: typeerasure.hh:169
Dune namespace.
Definition: alignedallocator.hh:13
STL namespace.
Derivative traits for local functions.
Definition: localderivativetraits.hh:32
Utilities for type computations, constraining overloads, ...
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 24, 23:30, 2024)