6#include <amdis/common/FakeContainer.hpp>
7#include <amdis/common/FieldMatVec.hpp>
8#include <amdis/functions/EntitySet.hpp>
9#include <amdis/functions/HierarchicNodeToRangeMap.hpp>
10#include <amdis/functions/NodeIndices.hpp>
11#include <amdis/linearalgebra/Traits.hpp>
12#include <amdis/operations/Assigner.hpp>
13#include <amdis/typetree/Traversal.hpp>
22 template <
class Basis,
23 class TreePath = Dune::TypeTree::HybridTreePath<>>
26 template <
class Coeff,
class Gr
idFct,
class BitVector>
27 void operator()(Coeff& coeff, GridFct
const& gf, BitVector
const& bitVec)
const
30 VectorType_t<typename Coeff::value_type, Coeff> coeff0(basis_);
31 VectorType_t<std::uint8_t, Coeff> counter(basis_);
32 using Counter = TYPEOF(counter);
35 auto lf = localFunction(gf);
36 auto localView = basis_.localView();
38 std::vector<typename Coeff::value_type> localCoeff;
39 std::vector<typename Counter::value_type> localOnes(localView.maxSize(), 1);
41 for (
const auto& e : entitySet(basis_))
46 auto&& subTree = Dune::TypeTree::child(localView.tree(),treePath_);
47 Traversal::forEachLeafNode(subTree, [&](
auto const& node,
auto const& tp)
49 auto bitVecRange = mappedRangeView(Dune::range(node.size()), [&](std::size_t i) ->
bool {
50 return bitVec[localView.index(node.localIndex(i))];
54 std::vector<bool> mask(bitVecRange.begin(), bitVecRange.end());
55 if (std::all_of(mask.begin(), mask.end(), [](
bool m) { return !m; }))
64 localOnes.resize(node.size(), 1);
74 std::map<typename Basis::MultiIndex, typename Coeff::value_type> coeffMap;
75 std::map<typename Basis::MultiIndex, std::uint8_t> counterMap;
77 std::vector<typename Coeff::value_type> localCoeffs;
78 std::vector<typename Counter::value_type> localCounter;
80 for (
const auto& e : entitySet(basis_))
84 auto&& node = Dune::TypeTree::child(localView.tree(),treePath_);
85 counter.gather(localView, node, localCounter);
86 coeff0.gather(localView, node, localCoeffs);
88 for (std::size_t i = 0; i < node.size(); ++i) {
89 if (localCounter[i] > 0) {
90 auto idx = localView.index(node.localIndex(i));
91 coeffMap[idx] = localCoeffs[i];
92 counterMap[idx] = localCounter[i];
97 assert(coeffMap.size() == counterMap.size());
100 auto value_it = coeffMap.begin();
101 auto count_it = counterMap.begin();
102 for (; value_it != coeffMap.end(); ++value_it, ++count_it) {
103 assert(count_it->second > 0);
104 coeff.set(value_it->first, value_it->second/
double(count_it->second));
109 template <
class Coeff,
class Gr
idFct>
110 void operator()(Coeff& coeff, GridFct
const& gf)
const
117 , treePath_{treePath}
121 TreePath treePath_ = {};
128 template <
class Basis,
129 class TreePath = Dune::TypeTree::HybridTreePath<>>
130 static auto create(Basis
const& basis, TreePath treePath = {})
A container-like data-structure not storing anything and with empty implementations in many container...
Definition: FakeContainer.hpp:36
Definition: Assigner.hpp:17
Definition: AverageInterpolator.hpp:25
Definition: HierarchicNodeToRangeMap.hpp:42
Definition: SimpleInterpolator.hpp:80
Definition: AverageInterpolator.hpp:19