50 using Element =
typename GridView::template Codim<0>::Entity;
52 using ElementMapper = Dune::MultipleCodimMultipleGeomTypeMapper<GridView>;
55 PffGridVector(
const GridView& gridView,
const DofMapper& dofMapper)
57 , elementMapper_(gridView_, Dune::mcmgElementLayout())
58 , dofMapper_(dofMapper)
61 template <
class DistFn>
62 void update(
const DistFn& distFn)
64 unsigned numElements = gridView_.size(0);
65 unsigned numLocalDofs = computeNumLocalDofs_();
67 elemData_.resize(numElements);
68 data_.resize(numLocalDofs);
72 Data *curElemDataPtr = &data_[0];
73 Stencil stencil(gridView_, dofMapper_);
74 for (
const auto& elem : elements(gridView_)) {
76 unsigned elemIdx = elementMapper_.index(elem);
77 elemData_[elemIdx] = curElemDataPtr;
80 unsigned numDof = stencil.numDof();
81 for (
unsigned localDofIdx = 0; localDofIdx < numDof; ++ localDofIdx)
82 distFn(curElemDataPtr[localDofIdx], stencil, localDofIdx);
86 curElemDataPtr += numDof;
90 void prefetch(
const Element& elem)
const
92 unsigned elemIdx = elementMapper_.index(elem);
99 const Data& get(
const Element& elem,
unsigned localDofIdx)
const
101 unsigned elemIdx = elementMapper_.index(elem);
102 return elemData_[elemIdx][localDofIdx];
106 unsigned computeNumLocalDofs_()
const
111 Stencil stencil(gridView_, dofMapper_);
112 for (
const auto& elem : elements(gridView_)) {
113 stencil.update(elem);
114 result += stencil.numDof();
121 ElementMapper elementMapper_;
122 const DofMapper& dofMapper_;
123 std::vector<Data> data_;
124 std::vector<Data*> elemData_;
void prefetch(const T &val, unsigned n=1)
Template function which emits prefetch instructions for a range of memory.
Definition prefetch.hh:38