2#ifndef DUNE_PDELAB_FUNCTION_LOCALFUNCTION_HH
3#define DUNE_PDELAB_FUNCTION_LOCALFUNCTION_HH
8#include <dune/pdelab/function/tags.hh>
9#include <dune/pdelab/function/localfunctionhelper.hh>
10#include <dune/pdelab/function/oldinterfaceadapter.hh>
11#include <dune/functions/common/signature.hh>
12#include <dune/functions/gridfunctions/gridviewfunction.hh>
17 template<
class F, std::
size_t k>
18 class PowerLocalFunction
19 :
public TypeTree::PowerNode<F,k>
21 typedef TypeTree::PowerNode<F,k> NodeType;
26 template <
typename TT>
27 void setTime(TT time){
28 PowerCompositeSetTimeVisitor<TT> visitor(time);
32 template <
typename Entity>
33 void bind(
const Entity & e){
34 Imp::PowerCompositeBindVisitor<Entity> visitor(e);
39 Imp::PowerCompositeUnbindVisitor visitor;
48 PowerLocalFunction (F& f)
57 template<
typename C0,
typename C1,
typename... Children>
58 PowerLocalFunction (C0&& c0, C1&& c1, Children&&... children)
59 : NodeType(
std::forward(c0),
std::forward(c1),
std::forward(children)...)
64 PowerLocalFunction(
const std::array<std::shared_ptr<F>,k>& children)
70 template<
typename... Children>
71 class CompositeLocalFunction
72 :
public TypeTree::CompositeNode<Children...>
74 typedef TypeTree::CompositeNode<Children...> NodeType;
79 template <
typename TT>
80 void setTime(TT time){
81 PowerCompositeSetTimeVisitor<TT> visitor(time);
85 template <
typename Entity>
86 void bind(
const Entity & e){
87 Imp::PowerCompositeBindVisitor<Entity> visitor(e);
92 Imp::PowerCompositeUnbindVisitor visitor;
97 CompositeLocalFunction()
101 template<
typename... Args,
typename =
typename std::enable_if<(
sizeof...(Args) ==
sizeof...(Children))>::type>
102 CompositeLocalFunction(Args&&... args)
103 : NodeType(
std::forward<Args>(args)...)
119 template<
class F,
class GV,
120 typename std::enable_if<
122 models< Dune::Functions::Imp::HasFreeLocalFunction, F>()
124 not(TypeTree::has_node_tag<typename
std::decay<F>::type>::value),
int>::type = 0>
125 auto makeLocalFunctionTree(const F& f, const GV & gv)
126 -> Imp::LocalFunctionLeafNodeWrapper< decltype(localFunction(f)) >
128 return Imp::LocalFunctionLeafNodeWrapper< decltype(localFunction(f)) >(localFunction(f));
131 template<
class F,
class GV,
133 typename std::enable_if<
134 Dune::Functions::Concept::isCallable<F, typename GV::template Codim<0>::Entity::Geometry::GlobalCoordinate>()
136 not(models< Dune::Functions::Imp::HasFreeLocalFunction, F>())
138 not(TypeTree::has_node_tag<
typename std::decay<F>::type>::value),
int>::type = 0>
139 auto makeLocalFunctionTree(
const F& f,
const GV & gv)
140 ->
decltype(makeLocalFunctionTree(Functions::makeGridViewFunction(f,gv), gv))
142 return makeLocalFunctionTree(Functions::makeGridViewFunction(f,gv), gv);
145 template<
class F,
class GV,
146 typename std::enable_if<
148 models< Dune::Functions::Imp::HasFreeLocalFunction, F>()
150 TypeTree::has_node_tag<typename
std::decay<F>::type>::value,
int>::type = 0>
151 auto makeLocalFunctionTree(F&& f, const GV & gv)
152 -> decltype(localView(f))
154 return localView(std::forward(f));
157 struct GridFunctionToLocalViewTransformation {};
159 template<
typename LeafNode>
160 Dune::TypeTree::GenericLeafNodeTransformation<LeafNode,GridFunctionToLocalViewTransformation, Imp::LocalGridViewFunctionAdapter<LeafNode> >
163 template<
typename PowerNode>
164 Dune::TypeTree::SimplePowerNodeTransformation<PowerNode,GridFunctionToLocalViewTransformation,PowerLocalFunction>
167 template<
typename CompositeNode>
168 Dune::TypeTree::SimpleCompositeNodeTransformation<CompositeNode,GridFunctionToLocalViewTransformation,CompositeLocalFunction>
171 template<
class F,
class GV,
172 typename std::enable_if<
174 IsGridFunction<F>::value,
int>::type = 0>
175 auto makeLocalFunctionTree(
const F& f,
const GV & gv)
177 GridFunctionToLocalViewTransformation>::transformed_type
181 GridFunctionToLocalViewTransformation>::transform(f);
184 template<
class F,
class GV,
185 typename std::enable_if<
187 not(IsGridFunction<F>::value)
189 std::is_same<TypeTree::NodeTag<F>,TypeTree::LeafNodeTag>::value,
int>::type = 0>
190 auto makeLocalFunctionTree(
const GridFunctionInterface<typename F::Traits,F>& f,
const GV & gv)
191 -> Imp::LocalGridViewFunctionAdapter<F>
194 return Imp::LocalGridViewFunctionAdapter<F>(
static_cast<const F&
>(f));
typename std::decay_t< T >::ImplementationTag ImplementationTag
Returns the implementation tag of the given Node.
Definition: nodeinterface.hh:74
void applyToTree(Tree &&tree, Visitor &&visitor)
Apply visitor to TypeTree.
Definition: traversal.hh:239
Dune namespace.
Definition: alignedallocator.hh:13