6#include <dune/common/exceptions.hh>
7#include <dune/functions/gridfunctions/gridviewentityset.hh>
9#include <amdis/ElementVector.hpp>
10#include <amdis/common/DerivativeTraits.hpp>
11#include <amdis/common/TypeTraits.hpp>
12#include <amdis/gridfunctions/ConstantGridFunction.hpp>
13#include <amdis/gridfunctions/GridFunction.hpp>
18 template <
class Signature,
class IndexSet,
class Container>
23 template <
class R,
class D,
class IndexSet,
class Container>
34 enum { hasDerivative =
true };
37 using Element =
typename IndexSet::template Codim<0>::Entity;
42 : indexSet_(&indexSet)
43 , container_(&container)
56 element_.emplace(element);
57 value_ = (*container_)[indexSet_->index(element)];
79 using RawSignature =
typename Dune::Functions::SignatureTraits<R(D)>::RawSignature;
81 DerivativeRange diff(0);
95 IndexSet
const* indexSet_;
96 Container
const* container_;
97 std::optional<Element> element_;
110 template <
class Gr
idView,
class Container>
114 using EntitySet = Dune::Functions::GridViewEntitySet<GridView, 0>;
115 using Domain =
typename EntitySet::GlobalCoordinate;
116 using Range =
typename Container::value_type;
118 enum { hasDerivative =
false };
121 using LocalDomain =
typename EntitySet::LocalCoordinate;
127 : entitySet_(gridView)
128 , container_(&container)
131 template <
class G,
class T,
132 std::enable_if_t<std::is_same_v<typename G::LeafGridView,GridView>,
int> = 0,
133 std::enable_if_t<std::is_same_v<typename ElementVector<G,T>::Data, Container>,
int> = 0>
135 : entitySet_(elementVector.gridView())
136 , container_(&elementVector.data())
142 DUNE_THROW(Dune::NotImplemented,
"Global evaluation not yet implemented");
146 EntitySet
const& entitySet()
const
154 return {entitySet_.gridView().indexSet(), *container_};
158 EntitySet entitySet_;
159 Container
const* container_;
163 template <
class G,
class T>
164 ElementGridFunction(ElementVector<G,T>
const&)
165 -> ElementGridFunction<typename G::LeafGridView, typename ElementVector<G,T>::Data>;
168 template <
class G,
class T>
169 auto valueOf(ElementVector<G,T>
const& ev)
171 return ElementGridFunction{ev.gridView(), ev.data()};
Definition: ConstantGridFunction.hpp:19
Gridfunction returning a constant value per element.
Definition: ElementGridFunction.hpp:112
LocalFunction makeLocalFunction() const
Create an ElementLocalFunction.
Definition: ElementGridFunction.hpp:152
ElementGridFunction(GridView const &gridView, Container const &container)
Constructor. Stores the function fct and creates an EntitySet.
Definition: ElementGridFunction.hpp:126
Range operator()(Domain const &) const
Return the constant value_
Definition: ElementGridFunction.hpp:140
D Domain
The LocalDomain this LocalFunction can be evaluated in.
Definition: ElementGridFunction.hpp:28
bool bound() const
Check whether this localfunction is bound to an element.
Definition: ElementGridFunction.hpp:63
typename IndexSet::template Codim< 0 >::Entity Element
Type of the entity to bind.
Definition: ElementGridFunction.hpp:37
Range const & operator()(Domain const &) const
Return the constant value_.
Definition: ElementGridFunction.hpp:69
ElementLocalFunction(IndexSet const &indexSet, Container const &container)
Constructor. Stores the constant value.
Definition: ElementGridFunction.hpp:41
R Range
The range type of the LocalFunction.
Definition: ElementGridFunction.hpp:31
void bind(Element const &element)
Extract the constant data associated to the element.
Definition: ElementGridFunction.hpp:54
int order() const
Return the constant polynomial order 0.
Definition: ElementGridFunction.hpp:89
auto makeDerivative(Type const &) const
Create a ConstantLocalFunction representing the derivative of a constant function,...
Definition: ElementGridFunction.hpp:77
Element const & localContext() const
Return the bound element.
Definition: ElementGridFunction.hpp:47
Definition: ElementGridFunction.hpp:19
An adaptive container that stores a value per grid element.
Definition: ElementVector.hpp:25
Definition: DerivativeTraits.hpp:29