dune-pdelab  2.5-dev
localfunction.hh
Go to the documentation of this file.
1 //-*- tab-width: 4; c-basic-offset: 2; indent-tabs-mode: nil -*-
2 #ifndef DUNE_PDELAB_FUNCTION_LOCALFUNCTION_HH
3 #define DUNE_PDELAB_FUNCTION_LOCALFUNCTION_HH
4 
5 #include <type_traits>
6 
10 #include <dune/functions/common/signature.hh>
11 #include <dune/functions/gridfunctions/gridviewfunction.hh>
12 
13 namespace Dune {
14 namespace PDELab {
15 
16  template<class F, std::size_t k>
18  : public TypeTree::PowerNode<F,k>
19  {
20  typedef TypeTree::PowerNode<F,k> NodeType;
21  public:
23 
25  template <typename TT>
26  void setTime(TT time){
28  TypeTree::applyToTree(*this,visitor);
29  }
30 
31  template <typename Entity>
32  void bind(const Entity & e){
34  TypeTree::applyToTree(*this,visitor);
35  }
36 
37  void unbind(){
39  TypeTree::applyToTree(*this,visitor);
40  }
41 
44  {}
45 
48  : NodeType(f) {}
49 
56  template<typename C0, typename C1, typename... Children>
57  PowerLocalFunction (C0&& c0, C1&& c1, Children&&... children)
58  : NodeType(std::forward(c0), std::forward(c1), std::forward(children)...)
59  {
60  }
61 
63  PowerLocalFunction(const Dune::array<Dune::shared_ptr<F>,k>& children)
64  : NodeType(children)
65  {}
66 
67  };
68 
69  template<typename... Children>
71  : public TypeTree::CompositeNode<Children...>
72  {
73  typedef TypeTree::CompositeNode<Children...> NodeType;
74  public:
76 
78  template <typename TT>
79  void setTime(TT time){
81  TypeTree::applyToTree(*this,visitor);
82  }
83 
84  template <typename Entity>
85  void bind(const Entity & e){
87  TypeTree::applyToTree(*this,visitor);
88  }
89 
90  void unbind(){
92  TypeTree::applyToTree(*this,visitor);
93  }
94 
97  {}
98 
100  template<typename... Args, typename = typename std::enable_if<(sizeof...(Args) == sizeof...(Children))>::type>
101  CompositeLocalFunction(Args&&... args)
102  : NodeType(std::forward<Args>(args)...)
103  {}
104 
105  };
106 
118  template<class F, class GV,
119  typename std::enable_if<
120  // case (a)
121  models< Dune::Functions::Imp::HasFreeLocalFunction, F>()
122  and
123  not(TypeTree::has_node_tag<typename std::decay<F>::type>::value), int>::type = 0>
124  auto makeLocalFunctionTree(const F& f, const GV & gv)
126  {
128  }
129 
130  template<class F, class GV,
131  // case (b)
132  typename std::enable_if<
133  Dune::Functions::Concept::isCallable<F, typename GV::template Codim<0>::Entity::Geometry::GlobalCoordinate>()
134  and
135  not(models< Dune::Functions::Imp::HasFreeLocalFunction, F>())
136  and
137  not(TypeTree::has_node_tag<typename std::decay<F>::type>::value), int>::type = 0>
138  auto makeLocalFunctionTree(const F& f, const GV & gv)
139  -> decltype(makeLocalFunctionTree(Functions::makeGridViewFunction(f,gv), gv))
140  {
141  return makeLocalFunctionTree(Functions::makeGridViewFunction(f,gv), gv);
142  }
143 
144  template<class F, class GV,
145  typename std::enable_if<
146  // case (c)
147  models< Dune::Functions::Imp::HasFreeLocalFunction, F>()
148  and
149  TypeTree::has_node_tag<typename std::decay<F>::type>::value, int>::type = 0>
150  auto makeLocalFunctionTree(F&& f, const GV & gv)
151  -> decltype(localView(f))
152  {
153  return localView(std::forward(f));
154  }
155 
157 
158  template<typename LeafNode>
159  Dune::TypeTree::GenericLeafNodeTransformation<LeafNode,GridFunctionToLocalViewTransformation, Imp::LocalGridViewFunctionAdapter<LeafNode> >
161 
162  template<typename PowerNode>
163  Dune::TypeTree::SimplePowerNodeTransformation<PowerNode,GridFunctionToLocalViewTransformation,PowerLocalFunction>
165 
166  template<typename CompositeNode>
167  Dune::TypeTree::SimpleCompositeNodeTransformation<CompositeNode,GridFunctionToLocalViewTransformation,CompositeLocalFunction>
169 
170  template<class F, class GV,
171  typename std::enable_if<
172  // case (d)
173  IsGridFunction<F>::value, int>::type = 0>
174  auto makeLocalFunctionTree(const F& f, const GV & gv)
175  -> typename Dune::TypeTree::TransformTree<typename std::decay<F>::type,
176  GridFunctionToLocalViewTransformation>::transformed_type
177  {
178  // call the transformation
179  return Dune::TypeTree::TransformTree<typename std::decay<F>::type,
181  }
182 
183  template<class F, class GV,
184  typename std::enable_if<
185  // case (e)
186  not(IsGridFunction<F>::value)
187  &&
188  std::is_same<TypeTree::NodeTag<F>,TypeTree::LeafNodeTag>::value, int>::type = 0>
191  {
192  // call the transformation
193  return Imp::LocalGridViewFunctionAdapter<F>(static_cast<const F&>(f));
194  }
195 
196 } // end namespace PDELab
197 } // end namespace Dune
198 
199 #endif // DUNE_PDELAB_FUNCTION_LOCALFUNCTION_HH
void unbind()
Definition: localfunction.hh:37
const Entity & e
Definition: localfunctionspace.hh:111
CompositeLocalFunction(Args &&... args)
Initialize all children with the passed-in objects.
Definition: localfunction.hh:101
void bind(const Entity &e)
Definition: localfunction.hh:32
Definition: function.hh:287
void unbind()
Definition: localfunction.hh:90
PowerLocalFunction(const Dune::array< Dune::shared_ptr< F >, k > &children)
Transformation Constructor, taking the set of new children.
Definition: localfunction.hh:63
Dune::TypeTree::GenericLeafNodeTransformation< LeafNode, GridFunctionToLocalViewTransformation, Imp::LocalGridViewFunctionAdapter< LeafNode > > registerNodeTransformation(LeafNode *l, GridFunctionToLocalViewTransformation *t, GridFunctionTag *tag)
For backward compatibility – Do not use this!
Definition: adaptivity.hh:27
PowerLocalFunction(F &f)
Construct a PowerGridFunction with k clones of the function t.
Definition: localfunction.hh:47
const P & p
Definition: constraints.hh:147
Definition: localfunctionhelper.hh:15
Definition: function.hh:356
CompositeLocalFunction()
Default Constructor.
Definition: localfunction.hh:96
void setTime(TT time)
Set the time in all leaf nodes of this function tree.
Definition: localfunction.hh:79
PowerDifferentiableFunctionLocalViewTag ImplementationTag
Definition: localfunction.hh:22
STL namespace.
a GridFunction maps x in DomainType to y in RangeType
Definition: function.hh:187
Definition: function.hh:516
Definition: localfunction.hh:17
Visitor for Power- and CompositeGridFunctions calling the setTime() method on the leafs of the corres...
Definition: function.hh:343
PowerLocalFunction(C0 &&c0, C1 &&c1, Children &&... children)
Initialize all children with different function objects.
Definition: localfunction.hh:57
Definition: localfunctionhelper.hh:38
auto makeLocalFunctionTree(const F &f, const GV &gv) -> Imp::LocalFunctionLeafNodeWrapper< decltype(localFunction(f)) >
turn a given function tree into a local function tree
Definition: localfunction.hh:124
PowerLocalFunction()
Deafult Constructor.
Definition: localfunction.hh:43
void bind(const Entity &e)
Definition: localfunction.hh:85
Definition: oldinterfaceadapter.hh:16
static const unsigned int value
Definition: gridfunctionspace/tags.hh:139
Definition: localfunctionhelper.hh:27
CompositeDifferentiableFunctionLocalViewTag ImplementationTag
Definition: localfunction.hh:75
Definition: localfunction.hh:70
void setTime(TT time)
Set the time in all leaf nodes of this function tree.
Definition: localfunction.hh:26
std::integral_constant< bool, impl::IsGridFunction< std::decay_t< T > >::value > IsGridFunction
Definition: typetraits.hh:45