3 #ifndef DUNE_FUNCTIONS_GRIDFUNCTIONS_DISCRETEGLOBALBASISFUNCTIONS_HH
4 #define DUNE_FUNCTIONS_GRIDFUNCTIONS_DISCRETEGLOBALBASISFUNCTIONS_HH
8 #include <dune/common/shared_ptr.hh>
66 template<
typename B,
typename TP,
typename V,
67 typename NTRE = DefaultNodeToRangeMap<typename std::decay<decltype(std::declval<B>().localView().tree().child(std::declval<TP>()))>::type>,
68 typename R =
typename V::value_type>
78 using Tree =
typename Basis::LocalView::Tree;
79 using SubTree =
typename TypeTree::ChildForTreePath<Tree, TreePath>;
92 using LocalBasisView =
typename Basis::LocalView;
93 using LocalIndexSet =
typename Basis::LocalIndexSet;
94 using size_type =
typename SubTree::size_type;
97 using LocalBasisRange =
typename Node::FiniteElement::Traits::LocalBasisType::Traits::RangeType;
100 using NodeData =
typename std::vector<LocalBasisRange<Node>>;
104 struct LocalEvaluateVisitor
105 :
public TypeTree::TreeVisitor
106 ,
public TypeTree::DynamicTraversal
111 localIndexSet_(localIndexSet),
112 coefficients_(coefficients),
113 nodeToRangeEntry_(nodeToRangeEntry),
114 shapeFunctionValueContainer_(shapeFunctionValueContainer)
117 template<
typename Node,
typename TreePath>
118 void leaf(Node& node,
TreePath treePath)
120 using LocalBasisRange =
typename Node::FiniteElement::Traits::LocalBasisType::Traits::RangeType;
121 using MultiIndex =
typename LocalIndexSet::MultiIndex;
122 using CoefficientBlock =
typename std::decay<decltype(std::declval<Vector>()[std::declval<MultiIndex>()])>::type;
123 using RangeBlock =
typename std::decay<decltype(nodeToRangeEntry_(node, y_))>::type;
125 auto&& fe = node.finiteElement();
126 auto&& localBasis = fe.localBasis();
128 auto&& shapeFunctionValues = shapeFunctionValueContainer_[node];
129 localBasis.evaluateFunction(x_, shapeFunctionValues);
132 auto&& re = nodeToRangeEntry_(node, y_);
135 for (size_type i = 0; i < localBasis.size(); ++i)
137 auto&& multiIndex = localIndexSet_.index(node.localIndex(i));
140 auto&& c = coefficients_[multiIndex];
143 auto&& v = shapeFunctionValues[i];
152 for(size_type j=0; j<dimC; ++j)
155 for(size_type k=0; k<dimV; ++k)
166 const LocalIndexSet& localIndexSet_;
167 const Vector& coefficients_;
181 : globalFunction_(&globalFunction)
182 , localBasisView_(globalFunction.basis().localView())
183 , localIndexSet_(globalFunction.basis().localIndexSet())
187 subTree_ = &TypeTree::child(localBasisView_.tree(), globalFunction_->treePath());
188 shapeFunctionValueContainer_.init(*subTree_);
193 : globalFunction_(other.globalFunction_)
194 , localBasisView_(other.localBasisView_)
195 , localIndexSet_(globalFunction_->basis().localIndexSet())
196 , bound_(other.bound_)
199 localIndexSet_.bind(localBasisView_);
203 subTree_ = &TypeTree::child(localBasisView_.tree(), globalFunction_->treePath());
204 shapeFunctionValueContainer_.init(*subTree_);
209 globalFunction_ = other.globalFunction_;
210 localBasisView_ = other.localBasisView_;
211 localIndexSet_ = other.localIndexSet_;
212 subTree_ = &TypeTree::child(localBasisView_.tree(), globalFunction_->treePath());
216 shapeFunctionValueContainer_.init(*subTree_);
227 localBasisView_.bind(element);
228 localIndexSet_.bind(localBasisView_);
239 localIndexSet_.unbind();
240 localBasisView_.unbind();
264 LocalEvaluateVisitor localEvaluateVisitor(x, y, localIndexSet_, globalFunction_->dofs(), globalFunction_->nodeToRangeEntry(), shapeFunctionValueContainer_);
265 TypeTree::applyToTree(*subTree_, localEvaluateVisitor);
272 return localBasisView_.element();
277 DUNE_THROW(NotImplemented,
"not implemented");
283 LocalBasisView localBasisView_;
284 LocalIndexSet localIndexSet_;
286 mutable ShapeFunctionValueContainer shapeFunctionValueContainer_;
294 entitySet_(basis.gridView()),
295 basis_(stackobject_to_shared_ptr(basis)),
297 coefficients_(stackobject_to_shared_ptr(coefficients)),
298 nodeToRangeEntry_(stackobject_to_shared_ptr(nodeToRangeEntry))
301 DiscreteGlobalBasisFunction(std::shared_ptr<const Basis> basis,
const TreePath& treePath, std::shared_ptr<const V> coefficients, std::shared_ptr<const NodeToRangeEntry> nodeToRangeEntry) :
302 entitySet_(basis->gridView()),
305 coefficients_(coefficients),
306 nodeToRangeEntry_(nodeToRangeEntry)
321 return *coefficients_;
326 return *nodeToRangeEntry_;
332 DUNE_THROW(NotImplemented,
"not implemented");
337 DUNE_THROW(NotImplemented,
"not implemented");
370 EntitySet entitySet_;
371 std::shared_ptr<const Basis> basis_;
372 const TreePath treePath_;
373 std::shared_ptr<const V> coefficients_;
374 std::shared_ptr<const NodeToRangeEntry> nodeToRangeEntry_;
389 template<
typename... TT>
390 void localFunction(DiscreteGlobalBasisFunction<TT...>&& t) =
delete;
394 template<
typename R,
typename B,
typename TP,
typename V>
397 using Basis = std::decay_t<B>;
398 using Vector = std::decay_t<V>;
401 auto basisPtr = Dune::wrap_or_move(std::forward<B>(basis));
402 auto vectorPtr = Dune::wrap_or_move(std::forward<V>(vector));
408 template<
typename R,
typename B,
typename V>
411 return makeDiscreteGlobalBasisFunction<R>(std::forward<B>(basis), TypeTree::hybridTreePath(), std::forward<V>(vector));
419 #endif // DUNE_FUNCTIONS_GRIDFUNCTIONS_DISCRETEGLOBALBASISFUNCTIONS_HH