6#include <dune/functions/common/signature.hh>
7#include <dune/functions/gridfunctions/gridviewentityset.hh>
9#include <amdis/Operations.hpp>
10#include <amdis/common/DerivativeTraits.hpp>
11#include <amdis/common/Order.hpp>
12#include <amdis/gridfunctions/GridFunction.hpp>
17 template <
class Signature,
class LocalContext,
class Function>
21 template <
class R,
class D,
class LC,
class Function>
35 enum { hasDerivative =
true };
38 using Geometry =
typename LC::Geometry;
49 localContext_.emplace(element);
50 geometry_.emplace(element.geometry());
57 localContext_.reset();
62 return !!localContext_;
68 assert( !!localContext_ );
69 return *localContext_;
76 assert( !!geometry_ );
77 return fct_(geometry_.value().global(local));
80 Function
const& fct()
const
87 std::optional<LocalContext> localContext_;
88 std::optional<Geometry> geometry_;
102 template <
class Sig,
class LC,
class F,
103 REQUIRES(Concepts::HasFunctorOrder<F,1>)>
106 return order(lf.fct(),1);
120 template <
class R,
class D,
class LC,
class F,
class Type>
123 static_assert(Concepts::HasDerivative<F,Type>,
124 "No derivative(F,DerivativeType) defined for Functor F of AnalyticLocalFunction.");
126 auto df = derivativeOf(lf.fct(), type);
128 using RawSignature =
typename Dune::Functions::SignatureTraits<R(D)>::RawSignature;
133 ldf.bind(lf.localContext());
149 template <
class Function,
class Gr
idView>
153 using EntitySet = Dune::Functions::GridViewEntitySet<GridView, 0>;
154 using Domain =
typename EntitySet::GlobalCoordinate;
155 using Range = remove_cvref_t<std::invoke_result_t<Function,Domain>>;
157 enum { hasDerivative =
true };
160 using Element =
typename EntitySet::Element;
161 using LocalDomain =
typename EntitySet::LocalCoordinate;
168 , entitySet_{gridView}
190 Function
const&
fct()
const {
return fct_; }
194 EntitySet entitySet_;
206 template <
class F,
class GV,
class Type>
207 auto derivativeOf(AnalyticGridFunction<F,GV>
const& gf, Type
const& type)
209 static_assert(Concepts::HasDerivative<F,Type>,
210 "No derivative(F,DerivativeType) defined for Functor of AnalyticLocalFunction.");
212 auto df = derivativeOf(gf.fct(), type);
213 return AnalyticGridFunction<
decltype(df), GV>{df, gf.entitySet().gridView()};
219 template <
class Function>
226 template <
class Gr
idView>
227 static auto create(
Self const& self, GridView
const& gridView)
229 using Coordinate =
typename GridView::template Codim<0>::Entity::Geometry::GlobalCoordinate;
230 static_assert(std::is_invocable_v<Function, Coordinate>);
241 template <
class Functor>
259 template <
class Function>
260 auto evalAtQP(Function
const& f)
A Gridfunction that evaluates a function with global coordinates.
Definition: AnalyticGridFunction.hpp:151
friend LocalFunction localFunction(AnalyticGridFunction const &gf)
Return the AnalyticLocalFunction of the AnalyticGridFunction.
Definition: AnalyticGridFunction.hpp:178
Range operator()(Domain const &x) const
Return the evaluated functor at global coordinates.
Definition: AnalyticGridFunction.hpp:172
EntitySet const & entitySet() const
Returns entitySet_.
Definition: AnalyticGridFunction.hpp:184
AnalyticGridFunction(Function const &fct, GridView const &gridView)
Constructor. Stores the function fct and creates an EntitySet.
Definition: AnalyticGridFunction.hpp:166
Function const & fct() const
Returns fct_.
Definition: AnalyticGridFunction.hpp:190
D Domain
The LocalDomain this LocalFunction can be evaluated in.
Definition: AnalyticGridFunction.hpp:26
bool bound() const
Check whether this localfunction is bound to an element.
Definition: AnalyticGridFunction.hpp:60
LocalContext const & localContext() const
Return the context this localfunction is bound to.
Definition: AnalyticGridFunction.hpp:66
LC LocalContext
The context this localfunction can be bound to.
Definition: AnalyticGridFunction.hpp:32
Range operator()(Domain const &local) const
Evaluate the function in global coordinate by a local-to-global mapping of the local coordinates usin...
Definition: AnalyticGridFunction.hpp:74
AnalyticLocalFunction(Function const &fct)
Constructor. stores the function fct.
Definition: AnalyticGridFunction.hpp:42
R Range
The range type of the LocalFunction.
Definition: AnalyticGridFunction.hpp:29
void bind(LocalContext const &element)
Create a geometry object from the element.
Definition: AnalyticGridFunction.hpp:47
void unbind()
Releases the geometry object.
Definition: AnalyticGridFunction.hpp:54
Definition: AnalyticGridFunction.hpp:18
int order(AnalyticLocalFunction< Sig, LC, F > const &lf)
Definition: AnalyticGridFunction.hpp:104
constexpr bool Functor
A Functor is a function F with signature Signature.
Definition: Concepts.hpp:133
Definition: AnalyticGridFunction.hpp:225
Definition: AnalyticGridFunction.hpp:221
Definition: DerivativeTraits.hpp:29
Definition: GridFunction.hpp:27