6#include <dune/common/typetraits.hh>
21 template <
class Gr
idView>
25 using Entity =
typename GridView::template Codim<0>::Entity;
26 using LocalCoordinate =
typename Entity::Geometry::LocalCoordinate;
28 template <
class LF,
class E>
29 using HasBind =
decltype((std::declval<LF>().bind(std::declval<E>()),
true));
34 using value_type = double;
35 using field_type = double;
38 std::vector<int>
const& components,
39 LocalCoordinate
const& local)
41 , components_(components)
45 std::size_t size ()
const
47 return components_.size();
50 double operator[] (std::size_t i)
const
52 return i < size() ? localFct_.evaluate(components_[i], local_) : 0.0;
57 std::vector<int>
const& components_;
58 LocalCoordinate local_;
64 disableCopyMove<Self, LF> = 0,
65 HasBind<LF,Entity> =
true>
71 explicit LocalFunction (std::shared_ptr<VTKFunction<GridView>
const>
const& lf)
80 void bind (Entity
const& entity)
82 assert(
bool(localFct_));
83 localFct_->bind(entity);
89 assert(
bool(localFct_));
96 assert(
bool(localFct_));
97 return {*localFct_, components_, xi};
101 double evaluate (
int c, LocalCoordinate
const& xi)
const
103 assert(
bool(localFct_));
104 return c < int(components_.size()) ? localFct_->evaluate(components_[c], xi) : 0.0;
109 components_ = std::move(components);
113 std::shared_ptr<LocalFunctionInterface<GridView>> localFct_ =
nullptr;
114 std::vector<int> components_;
Type erasure for dune-functions LocalFunction interface.
Definition: defaultvtkfunction.hh:19
Type erasure for Legacy VTKFunction.
Definition: legacyvtkfunction.hh:17
A Vtk::LocalFunction is a function-like object that can be bound to a grid element an that provides a...
Definition: localfunction.hh:23
LocalFunction(LF &&lf)
Construct the Vtk::LocalFunction from any function object that has a bind(element) method.
Definition: localfunction.hh:66
LocalFunction(std::shared_ptr< VTKFunction< GridView > const > const &lf)
Construct a Vtk::LocalFunction from a legacy VTKFunction.
Definition: localfunction.hh:71
void unbind()
Unbind from the currently bound entity.
Definition: localfunction.hh:87
RangeProxy operator()(LocalCoordinate const &xi) const
Return a proxy object to access the components of the range vector.
Definition: localfunction.hh:94
double evaluate(int c, LocalCoordinate const &xi) const
Evaluate the cth component of the Range value at local coordinate xi
Definition: localfunction.hh:101
void setComponents(std::vector< int > components)
Definition: localfunction.hh:107
void bind(Entity const &entity)
Bind the function to the grid entity.
Definition: localfunction.hh:80
An abstract base class for LocalFunctions that can be bound to an element and evaluated in local coor...
Definition: localfunctioninterface.hh:11