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