Go to the documentation of this file.
3 #ifndef DUNE_GRID_YASPGRIDENTITY_HH
4 #define DUNE_GRID_YASPGRIDENTITY_HH
39 for (
int d = 0; d <= n; ++d)
42 for (
int c = 0; c <= d; ++c, ++offset)
43 _values[offset] = binomial(d,c);
50 static int evaluate(
int d,
int c)
52 return _values[_offsets[d] + c];
59 static bool _initialized;
60 static std::array<int,(n+1)*(n+2)/2> _values;
61 static std::array<int,n+1> _offsets;
66 static int binomial(
int d,
int c)
69 for (
int i=d-c+1; i<=d; i++)
71 for (
long i=2; i<=c; i++)
78 bool BinomialTable<n>::_initialized =
false;
80 std::array<int,(n+1)*(n+2)/2> BinomialTable<n>::_values;
82 std::array<int,n+1> BinomialTable<n>::_offsets;
90 template<
int dimworld>
91 int subEnt(
int d,
int c)
93 return (d < c ? 0 : BinomialTable<dimworld>::evaluate(d,c) << c);
98 template<
typename F,
int dim>
99 struct EntityShiftTable
102 typedef std::bitset<dim> value_type;
110 for (
int codim = 0; codim <= dim; ++codim)
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());
119 static value_type evaluate(
int i,
int codim)
121 return {_values[_offsets[codim] + i]};
129 static bool _initialized;
130 static std::array<int,dim+1> _offsets;
131 static std::array<unsigned char,StaticPower<3,dim>::power> _values;
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;
144 struct calculate_entity_shift
146 calculate_entity_shift()
148 BinomialTable<dim>::init();
151 std::bitset<dim> operator()(
int index,
int cc)
const
153 std::bitset<dim> result(0ull);
154 for (
int d = dim; d>0; d--)
158 if (index < subEnt<dim>(d-1,cc))
162 index = (index - subEnt<dim>(d-1, cc)) % subEnt<dim>(d-1,cc-1);
179 std::bitset<dim> entityShift(
int index,
int cc)
181 return EntityShiftTable<calculate_entity_shift<dim>,dim>::evaluate(index,cc);
186 struct calculate_entity_move
189 calculate_entity_move()
191 BinomialTable<dim>::init();
194 std::bitset<dim> operator()(
int index,
int cc)
const
196 std::bitset<dim> result(0ull);
197 for (
int d = dim; d>0; d--)
201 result[d-1] = index & (1<<(d-1));
202 index &= ~(1<<(d-1));
204 if (index >= subEnt<dim>(d-1,cc))
206 if ((index - subEnt<dim>(d-1,cc)) / subEnt<dim>(d-1,cc-1) == 1)
210 index = (index - subEnt<dim>(d-1, cc)) % subEnt<dim>(d-1,cc-1);
227 std::bitset<dim> entityMove(
int index,
int cc)
229 return EntityShiftTable<calculate_entity_move<dim>,dim>::evaluate(index,cc);
236 template<
int codim,
int dim,
class Gr
idImp>
238 :
public EntityDefaultImplementation <codim,dim,GridImp,YaspEntity>
241 template<
int, PartitionIteratorType,
typename>
245 typedef typename GridImp::ctype
ctype;
247 typedef typename GridImp::template Codim<codim>::Geometry
Geometry;
248 typedef typename GridImp::Traits::template Codim<codim>::GeometryImpl
GeometryImpl;
250 typedef typename GridImp::template Codim<codim>::EntitySeed
EntitySeed;
276 if (
_g->interior[codim].inside(
_it.coord(),
_it.shift()))
278 if (
_g->interiorborder[codim].inside(
_it.coord(),
_it.shift()))
280 if (
_g->overlap[codim].inside(
_it.coord(),
_it.shift()))
282 if (
_g->overlapfront[codim].inside(
_it.coord(),
_it.shift()))
287 typedef typename GridImp::YGridLevelIterator
YGLI;
288 typedef typename GridImp::YGrid::Iterator
I;
299 #if not (defined(__GNUC__) && (__GNUC__ < 5) && (__GNUC_MINOR__ < 5))
302 :
_it(std::move(it)),
_g(std::move(g))
310 return _it == e._it &&
_g == e._g;
323 std::array<int,dim> size;
325 for (
int i=0; i<dim; i++)
328 size[i] =
_g->mg->levelSize(
_g->level(), i);
341 for (
int i=dim-1; i>=0; i--)
353 return _it.superindex();
361 std::bitset<dim> ent_shift =
_it.shift();
362 std::bitset<dim-codim> subent_shift = Dune::Yasp::entityShift<dim-codim>(i,cc);
363 std::bitset<dim-codim> subent_move = Dune::Yasp::entityMove<dim-codim>(i,cc);
365 std::bitset<dim> shift,move;
366 for (
int curDim=0,j=0; curDim < dim; curDim++)
367 if (ent_shift[curDim])
369 shift[curDim] = subent_shift[j];
370 move[curDim] = subent_move[j];
374 std::array<int, dim> size =
_g->mg->levelSize(
_g->level());
375 std::array<int, dim> coord =
_it.coord();
376 for (
int j=0; j<dim; j++)
384 int which =
_g->overlapfront[cc].shiftmapping(shift);
385 return _g->overlapfront[cc].superindex(coord,which);
400 template<
int dim,
class Gr
idImp>
404 enum { dimworld = GridImp::dimensionworld };
406 typedef typename GridImp::Traits::template Codim< 0 >::GeometryImpl
GeometryImpl;
408 template<
int, PartitionIteratorType,
typename>
415 typedef typename GridImp::ctype
ctype;
417 typedef typename GridImp::YGridLevelIterator
YGLI;
418 typedef typename GridImp::YGrid::Iterator
I;
420 typedef typename GridImp::template Codim< 0 >::Geometry
Geometry;
430 typedef typename GridImp::template Codim<0>::EntitySeed
EntitySeed;
440 typedef typename GridImp::YGrid::iTupel
iTupel;
451 :
_it(std::move(it)),
_g(g)
457 #if not (defined(__GNUC__) && (__GNUC__ < 5) && (__GNUC_MINOR__ < 5))
460 :
_it(std::move(it)),
_g(std::move(g))
468 return _it == e._it &&
_g == e._g;
484 if (
_g->interior[0].inside(
_it.coord(),
_it.shift()))
486 if (
_g->overlap[0].inside(
_it.coord(),
_it.shift()))
488 DUNE_THROW(
GridError,
"Impossible GhostEntity");
495 auto ll =
_it.lowerleft();
496 auto ur =
_it.upperright();
499 for (
int i=0; i<dimworld; i++) {
503 auto size =
_g->mg->domainSize()[i];
507 auto size =
_g->mg->domainSize()[i];
514 GeometryImpl _geometry(ll,ur);
524 return Dune::Yasp::subEnt<dim>(dim,cc);
533 return Dune::Yasp::subEnt<dim>(dim,codim);
542 std::bitset<dim> move = Dune::Yasp::entityMove<dim>(i,cc);
546 for (
int j=0; j<dim; j++)
550 int which =
_g->overlapfront[cc].shiftmapping(Dune::Yasp::entityShift<dim>(i,cc));
559 DUNE_THROW(
GridError,
"tried to call father on level 0");
569 for (
int k=0; k<dim; k++) coord[k] = coord[k]/2;
577 return (
_g->level()>0);
585 FieldVector<ctype,dim> ll(0.0),ur(0.5);
587 for (
int k=0; k<dim; k++)
607 return (
_g->level() ==
yaspgrid()->maxLevel());
688 for (
int i=dim-1; i>=0; i--)
700 return _it.superindex();
707 std::bitset<dim> shift = Dune::Yasp::entityShift<dim>(i,cc);
708 std::bitset<dim> move = Dune::Yasp::entityMove<dim>(i,cc);
710 int trailing = (cc == dim) ? 1000 : 0;
712 std::array<int,dim> size =
_g->mg->levelSize(
_g->level());
713 std::array<int, dim> coord =
_it.coord();
714 for (
int j=0; j<dim; j++)
725 for (
int j=0; j<dim; j++)
731 for (
int k=0; k<
_g->level(); k++)
732 if (coord[j] & (1<<k))
736 trailing =
std::min(trailing,zeroes);
748 for (
int j=dim-1; j>=0; j--)
761 std::bitset<dim> shift = Dune::Yasp::entityShift<dim>(i,cc);
762 std::bitset<dim> move = Dune::Yasp::entityMove<dim>(i,cc);
764 std::array<int,dim> size =
_g->mg->levelSize(
_g->level());
765 std::array<int, dim> coord =
_it.coord();
766 for (
int j=0; j<dim; j++)
769 size[j] += !shift[j];
773 int which =
_g->overlapfront[cc].shiftmapping(shift);
774 return _g->overlapfront[cc].superindex(coord,which);
783 template<
int dim,
class Gr
idImp>
787 enum { dimworld = GridImp::dimensionworld };
789 template<
int, PartitionIteratorType,
typename>
792 typedef typename GridImp::Traits::template Codim<dim>::GeometryImpl
GeometryImpl;
795 typedef typename GridImp::ctype
ctype;
797 typedef typename GridImp::YGridLevelIterator
YGLI;
798 typedef typename GridImp::YGrid::Iterator
I;
800 typedef typename GridImp::template Codim<dim>::Geometry
Geometry;
802 typedef typename GridImp::template Codim<dim>::EntitySeed
EntitySeed;
808 typedef typename GridImp::YGrid::iTupel
iTupel;
821 #if not (defined(__GNUC__) && (__GNUC__ < 5) && (__GNUC_MINOR__ < 5))
824 :
_it(std::move(it)),
_g(std::move(g))
832 return _it == e._it &&
_g == e._g;
847 GeometryImpl _geometry((
_it).lowerleft());
854 if (
_g->interior[dim].inside(
_it.coord(),
_it.shift()))
856 if (
_g->interiorborder[dim].inside(
_it.coord(),
_it.shift()))
858 if (
_g->overlap[dim].inside(
_it.coord(),
_it.shift()))
860 if (
_g->overlapfront[dim].inside(
_it.coord(),
_it.shift()))
883 for (
int i=0; i<dim; i++)
891 for (
int i=0; i<dim; i++)
895 for (
int j=0; j<
_g->level(); j++)
896 if (
_it.coord(i)&(1<<j))
900 trailing =
std::min(trailing,zeros);
904 int level =
_g->level()-trailing;
914 for (
int i=dim-1; i>=0; i--)
940 #endif // DUNE_GRID_YASPGRIDENTITY_HH
PartitionType partitionType() const
return partition type attribute
Definition: yaspgridentity.hh:852
LocalGeometry geometryInFather() const
Definition: yaspgridentity.hh:582
int min(const DofVectorPointer< int > &dofVector)
Definition: dofvector.hh:346
I & transformingsubiterator()
Definition: yaspgridentity.hh:601
IntersectionIterator iend() const
Reference to one past the last neighbor.
Definition: yaspgridentity.hh:638
Describes the minimal information necessary to create a fully functional YaspEntity.
Definition: yaspgrid.hh:60
bool equals(const YaspEntity &e) const
Return true when two iterators over the same grid are equal (!).
Definition: yaspgridentity.hh:830
LeafIntersectionIterator ileafbegin() const
returns intersection iterator for first intersection
Definition: yaspgridentity.hh:625
const I & transformingsubiterator() const
Definition: yaspgridentity.hh:599
YGLI _g
Definition: yaspgridentity.hh:935
GridImp::YGrid::iTupel iTupel
define type used for coordinates in grid module
Definition: yaspgridentity.hh:808
int level() const
level of this element
Definition: yaspgridentity.hh:472
Include standard header files.
Definition: agrid.hh:59
I & transformingsubiterator()
Definition: yaspgridentity.hh:390
YGLI & gridlevel()
Definition: yaspgridentity.hh:930
const GridImp * yaspgrid() const
Definition: yaspgridentity.hh:392
int subCompressedIndex(int, unsigned int) const
subentity compressed index simply returns compressedIndex
Definition: yaspgridentity.hh:866
GridImp::ctype ctype
Definition: yaspgridentity.hh:795
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
Entity father() const
Inter-level access to father element on coarser grid. Assumes that meshes are nested.
Definition: yaspgridentity.hh:555
bool mightVanish() const
Returns true, if entity might disappear during the next call to adapt()
Definition: yaspgridentity.hh:616
HierarchicIterator hend(int maxlevel) const
Returns iterator to one past the last son.
Definition: yaspgridentity.hh:665
int compressedIndex() const
consecutive, codim-wise, level-wise index
Definition: yaspgridentity.hh:351
YaspHierarchicIterator enables iteration over son entities of codim 0.
Definition: yaspgrid.hh:64
bool isLeaf() const
Definition: yaspgridentity.hh:605
Geometry geometry() const
geometry of this entity
Definition: yaspgridentity.hh:267
EntitySeed seed() const
Return the entity seed which contains sufficient information to generate the entity again and uses as...
Definition: yaspgridentity.hh:841
const YGLI & gridlevel() const
Definition: yaspgridentity.hh:600
YGLI _g
Definition: yaspgridentity.hh:395
YGLI & gridlevel()
Definition: yaspgridentity.hh:602
I _it
Definition: yaspgridentity.hh:394
PartitionType
Attributes used in the generic overlap model.
Definition: gridenums.hh:28
YaspIntersectionIterator enables iteration over intersections with neighboring codim 0 entities.
Definition: yaspgrid.hh:62
all entities lying in the overlap zone
Definition: gridenums.hh:31
YaspEntity()
Definition: yaspgridentity.hh:289
persistent, globally unique Ids
Definition: yaspgrid.hh:66
GridImp::LevelIntersectionIterator LevelIntersectionIterator
Definition: yaspgridentity.hh:432
const YGLI & gridlevel() const
Definition: yaspgridentity.hh:389
The general version that handles all codimensions but 0 and dim.
Definition: yaspgrid.hh:57
bool isNew() const
Returns true, if the entity has been created during the last call to adapt()
Definition: yaspgridentity.hh:612
const I & transformingsubiterator() const
Definition: yaspgridentity.hh:927
GridImp::LeafIntersectionIterator LeafIntersectionIterator
Definition: yaspgridentity.hh:433
Iterates over entities of one grid level.
Definition: yaspgrid.hh:61
GridImp::YGridLevelIterator YGLI
Definition: yaspgridentity.hh:287
const GridImp * yaspgrid() const
Definition: yaspgridentity.hh:603
Definition: yaspgrid.hh:58
GridImp::ctype ctype
Definition: yaspgridentity.hh:245
GridImp::template Codim< 0 >::Geometry Geometry
Definition: yaspgridentity.hh:420
GridImp::YGrid::Iterator I
Definition: yaspgridentity.hh:418
PersistentIndexType persistentIndex() const
globally unique, persistent index
Definition: yaspgridentity.hh:320
LeafIntersectionIterator ileafend() const
Reference to one past the last neighbor.
Definition: yaspgridentity.hh:644
GridImp::YGrid::iTupel iTupel
define type used for coordinates in grid module
Definition: yaspgridentity.hh:440
GridImp::ctype ctype
Definition: yaspgridentity.hh:415
GridImp::template Codim< codim >::Geometry Geometry
Definition: yaspgridentity.hh:247
GridImp::PersistentIndexType PersistentIndexType
Definition: yaspgridentity.hh:317
Geometry geometry() const
geometry of this entity
Definition: yaspgridentity.hh:846
GridImp::template Codim< 0 >::EntitySeed EntitySeed
Definition: yaspgridentity.hh:430
YaspEntity(const YGLI &g, const I &it)
Definition: yaspgridentity.hh:292
GridImp::YGridLevelIterator YGLI
Definition: yaspgridentity.hh:797
ghost entities
Definition: gridenums.hh:33
YaspEntity(const YGLI &g, const I &it)
Definition: yaspgridentity.hh:446
GridImp::template Codim< dim >::EntitySeed EntitySeed
Definition: yaspgridentity.hh:802
GridImp::HierarchicIterator HierarchicIterator
Definition: yaspgridentity.hh:434
LevelIntersectionIterator ilevelbegin() const
returns intersection iterator for first intersection
Definition: yaspgridentity.hh:632
GridImp::PersistentIndexType PersistentIndexType
define the type used for persistent indices
Definition: yaspgridentity.hh:437
on boundary between overlap and ghost
Definition: gridenums.hh:32
const GridImp * yaspgrid() const
Definition: yaspgridentity.hh:932
YaspEntity()
Definition: yaspgridentity.hh:443
GridImp::template Codim< dim >::Geometry Geometry
Definition: yaspgridentity.hh:800
YaspEntity()
Definition: yaspgridentity.hh:811
bool equals(const YaspEntity &e) const
Return true when two iterators over the same grid are equal (!).
Definition: yaspgridentity.hh:308
const YGLI & gridlevel() const
Definition: yaspgridentity.hh:928
GridImp::Traits::template Codim< codim >::GeometryImpl GeometryImpl
Definition: yaspgridentity.hh:248
GridImp::PersistentIndexType PersistentIndexType
define the type used for persistent indices
Definition: yaspgridentity.hh:805
bool hasFather() const
returns true if father entity exists
Definition: yaspgridentity.hh:575
all interior entities
Definition: gridenums.hh:29
GridImp::template Codim< cd >::EntitySeed EntitySeed
The corresponding entity seed (for storage of entities)
Definition: common/entity.hh:556
GridImp::LevelIntersectionIterator IntersectionIterator
Definition: yaspgridentity.hh:431
EntitySeed seed() const
Return the entity seed which contains sufficient information to generate the entity again and uses as...
Definition: yaspgridentity.hh:477
GridImp::YGridLevelIterator YGLI
Definition: yaspgridentity.hh:417
I & transformingsubiterator()
Definition: yaspgridentity.hh:929
on boundary between interior and overlap
Definition: gridenums.hh:30
YaspEntity(const YGLI &g, I &&it)
Definition: yaspgridentity.hh:450
GridImp::YGrid::Iterator I
Definition: yaspgridentity.hh:798
const int yaspgrid_dim_bits
Definition: yaspgrid.hh:49
HierarchicIterator hbegin(int maxlevel) const
Definition: yaspgridentity.hh:659
GridImp::template Codim< cd >::Entity Entity
Definition: yaspgridentity.hh:426
YaspEntity(const YGLI &g, const I &it)
Definition: yaspgridentity.hh:814
GridImp::template Codim< 0 >::LocalGeometry LocalGeometry
Definition: yaspgridentity.hh:421
PartitionType partitionType() const
return partition type attribute
Definition: yaspgridentity.hh:274
Geometry geometry() const
geometry of this entity
Definition: yaspgridentity.hh:493
GridImp::template Codim< codim >::EntitySeed EntitySeed
Definition: yaspgridentity.hh:250
int count() const
Definition: yaspgridentity.hh:522
Codim< cc >::Entity subEntity(int i) const
Definition: yaspgridentity.hh:539
YGLI & gridlevel()
Definition: yaspgridentity.hh:391
I _it
Definition: yaspgridentity.hh:934
Base class for exceptions in Dune grid modules.
Definition: exceptions.hh:16
int level() const
level of this element
Definition: yaspgridentity.hh:253
LevelIntersectionIterator ilevelend() const
Reference to one past the last neighbor.
Definition: yaspgridentity.hh:650
int subCompressedIndex(int i, unsigned int cc) const
subentity compressed index
Definition: yaspgridentity.hh:357
IntersectionIterator ibegin() const
returns intersection iterator for first intersection
Definition: yaspgridentity.hh:619
bool equals(const YaspEntity &e) const
Return true when two iterators over the same grid are equal (!).
Definition: yaspgridentity.hh:466
GridImp::YGrid::Iterator I
Definition: yaspgridentity.hh:288
const I & transformingsubiterator() const
Definition: yaspgridentity.hh:388
Implementation of Level- and LeafIndexSets for YaspGrid.
Definition: yaspgrid.hh:65
int level() const
level of this element
Definition: yaspgridentity.hh:836
EntitySeed seed() const
Return the entity seed which contains sufficient information to generate the entity again and uses as...
Definition: yaspgridentity.hh:261
PartitionType partitionType() const
return partition type attribute
Definition: yaspgridentity.hh:482
GridImp::template Codim< 0 >::Entity Entity
Definition: yaspgridentity.hh:429
Default Implementations for EntityImp.
Definition: common/entity.hh:543
unsigned int subEntities(unsigned int codim) const
Definition: yaspgridentity.hh:531
const int yaspgrid_level_bits
Definition: yaspgrid.hh:50