3 #ifndef DUNE_FUNCTIONS_FUNCTIONSPACEBASES_INTERPOLATE_HH 4 #define DUNE_FUNCTIONS_FUNCTIONSPACEBASES_INTERPOLATE_HH 9 #include <dune/common/exceptions.hh> 10 #include <dune/common/bitsetvector.hh> 12 #include <dune/typetree/childextraction.hh> 14 #include <dune/localfunctions/common/virtualinterface.hh> 25 #include <dune/typetree/traversal.hh> 26 #include <dune/typetree/visitor.hh> 37 bool test(
int i)
const {
return true; }
59 template <
class B,
class T,
class NTRE,
class HV,
class LF,
class HBV>
61 :
public TypeTree::TreeVisitor
62 ,
public TypeTree::DynamicTraversal
81 using Element =
typename GridView::template Codim<0>::Entity;
83 using LocalDomain =
typename Element::Geometry::LocalCoordinate;
87 using CoefficientBlock =
typename std::decay<decltype(std::declval<HierarchicVector>()[std::declval<MultiIndex>()])>::type;
88 using BitVectorBlock =
typename std::decay<decltype(std::declval<HierarchicBitVector>()[std::declval<MultiIndex>()])>::type;
93 bitVector_(bitVector),
94 localIndexSet_(localIndexSet),
95 nodeToRangeEntry_(nodeToRangeEntry)
97 static_assert(Dune::Functions::Concept::isCallable<LocalFunction, LocalDomain>(),
"Function passed to LocalInterpolateVisitor does not model the Callable<LocalCoordinate> concept");
100 template<
typename Node,
typename TreePath>
101 void pre(Node& node, TreePath treePath)
104 template<
typename Node,
typename TreePath>
105 void post(Node& node, TreePath treePath)
108 template<
typename Node,
typename TreePath>
109 void leaf(Node& node, TreePath treePath)
111 using FiniteElement =
typename Node::FiniteElement;
112 using FiniteElementRange =
typename FiniteElement::Traits::LocalBasisType::Traits::RangeType;
113 using FunctionBaseClass =
typename Dune::LocalFiniteElementFunctionBase<FiniteElement>::type;
121 const auto& y = localF_(x);
122 const auto& y_node = nodeToRangeEntry_(node, y);
123 using FunctionRange =
typename std::decay<decltype(y_node)>::type;
129 auto interpolationValues = std::vector<FiniteElementRange>();
131 auto&& fe = node.finiteElement();
138 for(j=0; j<blockSize; ++j)
143 for (
size_t i=0; i<fe.localBasis().size(); ++i)
145 auto multiIndex = localIndexSet_.index(node.localIndex(i));
146 const auto& bitVectorBlock = bitVector_[multiIndex];
151 auto&& vectorBlock = vector_[multiIndex];
191 template <
class B,
class... TreeIndices,
class NTRE,
class C,
class F,
class BV>
192 void interpolateTreeSubset(
const B& basis,
const TypeTree::HybridTreePath<TreeIndices...>& treePath, C&& coeff,
const F& f,
const NTRE& nodeToRangeEntry,
const BV& bv)
194 using GridView =
typename B::GridView;
195 using Element =
typename GridView::template Codim<0>::Entity;
197 using Tree =
typename std::decay<decltype(TypeTree::child(basis.localView().tree(),treePath))>::type;
199 using GlobalDomain =
typename Element::Geometry::GlobalCoordinate;
201 static_assert(Dune::Functions::Concept::isCallable<F, GlobalDomain>(),
"Function passed to interpolate does not model the Callable<GlobalCoordinate> concept");
203 auto&& gridView = basis.gridView();
205 auto&& bitVector = makeHierarchicVectorForMultiIndex<typename B::MultiIndex>(bv);
206 auto&& vector = makeHierarchicVectorForMultiIndex<typename B::MultiIndex>(coeff);
215 auto localF = localFunction(gf);
217 auto localView = basis.localView();
218 auto localIndexSet = basis.localIndexSet();
220 for (
const auto& e : elements(gridView))
223 localIndexSet.bind(localView);
226 auto&& subTree = TypeTree::child(localView.tree(),treePath);
228 Imp::LocalInterpolateVisitor<B, Tree, NTRE, decltype(vector), decltype(localF), decltype(bitVector)> localInterpolateVisitor(basis, vector, bitVector, localF, localIndexSet, nodeToRangeEntry);
229 TypeTree::applyToTree(subTree,localInterpolateVisitor);
234 template <
class B,
class... TreeIndices,
class C,
class F,
class BV>
235 void interpolateTreeSubset(
const B& basis,
const TypeTree::HybridTreePath<TreeIndices...>& treePath, C&& coeff,
const F& f,
const BV& bitVector)
241 template <
class B,
class... TreeIndices,
class NTRE,
class C,
class F>
242 void interpolateTree(
const B& basis,
const TypeTree::HybridTreePath<TreeIndices...>& treePath, C&& coeff,
const F& f,
const NTRE& nodeToRangeEntry)
248 template <
class B,
class... TreeIndices,
class C,
class F>
249 void interpolateTree(
const B& basis,
const TypeTree::HybridTreePath<TreeIndices...>& treePath, C&& coeff,
const F& f)
272 template <
class B,
class... TreeIndices,
class C,
class F,
class BV>
273 void interpolate(
const B& basis,
const TypeTree::HybridTreePath<TreeIndices...>& treePath, C&& coeff,
const F& f,
const BV& bitVector)
310 template <
class B,
class C,
class F,
class BV,
311 std::enable_if_t<not Imp::isHybridTreePath<C>(),
int> = 0>
312 void interpolate(
const B& basis, C&& coeff,
const F& f,
const BV& bitVector)
314 auto root = Dune::TypeTree::hybridTreePath();
334 template <
class B,
class C,
class F>
355 template <
class B,
class... TreeIndices,
class C,
class F>
356 void interpolate(
const B& basis,
const TypeTree::HybridTreePath<TreeIndices...>& treePath, C&& coeff,
const F& f)
364 #endif // DUNE_FUNCTIONS_FUNCTIONSPACEBASES_INTERPOLATE_HH typename LocalIndexSet::MultiIndex MultiIndex
Definition: interpolate.hh:69
void interpolateTree(const B &basis, const TypeTree::HybridTreePath< TreeIndices... > &treePath, C &&coeff, const F &f, const NTRE &nodeToRangeEntry)
Definition: interpolate.hh:242
void resize(const SP &) const
Definition: interpolate.hh:52
Definition: functionfromcallable.hh:20
NTRE NodeToRangeEntry
Definition: interpolate.hh:78
Definition: interpolate.hh:60
void leaf(Node &node, TreePath treePath)
Definition: interpolate.hh:109
typename Basis::GridView GridView
Definition: interpolate.hh:80
const NodeToRangeEntry & nodeToRangeEntry_
Definition: interpolate.hh:165
typename std::decay< decltype(std::declval< HierarchicBitVector >()[std::declval< MultiIndex >()])>::type BitVectorBlock
Definition: interpolate.hh:88
Definition: interpolate.hh:35
void interpolate(const B &basis, const TypeTree::HybridTreePath< TreeIndices... > &treePath, C &&coeff, const F &f, const BV &bitVector)
Interpolate given function in discrete function space.
Definition: interpolate.hh:273
typename GridView::template Codim< 0 >::Entity Element
Definition: interpolate.hh:81
const AllTrueBitSetVector & operator[](const I &) const
Definition: interpolate.hh:46
Definition: polynomial.hh:7
struct Dune::Functions::Imp::AllTrueBitSetVector::AllTrueBitSet allTrue_
void post(Node &node, TreePath treePath)
Definition: interpolate.hh:105
const LocalFunction & localF_
Definition: interpolate.hh:162
typename Element::Geometry::LocalCoordinate LocalDomain
Definition: interpolate.hh:83
const LocalIndexSet & localIndexSet_
Definition: interpolate.hh:164
std::decay< F >::type makeGridViewFunction(F &&f, const GridView &gridView)
Construct a function modeling GridViewFunction from function and grid view.
Definition: gridviewfunction.hh:68
typename Element::Geometry::GlobalCoordinate GlobalDomain
Definition: interpolate.hh:85
static auto size(VV &&v) -> decltype(v.size())
Definition: flatvectorbackend.hh:41
HV HierarchicVector
Definition: interpolate.hh:75
typename std::decay< decltype(std::declval< HierarchicVector >()[std::declval< MultiIndex >()])>::type CoefficientBlock
Definition: interpolate.hh:87
constexpr std::true_type isHybridTreePath(const TypeTree::HybridTreePath< T... > &)
Definition: interpolate.hh:281
HBV HierarchicBitVector
Definition: interpolate.hh:76
typename B::LocalIndexSet LocalIndexSet
Definition: interpolate.hh:68
bool test(int i) const
Definition: interpolate.hh:37
HierarchicVector & vector_
Definition: interpolate.hh:161
DefaultNodeToRangeMap< Tree > makeDefaultNodeToRangeMap(const Tree &tree)
Definition: defaultnodetorangemap.hh:107
SizeInfo< Basis > sizeInfo(const Basis &basis)
Definition: sizeinfo.hh:69
void pre(Node &node, TreePath treePath)
Definition: interpolate.hh:101
void interpolateTreeSubset(const B &basis, const TypeTree::HybridTreePath< TreeIndices... > &treePath, C &&coeff, const F &f, const NTRE &nodeToRangeEntry, const BV &bv)
Interpolate given function in discrete function space.
Definition: interpolate.hh:192
T Tree
Definition: interpolate.hh:73
Definition: interpolate.hh:33
B Basis
Definition: interpolate.hh:67
LF LocalFunction
Definition: interpolate.hh:71
LocalInterpolateVisitor(const B &basis, HV &coeff, const HBV &bitVector, const LF &localF, const LocalIndexSet &localIndexSet, const NodeToRangeEntry &nodeToRangeEntry)
Definition: interpolate.hh:90
const HierarchicBitVector & bitVector_
Definition: interpolate.hh:163
static auto getEntry(VV &&v, const Index &i) -> decltype(v[i])
Definition: flatvectorbackend.hh:25