dune-grid  2.5.0
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 #if DUNE_GRID_EXPERIMENTAL_GRID_EXTENSIONS
164  public:
165 #else
166  protected:
167  // give the GridDefaultImplementation class access to the realImp
168  friend class GridDefaultImplementation<
169  GridImp::dimension, GridImp::dimensionworld,
170  typename GridImp::ctype,
171  typename GridImp::GridFamily> ;
172 #endif
173  // type of underlying implementation, for internal use only
174  typedef IntersectionImp Implementation;
175 
177  Implementation &impl () { return real; }
179  const Implementation &impl () const { return real; }
180 
181  protected:
183 
184  public:
186  typedef typename GridImp::template Codim<0>::Entity Entity;
187 
189  typedef typename GridImp::template Codim<1>::Geometry Geometry;
190 
193 
196 
198  typedef typename GridImp::template Codim<1>::LocalGeometry LocalGeometry;
199 
203  enum DUNE_DEPRECATED_MSG("Deprecated: codimensions of an intersection are always 1!") { codimension=1 };
204 
210  enum DUNE_DEPRECATED_MSG("Deprecated: get this dimension from the grid itself, or from an element!") { dimension=GridImp::dimension };
211 
213  enum { mydimension=GridImp::dimension-1 };
214 
216  enum { dimensionworld=GridImp::dimensionworld };
217 
219  typedef typename GridImp::ctype ctype;
220 
222  bool boundary () const
223  {
224  return this->real.boundary();
225  }
226 
227 #if DUNE_GRID_EXPERIMENTAL_GRID_EXTENSIONS
228 
243  int boundaryId () const
244  {
245  return this->real.boundaryId();
246  }
247 #endif
248 
264  size_t boundarySegmentIndex () const
265  {
266  return this->real.boundarySegmentIndex();
267  }
268 
270  bool neighbor () const
271  {
272  return this->real.neighbor();
273  }
274 
278  Entity inside() const
279  {
280  return this->real.inside();
281  }
282 
289  Entity outside() const
290  {
291  return this->real.outside();
292  }
293 
296  bool conforming () const
297  {
298  return this->real.conforming();
299  }
300 
314  LocalGeometry geometryInInside () const
315  {
316  return this->real.geometryInInside();
317  }
318 
332  LocalGeometry geometryInOutside () const
333  {
334  return this->real.geometryInOutside();
335  }
336 
351  Geometry geometry () const
352  {
353  return this->real.geometry();
354  }
355 
358  {
359  return this->real.type();
360  }
361 
374  int indexInInside () const
375  {
376  return this->real.indexInInside();
377  }
378 
391  int indexInOutside () const
392  {
393  return this->real.indexInOutside();
394  }
395 
400  GlobalCoordinate outerNormal (const LocalCoordinate& local) const
401  {
402  return this->real.outerNormal(local);
403  }
404 
413  GlobalCoordinate integrationOuterNormal (const LocalCoordinate& local) const
414  {
415  return this->real.integrationOuterNormal(local);
416  }
417 
423  GlobalCoordinate unitOuterNormal (const LocalCoordinate& local) const
424  {
425  return this->real.unitOuterNormal(local);
426  }
427 
434  GlobalCoordinate centerUnitOuterNormal () const
435  {
436  return this->real.centerUnitOuterNormal();
437  }
438 
440  bool operator==(const Intersection& other) const
441  {
442  return real.equals(other.real);
443  }
444 
446  bool operator!=(const Intersection& other) const
447  {
448  return !real.equals(other.real);
449  }
450 
453  {}
454 
457  : real(other.real)
458  {}
459 
462  : real(std::move(other.real))
463  {}
464 
467  {
468  real = other.real;
469  return *this;
470  }
471 
474  {
475  real = std::move(other.real);
476  return *this;
477  }
478 
479  //===========================================================
483  //===========================================================
484 
487  : real( impl )
488  {}
489 
492  : real( std::move(impl) )
493  {}
494 
496 
497  protected:
500  friend class IntersectionIterator<GridImp, IntersectionImp, IntersectionImp>;
501 
502  };
503 
504  //**********************************************************************
510  template< class GridImp, class IntersectionImp >
512  {
513  enum { dim=GridImp::dimension };
514  enum { dimworld=GridImp::dimensionworld };
515  typedef typename GridImp::ctype ct;
516  public:
517 
521  FieldVector<ct, dimworld> integrationOuterNormal (const FieldVector<ct, dim-1>& local) const
522  {
523  FieldVector<ct, dimworld> n = asImp().unitOuterNormal(local);
524  n *= asImp().geometry().integrationElement(local);
525  return n;
526  }
527 
529  FieldVector<ct, dimworld> unitOuterNormal (const FieldVector<ct, dim-1>& local) const
530  {
531  FieldVector<ct, dimworld> n = asImp().outerNormal(local);
532  n /= n.two_norm();
533  return n;
534  }
535 
537  FieldVector<ct, dimworld> centerUnitOuterNormal () const
538  {
539  // For now, we do this...
540  GeometryType type = asImp().geometry().type();
541  const ReferenceElement<ct, dim-1> & refElement =
542  ReferenceElements<ct, dim-1>::general(type);
543  return asImp().unitOuterNormal(refElement.position(0,0));
544  // But later, if we change the meaning of center(),
545  // we may have to change to this...
546  // return asImp().unitOuterNormal(asImp().local(asImp().center()));
547  }
548 
549  private:
550  // CRTP (curiously recurring template pattern)
551  IntersectionImp &asImp () { return static_cast< IntersectionImp & >( *this ); }
552  const IntersectionImp &asImp () const { return static_cast< const IntersectionImp & >( *this ); }
553  };
554 
555 } // namespace Dune
556 
557 #endif // DUNE_GRID_INTERSECTION_HH
bool neighbor() const
Definition: intersection.cc:420
Definition: common/intersection.hh:203
size_t boundarySegmentIndex() const
Definition: intersection.cc:62
Intersection & operator=(const Intersection &other)
Copy assignment operator from an existing intersection.
Definition: common/intersection.hh:466
bool boundary() const
Return true if intersection is with interior or exterior boundary (see the cases above) ...
Definition: common/intersection.hh:222
Intersection of a mesh entity of codimension 0 ("element") with a "neighboring" element or with the d...
Definition: albertagrid/dgfparser.hh:26
Intersection(const Intersection &other)
Copy constructor from an existing intersection.
Definition: common/intersection.hh:456
GlobalCoordinate integrationOuterNormal(const LocalCoordinate &local) const
return unit outer normal scaled with the integration element
Definition: common/intersection.hh:413
GlobalCoordinate unitOuterNormal(const LocalCoordinate &local) const
Return unit outer normal (length == 1)
Definition: common/intersection.hh:423
int indexInInside() const
Local index of codim 1 entity in the inside() entity where intersection is contained in...
Definition: common/intersection.hh:374
bool operator!=(const Intersection &other) const
Compares two intersections for inequality.
Definition: common/intersection.hh:446
Geometry geometry() const
geometrical information about the intersection in global coordinates.
Definition: common/intersection.hh:351
GeometryType
Type representing VTK&#39;s entity geometry types.
Definition: common.hh:178
Intersection(Intersection &&other)
Move constructor from an existing intersection.
Definition: common/intersection.hh:461
Implementation real
Definition: common/intersection.hh:182
NormalVector integrationOuterNormal(const LocalCoordType &local) const
Definition: intersection.cc:188
Implementation & impl()
return reference to the real implementation
Definition: common/intersection.hh:177
Geometry geometry() const
Definition: intersection.cc:455
bool conforming() const
Return true if intersection is conforming.
Definition: common/intersection.hh:296
bool boundary() const
Definition: intersection.cc:41
Entity inside() const
return Entity on the inside of this intersection. That is the Entity where we started this...
Definition: common/intersection.hh:278
Intersection(const Implementation &impl)
Definition: common/intersection.hh:486
FieldVector< ct, dimworld > integrationOuterNormal(const FieldVector< ct, dim-1 > &local) const
Definition: common/intersection.hh:521
Intersection()
Default constructor.
Definition: common/intersection.hh:452
FieldVector< ct, dimworld > unitOuterNormal(const FieldVector< ct, dim-1 > &local) const
return unit outer normal
Definition: common/intersection.hh:529
GridImp::template Codim< 1 >::Geometry Geometry
Codim 1 geometry returned by geometry()
Definition: common/intersection.hh:189
const Implementation & impl() const
return reference to the real implementation
Definition: common/intersection.hh:179
Definition: common/intersection.hh:210
GridImp::template Codim< 0 >::Entity Entity
Type of entity that this Intersection belongs to.
Definition: common/intersection.hh:186
Mesh entities of codimension 0 ("elements") allow to visit all intersections with "neighboring" eleme...
Definition: common/grid.hh:345
NormalVector centerUnitOuterNormal() const
Definition: intersection.cc:178
int boundaryId() const
Definition: intersection.cc:48
int indexInInside() const
Definition: intersection.cc:72
GlobalCoordinate centerUnitOuterNormal() const
Return unit outer normal (length == 1)
Definition: common/intersection.hh:434
GlobalCoordinate outerNormal(const LocalCoordinate &local) const
Return an outer normal (length not necessarily 1)
Definition: common/intersection.hh:400
int indexInOutside() const
Local index of codim 1 entity in outside() entity where intersection is contained in...
Definition: common/intersection.hh:391
size_t boundarySegmentIndex() const
index of the boundary segment within the macro grid
Definition: common/intersection.hh:264
GeometryType type() const
Definition: intersection.cc:80
Default Implementations of integrationOuterNormal and unitOuterNormal for IntersectionImp.
Definition: common/intersection.hh:511
Geometry::GlobalCoordinate GlobalCoordinate
Type for normal vectors.
Definition: common/intersection.hh:195
bool operator==(const Intersection &other) const
Compares two intersections for equality.
Definition: common/intersection.hh:440
NormalVector outerNormal(const LocalCoordType &local) const
Definition: intersection.cc:196
Definition: common/intersection.hh:216
Include standard header files.
Definition: agrid.hh:59
FieldVector< ctype, cdim > GlobalCoordinate
type of the global coordinates
Definition: common/geometry.hh:96
LocalGeometry geometryInInside() const
Definition: intersection.cc:429
bool conforming() const
Definition: intersection.cc:414
Intersection & operator=(Intersection &&other)
Move assignment operator from an existing intersection.
Definition: common/intersection.hh:473
LocalGeometry geometryInInside() const
geometrical information about this intersection in local coordinates of the inside() entity...
Definition: common/intersection.hh:314
GridImp::ctype ctype
Type of individual coefficients of coordinate vectors.
Definition: common/intersection.hh:219
Definition: common/intersection.hh:213
NormalVector unitOuterNormal(const LocalCoordType &local) const
Definition: intersection.cc:204
Intersection(Implementation &&impl)
Definition: common/intersection.hh:491
bool neighbor() const
return true if intersection is shared with another element.
Definition: common/intersection.hh:270
FieldVector< ct, dimworld > centerUnitOuterNormal() const
return unit outer normal at center of intersection geometry
Definition: common/intersection.hh:537
STL namespace.
FieldVector< ctype, mydim > LocalCoordinate
type of local coordinates
Definition: common/geometry.hh:93
Different resources needed by all grid implementations.
Entity inside() const
Definition: intersection.cc:33
LocalGeometry geometryInOutside() const
Definition: intersection.cc:440
GridImp::template Codim< 1 >::LocalGeometry LocalGeometry
Codim 1 geometry returned by geometryInInside() and geometryInOutside()
Definition: common/intersection.hh:198
Entity outside() const
return Entity on the outside of this intersection. That is the neighboring Entity.
Definition: common/intersection.hh:289
Geometry::LocalCoordinate LocalCoordinate
Type for vectors of coordinates on the intersection.
Definition: common/intersection.hh:192
Definition: albertagrid/entity.hh:30
GeometryType type() const
obtain the type of reference element for this intersection
Definition: common/intersection.hh:357
bool equals(const AlbertaGridLeafIntersection &other) const
Definition: albertagrid/intersection.hh:147
GridImp::template Codim< 0 >::Entity outside() const
Definition: intersection.cc:397
LocalGeometry geometryInOutside() const
geometrical information about this intersection in local coordinates of the outside() entity...
Definition: common/intersection.hh:332
int indexInOutside() const
Definition: intersection.cc:464