27#ifndef EWOMS_PFF_GRID_VECTOR_HH
28#define EWOMS_PFF_GRID_VECTOR_HH
32#include <dune/grid/common/mcmgmapper.hh>
33#include <dune/common/version.hh>
47template <
class Gr
idView,
class Stencil,
class Data,
class DofMapper>
50 using Element =
typename GridView::template Codim<0>::Entity;
52 using ElementMapper = Dune::MultipleCodimMultipleGeomTypeMapper<GridView>;
57 , elementMapper_(gridView_,
Dune::mcmgElementLayout())
58 , dofMapper_(dofMapper)
61 template <
class 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;
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_;
A random-access container which stores data attached to a grid's degrees of freedom in a prefetch fri...
Definition: pffgridvector.hh:49
void prefetch(const Element &elem) const
Definition: pffgridvector.hh:90
const Data & get(const Element &elem, unsigned localDofIdx) const
Definition: pffgridvector.hh:99
PffGridVector(const GridView &gridView, const DofMapper &dofMapper)
Definition: pffgridvector.hh:55
void update(const DistFn &distFn)
Definition: pffgridvector.hh:62
Definition: fvbaseprimaryvariables.hh:141
Definition: blackoilboundaryratevector.hh:37
void prefetch(const T &val, unsigned n=1)
Template function which emits prefetch instructions for a range of memory.
Definition: prefetch.hh:38