3 #ifndef DUNE_PDELAB_DATAHANDLEPROVIDER_HH
4 #define DUNE_PDELAB_DATAHANDLEPROVIDER_HH
9 #include <dune/common/static_assert.hh>
10 #include <dune/common/typetraits.hh>
11 #include <dune/common/reservedvector.hh>
12 #include <dune/common/std/constexpr.hh>
13 #include <dune/typetree/visitor.hh>
22 template<
typename EntityIndex>
23 struct get_size_for_entity
24 :
public TypeTree::TreeVisitor
25 ,
public TypeTree::DynamicTraversal
28 template<
typename Ordering,
typename TreePath>
29 void leaf(
const Ordering& ordering, TreePath tp)
34 get_size_for_entity(
const EntityIndex& entity_index)
39 std::size_t size()
const
52 template<
typename EntityIndex,
typename OffsetIterator>
53 struct get_leaf_offsets_for_entity
54 :
public TypeTree::TreeVisitor
55 ,
public TypeTree::DynamicTraversal
58 template<
typename Ordering,
typename TreePath>
59 void leaf(
const Ordering& ordering, TreePath tp)
64 get_leaf_offsets_for_entity(
const EntityIndex& entity_index, OffsetIterator oit)
70 OffsetIterator offsetIterator()
const
83 template<
typename DOFIndex,
typename ContainerIndex, std::
size_t tree_depth,
bool map_dof_indices = false>
84 struct indices_for_entity
85 :
public TypeTree::TreeVisitor
86 ,
public TypeTree::DynamicTraversal
89 typedef std::size_t size_type;
91 typedef typename std::vector<ContainerIndex>::iterator CIIterator;
92 typedef typename std::conditional<
94 typename std::vector<DOFIndex>::iterator,
99 template<
typename Ordering,
typename Child,
typename TreePath,
typename ChildIndex>
100 void beforeChild(
const Ordering& ordering,
const Child& child, TreePath tp, ChildIndex childIndex)
105 template<
typename Ordering,
typename TreePath>
106 void leaf(
const Ordering& ordering, TreePath tp)
108 size_type size = ordering.extract_entity_indices(
_entity_index,
120 template<
typename Ordering,
typename Child,
typename TreePath,
typename ChildIndex>
121 void afterChild(
const Ordering& ordering,
const Child& child, TreePath tp, ChildIndex childIndex)
129 if (Ordering::consume_tree_index)
130 for (DIIterator it =
_stack.top().second;
133 it->treeIndex().push_back(childIndex);
139 indices_for_entity(
const EntityIndex& entity_index,
141 DIIterator di_begin = DIIterator())
151 CIIterator ci_end()
const
157 DIIterator di_end()
const
188 template<
typename GFS>
203 return gfs().ordering().contains(codim);
209 return gfs().ordering().fixedSize(codim);
236 template<
typename Entity>
239 typedef typename GFS::Ordering Ordering;
241 typedef typename Ordering::Traits::DOFIndex::EntityIndex EntityIndex;
244 Ordering::Traits::DOFIndexAccessor::GeometryIndex::store(
247 gfs().gridView().indexSet().index(e)
250 get_size_for_entity<EntityIndex> get_size(ei);
251 TypeTree::applyToTree(
gfs().ordering(),get_size);
253 return get_size.size();
256 template<
typename V,
typename EntityIndex>
260 for (
typename V::iterator it = v.begin(),
265 it->treeIndex().clear();
266 it->entityIndex() = ei;
270 template<
typename V,
typename EntityIndex>
287 template<
typename Entity,
typename ContainerIndex,
typename DOFIndex,
typename OffsetIterator,
bool map_dof_indices>
289 std::vector<ContainerIndex>& container_indices,
290 std::vector<DOFIndex>& dof_indices,
292 std::integral_constant<bool,map_dof_indices> map_dof_indices_value
295 typedef typename GFS::Ordering Ordering;
298 "dataHandleContainerIndices() called with invalid ContainerIndex type.");
300 typedef typename Ordering::Traits::DOFIndex::EntityIndex EntityIndex;
303 Ordering::Traits::DOFIndexAccessor::GeometryIndex::store(
306 gfs().gridView().indexSet().index(e)
309 get_leaf_offsets_for_entity<EntityIndex,OffsetIterator> get_offsets(ei,oit);
310 TypeTree::applyToTree(
gfs().ordering(),get_offsets);
311 OffsetIterator end_oit = oit + (TypeTree::TreeInfo<Ordering>::leafCount + 1);
314 std::partial_sum(oit,end_oit,oit);
315 size_type size = *(oit + TypeTree::TreeInfo<Ordering>::leafCount);
317 container_indices.resize(size);
319 for (
typename std::vector<ContainerIndex>::iterator it = container_indices.begin(),
320 endit = container_indices.end();
330 TypeTree::TreeInfo<Ordering>::depth,
332 > extract_indices(ei,container_indices.begin(),
dof_indices_begin(dof_indices,map_dof_indices_value));
333 TypeTree::applyToTree(
gfs().ordering(),extract_indices);
341 return static_cast<const GFS&
>(*this);
349 #endif // DUNE_PDELAB_DATAHANDLEPROVIDER
Definition: dofindex.hh:14
DIIterator _di_end
Definition: datahandleprovider.hh:168
std::size_t size_type
Definition: datahandleprovider.hh:194
DummyDOFIndexIterator dof_indices_begin(V &v, std::integral_constant< bool, false >) const
Definition: datahandleprovider.hh:281
V::iterator dof_indices_begin(V &v, std::integral_constant< bool, true >) const
Definition: datahandleprovider.hh:275
const EntityIndex & _entity_index
Definition: datahandleprovider.hh:47
std::stack< std::pair< CIIterator, DIIterator >, ReservedVector< std::pair< CIIterator, DIIterator >, tree_depth > > _stack
Definition: datahandleprovider.hh:182
DUNE_CONSTEXPR bool sendLeafSizes() const
Returns true if the sizes of the leaf orderings in this tree should be sent as part of the communcati...
Definition: datahandleprovider.hh:227
CIIterator _ci_end
Definition: datahandleprovider.hh:166
void dataHandleIndices(const Entity &e, std::vector< ContainerIndex > &container_indices, std::vector< DOFIndex > &dof_indices, OffsetIterator oit, std::integral_constant< bool, map_dof_indices > map_dof_indices_value) const
return vector of global indices associated with the given entity
Definition: datahandleprovider.hh:288
void setup_dof_indices(V &v, size_type n, const EntityIndex &ei, std::integral_constant< bool, false >) const
Definition: datahandleprovider.hh:271
bool dataHandleContains(int codim) const
returns true if data for this codim should be communicated
Definition: datahandleprovider.hh:201
void setup_dof_indices(V &v, size_type n, const EntityIndex &ei, std::integral_constant< bool, true >) const
Definition: datahandleprovider.hh:257
Dummy iterator type over DOF indices.
Definition: ordering/utility.hh:287
bool dataHandleFixedSize(int codim) const
returns true if size per entity of given dim and codim is a constant
Definition: datahandleprovider.hh:207
std::size_t _size
Definition: datahandleprovider.hh:46
size_type dataHandleSize(const Entity &e) const
Definition: datahandleprovider.hh:237
array< T, entity_capacity > EntityIndex
Definition: dofindex.hh:23
static const unsigned int value
Definition: gridfunctionspace/tags.hh:175
Definition: datahandleprovider.hh:189
DIIterator _di_it
Definition: datahandleprovider.hh:167
const GFS & gfs() const
Definition: datahandleprovider.hh:339
CIIterator _ci_it
Definition: datahandleprovider.hh:165
const E & e
Definition: interpolate.hh:172
OffsetIterator _oit
Definition: datahandleprovider.hh:77