3 #ifndef DUNE_PDELAB_DATAHANDLEPROVIDER_HH 4 #define DUNE_PDELAB_DATAHANDLEPROVIDER_HH 9 #include <dune/common/typetraits.hh> 10 #include <dune/common/reservedvector.hh> 11 #include <dune/common/std/constexpr.hh> 12 #include <dune/typetree/visitor.hh> 21 template<
typename EntityIndex>
22 struct get_size_for_entity
23 :
public TypeTree::TreeVisitor
24 ,
public TypeTree::DynamicTraversal
27 template<
typename Ordering,
typename TreePath>
28 void leaf(
const Ordering& ordering, TreePath tp)
30 _size += ordering.size(_entity_index);
33 get_size_for_entity(
const EntityIndex& entity_index)
35 , _entity_index(entity_index)
38 std::size_t size()
const 46 const EntityIndex& _entity_index;
51 template<
typename EntityIndex,
typename OffsetIterator>
52 struct get_leaf_offsets_for_entity
53 :
public TypeTree::TreeVisitor
54 ,
public TypeTree::DynamicTraversal
57 template<
typename Ordering,
typename TreePath>
58 void leaf(
const Ordering& ordering, TreePath tp)
60 *(++_oit) = ordering.size(_entity_index);
63 get_leaf_offsets_for_entity(
const EntityIndex& entity_index, OffsetIterator oit)
65 , _entity_index(entity_index)
69 OffsetIterator offsetIterator()
const 77 const EntityIndex& _entity_index;
82 template<
typename DOFIndex,
typename ContainerIndex, std::
size_t tree_depth,
bool map_dof_indices = false>
83 struct indices_for_entity
84 :
public TypeTree::TreeVisitor
85 ,
public TypeTree::DynamicTraversal
88 typedef std::size_t size_type;
90 typedef typename std::vector<ContainerIndex>::iterator CIIterator;
91 typedef typename std::conditional<
93 typename std::vector<DOFIndex>::iterator,
98 template<
typename Ordering,
typename Child,
typename TreePath,
typename ChildIndex>
99 void beforeChild(
const Ordering& ordering,
const Child& child, TreePath tp, ChildIndex childIndex)
101 _stack.push(std::make_pair(_ci_it,_di_it));
104 template<
typename Ordering,
typename TreePath>
105 void leaf(
const Ordering& ordering, TreePath tp)
107 size_type size = ordering.extract_entity_indices(_entity_index,
119 template<
typename Ordering,
typename Child,
typename TreePath,
typename ChildIndex>
120 void afterChild(
const Ordering& ordering,
const Child& child, TreePath tp, ChildIndex childIndex)
123 ordering.extract_entity_indices(_entity_index,
128 if (Ordering::consume_tree_index)
129 for (DIIterator it = _stack.top().second;
132 it->treeIndex().push_back(childIndex);
138 indices_for_entity(
const EntityIndex& entity_index,
140 DIIterator di_begin = DIIterator())
141 : _entity_index(entity_index)
150 CIIterator ci_end()
const 156 DIIterator di_end()
const 163 const EntityIndex& _entity_index;
187 template<
typename GFS>
202 return gfs().ordering().contains(codim);
208 return gfs().ordering().fixedSize(codim);
235 template<
typename Entity>
238 typedef typename GFS::Ordering Ordering;
240 typedef typename Ordering::Traits::DOFIndex::EntityIndex EntityIndex;
243 Ordering::Traits::DOFIndexAccessor::GeometryIndex::store(
246 gfs().gridView().indexSet().index(e)
249 get_size_for_entity<EntityIndex> get_size(ei);
250 TypeTree::applyToTree(gfs().ordering(),get_size);
252 return get_size.size();
255 template<
typename V,
typename EntityIndex>
256 void setup_dof_indices(V& v, size_type n,
const EntityIndex& ei, std::integral_constant<bool,true>)
const 259 for (
typename V::iterator it = v.begin(),
264 it->treeIndex().clear();
265 it->entityIndex() = ei;
269 template<
typename V,
typename EntityIndex>
270 void setup_dof_indices(V& v, size_type n,
const EntityIndex& ei, std::integral_constant<bool,false>)
const 286 template<
typename Entity,
typename ContainerIndex,
typename DOFIndex,
typename OffsetIterator,
bool map_dof_indices>
288 std::vector<ContainerIndex>& container_indices,
289 std::vector<DOFIndex>& dof_indices,
291 std::integral_constant<bool,map_dof_indices> map_dof_indices_value
294 typedef typename GFS::Ordering Ordering;
297 "dataHandleContainerIndices() called with invalid ContainerIndex type.");
299 typedef typename Ordering::Traits::DOFIndex::EntityIndex EntityIndex;
302 Ordering::Traits::DOFIndexAccessor::GeometryIndex::store(
305 gfs().entitySet().indexSet().index(e)
308 get_leaf_offsets_for_entity<EntityIndex,OffsetIterator> get_offsets(ei,oit);
309 TypeTree::applyToTree(gfs().ordering(),get_offsets);
310 OffsetIterator end_oit = oit + (TypeTree::TreeInfo<Ordering>::leafCount + 1);
313 std::partial_sum(oit,end_oit,oit);
314 size_type size = *(oit + TypeTree::TreeInfo<Ordering>::leafCount);
316 container_indices.resize(size);
318 for (
typename std::vector<ContainerIndex>::iterator it = container_indices.begin(),
319 endit = container_indices.end();
324 setup_dof_indices(dof_indices,size,ei,map_dof_indices_value);
329 TypeTree::TreeInfo<Ordering>::depth,
331 > extract_indices(ei,container_indices.begin(),dof_indices_begin(dof_indices,map_dof_indices_value));
332 TypeTree::applyToTree(gfs().ordering(),extract_indices);
340 return static_cast<const GFS&
>(*this);
348 #endif // DUNE_PDELAB_DATAHANDLEPROVIDER void setup_dof_indices(V &v, size_type n, const EntityIndex &ei, std::integral_constant< bool, false >) const
Definition: datahandleprovider.hh:270
bool dataHandleContains(int codim) const
returns true if data for this codim should be communicated
Definition: datahandleprovider.hh:200
std::array< T, entity_capacity > EntityIndex
Definition: dofindex.hh:157
static const unsigned int value
Definition: gridfunctionspace/tags.hh:177
Dummy iterator type over DOF indices.
Definition: ordering/utility.hh:288
size_type dataHandleSize(const Entity &e) const
Definition: datahandleprovider.hh:236
Definition: adaptivity.hh:27
const GFS & gfs() const
Definition: datahandleprovider.hh:338
Definition: datahandleprovider.hh:188
const Entity & e
Definition: localfunctionspace.hh:111
V::iterator dof_indices_begin(V &v, std::integral_constant< bool, true >) const
Definition: datahandleprovider.hh:274
std::size_t size_type
Definition: datahandleprovider.hh:193
DummyDOFIndexIterator dof_indices_begin(V &v, std::integral_constant< bool, false >) const
Definition: datahandleprovider.hh:280
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:226
A multi-index representing a degree of freedom in a GridFunctionSpace.
Definition: dofindex.hh:146
void setup_dof_indices(V &v, size_type n, const EntityIndex &ei, std::integral_constant< bool, true >) const
Definition: datahandleprovider.hh:256
bool dataHandleFixedSize(int codim) const
returns true if size per entity of given dim and codim is a constant
Definition: datahandleprovider.hh:206
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:287