Dune Core Modules (2.5.1)

yaspgridentity.hh
Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3#ifndef DUNE_GRID_YASPGRIDENTITY_HH
4#define DUNE_GRID_YASPGRIDENTITY_HH
5
19//========================================================================
20
21
22
23
24namespace Dune {
25
26 namespace Yasp {
27
28#ifndef DOXYGEN
29
30 // table for quick evaluation of binomial coefficients
31 template<int n>
32 struct BinomialTable
33 {
34 static void init()
35 {
36 if (_initialized)
37 return;
38 int offset = 0;
39 for (int d = 0; d <= n; ++d)
40 {
41 _offsets[d] = offset;
42 for (int c = 0; c <= d; ++c, ++offset)
43 _values[offset] = binomial(d,c);
44 }
45 _initialized = true;
46 }
47
48 // evaluation - note that in general d!=n, n is only the
49 // maximum value of d (in our case dimworld)
50 static int evaluate(int d, int c)
51 {
52 return _values[_offsets[d] + c];
53 }
54
55 private:
56 // prevent construction
57 BinomialTable();
58
59 static bool _initialized;
60 static std::array<int,(n+1)*(n+2)/2> _values;
61 static std::array<int,n+1> _offsets;
62
63 public:
64
65 // the actual implementation
66 static int binomial(int d, int c)
67 {
68 long binomial=1;
69 for (int i=d-c+1; i<=d; i++)
70 binomial *= i;
71 for (long i=2; i<=c; i++)
72 binomial /= i;
73 return binomial;
74 }
75 };
76
77 template<int n>
78 bool BinomialTable<n>::_initialized = false;
79 template<int n>
80 std::array<int,(n+1)*(n+2)/2> BinomialTable<n>::_values;
81 template<int n>
82 std::array<int,n+1> BinomialTable<n>::_offsets;
83
90 template<int dimworld>
91 int subEnt(int d, int c)
92 {
93 return (d < c ? 0 : BinomialTable<dimworld>::evaluate(d,c) << c);
94 }
95
96 // Make a table mapping all subentities of a codim 0 entity to a value.
97 // F is the functor to be evaluated.
98 template<typename F, int dim>
99 struct EntityShiftTable
100 {
101
102 typedef std::bitset<dim> value_type;
103
104 static void init()
105 {
106 if (_initialized)
107 return;
108 F f;
109 int offset = 0;
110 for (int codim = 0; codim <= dim; ++codim)
111 {
112 _offsets[codim] = offset;
113 for (int i = 0; i < subEnt<dim>(dim,codim); ++i, ++offset)
114 _values[offset] = static_cast<unsigned char>(f(i,codim).to_ulong());
115 }
116 _initialized = true;
117 }
118
119 static value_type evaluate(int i, int codim)
120 {
121 return {_values[_offsets[codim] + i]};
122 }
123
124 private:
125
126 // prevent construction
127 EntityShiftTable();
128
129 static bool _initialized;
130 static std::array<int,dim+1> _offsets;
131 static std::array<unsigned char,StaticPower<3,dim>::power> _values;
132
133 };
134
135 template<typename F, int dim>
136 bool EntityShiftTable<F,dim>::_initialized = false;
137 template<typename F, int dim>
138 std::array<int,dim+1> EntityShiftTable<F,dim>::_offsets;
139 template<typename F, int dim>
140 std::array<unsigned char,StaticPower<3,dim>::power> EntityShiftTable<F,dim>::_values;
141
142 // functor for doing the actual entity shift calculation
143 template<int dim>
144 struct calculate_entity_shift
145 {
146 calculate_entity_shift()
147 {
148 BinomialTable<dim>::init();
149 }
150
151 std::bitset<dim> operator()(int index, int cc) const
152 {
153 std::bitset<dim> result(0ull);
154 for (int d = dim; d>0; d--)
155 {
156 if (cc == d)
157 return result;
158 if (index < subEnt<dim>(d-1,cc))
159 result[d-1]=true;
160 else
161 {
162 index = (index - subEnt<dim>(d-1, cc)) % subEnt<dim>(d-1,cc-1);
163 cc--;
164 }
165 }
166 return result;
167 }
168 };
169
178 template<int dim>
179 std::bitset<dim> entityShift(int index, int cc)
180 {
181 return EntityShiftTable<calculate_entity_shift<dim>,dim>::evaluate(index,cc);
182 }
183
184 // functor for doing the actual entity move calculation
185 template<int dim>
186 struct calculate_entity_move
187 {
188
189 calculate_entity_move()
190 {
191 BinomialTable<dim>::init();
192 }
193
194 std::bitset<dim> operator()(int index, int cc) const
195 {
196 std::bitset<dim> result(0ull);
197 for (int d = dim; d>0; d--)
198 {
199 if (d == cc)
200 {
201 result[d-1] = index & (1<<(d-1));
202 index &= ~(1<<(d-1));
203 }
204 if (index >= subEnt<dim>(d-1,cc))
205 {
206 if ((index - subEnt<dim>(d-1,cc)) / subEnt<dim>(d-1,cc-1) == 1)
207 {
208 result[d-1] = true;
209 }
210 index = (index - subEnt<dim>(d-1, cc)) % subEnt<dim>(d-1,cc-1);
211 cc--;
212 }
213 }
214 return result;
215 }
216
217 };
218
226 template<int dim>
227 std::bitset<dim> entityMove(int index, int cc)
228 {
229 return EntityShiftTable<calculate_entity_move<dim>,dim>::evaluate(index,cc);
230 }
231
232#endif //DOXYGEN
233
234 } // namespace Yasp.
235
236 template<int codim, int dim, class GridImp>
237 class YaspEntity
238 : public EntityDefaultImplementation <codim,dim,GridImp,YaspEntity>
239 {
240
241 template<int, PartitionIteratorType, typename>
242 friend class YaspLevelIterator;
243
244 public:
245 typedef typename GridImp::ctype ctype;
246
247 typedef typename GridImp::template Codim<codim>::Geometry Geometry;
248 typedef typename GridImp::Traits::template Codim<codim>::GeometryImpl GeometryImpl;
249
250 typedef typename GridImp::template Codim<codim>::EntitySeed EntitySeed;
251
253 int level () const
254 {
255 return _g->level();
256 }
257
261 EntitySeed seed() const
262 {
263 return EntitySeed(YaspEntitySeed<codim,GridImp>(_g->level(), _it.coord(), _it.which()));
264 }
265
267 Geometry geometry () const
268 {
269 GeometryImpl _geometry(_it.lowerleft(),_it.upperright(),_it.shift());
270 return Geometry(_geometry);
271 }
272
277 unsigned int subEntities (unsigned int cc) const
278 {
279 return Dune::Yasp::subEnt<dim>(dim-codim,cc-codim);
280 }
281
283 PartitionType partitionType () const
284 {
285 if (_g->interior[codim].inside(_it.coord(),_it.shift()))
286 return InteriorEntity;
287 if (_g->interiorborder[codim].inside(_it.coord(),_it.shift()))
288 return BorderEntity;
289 if (_g->overlap[codim].inside(_it.coord(),_it.shift()))
290 return OverlapEntity;
291 if (_g->overlapfront[codim].inside(_it.coord(),_it.shift()))
292 return FrontEntity;
293 return GhostEntity;
294 }
295
296 typedef typename GridImp::YGridLevelIterator YGLI;
297 typedef typename GridImp::YGrid::Iterator I;
298 YaspEntity ()
299 {}
300
301 YaspEntity (const YGLI& g, const I& it)
302 : _it(it), _g(g)
303 {}
304
305 YaspEntity (YGLI&& g, const I&& it)
306 : _it(std::move(it)), _g(std::move(g))
307 {}
308
310 bool equals (const YaspEntity& e) const
311 {
312 return _it == e._it && _g == e._g;
313 }
314
315 // IndexSets needs access to the private index methods
316 friend class Dune::YaspIndexSet<GridImp,true>;
317 friend class Dune::YaspIndexSet<GridImp,false>;
318 friend class Dune::YaspGlobalIdSet<GridImp>;
319 typedef typename GridImp::PersistentIndexType PersistentIndexType;
320
322 PersistentIndexType persistentIndex () const
323 {
324 // get size of global grid (in elements)
325 std::array<int,dim> size;
326
327 for (int i=0; i<dim; i++)
328 {
329 // correct size according to shift
330 size[i] = _g->mg->levelSize(_g->level(), i);
331 if (!_it.shift(i))
332 size[i]++;
333 }
334
335 // encode codim
336 PersistentIndexType id(_it.shift().to_ulong());
337
338 // encode level
339 id = id << yaspgrid_level_bits;
340 id = id+PersistentIndexType(_g->level());
341
342 // encode coordinates
343 for (int i=dim-1; i>=0; i--)
344 {
345 id = id << yaspgrid_dim_bits;
346 id = id+PersistentIndexType(_it.coord(i));
347 }
348
349 return id;
350 }
351
353 int compressedIndex () const
354 {
355 return _it.superindex();
356 }
357
359 int subCompressedIndex (int i, unsigned int cc) const
360 {
361 // get the shift of the entity and the subentity
362 // the subentity shift is only available in the space spanned by the entity
363 std::bitset<dim> ent_shift = _it.shift();
364 std::bitset<dim-codim> subent_shift = Dune::Yasp::entityShift<dim-codim>(i,cc);
365 std::bitset<dim-codim> subent_move = Dune::Yasp::entityMove<dim-codim>(i,cc);
366 // combine the shifts to get the global shift of the subentity
367 std::bitset<dim> shift,move;
368 for (int curDim=0,j=0; curDim < dim; curDim++)
369 if (ent_shift[curDim])
370 {
371 shift[curDim] = subent_shift[j];
372 move[curDim] = subent_move[j];
373 j++;
374 }
375
376 std::array<int, dim> size = _g->mg->levelSize(_g->level());
377 std::array<int, dim> coord = _it.coord();
378 for (int j=0; j<dim; j++)
379 {
380 if (!shift[j])
381 size[j]++;
382 if (move[j])
383 coord[j]++;
384 }
385
386 int which = _g->overlapfront[cc].shiftmapping(shift);
387 return _g->overlapfront[cc].superindex(coord,which);
388 }
389 public:
390 const I& transformingsubiterator() const { return _it; }
391 const YGLI& gridlevel() const { return _g; }
392 I& transformingsubiterator() { return _it; }
393 YGLI& gridlevel() { return _g; }
394 const GridImp * yaspgrid() const { return _g->mg; }
395 protected:
396 I _it; // position in the grid level
397 YGLI _g; // access to grid level
398 };
399
400
401 // specialization for codim=0
402 template<int dim, class GridImp>
403 class YaspEntity<0,dim,GridImp>
404 : public EntityDefaultImplementation <0,dim,GridImp,YaspEntity>
405 {
406 enum { dimworld = GridImp::dimensionworld };
407
408 typedef typename GridImp::Traits::template Codim< 0 >::GeometryImpl GeometryImpl;
409
410 template<int, PartitionIteratorType, typename>
411 friend class YaspLevelIterator;
412
413 template<typename>
414 friend class YaspHierarchicIterator;
415
416 public:
417 typedef typename GridImp::ctype ctype;
418
419 typedef typename GridImp::YGridLevelIterator YGLI;
420 typedef typename GridImp::YGrid::Iterator I;
421
422 typedef typename GridImp::template Codim< 0 >::Geometry Geometry;
423 typedef typename GridImp::template Codim< 0 >::LocalGeometry LocalGeometry;
424
425 template <int cd>
426 struct Codim
427 {
428 typedef typename GridImp::template Codim<cd>::Entity Entity;
429 };
430
431 typedef typename GridImp::template Codim<0>::Entity Entity;
432 typedef typename GridImp::template Codim<0>::EntitySeed EntitySeed;
433 typedef typename GridImp::LevelIntersectionIterator IntersectionIterator;
434 typedef typename GridImp::LevelIntersectionIterator LevelIntersectionIterator;
435 typedef typename GridImp::LeafIntersectionIterator LeafIntersectionIterator;
436 typedef typename GridImp::HierarchicIterator HierarchicIterator;
437
439 typedef typename GridImp::PersistentIndexType PersistentIndexType;
440
442 typedef typename GridImp::YGrid::iTupel iTupel;
443
444 // constructor
445 YaspEntity ()
446 {}
447
448 YaspEntity (const YGLI& g, const I& it)
449 : _it(it), _g(g)
450 {}
451
452 YaspEntity (const YGLI& g, I&& it)
453 : _it(std::move(it)), _g(g)
454 {}
455
456 YaspEntity (YGLI&& g, I&& it)
457 : _it(std::move(it)), _g(std::move(g))
458 {}
459
461 bool equals (const YaspEntity& e) const
462 {
463 return _it == e._it && _g == e._g;
464 }
465
467 int level () const { return _g->level(); }
468
472 EntitySeed seed () const {
473 return EntitySeed(YaspEntitySeed<0,GridImp>(_g->level(), _it.coord()));
474 }
475
477 PartitionType partitionType () const
478 {
479 if (_g->interior[0].inside(_it.coord(),_it.shift()))
480 return InteriorEntity;
481 if (_g->overlap[0].inside(_it.coord(),_it.shift()))
482 return OverlapEntity;
483 DUNE_THROW(GridError, "Impossible GhostEntity");
484 return GhostEntity;
485 }
486
488 Geometry geometry () const {
489 // the element geometry
490 auto ll = _it.lowerleft();
491 auto ur = _it.upperright();
492
493 // If on periodic overlap, transform coordinates by domain size
494 for (int i=0; i<dimworld; i++) {
495 if (gridlevel()->mg->isPeriodic(i)) {
496 int coord = transformingsubiterator().coord(i);
497 if (coord < 0) {
498 auto size = _g->mg->domainSize()[i];
499 ll[i] += size;
500 ur[i] += size;
501 } else if (coord + 1 > gridlevel()->mg->levelSize(gridlevel()->level(),i)) {
502 auto size = _g->mg->domainSize()[i];
503 ll[i] -= size;
504 ur[i] -= size;
505 }
506 }
507 }
508
509 GeometryImpl _geometry(ll,ur);
510 return Geometry( _geometry );
511 }
512
517 template<int cc> int count () const
518 {
519 return Dune::Yasp::subEnt<dim>(dim,cc);
520 }
521
526 unsigned int subEntities (unsigned int codim) const
527 {
528 return Dune::Yasp::subEnt<dim>(dim,codim);
529 }
530
533 template<int cc>
534 typename Codim<cc>::Entity subEntity (int i) const
535 {
536 // calculate move bitset
537 std::bitset<dim> move = Dune::Yasp::entityMove<dim>(i,cc);
538
539 // get the coordinate and modify it
540 iTupel coord = _it.coord();
541 for (int j=0; j<dim; j++)
542 if (move[j])
543 coord[j]++;
544
545 int which = _g->overlapfront[cc].shiftmapping(Dune::Yasp::entityShift<dim>(i,cc));
546 return typename Codim<cc>::Entity(YaspEntity<cc,GridImp::dimension,GridImp>(_g,_g->overlapfront[cc].begin(coord, which)));
547 }
548
550 Entity father () const
551 {
552 // check if coarse level exists
553 if (_g->level()<=0)
554 DUNE_THROW(GridError, "tried to call father on level 0");
555
556 // yes, get iterator to it
557 YGLI cg(_g);
558 --cg;
559
560 // coordinates of the cell
561 iTupel coord = _it.coord();
562
563 // get coordinates on next coarser level
564 for (int k=0; k<dim; k++) coord[k] = coord[k]/2;
565
566 return Entity(YaspEntity<0,GridImp::dimension,GridImp>(cg,cg->overlap[0].begin(coord)));
567 }
568
570 bool hasFather () const
571 {
572 return (_g->level()>0);
573 }
574
577 LocalGeometry geometryInFather () const
578 {
579 // configure one of the 2^dim transformations
580 FieldVector<ctype,dim> ll(0.0),ur(0.5);
581
582 for (int k=0; k<dim; k++)
583 {
584 if (_it.coord(k)%2)
585 {
586 ll[k] = 0.5;
587 ur[k] = 1.0;
588 }
589 }
590
591 return LocalGeometry( YaspGeometry<dim,dim,GridImp>(ll,ur) );
592 }
593
594 const I& transformingsubiterator () const { return _it; }
595 const YGLI& gridlevel () const { return _g; }
596 I& transformingsubiterator() { return _it; }
597 YGLI& gridlevel() { return _g; }
598 const GridImp* yaspgrid () const { return _g->mg; }
599
600 bool isLeaf() const
601 {
602 return (_g->level() == yaspgrid()->maxLevel());
603 }
604
607 bool isNew () const { return yaspgrid()->adaptRefCount > 0 && yaspgrid()->maxLevel() < _g->level() + yaspgrid()->adaptRefCount; }
608
611 bool mightVanish () const { return false; }
612
614 IntersectionIterator ibegin () const
615 {
616 return YaspIntersectionIterator<GridImp>(*this,false);
617 }
618
620 LeafIntersectionIterator ileafbegin () const
621 {
622 // only if entity is leaf this iterator delivers intersections
623 return YaspIntersectionIterator<GridImp>(*this, ! isLeaf() );
624 }
625
627 LevelIntersectionIterator ilevelbegin () const
628 {
629 return ibegin();
630 }
631
633 IntersectionIterator iend () const
634 {
635 return YaspIntersectionIterator<GridImp>(*this,true);
636 }
637
639 LeafIntersectionIterator ileafend () const
640 {
641 return iend();
642 }
643
645 LevelIntersectionIterator ilevelend () const
646 {
647 return iend();
648 }
649
654 HierarchicIterator hbegin (int maxlevel) const
655 {
656 return YaspHierarchicIterator<GridImp>(_g,_it,maxlevel);
657 }
658
660 HierarchicIterator hend (int maxlevel) const
661 {
662 return YaspHierarchicIterator<GridImp>(_g,_it,_g->level());
663 }
664
665 private:
666 // IndexSets needs access to the private index methods
667 friend class Dune::YaspIndexSet<GridImp,true>;
668 friend class Dune::YaspIndexSet<GridImp,false>;
669 friend class Dune::YaspGlobalIdSet<GridImp>;
670
672 PersistentIndexType persistentIndex () const
673 {
674 // encode codim
675 PersistentIndexType id(_it.shift().to_ulong());
676
677 // encode level
678 id = id << yaspgrid_level_bits;
679 id = id+PersistentIndexType(_g->level());
680
681
682 // encode coordinates
683 for (int i=dim-1; i>=0; i--)
684 {
685 id = id << yaspgrid_dim_bits;
686 id = id+PersistentIndexType(_it.coord(i));
687 }
688
689 return id;
690 }
691
693 int compressedIndex () const
694 {
695 return _it.superindex();
696 }
697
699 PersistentIndexType subPersistentIndex (int i, int cc) const
700 {
701 // calculate shift and move bitsets
702 std::bitset<dim> shift = Dune::Yasp::entityShift<dim>(i,cc);
703 std::bitset<dim> move = Dune::Yasp::entityMove<dim>(i,cc);
704
705 int trailing = (cc == dim) ? 1000 : 0;
706
707 std::array<int,dim> size = _g->mg->levelSize(_g->level());
708 std::array<int, dim> coord = _it.coord();
709 for (int j=0; j<dim; j++)
710 {
711 // correct size according to shift
712 if (!shift[j])
713 size[j]++;
714
715 // move the coordinates to the cell on which the entity lives
716 if (move[j])
717 coord[j]++;
718 }
719
720 for (int j=0; j<dim; j++)
721 {
722 // in the codim==dim case, count trailing zeroes.
723 if (cc == dim)
724 {
725 int zeroes = 0;
726 for (int k=0; k<_g->level(); k++)
727 if (coord[j] & (1<<k))
728 break;
729 else
730 zeroes++;
731 trailing = std::min(trailing,zeroes);
732 }
733 }
734
735 // encode codim
736 PersistentIndexType id(shift.to_ulong());
737
738 // encode level
739 id = id << yaspgrid_level_bits;
740 id = id+PersistentIndexType(_g->level()-trailing);
741
742 // encode coordinates
743 for (int j=dim-1; j>=0; j--)
744 {
745 id = id << yaspgrid_dim_bits;
746 id = id+PersistentIndexType(coord[j]>>trailing);
747 }
748
749 return id;
750 }
751
753 int subCompressedIndex (int i, int cc) const
754 {
755 // get shift and move of the subentity in question
756 std::bitset<dim> shift = Dune::Yasp::entityShift<dim>(i,cc);
757 std::bitset<dim> move = Dune::Yasp::entityMove<dim>(i,cc);
758
759 std::array<int,dim> size = _g->mg->levelSize(_g->level());
760 std::array<int, dim> coord = _it.coord();
761 for (int j=0; j<dim; j++)
762 {
763
764 size[j] += !shift[j];
765 coord[j] += move[j];
766 }
767
768 int which = _g->overlapfront[cc].shiftmapping(shift);
769 return _g->overlapfront[cc].superindex(coord,which);
770 }
771
772 I _it; // position in the grid level
773 YGLI _g; // access to grid level
774 };
775
776
777 // specialization for codim=dim (vertex)
778 template<int dim, class GridImp>
779 class YaspEntity<dim,dim,GridImp>
780 : public EntityDefaultImplementation <dim,dim,GridImp,YaspEntity>
781 {
782 enum { dimworld = GridImp::dimensionworld };
783
784 template<int, PartitionIteratorType, typename>
785 friend class YaspLevelIterator;
786
787 typedef typename GridImp::Traits::template Codim<dim>::GeometryImpl GeometryImpl;
788
789 public:
790 typedef typename GridImp::ctype ctype;
791
792 typedef typename GridImp::YGridLevelIterator YGLI;
793 typedef typename GridImp::YGrid::Iterator I;
794
795 typedef typename GridImp::template Codim<dim>::Geometry Geometry;
796
797 typedef typename GridImp::template Codim<dim>::EntitySeed EntitySeed;
798
800 typedef typename GridImp::PersistentIndexType PersistentIndexType;
801
803 typedef typename GridImp::YGrid::iTupel iTupel;
804
805 // constructor
806 YaspEntity ()
807 {}
808
809 YaspEntity (const YGLI& g, const I& it)
810 : _it(it), _g(g)
811 {}
812
813 YaspEntity (YGLI&& g, I&& it)
814 : _it(std::move(it)), _g(std::move(g))
815 {}
816
818 bool equals (const YaspEntity& e) const
819 {
820 return _it == e._it && _g == e._g;
821 }
822
824 int level () const {return _g->level();}
825
829 EntitySeed seed () const {
830 return EntitySeed(YaspEntitySeed<dim,GridImp>(_g->level(), _it.coord(), _it.which()));
831 }
832
837 unsigned int subEntities (unsigned int cc) const
838 {
839 return Dune::Yasp::subEnt<dim>(dim-dim,cc-dim);
840 }
841
843 Geometry geometry () const {
844 GeometryImpl _geometry((_it).lowerleft());
845 return Geometry( _geometry );
846 }
847
849 PartitionType partitionType () const
850 {
851 if (_g->interior[dim].inside(_it.coord(),_it.shift()))
852 return InteriorEntity;
853 if (_g->interiorborder[dim].inside(_it.coord(),_it.shift()))
854 return BorderEntity;
855 if (_g->overlap[dim].inside(_it.coord(),_it.shift()))
856 return OverlapEntity;
857 if (_g->overlapfront[dim].inside(_it.coord(),_it.shift()))
858 return FrontEntity;
859 return GhostEntity;
860 }
861
863 int subCompressedIndex (int, unsigned int ) const
864 {
865 return compressedIndex();
866 }
867
868 private:
869 // IndexSets needs access to the private index methods
870 friend class Dune::YaspIndexSet<GridImp,true>;
871 friend class Dune::YaspIndexSet<GridImp,false>;
872 friend class Dune::YaspGlobalIdSet<GridImp>;
873
875 PersistentIndexType persistentIndex () const
876 {
877 // get coordinate and size of global grid
878 iTupel size = _g->mg->levelSize(_g->level());
879
880 for (int i=0; i<dim; i++)
881 {
882 // we have vertices, add 1 size to all directions
883 size[i]++;
884 }
885
886 // determine min number of trailing zeroes
887 int trailing = 1000;
888 for (int i=0; i<dim; i++)
889 {
890 // count trailing zeros
891 int zeros = 0;
892 for (int j=0; j<_g->level(); j++)
893 if (_it.coord(i)&(1<<j))
894 break;
895 else
896 zeros++;
897 trailing = std::min(trailing,zeros);
898 }
899
900 // determine the level of this vertex
901 int level = _g->level()-trailing;
902
903 // encode codim: shift vector of vertices is 0.
904 PersistentIndexType id(0);
905
906 // encode level
907 id = id << yaspgrid_level_bits;
908 id = id+PersistentIndexType(level);
909
910 // encode coordinates
911 for (int i=dim-1; i>=0; i--)
912 {
913 id = id << yaspgrid_dim_bits;
914 id = id+PersistentIndexType(_it.coord(i)>>trailing);
915 }
916
917 return id;
918 }
919
921 int compressedIndex () const { return _it.superindex();}
922
923 public:
924 const I& transformingsubiterator() const { return _it; }
925 const YGLI& gridlevel() const { return _g; }
926 I& transformingsubiterator() { return _it; }
927 YGLI& gridlevel() { return _g; }
928
929 const GridImp * yaspgrid() const { return _g->mg; }
930 protected:
931 I _it; // position in the grid level
932 YGLI _g; // access to grid level
933 };
934
935} // namespace Dune
936
937#endif // DUNE_GRID_YASPGRIDENTITY_HH
persistent, globally unique Ids
Definition: yaspgrididset.hh:23
IdType id(const typename std::remove_const< GridImp >::type::Traits::template Codim< cd >::Entity &e) const
get id of an entity
Definition: yaspgrididset.hh:42
Implementation of Level- and LeafIndexSets for YaspGrid.
Definition: yaspgridindexsets.hh:23
#define DUNE_THROW(E, m)
Definition: exceptions.hh:216
PartitionType
Attributes used in the generic overlap model.
Definition: gridenums.hh:28
@ FrontEntity
on boundary between overlap and ghost
Definition: gridenums.hh:32
@ InteriorEntity
all interior entities
Definition: gridenums.hh:29
@ GhostEntity
ghost entities
Definition: gridenums.hh:33
@ BorderEntity
on boundary between interior and overlap
Definition: gridenums.hh:30
@ OverlapEntity
all entities lying in the overlap zone
Definition: gridenums.hh:31
constexpr auto equals(T1 &&t1, T2 &&t2)
Equality comparison.
Definition: hybridutilities.hh:441
int binomial(int upper, int lower)
calculate
Definition: simplex.cc:294
Dune namespace.
Definition: alignment.hh:11
STL namespace.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Sep 26, 22:29, 2024)