dune-pdelab  2.5-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 
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)),0);
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  const Dune::ReferenceElement<typename Cell::Geometry::ctype,Cell::dimension>& 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(nullptr)
303  , gt_sizes(Dune::GlobalGeometryTypeIndex::size(dim),0)
304  {}
305 
306  void set_cell(const Cell& cell_)
307  {
308  cell = &cell_;
309  ref_el = &(Dune::ReferenceElements<typename ES::Traits::CoordinateField,dim>::general(cell_.type()));
310  }
311 
312  ES es;
313  const Cell* cell;
314  const Dune::ReferenceElement<typename ES::Traits::CoordinateField,dim>* 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  if (node._fixed_size_possible)
335  {
336  node._entity_dof_offsets = std::vector<typename Node::Traits::SizeType>();
337  node._fixed_size = true;
338  }
339  }
340  }
341 
342  template<typename Node, typename TreePath>
343  void pre(Node& node, TreePath tp) const
344  {
345  if (!node._fixed_size)
346  {
347  node._fixed_size_possible = true;
348  node._max_local_size = 0;
349  }
350  }
351 
352 
353  template<typename Node, typename Child, typename TreePath, typename ChildIndex>
354  void afterChild(Node& node, const Child& child, TreePath tp, ChildIndex childIndex) const
355  {
356  if (!node._fixed_size)
357  {
358  node._fixed_size_possible = node._fixed_size_possible && child._fixed_size;
359  node._max_local_size += child._max_local_size;
360  }
361  }
362 
363 
364  template<typename Node, typename TreePath>
365  void post(Node& node, TreePath tp) const
366  {
367  if (!node._fixed_size)
368  {
369 
370  typedef typename Node::Traits::SizeType size_type;
371  const size_type dim = ES::dimension;
372 
373  if (node._fixed_size_possible)
374  {
375 
376  for (size_type gt = 0; gt < GlobalGeometryTypeIndex::size(ES::dimension); ++gt)
377  {
378  for (size_type child_index = 0; child_index < TypeTree::degree(node); ++child_index)
379  {
380  const size_type per_gt_size = node.childOrdering(child_index)._child_count > 0 ? node.childOrdering(child_index)._child_count : 1;
381  const size_type size_offset = node.childOrdering(child_index)._child_count > 0 ? node.childOrdering(child_index)._child_count - 1 : 0;
382 
383  node._gt_dof_offsets[gt * TypeTree::degree(node) + child_index] = node.childOrdering(child_index)._gt_dof_offsets[gt * per_gt_size + size_offset];
384  }
385  }
386 
387  typedef typename std::vector<typename Node::Traits::SizeType>::iterator iterator;
388 
389  const iterator end_it = node._gt_dof_offsets.end();
390 
391  for (iterator it = node._gt_dof_offsets.begin();
392  it != end_it;
393  it += TypeTree::degree(node))
394  std::partial_sum(it,it + TypeTree::degree(node),it);
395 
396  node._fixed_size = true;
397  }
398  else
399  {
400  typedef typename Node::Traits::SizeType size_type;
401 
402  size_type index = 0;
403  for (size_type geometry_type_index = 0; geometry_type_index < GlobalGeometryTypeIndex::size(dim); ++geometry_type_index)
404  {
405  if (!node._gt_used[geometry_type_index])
406  continue;
407  const size_type entity_count = node._gt_entity_offsets[geometry_type_index+1] - node._gt_entity_offsets[geometry_type_index];
408  for (size_type entity_index = 0; entity_index < entity_count; ++entity_index)
409  {
410  size_type carry = 0;
411  for (size_type child_index = 0; child_index < TypeTree::degree(node); ++child_index)
412  node._entity_dof_offsets[index++] = (carry += node.childOrdering(child_index).size(geometry_type_index,entity_index));
413  }
414  }
415 
416  }
417  }
418  }
419 
421  : es(es_)
422  {}
423 
424  ES es;
425 
426  };
427 
428 
429  template<typename LocalOrdering>
431  : public TypeTree::CompositeNode<LocalOrdering>
432  , public VirtualOrderingBase<typename LocalOrdering::Traits::DOFIndex,
433  typename LocalOrdering::Traits::ContainerIndex>
434  , public OrderingBase<typename LocalOrdering::Traits::DOFIndex,
435  typename LocalOrdering::Traits::ContainerIndex>
436  {
437  public:
438  typedef typename LocalOrdering::Traits Traits;
439 
440  static const bool has_dynamic_ordering_children = false;
441 
442  static const bool consume_tree_index = false;
443 
444  private:
445 
446  typedef TypeTree::CompositeNode<LocalOrdering> NodeT;
447  typedef OrderingBase<
448  typename LocalOrdering::Traits::DOFIndex,
449  typename LocalOrdering::Traits::ContainerIndex
450  > BaseT;
451 
452  using EntitySet = typename Traits::EntitySet;
453 
454  public:
456 
461  GridViewOrdering(const typename NodeT::NodeStorage& local_ordering, bool container_blocked, typename BaseT::GFSData* gfs_data)
462  : NodeT(local_ordering)
463  , BaseT(*this,container_blocked,gfs_data,this)
464  , _es(localOrdering().entitySet())
465  {
466  // make sure to switch off container blocking handling in the local ordering,
467  // we already handle it in the GridViewOrdering
468  localOrdering().disable_container_blocking();
469  }
470 
471 #ifndef DOXYGEN
472 
473 // we need to override the default copy / move ctor to fix the delegate pointer, but that is
474 // hardly interesting to our users...
475 
477  : NodeT(r.nodeStorage())
478  , BaseT(r)
479  , _es(r._es)
480  , _gt_dof_offsets(r._gt_dof_offsets)
481  , _gt_entity_offsets(r._gt_entity_offsets)
482  , _entity_dof_offsets(r._entity_dof_offsets)
483  {
484  this->setDelegate(this);
485  }
486 
488  : NodeT(r.nodeStorage())
489  , BaseT(std::move(r))
490  , _es(std::move(r._es))
491  , _gt_dof_offsets(std::move(r._gt_dof_offsets))
492  , _gt_entity_offsets(std::move(r._gt_entity_offsets))
493  , _entity_dof_offsets(std::move(r._entity_dof_offsets))
494  {
495  this->setDelegate(this);
496  }
497 
498 #endif // DOXYGEN
499 
500  LocalOrdering& localOrdering()
501  {
502  return this->template child<0>();
503  }
504 
505  const LocalOrdering& localOrdering() const
506  {
507  return this->template child<0>();
508  }
509 
510  virtual void map_index_dynamic(typename Traits::DOFIndexView di, typename Traits::ContainerIndex& ci) const
511  {
512  mapIndex(di,ci);
513  }
514 
515  typename Traits::ContainerIndex mapIndex(const typename Traits::DOFIndex& di) const
516  {
517  typename Traits::ContainerIndex ci;
518  mapIndex(di.view(),ci);
519  return ci;
520  }
521 
522  void mapIndex(typename Traits::DOFIndexView di, typename Traits::ContainerIndex& ci) const
523  {
524  typedef typename Traits::SizeType size_type;
525  const size_type geometry_type_index = Traits::DOFIndexAccessor::geometryType(di);
526  const size_type entity_index = Traits::DOFIndexAccessor::entityIndex(di);
527  localOrdering().map_local_index(geometry_type_index,entity_index,di.treeIndex(),ci);
528  if (_container_blocked)
529  {
530  if (_fixed_size)
531  {
532  ci.push_back(_gt_dof_offsets[geometry_type_index] + entity_index);
533  }
534  else
535  {
536  ci.push_back(_gt_entity_offsets[geometry_type_index] + entity_index);
537  }
538  }
539  else
540  {
541  if (_fixed_size)
542  {
543  ci.back() += _gt_dof_offsets[geometry_type_index] + entity_index * localOrdering().size(geometry_type_index,entity_index);
544  }
545  else
546  {
547  ci.back() += _entity_dof_offsets[_gt_entity_offsets[geometry_type_index] + entity_index];
548  }
549  }
550  }
551 
552  template<typename ItIn, typename ItOut>
553  void map_lfs_indices(const ItIn begin, const ItIn end, ItOut out) const
554  {
555  typedef typename Traits::SizeType size_type;
556  if (_container_blocked)
557  {
558  if (_fixed_size)
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_dof_offsets[geometry_type_index] + entity_index);
564  }
565  else
566  for (ItIn in = begin; in != end; ++in, ++out)
567  {
568  const size_type geometry_type_index = Traits::DOFIndexAccessor::geometryType(*in);
569  const size_type entity_index = Traits::DOFIndexAccessor::entityIndex(*in);
570  out->push_back(_gt_entity_offsets[geometry_type_index] + entity_index);
571  }
572  }
573  else if (_fixed_size)
574  {
575  for (ItIn in = begin; in != end; ++in, ++out)
576  {
577  const size_type geometry_type_index = Traits::DOFIndexAccessor::geometryType(*in);
578  const size_type entity_index = Traits::DOFIndexAccessor::entityIndex(*in);
579  out->back() += _gt_dof_offsets[geometry_type_index] + entity_index * localOrdering().size(geometry_type_index,entity_index);
580  }
581  }
582  else
583  {
584  for (ItIn in = begin; in != end; ++in, ++out)
585  {
586  const size_type geometry_type_index = Traits::DOFIndexAccessor::geometryType(*in);
587  const size_type entity_index = Traits::DOFIndexAccessor::entityIndex(*in);
588  out->back() += _entity_dof_offsets[_gt_entity_offsets[geometry_type_index] + entity_index];
589  }
590  }
591  }
592 
593  template<typename CIOutIterator>
594  typename Traits::SizeType
595  extract_entity_indices(const typename Traits::DOFIndex::EntityIndex& ei,
596  typename Traits::SizeType child_index,
597  CIOutIterator ci_out, const CIOutIterator ci_end) const
598  {
599  typedef typename Traits::SizeType size_type;
600 
601  const size_type geometry_type_index = Traits::DOFIndexAccessor::GeometryIndex::geometryType(ei);
602  const size_type entity_index = Traits::DOFIndexAccessor::GeometryIndex::entityIndex(ei);
603 
604  if (_container_blocked)
605  {
606  if (_fixed_size)
607  for (; ci_out != ci_end; ++ci_out)
608  {
609  ci_out->push_back(_gt_dof_offsets[geometry_type_index] + entity_index);
610  }
611  else
612  for (; ci_out != ci_end; ++ci_out)
613  {
614  ci_out->push_back(_gt_entity_offsets[geometry_type_index] + entity_index);
615  }
616  }
617  else if (_fixed_size)
618  {
619  for (; ci_out != ci_end; ++ci_out)
620  {
621  ci_out->back() += _gt_dof_offsets[geometry_type_index] + entity_index * localOrdering().size(geometry_type_index,entity_index);
622  }
623  }
624  else
625  {
626  for (; ci_out != ci_end; ++ci_out)
627  {
628  ci_out->back() += _entity_dof_offsets[_gt_entity_offsets[geometry_type_index] + entity_index];
629  }
630  }
631 
632  // The return value is not used for non-leaf orderings.
633  return 0;
634  }
635 
636  void update()
637  {
638 
639  typedef typename Traits::SizeType size_type;
640  using ES = typename Traits::EntitySet;
641  const size_type dim = ES::dimension;
642 
643  typename ES::CodimMask codims;
644  codims.set(0); // we always need cells
645 
646  TypeTree::applyToTree(localOrdering(),collect_used_codims<typename ES::CodimMask>(codims));
647 
648  for (typename ES::dim_type codim = 0; codim <= ES::dimension; ++codim)
649  if (codims.test(codim))
650  _es.addCodim(codim);
651 
652  _es.update();
653 
654  // Do we already know that we have fixed per-GeometryType sizes?
655  collect_a_priori_fixed_size fixed_size_collector;
656  TypeTree::applyToTree(localOrdering(),fixed_size_collector);
657  _fixed_size = localOrdering().fixedSize();
658 
659  const size_type gt_index_count = GlobalGeometryTypeIndex::size(ES::dimension);
660 
661  if (fixed_size_collector.any)
662  {
663  // collect used GeometryTypes
664  TypeTree::applyToTree(localOrdering(),update_fixed_size<ES>(_es));
665  }
666 
667  if (!fixed_size_collector.all)
668  {
669  TypeTree::applyToTree(localOrdering(),pre_collect_used_geometry_types(ES::dimension));
670 
671  using Element = typename ES::template Codim<0>::Entity;
672 
673  for (const auto& element : elements(_es))
674  {
675  TypeTree::applyToTree(localOrdering(),collect_used_geometry_types_from_cell_visitor<Element>(element));
676  }
677  TypeTree::applyToTree(localOrdering(),post_collect_used_geometry_types<ES>(_es));
678  // allocate
679 
680  //TypeTree::applyToTree(localOrdering(),pre_extract_per_entity_sizes<GV>(_gv));
682  for (const auto& element : elements(_es))
683  {
684  visitor.set_cell(element);
685  TypeTree::applyToTree(localOrdering(),visitor);
686  }
687  TypeTree::applyToTree(localOrdering(),post_extract_per_entity_sizes<ES>(_es));
688  }
689 
690  _codim_used = localOrdering()._codim_used;
691 
692  if (localOrdering().fixedSize())
693  {
694  _fixed_size = true;
695  _gt_dof_offsets.assign(gt_index_count + 1,0);
696 
697  _block_count = 0;
698 
699  _size = 0;
700 
701  for (const auto& gt : _es.indexSet().types())
702  {
703  const size_type gt_index = GlobalGeometryTypeIndex::index(gt);
704  size_type gt_size = localOrdering().size(gt_index,0);
705  const size_type gt_entity_count = _es.indexSet().size(gt);
706  _size += gt_size * gt_entity_count;
707  if (_container_blocked)
708  gt_size = gt_size > 0;
709  _gt_dof_offsets[gt_index + 1] = gt_size * gt_entity_count;
710  }
711 
712  std::partial_sum(_gt_dof_offsets.begin(),_gt_dof_offsets.end(),_gt_dof_offsets.begin());
713  _block_count = _gt_dof_offsets.back();
714 
715  _codim_fixed_size.set();
716 
717  }
718  else
719  {
720  _gt_entity_offsets.assign(gt_index_count + 1,0);
721 
722  for (const auto& gt : _es.indexSet().types())
723  {
724  if (!localOrdering().contains(gt))
725  continue;
726  const size_type gt_index = GlobalGeometryTypeIndex::index(gt);
727  _gt_entity_offsets[gt_index + 1] = _es.indexSet().size(gt);
728  }
729 
730  std::partial_sum(_gt_entity_offsets.begin(),_gt_entity_offsets.end(),_gt_entity_offsets.begin());
731  _entity_dof_offsets.assign(_gt_entity_offsets.back()+1,0);
732  _block_count = 0;
733 
734  size_type carry = 0;
735  size_type index = 0;
736  for (size_type gt_index = 0; gt_index < GlobalGeometryTypeIndex::size(dim); ++gt_index)
737  {
738  if (!localOrdering().contains_geometry_type(gt_index))
739  continue;
740  const size_type entity_count = _gt_entity_offsets[gt_index + 1] - _gt_entity_offsets[gt_index];
741  for (size_type entity_index = 0; entity_index < entity_count; ++entity_index)
742  {
743  const size_type size = localOrdering().size(gt_index,entity_index);
744  _entity_dof_offsets[++index] = (carry += size);
745  _block_count += (size > 0);
746  }
747  }
748  _size = _entity_dof_offsets.back();
749 
750  if (!_container_blocked)
751  _block_count = _size;
752 
753  _codim_fixed_size.reset();
754  }
755 
756  _max_local_size = localOrdering().maxLocalSize();
757  }
758 
759  using BaseT::fixedSize;
760 
761  private:
762 
763  using BaseT::_container_blocked;
764  using BaseT::_fixed_size;
765  using BaseT::_max_local_size;
766  using BaseT::_size;
767  using BaseT::_block_count;
768  using BaseT::_codim_used;
769  using BaseT::_codim_fixed_size;
770 
771  typename Traits::EntitySet _es;
772  std::vector<typename Traits::SizeType> _gt_dof_offsets;
773  std::vector<typename Traits::SizeType> _gt_entity_offsets;
774  std::vector<typename Traits::SizeType> _entity_dof_offsets;
775 
776  };
777 
778 
780  } // namespace PDELab
781 } // namespace Dune
782 
783 #endif // DUNE_PDELAB_ORDERING_GRIDVIEWORDERING_HH
void leaf(Node &node, TreePath tp) const
Definition: gridviewordering.hh:330
LocalOrdering & localOrdering()
Definition: gridviewordering.hh:500
const LocalOrdering & localOrdering() const
Definition: gridviewordering.hh:505
void afterChild(Node &node, const Child &child, TreePath tp, ChildIndex childIndex) const
Definition: gridviewordering.hh:354
const Dune::ReferenceElement< typename Cell::Geometry::ctype, Cell::dimension > & ref_el
Definition: gridviewordering.hh:222
static const int dim
Definition: adaptivity.hh:83
void post(Node &node, TreePath tp) const
Definition: gridviewordering.hh:268
void mapIndex(typename Traits::DOFIndexView di, typename Traits::ContainerIndex &ci) const
Definition: gridviewordering.hh:522
std::vector< size_type > gt_sizes
Definition: gridviewordering.hh:315
Definition: gridviewordering.hh:23
Definition: ordering/utility.hh:231
void post(Node &node, TreePath tp) const
Definition: gridviewordering.hh:146
std::vector< GeometryType > GTVector
Definition: gridviewordering.hh:326
void afterChild(Node &node, const Child &child, TreePath tp, ChildIndex childIndex) const
Definition: gridviewordering.hh:63
const Cell & cell
Definition: gridviewordering.hh:221
void leaf(Node &node, TreePath tp)
Definition: gridviewordering.hh:49
ES es
Definition: gridviewordering.hh:424
GridViewOrdering(const typename NodeT::NodeStorage &local_ordering, bool container_blocked, typename BaseT::GFSData *gfs_data)
Construct ordering object.
Definition: gridviewordering.hh:461
void set_cell(const Cell &cell_)
Definition: gridviewordering.hh:306
ES es
Definition: gridviewordering.hh:312
void post(Node &node, TreePath tp) const
Definition: gridviewordering.hh:365
Definition: orderingbase.hh:20
void pre(Node &node, TreePath tp) const
Definition: gridviewordering.hh:107
Codims & codims
Definition: gridviewordering.hh:38
Definition: gridviewordering.hh:43
void update()
Definition: gridviewordering.hh:636
void leaf(Node &node, TreePath tp) const
Definition: gridviewordering.hh:86
collect_used_codims(Codims &codims_)
Definition: gridviewordering.hh:34
void map_lfs_indices(const ItIn begin, const ItIn end, ItOut out) const
Definition: gridviewordering.hh:553
pre_collect_used_geometry_types(std::size_t dimension)
Definition: gridviewordering.hh:194
const std::size_t dim
Definition: gridviewordering.hh:198
ES::template Codim< 0 >::Entity Cell
Definition: gridviewordering.hh:289
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:595
virtual void map_index_dynamic(typename Traits::DOFIndexView di, typename Traits::ContainerIndex &ci) const
Definition: gridviewordering.hh:510
extract_per_entity_sizes_from_cell_visitor(const ES &es_)
Definition: gridviewordering.hh:299
void leaf(Node &node, TreePath tp)
Definition: gridviewordering.hh:29
Definition: gridviewordering.hh:171
void leaf(Node &node, TreePath tp) const
Definition: gridviewordering.hh:177
bool all
Definition: gridviewordering.hh:74
LocalOrdering::Traits Traits
Definition: gridviewordering.hh:438
void leaf(Node &node, TreePath tp)
Definition: gridviewordering.hh:293
void leaf(Node &node, TreePath tp) const
Definition: gridviewordering.hh:234
collect_used_geometry_types_from_cell_visitor(const Cell &cell_)
Definition: gridviewordering.hh:216
void pre(Node &node, TreePath tp) const
Definition: gridviewordering.hh:343
void pre(Node &node, TreePath tp) const
Definition: gridviewordering.hh:57
Definition: gridviewordering.hh:430
For backward compatibility – Do not use this!
Definition: adaptivity.hh:27
update_fixed_size(const ES es_)
Definition: gridviewordering.hh:162
Definition: gridviewordering.hh:228
Definition: gridviewordering.hh:80
const Cell * cell
Definition: gridviewordering.hh:313
collect_a_priori_fixed_size()
Definition: gridviewordering.hh:68
void pre(Node &node, TreePath tp) const
Definition: gridviewordering.hh:189
ES es
Definition: gridviewordering.hh:277
const Dune::ReferenceElement< typename ES::Traits::CoordinateField, dim > * ref_el
Definition: gridviewordering.hh:314
Traits::ContainerIndex mapIndex(const typename Traits::DOFIndex &di) const
Definition: gridviewordering.hh:515
ES es
Definition: gridviewordering.hh:166
post_collect_used_geometry_types(const ES &es_)
Definition: gridviewordering.hh:273
Definition: gridviewordering.hh:321
void afterChild(Node &node, const Child &child, TreePath tp, ChildIndex childIndex) const
Definition: gridviewordering.hh:121
std::size_t size_type
Definition: gridviewordering.hh:290
bool any
Definition: gridviewordering.hh:73
void leaf(Node &node, TreePath tp) const
Definition: gridviewordering.hh:210
Dune::PDELab::impl::GridFunctionSpaceOrderingData< typename Traits::SizeType > GFSData
Definition: orderingbase.hh:32
void afterChild(Node &node, const Child &child, TreePath tp, ChildIndex childIndex) const
Definition: gridviewordering.hh:253
post_extract_per_entity_sizes(const ES &es_)
Definition: gridviewordering.hh:420