3#ifndef DUNE_FUNCTIONS_GRIDFUNCTIONS_ANALYTICGRIDVIEWFUNCTION_HH
4#define DUNE_FUNCTIONS_GRIDFUNCTIONS_ANALYTICGRIDVIEWFUNCTION_HH
9#include <dune/common/typeutilities.hh>
24template<
class Signature,
class GV,
class FLocal,
template<
class>
class DerivativeTraits=DefaultDerivativeTraits>
25class LocalAnalyticGridViewFunction;
27template<
class Range,
class LocalDomain,
class GV,
class F,
template<
class>
class DerivativeTraits>
28class LocalAnalyticGridViewFunction<Range(LocalDomain), GV, F, DerivativeTraits>
31 using Signature = Range(LocalDomain);
32 using RawSignature =
typename SignatureTraits<Signature>::RawSignature;
33 using DerivativeSignature =
typename DerivativeTraits<RawSignature>::Range(LocalDomain);
36 using EntitySet = GridViewEntitySet<GridView, 0>;
37 using Element =
typename EntitySet::Element;
39 using Geometry =
typename std::decay<typename Element::Geometry>::type;
45 using DerivativeDummy = DifferentiableFunction<DerivativeSignature>;
46 using GlobalRawDerivative =
decltype(Imp::derivativeIfImplemented<DerivativeDummy, F>(std::declval<F>()));
47 using LocalDerivative = LocalAnalyticGridViewFunction<DerivativeSignature, GridView, GlobalRawDerivative, DerivativeTraits>;
50 template<
class FT, disableCopyMove<LocalAnalyticGr
idViewFunction, FT> = 0>
51 LocalAnalyticGridViewFunction(FT&& f) :
52 f_(std::forward<FT>(f))
57 LocalAnalyticGridViewFunction(FT&& f,
const Element& element,
const std::optional<Geometry>& geometry) :
58 f_(std::forward<FT>(f)),
72 void bind(
const Element& element)
75 geometry_.emplace(element_.geometry());
88 return static_cast<bool>(geometry_);
100 Range operator()(
const LocalDomain& x)
const
103 return f_(geometry_->global(x));
107 const Element& localContext()
const
121 friend LocalDerivative
derivative(
const LocalAnalyticGridViewFunction& t)
123 return LocalDerivative(Imp::derivativeIfImplemented<DerivativeDummy, F>(t.f_), t.element_, t.geometry_);
129 std::optional<Geometry> geometry_ = std::nullopt;
137template<
class Signature,
class GV,
class F,
template<
class>
class DerivativeTraits=DefaultDerivativeTraits>
146template<
class Range,
class Domain,
class GV,
class F,
template<
class>
class DerivativeTraits>
164 using GlobalRawDerivative =
decltype(Imp::derivativeIfImplemented<DerivativeDummy, F>(std::declval<F>()));
173 f_(std::forward<FT>(f)),
186 return Derivative(Imp::derivativeIfImplemented<DerivativeDummy, F>(t.f_), t.entitySet_.gridView());
203 EntitySet entitySet_;
224template<
class F,
class Gr
idView>
225AnalyticGridViewFunction<
226 typename std::invoke_result<F, typename GridView::template Codim<0>::Geometry::GlobalCoordinate>::type
227 (
typename GridView::template Codim<0>::Geometry::GlobalCoordinate),
229 typename std::decay<F>::type >
232 using Domain =
typename GridView::template Codim<0>::Geometry::GlobalCoordinate;
233 using Range =
typename std::invoke_result<F, Domain>::type;
234 using FRaw =
typename std::decay<F>::type;
TrigonometricFunction< K, -cosFactor, sinFactor > derivative(const TrigonometricFunction< K, sinFactor, cosFactor > &f)
Obtain derivative of TrigonometricFunction function.
Definition: trigonometricfunction.hh:39
AnalyticGridViewFunction< typename std::invoke_result< F, typename GridView::template Codim< 0 >::Geometry::GlobalCoordinate >::type(typename GridView::template Codim< 0 >::Geometry::GlobalCoordinate), GridView, typename std::decay< F >::type > makeAnalyticGridViewFunction(F &&f, const GridView &gridView)
Create an AnalyticGridViewFunction from a function and a grid view.
Definition: analyticgridviewfunction.hh:230
Definition: polynomial.hh:10
Definition: differentiablefunction.hh:29
Helper class to deduce the signature of a callable.
Definition: signature.hh:56
Definition: analyticgridviewfunction.hh:138
Range operator()(const Domain &x) const
Evaluate the wrapped function f directly in global coordinates x.
Definition: analyticgridviewfunction.hh:178
typename EntitySet::LocalCoordinate LocalDomain
Definition: analyticgridviewfunction.hh:167
friend Derivative derivative(const AnalyticGridViewFunction &t)
Create a derivative grid-function by wrapping the derivative of f.
Definition: analyticgridviewfunction.hh:184
typename Element::Geometry Geometry
Definition: analyticgridviewfunction.hh:157
typename EntitySet::Element Element
Definition: analyticgridviewfunction.hh:156
GV GridView
Definition: analyticgridviewfunction.hh:154
decltype(Imp::derivativeIfImplemented< DerivativeDummy, F >(std::declval< F >())) GlobalRawDerivative
Definition: analyticgridviewfunction.hh:164
Range(Domain) Signature
Definition: analyticgridviewfunction.hh:150
AnalyticGridViewFunction(FT &&f, const GridView &gridView)
Create the grid-function by wrapping a function f and create a GridViewEntitySet.
Definition: analyticgridviewfunction.hh:172
friend LocalFunction localFunction(const AnalyticGridViewFunction &t)
Construct the associated local-function.
Definition: analyticgridviewfunction.hh:190
typename Imp::LocalAnalyticGridViewFunction< Range(LocalDomain), GridView, F, LocalDerivativeTraits< EntitySet, DerivativeTraits >::template Traits > LocalFunction
Definition: analyticgridviewfunction.hh:168
typename SignatureTraits< Signature >::RawSignature RawSignature
Definition: analyticgridviewfunction.hh:151
const EntitySet & entitySet() const
Return the set of entities this local-function can be bound to.
Definition: analyticgridviewfunction.hh:196
typename DerivativeTraits< RawSignature >::Range(Domain) DerivativeSignature
Definition: analyticgridviewfunction.hh:152
GridView::template Codim< codim >::Entity Element
Type of Elements contained in this EntitySet.
Definition: gridviewentityset.hh:32
Element::Geometry::LocalCoordinate LocalCoordinate
Type of local coordinates with respect to the Element.
Definition: gridviewentityset.hh:35
Derivative traits for local functions.
Definition: localderivativetraits.hh:28