dune-pdelab  2.0.0
gridviewordering.hh
Go to the documentation of this file.
1 // -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=8 sw=2 sts=2:
3 
4 #ifndef DUNE_PDELAB_ORDERING_GRIDVIEWORDERING_HH
5 #define DUNE_PDELAB_ORDERING_GRIDVIEWORDERING_HH
6 
7 #include <dune/typetree/typetree.hh>
8 
15 
16 namespace Dune {
17  namespace PDELab {
18 
21 
23  : public TypeTree::TreeVisitor
24  , public TypeTree::DynamicTraversal
25  {
26 
27  template<typename Node, typename TreePath>
28  void leaf(Node& node, TreePath tp)
29  {
30  node.update_a_priori_fixed_size();
31  any = any || node._fixed_size;
32  all = all && node._fixed_size;
33  }
34 
35  template<typename Node, typename TreePath>
36  void pre(Node& node, TreePath tp) const
37  {
38  node._fixed_size = true;
39  }
40 
41  template<typename Node, typename Child, typename TreePath, typename ChildIndex>
42  void afterChild(Node& node, const Child& child, TreePath tp, ChildIndex childIndex) const
43  {
44  node._fixed_size = node._fixed_size && child._fixed_size;
45  }
46 
48  : any(false)
49  , all(true)
50  {}
51 
52  bool any;
53  bool all;
54 
55  };
56 
57 
58  template<typename GV>
60  : public TypeTree::TreeVisitor
61  , public TypeTree::DynamicTraversal
62  {
63 
64  typedef std::vector<Dune::GeometryType> GTVector;
65 
66  template<typename Node, typename TreePath>
67  void leaf(Node& node, TreePath tp) const
68  {
69  if (node._fixed_size)
70  {
71  typedef typename Node::Traits::SizeType size_type;
72  const size_type dim = GV::dimension;
73  node._codim_used.reset();
74  node._gt_used.assign(GlobalGeometryTypeIndex::size(dim),false);
75  node._gt_dof_offsets.assign(GlobalGeometryTypeIndex::size(dim),0);
76  for (GTVector::const_iterator it = geom_types.begin(); it != geom_types.end(); ++it)
77  {
78  size_type size = node.finiteElementMap().size(*it);
79  node._gt_dof_offsets[GlobalGeometryTypeIndex::index(*it)] = size;
80  node._gt_used[GlobalGeometryTypeIndex::index(*it)] = size > 0;
81  node._codim_used[dim - it->dim()] = node._codim_used[dim - it->dim()] || (size > 0);
82  }
83  node._max_local_size = node.finiteElementMap().maxLocalSize();
84  }
85  }
86 
87  template<typename Node, typename TreePath>
88  void pre(Node& node, TreePath tp) const
89  {
90  if (node._fixed_size)
91  {
92  typedef typename Node::Traits::SizeType size_type;
93  const size_type dim = GV::dimension;
94  node._codim_used.reset();
95  node._gt_used.assign(Dune::GlobalGeometryTypeIndex::size(dim),false);
96  node._gt_dof_offsets.assign(Dune::GlobalGeometryTypeIndex::size(dim) * Node::CHILDREN,0);
97  node._max_local_size = 0;
98  }
99  }
100 
101  template<typename Node, typename Child, typename TreePath, typename ChildIndex>
102  void afterChild(Node& node, const Child& child, TreePath tp, ChildIndex childIndex) const
103  {
104  if (node._fixed_size)
105  {
106  node._codim_used |= child._codim_used;
107 
108  std::transform(node._gt_used.begin(),
109  node._gt_used.end(),
110  child._gt_used.begin(),
111  node._gt_used.begin(),
112  std::logical_or<bool>());
113 
114  node._max_local_size += child._max_local_size;
115 
116  typedef typename Node::Traits::SizeType size_type;
117 
118  const size_type per_gt_size = child._child_count > 0 ? child._child_count : 1;
119  const size_type size_offset = child._child_count > 0 ? child._child_count - 1 : 0;
120 
121  for (size_type gt = 0; gt < Dune::GlobalGeometryTypeIndex::size(GV::dimension); ++gt)
122  node._gt_dof_offsets[gt * Node::CHILDREN + childIndex] = child._gt_dof_offsets[gt * per_gt_size + size_offset];
123  }
124  }
125 
126  template<typename Node, typename TreePath>
127  void post(Node& node, TreePath tp) const
128  {
129  if (node._fixed_size)
130  {
131  typedef typename std::vector<typename Node::Traits::SizeType>::iterator iterator;
132 
133  iterator next_gt_it = node._gt_dof_offsets.begin() + Node::CHILDREN;
134  const iterator end_it = node._gt_dof_offsets.end();
135 
136  for (iterator it = node._gt_dof_offsets.begin();
137  it != end_it;
138  it += Node::CHILDREN, next_gt_it += Node::CHILDREN)
139  std::partial_sum(it,next_gt_it,it);
140  }
141  }
142 
143  update_fixed_size(const GV gv_, const GTVector& geom_types_)
144  : gv(gv_)
145  , geom_types(geom_types_)
146  {}
147 
148  GV gv;
150 
151  };
152 
153 
155  : public TypeTree::TreeVisitor
156  , public TypeTree::DynamicTraversal
157  {
158 
159  template<typename Node, typename TreePath>
160  void leaf(Node& node, TreePath tp) const
161  {
162  if (!node._fixed_size)
163  {
164  node._codim_used.reset();
165  node._gt_used.assign(Dune::GlobalGeometryTypeIndex::size(dim),false);
166  node._gt_dof_offsets.assign(Dune::GlobalGeometryTypeIndex::size(dim) * std::max(node._child_count,static_cast<std::size_t>(1)),0);
167  node._gt_entity_offsets.assign(Dune::GlobalGeometryTypeIndex::size(dim) + 1,0);
168  }
169  }
170 
171  template<typename Node, typename TreePath>
172  void pre(Node& node, TreePath tp) const
173  {
174  leaf(node,tp);
175  }
176 
177  pre_collect_used_geometry_types(std::size_t dimension)
178  : dim(dimension)
179  {}
180 
181  const std::size_t dim;
182 
183  };
184 
185 
186  template<typename Cell>
188  : public TypeTree::TreeVisitor
189  , public TypeTree::DynamicTraversal
190  {
191 
192  template<typename Node, typename TreePath>
193  void leaf(Node& node, TreePath tp) const
194  {
195  if (!node._fixed_size)
196  node.collect_used_geometry_types_from_cell(cell);
197  }
198 
200  : cell(cell_)
201  , ref_el(Dune::ReferenceElements<typename Cell::Geometry::ctype,Cell::dimension>::general(cell_.type()))
202  {}
203 
204  const Cell& cell;
205  const Dune::ReferenceElement<typename Cell::Geometry::ctype,Cell::dimension>& ref_el;
206 
207  };
208 
209 
210  template<typename GV>
212  : public TypeTree::TreeVisitor
213  , public TypeTree::DynamicTraversal
214  {
215 
216  typedef std::vector<Dune::GeometryType> GTVector;
217 
218 
219  template<typename Node, typename TreePath>
220  void leaf(Node& node, TreePath tp) const
221  {
222  if (!node._fixed_size)
223  {
224  typedef typename Node::Traits::SizeType size_type;
225 
226  for (GTVector::const_iterator it = geom_types.begin(); it != geom_types.end(); ++it)
227  {
228  if (node._gt_used[Dune::GlobalGeometryTypeIndex::index(*it)])
229  node._gt_entity_offsets[Dune::GlobalGeometryTypeIndex::index(*it) + 1] = gv.indexSet().size(*it);
230  }
231 
232  std::partial_sum(node._gt_entity_offsets.begin(),node._gt_entity_offsets.end(),node._gt_entity_offsets.begin());
233  node._entity_dof_offsets.assign(node._gt_entity_offsets.back() * std::max(node._child_count,static_cast<size_type>(1)),0);
234  node.setup_fixed_size_possible();
235  }
236  }
237 
238  template<typename Node, typename Child, typename TreePath, typename ChildIndex>
239  void afterChild(Node& node, const Child& child, TreePath tp, ChildIndex childIndex) const
240  {
241  if (!node._fixed_size)
242  {
243  node._codim_used |= child._codim_used;
244 
245  std::transform(node._gt_used.begin(),
246  node._gt_used.end(),
247  child._gt_used.begin(),
248  node._gt_used.begin(),
249  std::logical_or<bool>());
250  }
251  }
252 
253  template<typename Node, typename TreePath>
254  void post(Node& node, TreePath tp) const
255  {
256  leaf(node,tp);
257  }
258 
259  post_collect_used_geometry_types(const GV& gv_, const GTVector& geom_types_)
260  : gv(gv_)
261  , geom_types(geom_types_)
262  {}
263 
264  GV gv;
266 
267  };
268 
269 
270  template<typename GV>
272  : public TypeTree::TreeVisitor
273  , public TypeTree::DynamicTraversal
274  {
275 
276  static const std::size_t dim = GV::dimension;
277  typedef typename GV::template Codim<0>::Entity Cell;
278  typedef std::size_t size_type;
279 
280  template<typename Node, typename TreePath>
281  void leaf(Node& node, TreePath tp)
282  {
283  if (!node._fixed_size)
284  node.extract_per_entity_sizes_from_cell(*cell,gt_sizes);
285  }
286 
288  : gv(gv_)
289  , cell(nullptr)
290  , ref_el(nullptr)
291  , gt_sizes(Dune::GlobalGeometryTypeIndex::size(dim),0)
292  {}
293 
294  void set_cell(const Cell& cell_)
295  {
296  cell = &cell_;
297  ref_el = &(Dune::ReferenceElements<typename GV::ctype,dim>::general(cell_.type()));
298  }
299 
300  GV gv;
301  const Cell* cell;
302  const Dune::ReferenceElement<typename GV::ctype,dim>* ref_el;
303  std::vector<size_type> gt_sizes;
304 
305  };
306 
307 
308  template<typename GV>
310  : public TypeTree::TreeVisitor
311  , public TypeTree::DynamicTraversal
312  {
313 
314  typedef std::vector<GeometryType> GTVector;
315 
316 
317  template<typename Node, typename TreePath>
318  void leaf(Node& node, TreePath tp) const
319  {
320  if (!node._fixed_size)
321  {
322  if (node._fixed_size_possible)
323  {
324  node._entity_dof_offsets = std::vector<typename Node::Traits::SizeType>();
325  node._fixed_size = true;
326  }
327  }
328  }
329 
330  template<typename Node, typename TreePath>
331  void pre(Node& node, TreePath tp) const
332  {
333  if (!node._fixed_size)
334  {
335  node._fixed_size_possible = true;
336  node._max_local_size = 0;
337  }
338  }
339 
340 
341  template<typename Node, typename Child, typename TreePath, typename ChildIndex>
342  void afterChild(Node& node, const Child& child, TreePath tp, ChildIndex childIndex) const
343  {
344  if (!node._fixed_size)
345  {
346  node._fixed_size_possible = node._fixed_size_possible && child._fixed_size;
347  node._max_local_size += child._max_local_size;
348  }
349  }
350 
351 
352  template<typename Node, typename TreePath>
353  void post(Node& node, TreePath tp) const
354  {
355  if (!node._fixed_size)
356  {
357 
358  typedef typename Node::Traits::SizeType size_type;
359  const size_type dim = GV::dimension;
360 
361  if (node._fixed_size_possible)
362  {
363 
364  for (size_type gt = 0; gt < GlobalGeometryTypeIndex::size(GV::dimension); ++gt)
365  {
366  for (size_type child_index = 0; child_index < Node::CHILDREN; ++child_index)
367  {
368  const size_type per_gt_size = node.childOrdering(child_index)._child_count > 0 ? node.childOrdering(child_index)._child_count : 1;
369  const size_type size_offset = node.childOrdering(child_index)._child_count > 0 ? node.childOrdering(child_index)._child_count - 1 : 0;
370 
371  node._gt_dof_offsets[gt * Node::CHILDREN + child_index] = node.childOrdering(child_index)._gt_dof_offsets[gt * per_gt_size + size_offset];
372  }
373  }
374 
375  typedef typename std::vector<typename Node::Traits::SizeType>::iterator iterator;
376 
377  const iterator end_it = node._gt_dof_offsets.end();
378 
379  for (iterator it = node._gt_dof_offsets.begin();
380  it != end_it;
381  it += Node::CHILDREN)
382  std::partial_sum(it,it + Node::CHILDREN,it);
383 
384  node._fixed_size = true;
385  }
386  else
387  {
388  typedef typename Node::Traits::SizeType size_type;
389 
390  size_type index = 0;
391  for (size_type geometry_type_index = 0; geometry_type_index < GlobalGeometryTypeIndex::size(dim); ++geometry_type_index)
392  {
393  if (!node._gt_used[geometry_type_index])
394  continue;
395  const size_type entity_count = node._gt_entity_offsets[geometry_type_index+1] - node._gt_entity_offsets[geometry_type_index];
396  for (size_type entity_index = 0; entity_index < entity_count; ++entity_index)
397  {
398  size_type carry = 0;
399  for (size_type child_index = 0; child_index < Node::CHILDREN; ++child_index)
400  node._entity_dof_offsets[index++] = (carry += node.childOrdering(child_index).size(geometry_type_index,entity_index));
401  }
402  }
403 
404  }
405  }
406  }
407 
408  post_extract_per_entity_sizes(const GV& gv_, const GTVector& geom_types_)
409  : gv(gv_)
410  , geom_types(geom_types_)
411  {}
412 
413  GV gv;
415 
416  };
417 
418 
419  template<typename LocalOrdering>
421  : public TypeTree::VariadicCompositeNode<LocalOrdering>
422  , public VirtualOrderingBase<typename LocalOrdering::Traits::DOFIndex,
423  typename LocalOrdering::Traits::ContainerIndex>
424  , public OrderingBase<typename LocalOrdering::Traits::DOFIndex,
425  typename LocalOrdering::Traits::ContainerIndex>
426  {
427  public:
428  typedef typename LocalOrdering::Traits Traits;
429 
430  static const bool has_dynamic_ordering_children = false;
431 
432  static const bool consume_tree_index = false;
433 
434  private:
435 
436  typedef TypeTree::VariadicCompositeNode<LocalOrdering> NodeT;
437  typedef OrderingBase<
438  typename LocalOrdering::Traits::DOFIndex,
439  typename LocalOrdering::Traits::ContainerIndex
440  > BaseT;
441 
442  typedef typename Traits::GridView GV;
443 
444  public:
446 
451  GridViewOrdering(const typename NodeT::NodeStorage& local_ordering, bool container_blocked, typename BaseT::GFSData* gfs_data)
452  : NodeT(local_ordering)
453  , BaseT(*this,container_blocked,gfs_data,this)
454  , _gv(localOrdering().gridView())
455  {
456  // make sure to switch off container blocking handling in the local ordering,
457  // we already handle it in the GridViewOrdering
458  localOrdering().disable_container_blocking();
459  // manually copy grid partition information from the local ordering, as this isn't handled
460  // automatically by LocalOrdering in this case
462  }
463 
464 #ifndef DOXYGEN
465 
466 // we need to override the default copy / move ctor to fix the delegate pointer, but that is
467 // hardly interesting to our users...
468 
470  : NodeT(r.nodeStorage())
471  , BaseT(r)
472  , _gv(r._gv)
473  , _gt_dof_offsets(r._gt_dof_offsets)
474  , _gt_entity_offsets(r._gt_entity_offsets)
475  , _entity_dof_offsets(r._entity_dof_offsets)
476  {
477  this->setDelegate(this);
478  }
479 
480 #if HAVE_RVALUE_REFERENCES
481 
483  : NodeT(r.nodeStorage())
484  , BaseT(std::move(r))
485  , _gv(std::move(r._gv))
486  , _gt_dof_offsets(std::move(r._gt_dof_offsets))
487  , _gt_entity_offsets(std::move(r._gt_entity_offsets))
488  , _entity_dof_offsets(std::move(r._entity_dof_offsets))
489  {
490  this->setDelegate(this);
491  }
492 
493 #endif // HAVE_RVALUE_REFERENCES
494 
495 #endif // DOXYGEN
496 
497  LocalOrdering& localOrdering()
498  {
499  return this->template child<0>();
500  }
501 
502  const LocalOrdering& localOrdering() const
503  {
504  return this->template child<0>();
505  }
506 
507  virtual void map_index_dynamic(typename Traits::DOFIndexView di, typename Traits::ContainerIndex& ci) const
508  {
509  mapIndex(di,ci);
510  }
511 
512  typename Traits::ContainerIndex mapIndex(const typename Traits::DOFIndex& di) const
513  {
514  typename Traits::ContainerIndex ci;
515  mapIndex(di.view(),ci);
516  return ci;
517  }
518 
519  void mapIndex(typename Traits::DOFIndexView di, typename Traits::ContainerIndex& ci) const
520  {
521  typedef typename Traits::SizeType size_type;
522  const size_type geometry_type_index = Traits::DOFIndexAccessor::geometryType(di);
523  const size_type entity_index = Traits::DOFIndexAccessor::entityIndex(di);
524  localOrdering().map_local_index(geometry_type_index,entity_index,di.treeIndex(),ci);
525  if (_container_blocked)
526  {
527  if (_fixed_size)
528  {
529  ci.push_back(_gt_dof_offsets[geometry_type_index] + entity_index);
530  }
531  else
532  {
533  ci.push_back(_gt_entity_offsets[geometry_type_index] + entity_index);
534  }
535  }
536  else
537  {
538  if (_fixed_size)
539  {
540  ci.back() += _gt_dof_offsets[geometry_type_index] + entity_index * localOrdering().size(geometry_type_index,entity_index);
541  }
542  else
543  {
544  ci.back() += _entity_dof_offsets[_gt_entity_offsets[geometry_type_index] + entity_index];
545  }
546  }
547  }
548 
549  template<typename ItIn, typename ItOut>
550  void map_lfs_indices(const ItIn begin, const ItIn end, ItOut out) const
551  {
552  typedef typename Traits::SizeType size_type;
553  if (_container_blocked)
554  {
555  if (_fixed_size)
556  for (ItIn in = begin; in != end; ++in, ++out)
557  {
558  const size_type geometry_type_index = Traits::DOFIndexAccessor::geometryType(*in);
559  const size_type entity_index = Traits::DOFIndexAccessor::entityIndex(*in);
560  out->push_back(_gt_dof_offsets[geometry_type_index] + entity_index);
561  }
562  else
563  for (ItIn in = begin; in != end; ++in, ++out)
564  {
565  const size_type geometry_type_index = Traits::DOFIndexAccessor::geometryType(*in);
566  const size_type entity_index = Traits::DOFIndexAccessor::entityIndex(*in);
567  out->push_back(_gt_entity_offsets[geometry_type_index] + entity_index);
568  }
569  }
570  else if (_fixed_size)
571  {
572  for (ItIn in = begin; in != end; ++in, ++out)
573  {
574  const size_type geometry_type_index = Traits::DOFIndexAccessor::geometryType(*in);
575  const size_type entity_index = Traits::DOFIndexAccessor::entityIndex(*in);
576  out->back() += _gt_dof_offsets[geometry_type_index] + entity_index * localOrdering().size(geometry_type_index,entity_index);
577  }
578  }
579  else
580  {
581  for (ItIn in = begin; in != end; ++in, ++out)
582  {
583  const size_type geometry_type_index = Traits::DOFIndexAccessor::geometryType(*in);
584  const size_type entity_index = Traits::DOFIndexAccessor::entityIndex(*in);
585  out->back() += _entity_dof_offsets[_gt_entity_offsets[geometry_type_index] + entity_index];
586  }
587  }
588  }
589 
590  template<typename CIOutIterator>
591  typename Traits::SizeType
592  extract_entity_indices(const typename Traits::DOFIndex::EntityIndex& ei,
593  typename Traits::SizeType child_index,
594  CIOutIterator ci_out, const CIOutIterator ci_end) const
595  {
596  typedef typename Traits::SizeType size_type;
597 
598  const size_type geometry_type_index = Traits::DOFIndexAccessor::GeometryIndex::geometryType(ei);
599  const size_type entity_index = Traits::DOFIndexAccessor::GeometryIndex::entityIndex(ei);
600 
601  if (_container_blocked)
602  {
603  if (_fixed_size)
604  for (; ci_out != ci_end; ++ci_out)
605  {
606  ci_out->push_back(_gt_dof_offsets[geometry_type_index] + entity_index);
607  }
608  else
609  for (; ci_out != ci_end; ++ci_out)
610  {
611  ci_out->push_back(_gt_entity_offsets[geometry_type_index] + entity_index);
612  }
613  }
614  else if (_fixed_size)
615  {
616  for (; ci_out != ci_end; ++ci_out)
617  {
618  ci_out->back() += _gt_dof_offsets[geometry_type_index] + entity_index * localOrdering().size(geometry_type_index,entity_index);
619  }
620  }
621  else
622  {
623  for (; ci_out != ci_end; ++ci_out)
624  {
625  ci_out->back() += _entity_dof_offsets[_gt_entity_offsets[geometry_type_index] + entity_index];
626  }
627  }
628 
629  // The return value is not used for non-leaf orderings.
630  return 0;
631  }
632 
633  void update()
634  {
635 
636  typedef std::vector<GeometryType> GTVector;
637  typedef typename Traits::SizeType size_type;
638  const size_type dim = GV::dimension;
639  GTVector geom_types;
640 
641  for (size_type cc = 0; cc <= dim; ++cc)
642  {
643  const GTVector& per_codim_geom_types = _gv.indexSet().geomTypes(cc);
644  std::copy(per_codim_geom_types.begin(),per_codim_geom_types.end(),std::back_inserter(geom_types));
645  }
646 
647  // Do we already know that we have fixed per-GeometryType sizes?
648  collect_a_priori_fixed_size fixed_size_collector;
649  TypeTree::applyToTree(localOrdering(),fixed_size_collector);
650  _fixed_size = localOrdering().fixedSize();
651 
652  typedef std::vector<GeometryType> GTVector;
653  const size_type gt_index_count = GlobalGeometryTypeIndex::size(GV::dimension);
654 
655  if (fixed_size_collector.any)
656  {
657  // collect used GeometryTypes
658  TypeTree::applyToTree(localOrdering(),update_fixed_size<GV>(_gv,geom_types));
659  }
660 
661  if (!fixed_size_collector.all)
662  {
663  TypeTree::applyToTree(localOrdering(),pre_collect_used_geometry_types(GV::dimension));
664 
665  typedef typename GV::template Codim<0>::Iterator CellIterator;
666  typedef typename GV::template Codim<0>::Entity Cell;
667 
668  const CellIterator end_it = _gv.template end<0>();
669  for (CellIterator it = _gv.template begin<0>(); it != end_it; ++it)
670  {
672  }
673  TypeTree::applyToTree(localOrdering(),post_collect_used_geometry_types<GV>(_gv,geom_types));
674  // allocate
675 
676  //TypeTree::applyToTree(localOrdering(),pre_extract_per_entity_sizes<GV>(_gv));
678  for (CellIterator it = _gv.template begin<0>(); it != end_it; ++it)
679  {
680  visitor.set_cell(*it);
681  TypeTree::applyToTree(localOrdering(),visitor);
682  }
683  TypeTree::applyToTree(localOrdering(),post_extract_per_entity_sizes<GV>(_gv,geom_types));
684  }
685 
686  _codim_used = localOrdering()._codim_used;
687 
688  if (localOrdering().fixedSize())
689  {
690  _fixed_size = true;
691  _gt_dof_offsets.assign(gt_index_count + 1,0);
692 
693  _block_count = 0;
694 
695  _size = 0;
696 
697  for (GTVector::const_iterator it = geom_types.begin(); it != geom_types.end(); ++it)
698  {
699  const size_type gt_index = GlobalGeometryTypeIndex::index(*it);
700  size_type gt_size = localOrdering().size(gt_index,0);
701  const size_type gt_entity_count = _gv.indexSet().size(*it);
702  _size += gt_size * gt_entity_count;
703  if (_container_blocked)
704  gt_size = gt_size > 0;
705  _gt_dof_offsets[gt_index + 1] = gt_size * gt_entity_count;
706  }
707 
708  std::partial_sum(_gt_dof_offsets.begin(),_gt_dof_offsets.end(),_gt_dof_offsets.begin());
709  _block_count = _gt_dof_offsets.back();
710 
711  _codim_fixed_size.set();
712 
713  }
714  else
715  {
716  _gt_entity_offsets.assign(gt_index_count + 1,0);
717 
718  for (GTVector::const_iterator it = geom_types.begin(); it != geom_types.end(); ++it)
719  {
720  if (!localOrdering().contains(*it))
721  continue;
722  const size_type gt_index = GlobalGeometryTypeIndex::index(*it);
723  _gt_entity_offsets[gt_index + 1] = _gv.indexSet().size(*it);
724  }
725 
726  std::partial_sum(_gt_entity_offsets.begin(),_gt_entity_offsets.end(),_gt_entity_offsets.begin());
727  _entity_dof_offsets.assign(_gt_entity_offsets.back()+1,0);
728  _block_count = 0;
729 
730  size_type carry = 0;
731  size_type index = 0;
732  for (size_type gt_index = 0; gt_index < GlobalGeometryTypeIndex::size(dim); ++gt_index)
733  {
734  if (!localOrdering().contains_geometry_type(gt_index))
735  continue;
736  const size_type entity_count = _gt_entity_offsets[gt_index + 1] - _gt_entity_offsets[gt_index];
737  for (size_type entity_index = 0; entity_index < entity_count; ++entity_index)
738  {
739  const size_type size = localOrdering().size(gt_index,entity_index);
740  _entity_dof_offsets[++index] = (carry += size);
741  _block_count += (size > 0);
742  }
743  }
744  _size = _entity_dof_offsets.back();
745 
746  if (!_container_blocked)
748 
749  _codim_fixed_size.reset();
750  }
751 
752  _max_local_size = localOrdering().maxLocalSize();
753  }
754 
755  using BaseT::fixedSize;
756 
757  private:
758 
760  using BaseT::_fixed_size;
762  using BaseT::_size;
763  using BaseT::_block_count;
764  using BaseT::_codim_used;
766 
767  typename Traits::GridView _gv;
768  std::vector<typename Traits::SizeType> _gt_dof_offsets;
769  std::vector<typename Traits::SizeType> _gt_entity_offsets;
770  std::vector<typename Traits::SizeType> _entity_dof_offsets;
771 
772  };
773 
774 
776  } // namespace PDELab
777 } // namespace Dune
778 
779 #endif // DUNE_PDELAB_ORDERING_LEAFORDERING_HH
GV gv
Definition: gridviewordering.hh:264
bool all
Definition: gridviewordering.hh:53
post_collect_used_geometry_types(const GV &gv_, const GTVector &geom_types_)
Definition: gridviewordering.hh:259
void leaf(Node &node, TreePath tp) const
Definition: gridviewordering.hh:193
bool fixedSize(typename Traits::SizeType codim) const
Definition: orderingbase.hh:214
void leaf(Node &node, TreePath tp)
Definition: gridviewordering.hh:281
Traits::SizeType extract_entity_indices(const typename Traits::DOFIndex::EntityIndex &ei, typename Traits::SizeType child_index, CIOutIterator ci_out, const CIOutIterator ci_end) const
Definition: gridviewordering.hh:592
GV gv
Definition: gridviewordering.hh:300
Definition: gridviewordering.hh:211
GV::template Codim< 0 >::Entity Cell
Definition: gridviewordering.hh:277
void post(Node &node, TreePath tp) const
Definition: gridviewordering.hh:353
const LocalOrdering & localOrdering() const
Definition: gridviewordering.hh:502
void post(Node &node, TreePath tp) const
Definition: gridviewordering.hh:127
GV gv
Definition: gridviewordering.hh:148
void setPartitionSet(const std::bitset< 6 > &partitions)
Sets the set of contained partitions to the passed-in value.
Definition: partitioninfoprovider.hh:58
const GTVector & geom_types
Definition: gridviewordering.hh:149
Definition: orderingbase.hh:22
void pre(Node &node, TreePath tp) const
Definition: gridviewordering.hh:172
const Dune::ReferenceElement< typename Cell::Geometry::ctype, Cell::dimension > & ref_el
Definition: gridviewordering.hh:205
const Dune::ReferenceElement< typename GV::ctype, dim > * ref_el
Definition: gridviewordering.hh:302
void afterChild(Node &node, const Child &child, TreePath tp, ChildIndex childIndex) const
Definition: gridviewordering.hh:342
std::vector< Dune::GeometryType > GTVector
Definition: gridviewordering.hh:64
Definition: gridviewordering.hh:309
Definition: gridviewordering.hh:59
static const int dim
Definition: adaptivity.hh:82
std::vector< size_type > gt_sizes
Definition: gridviewordering.hh:303
post_extract_per_entity_sizes(const GV &gv_, const GTVector &geom_types_)
Definition: gridviewordering.hh:408
Definition: ordering/utility.hh:230
Definition: gridviewordering.hh:154
void leaf(Node &node, TreePath tp) const
Definition: gridviewordering.hh:160
GV gv
Definition: gridviewordering.hh:413
collect_used_geometry_types_from_cell_visitor(const Cell &cell_)
Definition: gridviewordering.hh:199
Traits::ContainerIndex mapIndex(const typename Traits::DOFIndex &di) const
Definition: gridviewordering.hh:512
void pre(Node &node, TreePath tp) const
Definition: gridviewordering.hh:36
void update()
Definition: gridviewordering.hh:633
collect_a_priori_fixed_size()
Definition: gridviewordering.hh:47
static const bool consume_tree_index
Definition: gridviewordering.hh:432
void pre(Node &node, TreePath tp) const
Definition: gridviewordering.hh:88
const GTVector & geom_types
Definition: gridviewordering.hh:265
void pre(Node &node, TreePath tp) const
Definition: gridviewordering.hh:331
std::size_t size_type
Definition: gridviewordering.hh:278
static const bool has_dynamic_ordering_children
Definition: gridviewordering.hh:430
bool any
Definition: gridviewordering.hh:52
const Cell & cell
Definition: gridviewordering.hh:204
const Cell * cell
Definition: gridviewordering.hh:301
void afterChild(Node &node, const Child &child, TreePath tp, ChildIndex childIndex) const
Definition: gridviewordering.hh:102
void set_cell(const Cell &cell_)
Definition: gridviewordering.hh:294
std::vector< GeometryType > GTVector
Definition: gridviewordering.hh:314
GridViewOrdering(const typename NodeT::NodeStorage &local_ordering, bool container_blocked, typename BaseT::GFSData *gfs_data)
Construct ordering object.
Definition: gridviewordering.hh:451
void leaf(Node &node, TreePath tp) const
Definition: gridviewordering.hh:67
void post(Node &node, TreePath tp) const
Definition: gridviewordering.hh:254
const GTVector & geom_types
Definition: gridviewordering.hh:414
update_fixed_size(const GV gv_, const GTVector &geom_types_)
Definition: gridviewordering.hh:143
const std::size_t dim
Definition: gridviewordering.hh:181
static const std::size_t dim
Definition: gridviewordering.hh:276
virtual void map_index_dynamic(typename Traits::DOFIndexView di, typename Traits::ContainerIndex &ci) const
Definition: gridviewordering.hh:507
void afterChild(Node &node, const Child &child, TreePath tp, ChildIndex childIndex) const
Definition: gridviewordering.hh:239
LocalOrdering::Traits Traits
Definition: gridviewordering.hh:428
void mapIndex(typename Traits::DOFIndexView di, typename Traits::ContainerIndex &ci) const
Definition: gridviewordering.hh:519
void afterChild(Node &node, const Child &child, TreePath tp, ChildIndex childIndex) const
Definition: gridviewordering.hh:42
Definition: gridviewordering.hh:22
std::vector< Dune::GeometryType > GTVector
Definition: gridviewordering.hh:216
Dune::PDELab::impl::GridFunctionSpaceOrderingData< typename Traits::SizeType > GFSData
Definition: orderingbase.hh:35
Definition: gridviewordering.hh:420
void leaf(Node &node, TreePath tp) const
Definition: gridviewordering.hh:220
void leaf(Node &node, TreePath tp) const
Definition: gridviewordering.hh:318
void map_lfs_indices(const ItIn begin, const ItIn end, ItOut out) const
Definition: gridviewordering.hh:550
void leaf(Node &node, TreePath tp)
Definition: gridviewordering.hh:28
extract_per_entity_sizes_from_cell_visitor(const GV &gv_)
Definition: gridviewordering.hh:287
pre_collect_used_geometry_types(std::size_t dimension)
Definition: gridviewordering.hh:177
LocalOrdering & localOrdering()
Definition: gridviewordering.hh:497
void setDelegate(const VirtualOrderingBase< LocalOrdering::Traits::DOFIndex, LocalOrdering::Traits::ContainerIndex > *delegate)
Set the delegate called in mapIndex().
Definition: orderingbase.hh:227