dune-grid  2.6-git
common/intersection.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 
4 #ifndef DUNE_GRID_INTERSECTION_HH
5 #define DUNE_GRID_INTERSECTION_HH
6 
8 
9 namespace Dune
10 {
11 
160  template< class GridImp, class IntersectionImp >
161  class Intersection
162  {
163  public:
169  typedef IntersectionImp Implementation;
170 
176  Implementation &impl () { return real; }
177 
183  const Implementation &impl () const { return real; }
184 
185  protected:
186  Implementation real;
187 
188  public:
190  typedef typename GridImp::template Codim<0>::Entity Entity;
191 
193  typedef typename GridImp::template Codim<1>::Geometry Geometry;
194 
197 
200 
202  typedef typename GridImp::template Codim<1>::LocalGeometry LocalGeometry;
203 
207  enum DUNE_DEPRECATED_MSG("Deprecated: codimensions of an intersection are always 1!") { codimension=1 };
208 
214  enum DUNE_DEPRECATED_MSG("Deprecated: get this dimension from the grid itself, or from an element!") { dimension=GridImp::dimension };
215 
217  enum { mydimension=GridImp::dimension-1 };
218 
220  enum { dimensionworld=GridImp::dimensionworld };
221 
223  typedef typename GridImp::ctype ctype;
224 
226  bool boundary () const
227  {
228  return this->real.boundary();
229  }
230 
246  size_t boundarySegmentIndex () const
247  {
248  return this->real.boundarySegmentIndex();
249  }
250 
252  bool neighbor () const
253  {
254  return this->real.neighbor();
255  }
256 
260  Entity inside() const
261  {
262  return this->real.inside();
263  }
264 
271  Entity outside() const
272  {
273  return this->real.outside();
274  }
275 
278  bool conforming () const
279  {
280  return this->real.conforming();
281  }
282 
296  LocalGeometry geometryInInside () const
297  {
298  return this->real.geometryInInside();
299  }
300 
314  LocalGeometry geometryInOutside () const
315  {
316  return this->real.geometryInOutside();
317  }
318 
333  Geometry geometry () const
334  {
335  return this->real.geometry();
336  }
337 
340  {
341  return this->real.type();
342  }
343 
356  int indexInInside () const
357  {
358  return this->real.indexInInside();
359  }
360 
373  int indexInOutside () const
374  {
375  return this->real.indexInOutside();
376  }
377 
382  GlobalCoordinate outerNormal (const LocalCoordinate& local) const
383  {
384  return this->real.outerNormal(local);
385  }
386 
395  GlobalCoordinate integrationOuterNormal (const LocalCoordinate& local) const
396  {
397  return this->real.integrationOuterNormal(local);
398  }
399 
405  GlobalCoordinate unitOuterNormal (const LocalCoordinate& local) const
406  {
407  return this->real.unitOuterNormal(local);
408  }
409 
416  GlobalCoordinate centerUnitOuterNormal () const
417  {
418  return this->real.centerUnitOuterNormal();
419  }
420 
422  bool operator==(const Intersection& other) const
423  {
424  return real.equals(other.real);
425  }
426 
428  bool operator!=(const Intersection& other) const
429  {
430  return !real.equals(other.real);
431  }
432 
435  {}
436 
439  : real(other.real)
440  {}
441 
444  : real(std::move(other.real))
445  {}
446 
449  {
450  real = other.real;
451  return *this;
452  }
453 
456  {
457  real = std::move(other.real);
458  return *this;
459  }
460 
461  //===========================================================
465  //===========================================================
466 
468  Intersection ( const Implementation &impl )
469  : real( impl )
470  {}
471 
473  Intersection ( Implementation&& impl )
474  : real( std::move(impl) )
475  {}
476 
478 
479  protected:
482  friend class IntersectionIterator<GridImp, IntersectionImp, IntersectionImp>;
483 
484  };
485 
486  //**********************************************************************
492  template< class GridImp, class IntersectionImp >
494  {
495  enum { dim=GridImp::dimension };
496  enum { dimworld=GridImp::dimensionworld };
497  typedef typename GridImp::ctype ct;
498  public:
499 
503  FieldVector<ct, dimworld> integrationOuterNormal (const FieldVector<ct, dim-1>& local) const
504  {
505  FieldVector<ct, dimworld> n = asImp().unitOuterNormal(local);
506  n *= asImp().geometry().integrationElement(local);
507  return n;
508  }
509 
511  FieldVector<ct, dimworld> unitOuterNormal (const FieldVector<ct, dim-1>& local) const
512  {
513  FieldVector<ct, dimworld> n = asImp().outerNormal(local);
514  n /= n.two_norm();
515  return n;
516  }
517 
519  FieldVector<ct, dimworld> centerUnitOuterNormal () const
520  {
521  // For now, we do this...
522  GeometryType type = asImp().geometry().type();
523  auto refElement = referenceElement<ct, dim-1>(type);
524  return asImp().unitOuterNormal(refElement.position(0,0));
525  // But later, if we change the meaning of center(),
526  // we may have to change to this...
527  // return asImp().unitOuterNormal(asImp().local(asImp().center()));
528  }
529 
530  private:
531  // CRTP (curiously recurring template pattern)
532  IntersectionImp &asImp () { return static_cast< IntersectionImp & >( *this ); }
533  const IntersectionImp &asImp () const { return static_cast< const IntersectionImp & >( *this ); }
534  };
535 
536 } // namespace Dune
537 
538 #endif // DUNE_GRID_INTERSECTION_HH
GridImp::ctype ctype
Type of individual coefficients of coordinate vectors.
Definition: common/intersection.hh:223
GlobalCoordinate integrationOuterNormal(const LocalCoordinate &local) const
return unit outer normal scaled with the integration element
Definition: common/intersection.hh:395
Include standard header files.
Definition: agrid.hh:58
Implementation real
Definition: common/intersection.hh:186
bool operator!=(const Intersection &other) const
Compares two intersections for inequality.
Definition: common/intersection.hh:428
Definition: common/intersection.hh:220
NormalVector unitOuterNormal(const LocalCoordType &local) const
Definition: intersection.cc:203
LocalGeometry geometryInOutside() const
Definition: intersection.cc:400
auto referenceElement(const Geometry< mydim, cdim, GridImp, GeometryImp > &geo) -> decltype(referenceElement(geo, geo.impl()))
Definition: common/geometry.hh:411
GridImp::template Codim< 0 >::Entity outside() const
Definition: intersection.cc:363
bool boundary() const
Definition: intersection.cc:41
FieldVector< ct, dimworld > integrationOuterNormal(const FieldVector< ct, dim-1 > &local) const
Definition: common/intersection.hh:503
FieldVector< ctype, mydim > LocalCoordinate
type of local coordinates
Definition: common/geometry.hh:98
Intersection of a mesh entity of codimension 0 ("element") with a "neighboring" element or with the d...
Definition: albertagrid/dgfparser.hh:26
Geometry geometry() const
Definition: intersection.cc:415
Definition: common/intersection.hh:207
GlobalCoordinate centerUnitOuterNormal() const
Return unit outer normal (length == 1)
Definition: common/intersection.hh:416
NormalVector centerUnitOuterNormal() const
Definition: intersection.cc:177
STL namespace.
Default Implementations of integrationOuterNormal and unitOuterNormal for IntersectionImp.
Definition: common/intersection.hh:493
Mesh entities of codimension 0 ("elements") allow to visit all intersections with "neighboring" eleme...
Definition: common/grid.hh:345
bool operator==(const Intersection &other) const
Compares two intersections for equality.
Definition: common/intersection.hh:422
int indexInInside() const
Local index of codim 1 entity in the inside() entity where intersection is contained in...
Definition: common/intersection.hh:356
Intersection(Intersection &&other)
Move constructor from an existing intersection.
Definition: common/intersection.hh:443
FieldVector< ct, dimworld > centerUnitOuterNormal() const
return unit outer normal at center of intersection geometry
Definition: common/intersection.hh:519
int indexInOutside() const
Local index of codim 1 entity in outside() entity where intersection is contained in...
Definition: common/intersection.hh:373
Entity inside() const
return Entity on the inside of this intersection. That is the Entity where we started this...
Definition: common/intersection.hh:260
Intersection(const Implementation &impl)
Definition: common/intersection.hh:468
bool boundary() const
Return true if intersection is with interior or exterior boundary (see the cases above) ...
Definition: common/intersection.hh:226
Geometry geometry() const
geometrical information about the intersection in global coordinates.
Definition: common/intersection.hh:333
GeometryType
Type representing VTK&#39;s entity geometry types.
Definition: common.hh:178
GridImp::template Codim< 0 >::Entity Entity
Type of entity that this Intersection belongs to.
Definition: common/intersection.hh:190
bool neighbor() const
return true if intersection is shared with another element.
Definition: common/intersection.hh:252
Entity outside() const
return Entity on the outside of this intersection. That is the neighboring Entity.
Definition: common/intersection.hh:271
Intersection(const Intersection &other)
Copy constructor from an existing intersection.
Definition: common/intersection.hh:438
NormalVector outerNormal(const LocalCoordType &local) const
Definition: intersection.cc:195
int indexInInside() const
Definition: intersection.cc:72
Intersection(Implementation &&impl)
Definition: common/intersection.hh:473
bool conforming() const
Definition: albertagrid/intersection.hh:164
Intersection & operator=(const Intersection &other)
Copy assignment operator from an existing intersection.
Definition: common/intersection.hh:448
LocalGeometry geometryInInside() const
Definition: intersection.cc:389
FieldVector< ctype, cdim > GlobalCoordinate
type of the global coordinates
Definition: common/geometry.hh:101
GeometryType type() const
obtain the type of reference element for this intersection
Definition: common/intersection.hh:339
size_t boundarySegmentIndex() const
Definition: intersection.cc:62
Geometry::LocalCoordinate LocalCoordinate
Type for vectors of coordinates on the intersection.
Definition: common/intersection.hh:196
size_t boundarySegmentIndex() const
index of the boundary segment within the macro grid
Definition: common/intersection.hh:246
LocalGeometry geometryInOutside() const
geometrical information about this intersection in local coordinates of the outside() entity...
Definition: common/intersection.hh:314
bool conforming() const
Return true if intersection is conforming.
Definition: common/intersection.hh:278
IntersectionImp Implementation
type of underlying implementation
Definition: common/intersection.hh:169
Geometry::GlobalCoordinate GlobalCoordinate
Type for normal vectors.
Definition: common/intersection.hh:199
GlobalCoordinate unitOuterNormal(const LocalCoordinate &local) const
Return unit outer normal (length == 1)
Definition: common/intersection.hh:405
GeometryType type() const
Definition: intersection.cc:80
bool neighbor() const
Definition: intersection.cc:380
Intersection()
Default constructor.
Definition: common/intersection.hh:434
GridImp::template Codim< 1 >::Geometry Geometry
Codim 1 geometry returned by geometry()
Definition: common/intersection.hh:193
Intersection & operator=(Intersection &&other)
Move assignment operator from an existing intersection.
Definition: common/intersection.hh:455
Definition: common/intersection.hh:214
FieldVector< ct, dimworld > unitOuterNormal(const FieldVector< ct, dim-1 > &local) const
return unit outer normal
Definition: common/intersection.hh:511
Different resources needed by all grid implementations.
GridImp::template Codim< 1 >::LocalGeometry LocalGeometry
Codim 1 geometry returned by geometryInInside() and geometryInOutside()
Definition: common/intersection.hh:202
Implementation & impl()
access to the underlying implementation
Definition: common/intersection.hh:176
LocalGeometry geometryInInside() const
geometrical information about this intersection in local coordinates of the inside() entity...
Definition: common/intersection.hh:296
Entity inside() const
Definition: intersection.cc:33
bool equals(const AlbertaGridLeafIntersection &other) const
Definition: albertagrid/intersection.hh:156
int indexInOutside() const
Definition: intersection.cc:424
Definition: common/intersection.hh:217
GlobalCoordinate outerNormal(const LocalCoordinate &local) const
Return an outer normal (length not necessarily 1)
Definition: common/intersection.hh:382
const Implementation & impl() const
access to the underlying implementation
Definition: common/intersection.hh:183
NormalVector integrationOuterNormal(const LocalCoordType &local) const
Definition: intersection.cc:187