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>;
88 using Traits = Imp::GridFunctionTraits<Range(Domain), EntitySet, DefaultDerivativeTraits, 16>;
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_;
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");
371 std::shared_ptr<const Basis> basis_;
373 std::shared_ptr<const V> coefficients_;
374 std::shared_ptr<const NodeToRangeEntry> nodeToRangeEntry_;
389 template<
typename... TT>
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 Imp::GridFunctionTraits< Range(Domain), EntitySet, DefaultDerivativeTraits, 16 > Traits
Definition: discreteglobalbasisfunction.hh:88
friend Traits::LocalFunctionTraits::DerivativeInterface derivative(const LocalFunction &t)
Definition: discreteglobalbasisfunction.hh:275
LocalDomain Domain
Definition: discreteglobalbasisfunction.hh:176
TP TreePath
Definition: discreteglobalbasisfunction.hh:73
GridView::template Codim< codim >::Entity Element
Type of Elements contained in this EntitySet.
Definition: gridviewentityset.hh:32
bool bound() const
Check if LocalFunction is already bound to an element.
Definition: discreteglobalbasisfunction.hh:247
typename Basis::GridView GridView
Definition: discreteglobalbasisfunction.hh:76
void localFunction(DiscreteGlobalBasisFunction< TT... > &&t)=delete
Construction of local functions from a temporary DiscreteGlobalBasisFunction (forbidden) ...
const Element & localContext() const
Definition: discreteglobalbasisfunction.hh:270
GlobalFunction::Element Element
Definition: discreteglobalbasisfunction.hh:178
typename EntitySet::GlobalCoordinate Domain
Definition: discreteglobalbasisfunction.hh:82
static auto size(VV &&v) -> decltype(v.size())
Definition: flatvectorbackend.hh:41
A simple node to range map using lexicographic ordering.
Definition: defaultnodetorangemap.hh:38
typename EntitySet::Element Element
Definition: discreteglobalbasisfunction.hh:86
Definition: flatvectorbackend.hh:20
const Basis & basis() const
Definition: discreteglobalbasisfunction.hh:309
typename TypeTree::ChildForTreePath< Tree, TreePath > SubTree
Definition: discreteglobalbasisfunction.hh:79
Definition: discreteglobalbasisfunction.hh:90
NTRE NodeToRangeEntry
Definition: discreteglobalbasisfunction.hh:80
DiscreteGlobalBasisFunction(const Basis &basis, const TreePath &treePath, const V &coefficients, const NodeToRangeEntry &nodeToRangeEntry)
Definition: discreteglobalbasisfunction.hh:293
static auto getEntry(VV &&v, const Index &i) -> decltype(v[i])
Definition: flatvectorbackend.hh:25
friend LocalFunction localFunction(const DiscreteGlobalBasisFunction &t)
Construct local function from a DiscreteGlobalBasisFunction.
Definition: discreteglobalbasisfunction.hh:355
typename Basis::LocalView::Tree Tree
Definition: discreteglobalbasisfunction.hh:78
Element::Geometry::LocalCoordinate LocalCoordinate
Type of local coordinates with respect to the Element.
Definition: gridviewentityset.hh:35
Definition: gridfunction.hh:31
V Vector
Definition: discreteglobalbasisfunction.hh:74
const EntitySet & entitySet() const
Get associated EntitySet.
Definition: discreteglobalbasisfunction.hh:363
Element::Geometry::GlobalCoordinate GlobalCoordinate
Definition: gridviewentityset.hh:36
DefaultNodeToRangeMap< Tree > makeDefaultNodeToRangeMap(const Tree &tree)
Definition: defaultnodetorangemap.hh:106
B Basis
Definition: discreteglobalbasisfunction.hh:72
GlobalFunction::Range Range
Definition: discreteglobalbasisfunction.hh:177
const NodeToRangeEntry & nodeToRangeEntry() const
Definition: discreteglobalbasisfunction.hh:324
void unbind()
Definition: discreteglobalbasisfunction.hh:237
LocalFunction operator=(const LocalFunction &other)
Definition: discreteglobalbasisfunction.hh:207
const V & dofs() const
Definition: discreteglobalbasisfunction.hh:319
Range operator()(const Domain &x) const
Evaluate LocalFunction at bound element.
Definition: discreteglobalbasisfunction.hh:260
Definition: polynomial.hh:7
typename EntitySet::LocalCoordinate LocalDomain
Definition: discreteglobalbasisfunction.hh:85
LocalFunction(const LocalFunction &other)
Definition: discreteglobalbasisfunction.hh:192
friend Traits::DerivativeInterface derivative(const DiscreteGlobalBasisFunction &t)
Definition: discreteglobalbasisfunction.hh:335
void bind(const Element &element)
Bind LocalFunction to grid element.
Definition: discreteglobalbasisfunction.hh:225
const TreePath & treePath() const
Definition: discreteglobalbasisfunction.hh:314
auto makeDiscreteGlobalBasisFunction(B &&basis, const TP &treePath, V &&vector)
Definition: discreteglobalbasisfunction.hh:395
R Range
Definition: discreteglobalbasisfunction.hh:83
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:301
A grid function induced by a global basis and a coefficient vector.
Definition: discreteglobalbasisfunction.hh:69
LocalFunction(const DiscreteGlobalBasisFunction &globalFunction)
Definition: discreteglobalbasisfunction.hh:180