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_(globalFunction_->basis().localView())
195 , localIndexSet_(globalFunction_->basis().localIndexSet())
199 subTree_ = &TypeTree::child(localBasisView_.tree(), globalFunction_->treePath());
200 shapeFunctionValueContainer_.init(*subTree_);
205 globalFunction_ = other.globalFunction_;
206 localBasisView_ = other.localBasisView_;
207 localIndexSet_ = other.localIndexSet_;
208 subTree_ = &TypeTree::child(localBasisView_.tree(), globalFunction_->treePath());
212 shapeFunctionValueContainer_.init(*subTree_);
223 localBasisView_.bind(element);
224 localIndexSet_.bind(localBasisView_);
234 localIndexSet_.unbind();
235 localBasisView_.unbind();
251 LocalEvaluateVisitor localEvaluateVisitor(x, y, localIndexSet_, globalFunction_->dofs(), globalFunction_->nodeToRangeEntry(), shapeFunctionValueContainer_);
252 TypeTree::applyToTree(*subTree_, localEvaluateVisitor);
259 return localBasisView_.element();
264 DUNE_THROW(NotImplemented,
"not implemented");
270 LocalBasisView localBasisView_;
271 LocalIndexSet localIndexSet_;
279 entitySet_(basis.gridView()),
280 basis_(stackobject_to_shared_ptr(basis)),
282 coefficients_(stackobject_to_shared_ptr(coefficients)),
283 nodeToRangeEntry_(stackobject_to_shared_ptr(nodeToRangeEntry))
286 DiscreteGlobalBasisFunction(std::shared_ptr<const Basis> basis,
const TreePath& treePath, std::shared_ptr<const V> coefficients, std::shared_ptr<const NodeToRangeEntry> nodeToRangeEntry) :
287 entitySet_(basis->gridView()),
290 coefficients_(coefficients),
291 nodeToRangeEntry_(nodeToRangeEntry)
306 return *coefficients_;
311 return *nodeToRangeEntry_;
317 DUNE_THROW(NotImplemented,
"not implemented");
322 DUNE_THROW(NotImplemented,
"not implemented");
341 std::shared_ptr<const Basis> basis_;
343 std::shared_ptr<const V> coefficients_;
344 std::shared_ptr<const NodeToRangeEntry> nodeToRangeEntry_;
349 template<
typename R,
typename B,
typename TP,
typename V>
352 using Basis = std::decay_t<B>;
353 using Vector = std::decay_t<V>;
356 auto basisPtr = Dune::wrap_or_move(std::forward<B>(basis));
357 auto vectorPtr = Dune::wrap_or_move(std::forward<V>(vector));
363 template<
typename R,
typename B,
typename V>
366 return makeDiscreteGlobalBasisFunction<R>(std::forward<B>(basis), TypeTree::hybridTreePath(), std::forward<V>(vector));
374 #endif // DUNE_FUNCTIONS_GRIDFUNCTIONS_DISCRETEGLOBALBASISFUNCTIONS_HH void bind(const Element &element)
Bind LocalFunction to grid element.
Definition: discreteglobalbasisfunction.hh:221
LocalFunction(const LocalFunction &other)
Definition: discreteglobalbasisfunction.hh:192
const Basis & basis() const
Definition: discreteglobalbasisfunction.hh:294
B Basis
Definition: discreteglobalbasisfunction.hh:72
void unbind()
Definition: discreteglobalbasisfunction.hh:232
friend Traits::LocalFunctionTraits::DerivativeInterface derivative(const LocalFunction &t)
Definition: discreteglobalbasisfunction.hh:262
GridView::template Codim< codim >::Entity Element
Type of Elements contained in this EntitySet.
Definition: gridviewentityset.hh:32
auto makeDiscreteGlobalBasisFunction(B &&basis, const TP &treePath, V &&vector)
Definition: discreteglobalbasisfunction.hh:350
Definition: polynomial.hh:7
Definition: discreteglobalbasisfunction.hh:90
Traits class providing type information for DifferentiableFunction.
Definition: gridfunction.hh:41
typename EntitySet::Element Element
Definition: discreteglobalbasisfunction.hh:86
V Vector
Definition: discreteglobalbasisfunction.hh:74
Element::Geometry::LocalCoordinate LocalCoordinate
Type of local coordinates with respect to the Element.
Definition: gridviewentityset.hh:35
static auto size(VV &&v) -> decltype(v.size())
Definition: flatvectorbackend.hh:41
const V & dofs() const
Definition: discreteglobalbasisfunction.hh:304
typename TypeTree::ChildForTreePath< Tree, TreePath > SubTree
Definition: discreteglobalbasisfunction.hh:79
Range operator()(const Domain &x) const
Evaluate LocalFunction at bound element.
Definition: discreteglobalbasisfunction.hh:247
Definition: flatvectorbackend.hh:20
LocalDomain Domain
Definition: discreteglobalbasisfunction.hh:176
A simple node to range map using lexicographic ordering.
Definition: defaultnodetorangemap.hh:38
R Range
Definition: discreteglobalbasisfunction.hh:83
const EntitySet & entitySet() const
Get associated EntitySet.
Definition: discreteglobalbasisfunction.hh:333
NTRE NodeToRangeEntry
Definition: discreteglobalbasisfunction.hh:80
DiscreteGlobalBasisFunction(const Basis &basis, const TreePath &treePath, const V &coefficients, const NodeToRangeEntry &nodeToRangeEntry)
Definition: discreteglobalbasisfunction.hh:278
DefaultNodeToRangeMap< Tree > makeDefaultNodeToRangeMap(const Tree &tree)
Definition: defaultnodetorangemap.hh:107
typename EntitySet::GlobalCoordinate Domain
Definition: discreteglobalbasisfunction.hh:82
LocalFunction(const DiscreteGlobalBasisFunction &globalFunction)
Definition: discreteglobalbasisfunction.hh:180
typename Basis::LocalView::Tree Tree
Definition: discreteglobalbasisfunction.hh:78
GlobalFunction::Range Range
Definition: discreteglobalbasisfunction.hh:177
const TreePath & treePath() const
Definition: discreteglobalbasisfunction.hh:299
LocalFunction operator=(const LocalFunction &other)
Definition: discreteglobalbasisfunction.hh:203
TP TreePath
Definition: discreteglobalbasisfunction.hh:73
typename Basis::GridView GridView
Definition: discreteglobalbasisfunction.hh:76
A grid function induced by a global basis and a coefficient vector.
Definition: discreteglobalbasisfunction.hh:69
friend Traits::DerivativeInterface derivative(const DiscreteGlobalBasisFunction &t)
Definition: discreteglobalbasisfunction.hh:320
const NodeToRangeEntry & nodeToRangeEntry() const
Definition: discreteglobalbasisfunction.hh:309
Element::Geometry::GlobalCoordinate GlobalCoordinate
Definition: gridviewentityset.hh:36
typename EntitySet::LocalCoordinate LocalDomain
Definition: discreteglobalbasisfunction.hh:85
static auto getEntry(VV &&v, const Index &i) -> decltype(v[i])
Definition: flatvectorbackend.hh:25
GlobalFunction::Element Element
Definition: discreteglobalbasisfunction.hh:178
DiscreteGlobalBasisFunction(std::shared_ptr< const Basis > basis, const TreePath &treePath, std::shared_ptr< const V > coefficients, std::shared_ptr< const NodeToRangeEntry > nodeToRangeEntry)
Definition: discreteglobalbasisfunction.hh:286
const Element & localContext() const
Definition: discreteglobalbasisfunction.hh:257
friend LocalFunction localFunction(const DiscreteGlobalBasisFunction &t)
Definition: discreteglobalbasisfunction.hh:325
Definition: gridfunction.hh:31