dune-pdelab  2.4-dev
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;
149  const GTVector& geom_types;
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;
265  const GTVector& geom_types;
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;
414  const GTVector& geom_types;
415 
416  };
417 
418 
419  template<typename LocalOrdering>
421  : public TypeTree::CompositeNode<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::CompositeNode<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 
481  : NodeT(r.nodeStorage())
482  , BaseT(std::move(r))
483  , _gv(std::move(r._gv))
484  , _gt_dof_offsets(std::move(r._gt_dof_offsets))
485  , _gt_entity_offsets(std::move(r._gt_entity_offsets))
486  , _entity_dof_offsets(std::move(r._entity_dof_offsets))
487  {
488  this->setDelegate(this);
489  }
490 
491 #endif // DOXYGEN
492 
493  LocalOrdering& localOrdering()
494  {
495  return this->template child<0>();
496  }
497 
498  const LocalOrdering& localOrdering() const
499  {
500  return this->template child<0>();
501  }
502 
503  virtual void map_index_dynamic(typename Traits::DOFIndexView di, typename Traits::ContainerIndex& ci) const
504  {
505  mapIndex(di,ci);
506  }
507 
508  typename Traits::ContainerIndex mapIndex(const typename Traits::DOFIndex& di) const
509  {
510  typename Traits::ContainerIndex ci;
511  mapIndex(di.view(),ci);
512  return ci;
513  }
514 
515  void mapIndex(typename Traits::DOFIndexView di, typename Traits::ContainerIndex& ci) const
516  {
517  typedef typename Traits::SizeType size_type;
518  const size_type geometry_type_index = Traits::DOFIndexAccessor::geometryType(di);
519  const size_type entity_index = Traits::DOFIndexAccessor::entityIndex(di);
520  localOrdering().map_local_index(geometry_type_index,entity_index,di.treeIndex(),ci);
521  if (_container_blocked)
522  {
523  if (_fixed_size)
524  {
525  ci.push_back(_gt_dof_offsets[geometry_type_index] + entity_index);
526  }
527  else
528  {
529  ci.push_back(_gt_entity_offsets[geometry_type_index] + entity_index);
530  }
531  }
532  else
533  {
534  if (_fixed_size)
535  {
536  ci.back() += _gt_dof_offsets[geometry_type_index] + entity_index * localOrdering().size(geometry_type_index,entity_index);
537  }
538  else
539  {
540  ci.back() += _entity_dof_offsets[_gt_entity_offsets[geometry_type_index] + entity_index];
541  }
542  }
543  }
544 
545  template<typename ItIn, typename ItOut>
546  void map_lfs_indices(const ItIn begin, const ItIn end, ItOut out) const
547  {
548  typedef typename Traits::SizeType size_type;
549  if (_container_blocked)
550  {
551  if (_fixed_size)
552  for (ItIn in = begin; in != end; ++in, ++out)
553  {
554  const size_type geometry_type_index = Traits::DOFIndexAccessor::geometryType(*in);
555  const size_type entity_index = Traits::DOFIndexAccessor::entityIndex(*in);
556  out->push_back(_gt_dof_offsets[geometry_type_index] + entity_index);
557  }
558  else
559  for (ItIn in = begin; in != end; ++in, ++out)
560  {
561  const size_type geometry_type_index = Traits::DOFIndexAccessor::geometryType(*in);
562  const size_type entity_index = Traits::DOFIndexAccessor::entityIndex(*in);
563  out->push_back(_gt_entity_offsets[geometry_type_index] + entity_index);
564  }
565  }
566  else if (_fixed_size)
567  {
568  for (ItIn in = begin; in != end; ++in, ++out)
569  {
570  const size_type geometry_type_index = Traits::DOFIndexAccessor::geometryType(*in);
571  const size_type entity_index = Traits::DOFIndexAccessor::entityIndex(*in);
572  out->back() += _gt_dof_offsets[geometry_type_index] + entity_index * localOrdering().size(geometry_type_index,entity_index);
573  }
574  }
575  else
576  {
577  for (ItIn in = begin; in != end; ++in, ++out)
578  {
579  const size_type geometry_type_index = Traits::DOFIndexAccessor::geometryType(*in);
580  const size_type entity_index = Traits::DOFIndexAccessor::entityIndex(*in);
581  out->back() += _entity_dof_offsets[_gt_entity_offsets[geometry_type_index] + entity_index];
582  }
583  }
584  }
585 
586  template<typename CIOutIterator>
587  typename Traits::SizeType
588  extract_entity_indices(const typename Traits::DOFIndex::EntityIndex& ei,
589  typename Traits::SizeType child_index,
590  CIOutIterator ci_out, const CIOutIterator ci_end) const
591  {
592  typedef typename Traits::SizeType size_type;
593 
594  const size_type geometry_type_index = Traits::DOFIndexAccessor::GeometryIndex::geometryType(ei);
595  const size_type entity_index = Traits::DOFIndexAccessor::GeometryIndex::entityIndex(ei);
596 
597  if (_container_blocked)
598  {
599  if (_fixed_size)
600  for (; ci_out != ci_end; ++ci_out)
601  {
602  ci_out->push_back(_gt_dof_offsets[geometry_type_index] + entity_index);
603  }
604  else
605  for (; ci_out != ci_end; ++ci_out)
606  {
607  ci_out->push_back(_gt_entity_offsets[geometry_type_index] + entity_index);
608  }
609  }
610  else if (_fixed_size)
611  {
612  for (; ci_out != ci_end; ++ci_out)
613  {
614  ci_out->back() += _gt_dof_offsets[geometry_type_index] + entity_index * localOrdering().size(geometry_type_index,entity_index);
615  }
616  }
617  else
618  {
619  for (; ci_out != ci_end; ++ci_out)
620  {
621  ci_out->back() += _entity_dof_offsets[_gt_entity_offsets[geometry_type_index] + entity_index];
622  }
623  }
624 
625  // The return value is not used for non-leaf orderings.
626  return 0;
627  }
628 
629  void update()
630  {
631 
632  typedef std::vector<GeometryType> GTVector;
633  typedef typename Traits::SizeType size_type;
634  const size_type dim = GV::dimension;
635  GTVector geom_types;
636 
637  for (size_type cc = 0; cc <= dim; ++cc)
638  {
639  auto per_codim_geom_types = _gv.indexSet().types(cc);
640  std::copy(per_codim_geom_types.begin(),per_codim_geom_types.end(),std::back_inserter(geom_types));
641  }
642 
643  // Do we already know that we have fixed per-GeometryType sizes?
644  collect_a_priori_fixed_size fixed_size_collector;
645  TypeTree::applyToTree(localOrdering(),fixed_size_collector);
646  _fixed_size = localOrdering().fixedSize();
647 
648  typedef std::vector<GeometryType> GTVector;
649  const size_type gt_index_count = GlobalGeometryTypeIndex::size(GV::dimension);
650 
651  if (fixed_size_collector.any)
652  {
653  // collect used GeometryTypes
654  TypeTree::applyToTree(localOrdering(),update_fixed_size<GV>(_gv,geom_types));
655  }
656 
657  if (!fixed_size_collector.all)
658  {
659  TypeTree::applyToTree(localOrdering(),pre_collect_used_geometry_types(GV::dimension));
660 
661  typedef typename GV::template Codim<0>::Iterator CellIterator;
662  typedef typename GV::template Codim<0>::Entity Cell;
663 
664  const CellIterator end_it = _gv.template end<0>();
665  for (CellIterator it = _gv.template begin<0>(); it != end_it; ++it)
666  {
668  }
669  TypeTree::applyToTree(localOrdering(),post_collect_used_geometry_types<GV>(_gv,geom_types));
670  // allocate
671 
672  //TypeTree::applyToTree(localOrdering(),pre_extract_per_entity_sizes<GV>(_gv));
674  for (CellIterator it = _gv.template begin<0>(); it != end_it; ++it)
675  {
676  visitor.set_cell(*it);
677  TypeTree::applyToTree(localOrdering(),visitor);
678  }
679  TypeTree::applyToTree(localOrdering(),post_extract_per_entity_sizes<GV>(_gv,geom_types));
680  }
681 
682  _codim_used = localOrdering()._codim_used;
683 
684  if (localOrdering().fixedSize())
685  {
686  _fixed_size = true;
687  _gt_dof_offsets.assign(gt_index_count + 1,0);
688 
689  _block_count = 0;
690 
691  _size = 0;
692 
693  for (GTVector::const_iterator it = geom_types.begin(); it != geom_types.end(); ++it)
694  {
695  const size_type gt_index = GlobalGeometryTypeIndex::index(*it);
696  size_type gt_size = localOrdering().size(gt_index,0);
697  const size_type gt_entity_count = _gv.indexSet().size(*it);
698  _size += gt_size * gt_entity_count;
699  if (_container_blocked)
700  gt_size = gt_size > 0;
701  _gt_dof_offsets[gt_index + 1] = gt_size * gt_entity_count;
702  }
703 
704  std::partial_sum(_gt_dof_offsets.begin(),_gt_dof_offsets.end(),_gt_dof_offsets.begin());
705  _block_count = _gt_dof_offsets.back();
706 
707  _codim_fixed_size.set();
708 
709  }
710  else
711  {
712  _gt_entity_offsets.assign(gt_index_count + 1,0);
713 
714  for (GTVector::const_iterator it = geom_types.begin(); it != geom_types.end(); ++it)
715  {
716  if (!localOrdering().contains(*it))
717  continue;
718  const size_type gt_index = GlobalGeometryTypeIndex::index(*it);
719  _gt_entity_offsets[gt_index + 1] = _gv.indexSet().size(*it);
720  }
721 
722  std::partial_sum(_gt_entity_offsets.begin(),_gt_entity_offsets.end(),_gt_entity_offsets.begin());
723  _entity_dof_offsets.assign(_gt_entity_offsets.back()+1,0);
724  _block_count = 0;
725 
726  size_type carry = 0;
727  size_type index = 0;
728  for (size_type gt_index = 0; gt_index < GlobalGeometryTypeIndex::size(dim); ++gt_index)
729  {
730  if (!localOrdering().contains_geometry_type(gt_index))
731  continue;
732  const size_type entity_count = _gt_entity_offsets[gt_index + 1] - _gt_entity_offsets[gt_index];
733  for (size_type entity_index = 0; entity_index < entity_count; ++entity_index)
734  {
735  const size_type size = localOrdering().size(gt_index,entity_index);
736  _entity_dof_offsets[++index] = (carry += size);
737  _block_count += (size > 0);
738  }
739  }
740  _size = _entity_dof_offsets.back();
741 
742  if (!_container_blocked)
744 
745  _codim_fixed_size.reset();
746  }
747 
748  _max_local_size = localOrdering().maxLocalSize();
749  }
750 
751  using BaseT::fixedSize;
752 
753  private:
754 
756  using BaseT::_fixed_size;
758  using BaseT::_size;
759  using BaseT::_block_count;
760  using BaseT::_codim_used;
762 
763  typename Traits::GridView _gv;
764  std::vector<typename Traits::SizeType> _gt_dof_offsets;
765  std::vector<typename Traits::SizeType> _gt_entity_offsets;
766  std::vector<typename Traits::SizeType> _entity_dof_offsets;
767 
768  };
769 
770 
772  } // namespace PDELab
773 } // namespace Dune
774 
775 #endif // DUNE_PDELAB_ORDERING_LEAFORDERING_HH
Traits::ContainerIndex mapIndex(const typename Traits::DOFIndex &di) const
Definition: gridviewordering.hh:508
bool fixedSize(typename Traits::SizeType codim) const
Definition: orderingbase.hh:215
static const bool consume_tree_index
Definition: gridviewordering.hh:432
void leaf(Node &node, TreePath tp) const
Definition: gridviewordering.hh:160
void leaf(Node &node, TreePath tp) const
Definition: gridviewordering.hh:193
void leaf(Node &node, TreePath tp) const
Definition: gridviewordering.hh:318
void pre(Node &node, TreePath tp) const
Definition: gridviewordering.hh:331
post_extract_per_entity_sizes(const GV &gv_, const GTVector &geom_types_)
Definition: gridviewordering.hh:408
void afterChild(Node &node, const Child &child, TreePath tp, ChildIndex childIndex) const
Definition: gridviewordering.hh:342
const std::size_t dim
Definition: gridviewordering.hh:181
void post(Node &node, TreePath tp) const
Definition: gridviewordering.hh:353
void pre(Node &node, TreePath tp) const
Definition: gridviewordering.hh:36
static const std::size_t dim
Definition: gridviewordering.hh:276
const GTVector & geom_types
Definition: gridviewordering.hh:414
const Dune::ReferenceElement< typename Cell::Geometry::ctype, Cell::dimension > & ref_el
Definition: gridviewordering.hh:205
static const bool has_dynamic_ordering_children
Definition: gridviewordering.hh:430
collect_used_geometry_types_from_cell_visitor(const Cell &cell_)
Definition: gridviewordering.hh:199
pre_collect_used_geometry_types(std::size_t dimension)
Definition: gridviewordering.hh:177
update_fixed_size(const GV gv_, const GTVector &geom_types_)
Definition: gridviewordering.hh:143
virtual void map_index_dynamic(typename Traits::DOFIndexView di, typename Traits::ContainerIndex &ci) const
Definition: gridviewordering.hh:503
std::vector< Dune::GeometryType > GTVector
Definition: gridviewordering.hh:64
STL namespace.
GridViewOrdering(const typename NodeT::NodeStorage &local_ordering, bool container_blocked, typename BaseT::GFSData *gfs_data)
Construct ordering object.
Definition: gridviewordering.hh:451
void set_cell(const Cell &cell_)
Definition: gridviewordering.hh:294
void map_lfs_indices(const ItIn begin, const ItIn end, ItOut out) const
Definition: gridviewordering.hh:546
bool all
Definition: gridviewordering.hh:53
void leaf(Node &node, TreePath tp)
Definition: gridviewordering.hh:281
LocalOrdering::Traits Traits
Definition: gridviewordering.hh:428
void mapIndex(typename Traits::DOFIndexView di, typename Traits::ContainerIndex &ci) const
Definition: gridviewordering.hh:515
Definition: gridviewordering.hh:59
void setPartitionSet(const std::bitset< 6 > &partitions)
Sets the set of contained partitions to the passed-in value.
Definition: partitioninfoprovider.hh:58
LocalOrdering & localOrdering()
Definition: gridviewordering.hh:493
Definition: gridviewordering.hh:309
extract_per_entity_sizes_from_cell_visitor(const GV &gv_)
Definition: gridviewordering.hh:287
Definition: gridviewordering.hh:22
Definition: adaptivity.hh:27
void leaf(Node &node, TreePath tp) const
Definition: gridviewordering.hh:67
const Cell & cell
Definition: gridviewordering.hh:204
void pre(Node &node, TreePath tp) const
Definition: gridviewordering.hh:88
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:588
GV gv
Definition: gridviewordering.hh:264
void pre(Node &node, TreePath tp) const
Definition: gridviewordering.hh:172
post_collect_used_geometry_types(const GV &gv_, const GTVector &geom_types_)
Definition: gridviewordering.hh:259
Dune::PDELab::impl::GridFunctionSpaceOrderingData< typename Traits::SizeType > GFSData
Definition: orderingbase.hh:34
const Dune::ReferenceElement< typename GV::ctype, dim > * ref_el
Definition: gridviewordering.hh:302
std::vector< size_type > gt_sizes
Definition: gridviewordering.hh:303
Definition: gridviewordering.hh:420
GV gv
Definition: gridviewordering.hh:148
static const int dim
Definition: adaptivity.hh:83
const GTVector & geom_types
Definition: gridviewordering.hh:265
void afterChild(Node &node, const Child &child, TreePath tp, ChildIndex childIndex) const
Definition: gridviewordering.hh:102
void post(Node &node, TreePath tp) const
Definition: gridviewordering.hh:127
GV gv
Definition: gridviewordering.hh:300
void setDelegate(const VirtualOrderingBase< LocalOrdering::Traits::DOFIndex, LocalOrdering::Traits::ContainerIndex > *delegate)
Set the delegate called in mapIndex().
Definition: orderingbase.hh:228
void afterChild(Node &node, const Child &child, TreePath tp, ChildIndex childIndex) const
Definition: gridviewordering.hh:239
const GTVector & geom_types
Definition: gridviewordering.hh:149
const LocalOrdering & localOrdering() const
Definition: gridviewordering.hh:498
void leaf(Node &node, TreePath tp)
Definition: gridviewordering.hh:28
Definition: ordering/utility.hh:230
Definition: gridviewordering.hh:154
Definition: gridviewordering.hh:211
GV::template Codim< 0 >::Entity Cell
Definition: gridviewordering.hh:277
Definition: orderingbase.hh:21
collect_a_priori_fixed_size()
Definition: gridviewordering.hh:47
void update()
Definition: gridviewordering.hh:629
void leaf(Node &node, TreePath tp) const
Definition: gridviewordering.hh:220
std::vector< GeometryType > GTVector
Definition: gridviewordering.hh:314
std::vector< Dune::GeometryType > GTVector
Definition: gridviewordering.hh:216
GV gv
Definition: gridviewordering.hh:413
std::size_t size_type
Definition: gridviewordering.hh:278
void afterChild(Node &node, const Child &child, TreePath tp, ChildIndex childIndex) const
Definition: gridviewordering.hh:42
const Cell * cell
Definition: gridviewordering.hh:301
bool any
Definition: gridviewordering.hh:52
void post(Node &node, TreePath tp) const
Definition: gridviewordering.hh:254