dune-grid  2.4.1
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 
159  template< class GridImp, class IntersectionImp >
160  class Intersection
161  {
162 #if DUNE_GRID_EXPERIMENTAL_GRID_EXTENSIONS
163  public:
164 #else
165  protected:
166  // give the GridDefaultImplementation class access to the realImp
167  friend class GridDefaultImplementation<
168  GridImp::dimension, GridImp::dimensionworld,
169  typename GridImp::ctype,
170  typename GridImp::GridFamily> ;
171 #endif
172  // type of underlying implementation, for internal use only
173  typedef IntersectionImp Implementation;
174 
176  Implementation &impl () { return real; }
178  const Implementation &impl () const { return real; }
179 
180  protected:
182 
183  public:
185  typedef typename GridImp::template Codim<0>::Entity Entity;
186 
188  typedef typename GridImp::template Codim<0>::EntityPointer EntityPointer;
189 
191  typedef typename GridImp::template Codim<1>::Geometry Geometry;
192 
195 
198 
200  typedef typename GridImp::template Codim<1>::LocalGeometry LocalGeometry;
201 
203  enum { codimension=1 };
204 
206  enum { dimension=GridImp::dimension };
207 
209  enum { mydimension=GridImp::dimension-1 };
210 
212  enum { dimensionworld=GridImp::dimensionworld };
213 
215  typedef typename GridImp::ctype ctype;
216 
218  bool boundary () const
219  {
220  return this->real.boundary();
221  }
222 
223 #if DUNE_GRID_EXPERIMENTAL_GRID_EXTENSIONS
224 
239  int boundaryId () const
240  {
241  return this->real.boundaryId();
242  }
243 #endif
244 
260  size_t boundarySegmentIndex () const
261  {
262  return this->real.boundarySegmentIndex();
263  }
264 
266  bool neighbor () const
267  {
268  return this->real.neighbor();
269  }
270 
274 #ifdef DOXYGEN
275  Entity
276 #else
277  typename std::conditional<
278  std::is_same<
279  decltype(real.inside()),
280  Entity
281  >::value,
282  Entity,
283  EntityPointer
284  >::type
285 #endif
286  inside() const
287  {
288  Entity::template warnOnDeprecatedEntityPointer<decltype(real.inside())>();
289  return this->real.inside();
290  }
291 
298 #ifdef DOXYGEN
299  Entity
300 #else
301  typename std::conditional<
302  std::is_same<
303  decltype(real.outside()),
304  Entity
305  >::value,
306  Entity,
307  EntityPointer
308  >::type
309 #endif
310  outside() const
311  {
312  Entity::template warnOnDeprecatedEntityPointer<decltype(real.outside())>();
313  return this->real.outside();
314  }
315 
318  bool conforming () const
319  {
320  return this->real.conforming();
321  }
322 
336  LocalGeometry geometryInInside () const
337  {
338  return this->real.geometryInInside();
339  }
340 
354  LocalGeometry geometryInOutside () const
355  {
356  return this->real.geometryInOutside();
357  }
358 
373  Geometry geometry () const
374  {
375  return this->real.geometry();
376  }
377 
380  {
381  return this->real.type();
382  }
383 
393  int indexInInside () const
394  {
395  return this->real.indexInInside();
396  }
397 
407  int indexInOutside () const
408  {
409  return this->real.indexInOutside();
410  }
411 
416  GlobalCoordinate outerNormal (const LocalCoordinate& local) const
417  {
418  return this->real.outerNormal(local);
419  }
420 
429  GlobalCoordinate integrationOuterNormal (const LocalCoordinate& local) const
430  {
431  return this->real.integrationOuterNormal(local);
432  }
433 
439  GlobalCoordinate unitOuterNormal (const LocalCoordinate& local) const
440  {
441  return this->real.unitOuterNormal(local);
442  }
443 
450  GlobalCoordinate centerUnitOuterNormal () const
451  {
452  return this->real.centerUnitOuterNormal();
453  }
454 
456  bool operator==(const Intersection& other) const
457  {
458  return real.equals(other.real);
459  }
460 
462  bool operator!=(const Intersection& other) const
463  {
464  return !real.equals(other.real);
465  }
466 
469  {}
470 
473  : real(other.real)
474  {}
475 
478  : real(std::move(other.real))
479  {}
480 
483  {
484  real = other.real;
485  return *this;
486  }
487 
490  {
491  real = std::move(other.real);
492  return *this;
493  }
494 
495  //===========================================================
499  //===========================================================
500 
503  : real( impl )
504  {}
505 
508  : real( std::move(impl) )
509  {}
510 
512 
513  protected:
516  friend class IntersectionIterator<GridImp, IntersectionImp, IntersectionImp>;
517 
518  };
519 
520  //**********************************************************************
526  template< class GridImp, class IntersectionImp >
528  {
529  enum { dim=GridImp::dimension };
530  enum { dimworld=GridImp::dimensionworld };
531  typedef typename GridImp::ctype ct;
532  public:
533 
537  FieldVector<ct, dimworld> integrationOuterNormal (const FieldVector<ct, dim-1>& local) const
538  {
539  FieldVector<ct, dimworld> n = asImp().unitOuterNormal(local);
540  n *= asImp().geometry().integrationElement(local);
541  return n;
542  }
543 
545  FieldVector<ct, dimworld> unitOuterNormal (const FieldVector<ct, dim-1>& local) const
546  {
547  FieldVector<ct, dimworld> n = asImp().outerNormal(local);
548  n /= n.two_norm();
549  return n;
550  }
551 
553  FieldVector<ct, dimworld> centerUnitOuterNormal () const
554  {
555  // For now, we do this...
556  GeometryType type = asImp().geometry().type();
557  const ReferenceElement<ct, dim-1> & refElement =
558  ReferenceElements<ct, dim-1>::general(type);
559  return asImp().unitOuterNormal(refElement.position(0,0));
560  // But later, if we change the meaning of center(),
561  // we may have to change to this...
562  // return asImp().unitOuterNormal(asImp().local(asImp().center()));
563  }
564 
565  private:
566  // CRTP (curiously recurring template pattern)
567  IntersectionImp &asImp () { return static_cast< IntersectionImp & >( *this ); }
568  const IntersectionImp &asImp () const { return static_cast< const IntersectionImp & >( *this ); }
569  };
570 
571 } // namespace Dune
572 
573 #endif // DUNE_GRID_INTERSECTION_HH
Entity inside() const
GridImp::template Codim< 1 >::LocalGeometry LocalGeometry
Codim 1 geometry returned by geometryInInside() and geometryInOutside()
Definition: common/intersection.hh:200
LocalGeometry geometryInOutside() const
Intersection of a mesh entities of codimension 0 ("elements") with a "neighboring" element or with th...
Definition: albertagrid/dgfparser.hh:26
bool operator==(const Intersection &other) const
Compares two intersections for equality.
Definition: common/intersection.hh:456
Default Implementations of integrationOuterNormal and unitOuterNormal for IntersectionImp.
Definition: common/intersection.hh:527
GlobalCoordinate integrationOuterNormal(const LocalCoordinate &local) const
return outer normal scaled with the integration element
Definition: sgrid.hh:782
bool conforming() const
return true if intersection is conform.
Definition: sgrid.hh:770
Definition: common/intersection.hh:212
FieldVector< ct, dimworld > centerUnitOuterNormal() const
return unit outer normal at center of intersection geometry
Definition: common/intersection.hh:553
Definition: common/intersection.hh:203
Intersection(Intersection &&other)
Move constructor from an existing intersection.
Definition: common/intersection.hh:477
GeometryType
Type representing VTK&#39;s entity geometry types.
Definition: common.hh:178
bool conforming() const
Return true if intersection is conforming.
Definition: common/intersection.hh:318
FieldVector< ctype, mydim > LocalCoordinate
type of local coordinates
Definition: common/geometry.hh:101
GeometryType type() const
obtain the type of reference element for this intersection
Definition: common/intersection.hh:379
LocalGeometry geometryInInside() const
geometrical information about this intersection in local coordinates of the inside() entity...
Definition: common/intersection.hh:336
bool boundary() const
Return true if intersection is with interior or exterior boundary (see the cases above) ...
Definition: common/intersection.hh:218
size_t boundarySegmentIndex() const
index of the boundary segment within the macro grid
Definition: common/intersection.hh:260
GridImp::template Codim< 0 >::EntityPointer EntityPointer
Pointer to the type of entities that this Intersection belongs to.
Definition: common/intersection.hh:188
LocalGeometry geometryInInside() const
FieldVector< ctype, cdim > GlobalCoordinate
type of the global coordinates
Definition: common/geometry.hh:104
Entity inside() const
return EntityPointer to the Entity on the inside of this intersection. That is the Entity where we st...
Definition: common/intersection.hh:286
Definition: common/intersection.hh:209
bool neighbor() const
return true if intersection is shared with another element.
Definition: common/intersection.hh:266
Geometry::LocalCoordinate LocalCoordinate
Type for vectors of coordinates on the intersection.
Definition: common/intersection.hh:194
LocalGeometry geometryInOutside() const
geometrical information about this intersection in local coordinates of the outside() entity...
Definition: common/intersection.hh:354
FieldVector< ct, dimworld > unitOuterNormal(const FieldVector< ct, dim-1 > &local) const
return unit outer normal
Definition: common/intersection.hh:545
GridImp::template Codim< 1 >::Geometry Geometry
Codim 1 geometry returned by geometry()
Definition: common/intersection.hh:191
const Implementation & impl() const
return reference to the real implementation
Definition: common/intersection.hh:178
bool operator!=(const Intersection &other) const
Compares two intersections for inequality.
Definition: common/intersection.hh:462
Intersection()
Default constructor.
Definition: common/intersection.hh:468
GlobalCoordinate unitOuterNormal(const LocalCoordinate &local) const
Return unit outer normal (length == 1)
Definition: sgrid.hh:790
Geometry::GlobalCoordinate GlobalCoordinate
Type for normal vectors.
Definition: common/intersection.hh:197
GridImp::ctype ctype
Type of individual coefficients of coordinate vectors.
Definition: common/intersection.hh:215
bool boundary() const
return true if intersection is with boundary.
bool neighbor() const
return true if neighbor on this level exists
int indexInInside() const
local index of codim 1 entity in self where intersection is contained in
static void(*)(*)(*)(*)(*)(*) move(const double *)
Definition: partitiondisplay.cc:122
Intersection(const Implementation &impl)
Definition: common/intersection.hh:502
int indexInOutside() const
local index of codim 1 entity in neighbor where intersection is contained in
Intersection & operator=(const Intersection &other)
Copy assignment operator from an existing intersection.
Definition: common/intersection.hh:482
Geometry geometry() const
int boundaryId() const
Definition: sgrid.hh:683
Implementation real
Definition: common/intersection.hh:181
Intersection(const Intersection &other)
Copy constructor from an existing intersection.
Definition: common/intersection.hh:472
Include standard header files.
Definition: agrid.hh:59
GeometryType type() const
obtain the type of reference element for this intersection
Definition: sgrid.hh:711
GlobalCoordinate centerUnitOuterNormal() const
Return unit outer normal (length == 1)
Definition: sgrid.hh:796
Mesh entities of codimension 0 ("elements") allow to visit all intersections with "neighboring" eleme...
Definition: common/grid.hh:360
int indexInInside() const
Local index of codim 1 entity in the inside() entity where intersection is contained in...
Definition: common/intersection.hh:393
STL namespace.
GlobalCoordinate centerUnitOuterNormal() const
Return unit outer normal (length == 1)
Definition: common/intersection.hh:450
Intersection(Implementation &&impl)
Definition: common/intersection.hh:507
bool equals(const SIntersection &other) const
GridImp::template Codim< 0 >::Entity Entity
Type of entity that this Intersection belongs to.
Definition: common/intersection.hh:185
Different resources needed by all grid implementations.
Entity outside() const
return EntityPointer to the Entity on the outside of this intersection. That is the neighboring Entit...
Definition: common/intersection.hh:310
FieldVector< ct, dimworld > integrationOuterNormal(const FieldVector< ct, dim-1 > &local) const
Definition: common/intersection.hh:537
GlobalCoordinate outerNormal(const LocalCoordinate &local) const
Return an outer normal (length not necessarily 1)
Definition: common/intersection.hh:416
Geometry geometry() const
geometrical information about the intersection in global coordinates.
Definition: common/intersection.hh:373
Implementation & impl()
return reference to the real implementation
Definition: common/intersection.hh:176
Intersection & operator=(Intersection &&other)
Move assignment operator from an existing intersection.
Definition: common/intersection.hh:489
int boundarySegmentIndex() const
Definition: sgrid.hh:688
GlobalCoordinate unitOuterNormal(const LocalCoordinate &local) const
Return unit outer normal (length == 1)
Definition: common/intersection.hh:439
GlobalCoordinate outerNormal(const LocalCoordinate &local) const
Return an outer normal (length not necessarily 1)
Definition: sgrid.hh:776
int indexInOutside() const
Local index of codim 1 entity in outside() entity where intersection is contained in...
Definition: common/intersection.hh:407
Definition: common/intersection.hh:206
Entity outside() const
GlobalCoordinate integrationOuterNormal(const LocalCoordinate &local) const
return unit outer normal scaled with the integration element
Definition: common/intersection.hh:429