3#ifndef DUNE_GRID_YASPGRIDINTERSECTION_HH
4#define DUNE_GRID_YASPGRIDINTERSECTION_HH
18 template<
class Gr
idImp>
21 enum { dim=GridImp::dimension };
22 enum { dimworld=GridImp::dimensionworld };
23 typedef typename GridImp::ctype ctype;
32 typedef typename GridImp::YGridLevelIterator YGLI;
33 typedef typename GridImp::YGrid::Iterator I;
42 std::array<int,dim> dist{{0}};
45 dist[_dir] = 1 - 2*_face;
52 dist[_dir] += -1 + 2*_face;
55 _outside.transformingsubiterator().move(dist);
64 int coord = _inside.transformingsubiterator().coord(_dir) + _face;
65 if (_inside.gridlevel()->mg->isPeriodic(_dir))
70 coord == _inside.gridlevel()->mg->levelSize(_inside.gridlevel()->level(),_dir);
77 int coord = _inside.transformingsubiterator().coord(_dir) + _face;
78 return coord > _inside.gridlevel()->overlap[0].dataBegin()->min(_dir)
80 coord <= _inside.gridlevel()->overlap[0].dataBegin()->max(_dir);
93 return Entity(_inside);
99 return Entity(_outside);
102#if DUNE_GRID_EXPERIMENTAL_GRID_EXTENSIONS
105 int boundaryId()
const
119 const Dune::array<int, dim> & size = _inside.gridlevel()->mg->begin()->overlap[0].dataBegin()->size();
120 const Dune::array<int, dim> & origin = _inside.gridlevel()->mg->begin()->overlap[0].dataBegin()->origin();
121 Dune::array<int, dim> sides;
123 for (
int i=0; i<dim; i++)
126 ((_inside.gridlevel()->mg->begin()->overlap[0].dataBegin()->origin(i)
128 (_inside.gridlevel()->mg->begin()->overlap[0].dataBegin()->origin(i) +
129 _inside.gridlevel()->mg->begin()->overlap[0].dataBegin()->size(i)
131 _inside.gridlevel()->mg->levelSize(0,i)));
136 Dune::array<int, dim> pos = _inside.transformingsubiterator().coord();
137 for(
int i=0; i<dim; i++)
139 pos[i] = pos[i] / (1<<_inside.level());
140 pos[i] = pos[i] - origin[i];
143 Dune::array<int, dim> fsize;
146 for (
int k=0; k<dim; k++)
148 for (
int k=0; k<dim; k++)
149 fsize[k] = vol/size[k];
155 for (
int k=dim-1; k>=0; k--)
157 if (k == _dir)
continue;
158 index += (pos[k]) * localoffset;
159 localoffset *= size[k];
164 for (
int k=0; k<_dir; k++)
165 index += sides[k] * fsize[k];
167 index += _face * (sides[_dir]>1) * fsize[_dir];
176 return _faceInfo[_count].normal;
182 return _faceInfo[_count].normal;
188 return _faceInfo[_count].normal;
206 return LocalGeometry( _faceInfo[_count].geom_inside );
214 return LocalGeometry( _faceInfo[_count].geom_outside );
222 std::bitset<dim> shift;
227 for (
int i=0; i<dimworld; i++)
229 int coord = _inside.transformingsubiterator().coord(i);
231 if ((i == _dir) and (_face))
234 ll[i] = _inside.transformingsubiterator().coordCont()->coordinate(i,coord);
237 ur[i] = _inside.transformingsubiterator().coordCont()->coordinate(i,coord);
240 if (_inside.gridlevel()->mg->isPeriodic(i)) {
241 int coord = _inside.transformingsubiterator().coord(i);
243 auto size = _inside.gridlevel()->mg->domainSize()[i];
246 }
else if (coord + 1 > _inside.gridlevel()->mg->levelSize(_inside.gridlevel()->level(),i)) {
247 auto size = _inside.gridlevel()->mg->domainSize()[i];
254 GeometryImpl _is_global(ll,ur,shift);
255 return Geometry( _is_global );
278 : _count(~uint8_t(0))
285 _inside(myself.gridlevel(),
286 myself.transformingsubiterator()),
287 _outside(myself.gridlevel(),
288 myself.transformingsubiterator()),
303 _outside.transformingsubiterator().move(_dir,-1);
317 return _count == other._count && _inside.equals(other._inside);
322 YaspEntity<0,GridImp::dimension,GridImp> _inside;
323 YaspEntity<0,GridImp::dimension,GridImp> _outside;
332 FieldVector<ctype, dimworld> normal;
333 LocalGeometryImpl geom_inside;
334 LocalGeometryImpl geom_outside;
338 static const array<faceInfo, 2*GridImp::dimension> _faceInfo;
340 static array<faceInfo, 2*dim> initFaceInfo()
342 array<faceInfo, 2*dim> I;
343 for (uint8_t i=0; i<dim; i++)
347 I[2*i+1].normal = 0.0;
348 I[2*i].normal[i] = -1.0;
349 I[2*i+1].normal[i] = +1.0;
361 I[2*i].geom_inside = LocalGeometryImpl(ll,ur,s);
362 I[2*i+1].geom_outside = LocalGeometryImpl(ll,ur,s);
367 I[2*i].geom_outside = LocalGeometryImpl(ll,ur,s);
368 I[2*i+1].geom_inside = LocalGeometryImpl(ll,ur,s);
375 template<
class Gr
idImp>
376 const array<typename YaspIntersection<GridImp>::faceInfo, 2*GridImp::dimension>
377 YaspIntersection<GridImp>::_faceInfo =
378 YaspIntersection<GridImp>::initFaceInfo();
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:25
@ cube
Cube element in any nonnegative dimension.
Definition: type.hh:31
Base class for exceptions in Dune grid modules.
Definition: exceptions.hh:18
YaspIntersectionIterator enables iteration over intersections with neighboring codim 0 entities.
Definition: yaspgridintersectioniterator.hh:20
YaspIntersection provides data about intersection with neighboring codim 0 entities.
Definition: yaspgridintersection.hh:20
FieldVector< ctype, dimworld > centerUnitOuterNormal() const
return unit outer normal at center of intersection geometry
Definition: yaspgridintersection.hh:186
Entity inside() const
Definition: yaspgridintersection.hh:91
FieldVector< ctype, dimworld > unitOuterNormal(const FieldVector< ctype, dim-1 > &local) const
return unit outer normal, this should be dependent on local coordinates for higher order boundary
Definition: yaspgridintersection.hh:180
Geometry geometry() const
Definition: yaspgridintersection.hh:219
int indexInOutside() const
local index of codim 1 entity in neighbor where intersection is contained in
Definition: yaspgridintersection.hh:271
LocalGeometry geometryInInside() const
Definition: yaspgridintersection.hh:204
int boundarySegmentIndex() const
Definition: yaspgridintersection.hh:114
bool conforming() const
Yasp is always conform.
Definition: yaspgridintersection.hh:84
bool neighbor() const
return true if neighbor across intersection exists in this processor
Definition: yaspgridintersection.hh:74
YaspIntersection(const YaspEntity< 0, dim, GridImp > &myself, bool toend)
make intersection iterator from entity, initialize to first neighbor
Definition: yaspgridintersection.hh:284
GeometryType type() const
obtain the type of reference element for this intersection
Definition: yaspgridintersection.hh:259
void assign(const YaspIntersection &it)
copy constructor – use default
Definition: yaspgridintersection.hh:309
int indexInInside() const
local index of codim 1 entity in self where intersection is contained in
Definition: yaspgridintersection.hh:265
FieldVector< ctype, dimworld > integrationOuterNormal(const FieldVector< ctype, dim-1 > &local) const
Definition: yaspgridintersection.hh:194
LocalGeometry geometryInOutside() const
Definition: yaspgridintersection.hh:212
Entity outside() const
return EntityPointer to the Entity on the outside of this intersection
Definition: yaspgridintersection.hh:97
FieldVector< ctype, dimworld > outerNormal(const FieldVector< ctype, dim-1 > &local) const
return unit outer normal, this should be dependent on local coordinates for higher order boundary
Definition: yaspgridintersection.hh:174
bool boundary() const
Definition: yaspgridintersection.hh:61
#define DUNE_THROW(E, m)
Definition: exceptions.hh:243
Dune namespace.
Definition: alignment.hh:10
Static tag representing a codimension.
Definition: dimension.hh:22