5#ifndef DUNE_GRID_YASPGRIDINTERSECTION_HH
6#define DUNE_GRID_YASPGRIDINTERSECTION_HH
20 template<
class Gr
idImp>
23 constexpr static int dim = GridImp::dimension;
24 constexpr static int dimworld = GridImp::dimensionworld;
25 typedef typename GridImp::ctype ctype;
27 typedef typename GridImp::Traits::template Codim< 1 >::GeometryImpl GeometryImpl;
28 typedef typename GridImp::Traits::template Codim< 1 >::LocalGeometryImpl LocalGeometryImpl;
34 typedef typename GridImp::YGridLevelIterator
YGLI;
35 typedef typename GridImp::YGrid::Iterator
I;
36 typedef typename GridImp::template Codim<0>::Entity
Entity;
37 typedef typename GridImp::template Codim<1>::Geometry
Geometry;
38 typedef typename GridImp::template Codim<1>::LocalGeometry
LocalGeometry;
43 std::array<int,dim> dist{{0}};
46 dist[_dir] = 1 - 2*_face;
53 dist[_dir] += -1 + 2*_face;
66 if (_inside.
gridlevel()->mg->isPeriodic(_dir))
79 return coord > _inside.
gridlevel()->overlap[0].dataBegin()->min(_dir)
81 coord <= _inside.
gridlevel()->overlap[0].dataBegin()->max(_dir);
108 DUNE_THROW(
GridError,
"called boundarySegmentIndex while boundary() == false");
110 const std::array<int, dim> & size = _inside.
gridlevel()->mg->begin()->overlap[0].dataBegin()->size();
111 const std::array<int, dim> & origin = _inside.
gridlevel()->mg->begin()->overlap[0].dataBegin()->origin();
112 std::array<int, dim> sides;
114 for (
int i=0; i<dim; i++)
117 ((_inside.
gridlevel()->mg->begin()->overlap[0].dataBegin()->origin(i)
119 (_inside.
gridlevel()->mg->begin()->overlap[0].dataBegin()->origin(i) +
120 _inside.
gridlevel()->mg->begin()->overlap[0].dataBegin()->size(i)
122 _inside.
gridlevel()->mg->levelSize(0,i)));
128 for(
int i=0; i<dim; i++)
130 pos[i] = pos[i] / (1<<_inside.
level());
131 pos[i] = pos[i] - origin[i];
134 std::array<int, dim> fsize;
137 for (
int k=0; k<dim; k++)
139 for (
int k=0; k<dim; k++)
140 fsize[k] = vol/size[k];
146 for (
int k=dim-1; k>=0; k--)
148 if (k == _dir)
continue;
149 index += (pos[k]) * localoffset;
150 localoffset *= size[k];
155 for (
int k=0; k<_dir; k++)
156 index += sides[k] * fsize[k];
158 index += _face * (sides[_dir]>1) * fsize[_dir];
165 FieldVector<ctype, dimworld>
outerNormal (
const FieldVector<ctype, dim-1>& )
const
171 FieldVector<ctype, dimworld>
unitOuterNormal (
const FieldVector<ctype, dim-1>& )
const
179 FieldVector<ctype, dimworld> normal(0);
180 normal[_dir] = (_face==0) ? -1.0 : 1.0;
203 Dune::FieldVector<ctype, dim> ll(0.0);
204 Dune::FieldVector<ctype, dim> ur(1.0);
206 ll[_dir] = ur[_dir] = (_face==0) ? 0.0 : 1.0;
222 Dune::FieldVector<ctype, dim> ll(0.0);
223 Dune::FieldVector<ctype, dim> ur(1.0);
225 ll[_dir] = ur[_dir] = (_face==1) ? 0.0 : 1.0;
235 std::bitset<dim> shift;
239 Dune::FieldVector<ctype,dimworld> ll, ur;
240 for (
int i=0; i<dimworld; i++)
244 if ((i == _dir) and (_face))
253 if (_inside.
gridlevel()->mg->isPeriodic(i)) {
255 if (coordPeriodic < 0) {
256 auto size = _inside.
gridlevel()->mg->domainSize()[i];
259 }
else if (coordPeriodic + 1 > _inside.
gridlevel()->mg->levelSize(_inside.
gridlevel()->level(),i)) {
260 auto size = _inside.
gridlevel()->mg->domainSize()[i];
267 GeometryImpl _is_global(ll,ur,shift);
274 return GeometryTypes::cube(dim-1);
291 : _count(~
std::uint8_t(0))
298 _inside(myself.gridlevel(),
299 myself.transformingsubiterator()),
300 _outside(myself.gridlevel(),
301 myself.transformingsubiterator()),
330 return _count == other._count && _inside.
equals(other._inside);
Include standard header files.
Definition: agrid.hh:60
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:132
Base class for exceptions in Dune grid modules.
Definition: exceptions.hh:20
int level() const
level of this element
Definition: yaspgridentity.hh:282
const YGLI & gridlevel() const
Definition: yaspgridentity.hh:420
const I & transformingsubiterator() const
Definition: yaspgridentity.hh:419
bool equals(const YaspEntity &e) const
Return true when two iterators over the same grid are equal (!).
Definition: yaspgridentity.hh:347
YaspIntersectionIterator enables iteration over intersections with neighboring codim 0 entities.
Definition: yaspgridintersectioniterator.hh:22
YaspIntersection provides data about intersection with neighboring codim 0 entities.
Definition: yaspgridintersection.hh:22
FieldVector< ctype, dimworld > centerUnitOuterNormal() const
return unit outer normal at center of intersection geometry
Definition: yaspgridintersection.hh:177
bool equals(const YaspIntersection &other) const
Definition: yaspgridintersection.hh:327
Entity inside() const
Definition: yaspgridintersection.hh:92
Geometry geometry() const
Definition: yaspgridintersection.hh:232
GridImp::template Codim< 1 >::LocalGeometry LocalGeometry
Definition: yaspgridintersection.hh:38
YaspIntersection()
Definition: yaspgridintersection.hh:290
int indexInOutside() const
local index of codim 1 entity in neighbor where intersection is contained in
Definition: yaspgridintersection.hh:284
LocalGeometry geometryInInside() const
Definition: yaspgridintersection.hh:195
int boundarySegmentIndex() const
Definition: yaspgridintersection.hh:105
GridImp::template Codim< 1 >::Geometry Geometry
Definition: yaspgridintersection.hh:37
bool conforming() const
Yasp is always conform.
Definition: yaspgridintersection.hh:85
GridImp::template Codim< 0 >::Entity Entity
Definition: yaspgridintersection.hh:36
bool neighbor() const
return true if neighbor across intersection exists in this processor
Definition: yaspgridintersection.hh:75
FieldVector< ctype, dimworld > outerNormal(const FieldVector< ctype, dim-1 > &) const
return unit outer normal, this should be dependent on local coordinates for higher order boundary
Definition: yaspgridintersection.hh:165
YaspIntersection(const YaspEntity< 0, dim, GridImp > &myself, bool toend)
make intersection iterator from entity, initialize to first neighbor
Definition: yaspgridintersection.hh:297
GeometryType type() const
obtain the type of reference element for this intersection
Definition: yaspgridintersection.hh:272
void assign(const YaspIntersection &it)
copy constructor – use default
Definition: yaspgridintersection.hh:322
int indexInInside() const
local index of codim 1 entity in self where intersection is contained in
Definition: yaspgridintersection.hh:278
FieldVector< ctype, dimworld > integrationOuterNormal(const FieldVector< ctype, dim-1 > &local) const
Definition: yaspgridintersection.hh:187
GridImp::YGrid::Iterator I
Definition: yaspgridintersection.hh:35
LocalGeometry geometryInOutside() const
Definition: yaspgridintersection.hh:214
GridImp::YGridLevelIterator YGLI
Definition: yaspgridintersection.hh:34
Entity outside() const
return Entity on the outside of this intersection
Definition: yaspgridintersection.hh:98
bool boundary() const
Definition: yaspgridintersection.hh:62
FieldVector< ctype, dimworld > unitOuterNormal(const FieldVector< ctype, dim-1 > &) const
return unit outer normal, this should be dependent on local coordinates for higher order boundary
Definition: yaspgridintersection.hh:171
void update()
Definition: yaspgridintersection.hh:40
Definition: yaspgridentity.hh:434