dune-grid  2.8.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_COMMON_INTERSECTION_HH
5 #define DUNE_GRID_COMMON_INTERSECTION_HH
6 
8 
9 namespace Dune
10 {
11 
160  template< class GridImp, class IntersectionImp >
162  {
163  public:
169  typedef IntersectionImp Implementation;
170 
176  Implementation &impl () { return real; }
177 
183  const Implementation &impl () const { return real; }
184 
185  protected:
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 
205  enum { mydimension=GridImp::dimension-1 };
206 
208  enum { dimensionworld=GridImp::dimensionworld };
209 
211  typedef typename GridImp::ctype ctype;
212 
214  bool boundary () const
215  {
216  return this->real.boundary();
217  }
218 
234  size_t boundarySegmentIndex () const
235  {
236  return this->real.boundarySegmentIndex();
237  }
238 
240  bool neighbor () const
241  {
242  return this->real.neighbor();
243  }
244 
248  Entity inside() const
249  {
250  return this->real.inside();
251  }
252 
259  Entity outside() const
260  {
261  return this->real.outside();
262  }
263 
266  bool conforming () const
267  {
268  return this->real.conforming();
269  }
270 
285  {
286  return this->real.geometryInInside();
287  }
288 
303  {
304  return this->real.geometryInOutside();
305  }
306 
322  {
323  return this->real.geometry();
324  }
325 
328  {
329  return this->real.type();
330  }
331 
344  int indexInInside () const
345  {
346  return this->real.indexInInside();
347  }
348 
361  int indexInOutside () const
362  {
363  return this->real.indexInOutside();
364  }
365 
371  {
372  return this->real.outerNormal(local);
373  }
374 
384  {
385  return this->real.integrationOuterNormal(local);
386  }
387 
394  {
395  return this->real.unitOuterNormal(local);
396  }
397 
405  {
406  return this->real.centerUnitOuterNormal();
407  }
408 
410  bool operator==(const Intersection& other) const
411  {
412  return real.equals(other.real);
413  }
414 
416  bool operator!=(const Intersection& other) const
417  {
418  return !real.equals(other.real);
419  }
420 
423  {}
424 
427  : real(other.real)
428  {}
429 
432  : real(std::move(other.real))
433  {}
434 
437  {
438  real = other.real;
439  return *this;
440  }
441 
444  {
445  real = std::move(other.real);
446  return *this;
447  }
448 
449  //===========================================================
453  //===========================================================
454 
457  : real( impl )
458  {}
459 
462  : real( std::move(impl) )
463  {}
464 
466 
467  protected:
470  friend class IntersectionIterator<GridImp, IntersectionImp, IntersectionImp>;
471 
472  };
473 
474  //**********************************************************************
480  template< class GridImp, class IntersectionImp >
482  {
483  enum { dim=GridImp::dimension };
484  enum { dimworld=GridImp::dimensionworld };
485  typedef typename GridImp::ctype ct;
486  public:
487 
491  FieldVector<ct, dimworld> integrationOuterNormal (const FieldVector<ct, dim-1>& local) const
492  {
493  FieldVector<ct, dimworld> n = asImp().unitOuterNormal(local);
494  n *= asImp().geometry().integrationElement(local);
495  return n;
496  }
497 
499  FieldVector<ct, dimworld> unitOuterNormal (const FieldVector<ct, dim-1>& local) const
500  {
501  FieldVector<ct, dimworld> n = asImp().outerNormal(local);
502  n /= n.two_norm();
503  return n;
504  }
505 
507  FieldVector<ct, dimworld> centerUnitOuterNormal () const
508  {
509  // For now, we do this...
510  GeometryType type = asImp().geometry().type();
511  auto refElement = referenceElement<ct, dim-1>(type);
512  return asImp().unitOuterNormal(refElement.position(0,0));
513  // But later, if we change the meaning of center(),
514  // we may have to change to this...
515  // return asImp().unitOuterNormal(asImp().local(asImp().center()));
516  }
517 
518  private:
519  // CRTP (curiously recurring template pattern)
520  IntersectionImp &asImp () { return static_cast< IntersectionImp & >( *this ); }
521  const IntersectionImp &asImp () const { return static_cast< const IntersectionImp & >( *this ); }
522  };
523 
524 } // namespace Dune
525 
526 #endif // DUNE_GRID_COMMON_INTERSECTION_HH
Include standard header files.
Definition: agrid.hh:58
auto referenceElement(const Geometry< mydim, cdim, GridImp, GeometryImp > &geo) -> decltype(referenceElement(geo, geo.impl()))
Definition: common/geometry.hh:417
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:130
Intersection of a mesh entity of codimension 0 ("element") with a "neighboring" element or with the d...
Definition: common/intersection.hh:162
Geometry geometry() const
geometrical information about the intersection in global coordinates.
Definition: common/intersection.hh:321
bool conforming() const
Return true if intersection is conforming.
Definition: common/intersection.hh:266
Entity outside() const
return Entity on the outside of this intersection. That is the neighboring Entity.
Definition: common/intersection.hh:259
Intersection & operator=(const Intersection &other)
Copy assignment operator from an existing intersection.
Definition: common/intersection.hh:436
int indexInOutside() const
Local index of codim 1 entity in outside() entity where intersection is contained in.
Definition: common/intersection.hh:361
Intersection & operator=(Intersection &&other)
Move assignment operator from an existing intersection.
Definition: common/intersection.hh:443
bool neighbor() const
return true if intersection is shared with another element.
Definition: common/intersection.hh:240
const Implementation & impl() const
access to the underlying implementation
Definition: common/intersection.hh:183
bool boundary() const
Return true if intersection is with interior or exterior boundary (see the cases above)
Definition: common/intersection.hh:214
int indexInInside() const
Local index of codim 1 entity in the inside() entity where intersection is contained in.
Definition: common/intersection.hh:344
Intersection(Implementation &&impl)
Definition: common/intersection.hh:461
Geometry::GlobalCoordinate GlobalCoordinate
Type for normal vectors.
Definition: common/intersection.hh:199
GridImp::template Codim< 1 >::LocalGeometry LocalGeometry
Codim 1 geometry returned by geometryInInside() and geometryInOutside()
Definition: common/intersection.hh:202
GlobalCoordinate unitOuterNormal(const LocalCoordinate &local) const
Return unit outer normal (length == 1)
Definition: common/intersection.hh:393
bool operator!=(const Intersection &other) const
Compares two intersections for inequality.
Definition: common/intersection.hh:416
GeometryType type() const
obtain the type of reference element for this intersection
Definition: common/intersection.hh:327
@ dimensionworld
Definition: common/intersection.hh:208
Intersection(Intersection &&other)
Move constructor from an existing intersection.
Definition: common/intersection.hh:431
LocalGeometry geometryInOutside() const
geometrical information about this intersection in local coordinates of the outside() entity.
Definition: common/intersection.hh:302
LocalGeometry geometryInInside() const
geometrical information about this intersection in local coordinates of the inside() entity.
Definition: common/intersection.hh:284
size_t boundarySegmentIndex() const
index of the boundary segment within the macro grid
Definition: common/intersection.hh:234
Entity inside() const
return Entity on the inside of this intersection. That is the Entity where we started this.
Definition: common/intersection.hh:248
Geometry::LocalCoordinate LocalCoordinate
Type for vectors of coordinates on the intersection.
Definition: common/intersection.hh:196
Implementation real
Definition: common/intersection.hh:186
GlobalCoordinate centerUnitOuterNormal() const
Return unit outer normal (length == 1)
Definition: common/intersection.hh:404
GridImp::template Codim< 1 >::Geometry Geometry
Codim 1 geometry returned by geometry()
Definition: common/intersection.hh:193
GridImp::template Codim< 0 >::Entity Entity
Type of entity that this Intersection belongs to.
Definition: common/intersection.hh:190
@ mydimension
Definition: common/intersection.hh:205
GlobalCoordinate outerNormal(const LocalCoordinate &local) const
Return an outer normal (length not necessarily 1)
Definition: common/intersection.hh:370
Implementation & impl()
access to the underlying implementation
Definition: common/intersection.hh:176
Intersection()
Default constructor.
Definition: common/intersection.hh:422
GridImp::ctype ctype
Type of individual coefficients of coordinate vectors.
Definition: common/intersection.hh:211
Intersection(const Implementation &impl)
Definition: common/intersection.hh:456
IntersectionImp Implementation
type of underlying implementation
Definition: common/intersection.hh:169
GlobalCoordinate integrationOuterNormal(const LocalCoordinate &local) const
return unit outer normal scaled with the integration element
Definition: common/intersection.hh:383
bool operator==(const Intersection &other) const
Compares two intersections for equality.
Definition: common/intersection.hh:410
Intersection(const Intersection &other)
Copy constructor from an existing intersection.
Definition: common/intersection.hh:426
FieldVector< ctype, cdim > GlobalCoordinate
type of the global coordinates
Definition: common/geometry.hh:101
FieldVector< ctype, mydim > LocalCoordinate
type of local coordinates
Definition: common/geometry.hh:98
Mesh entities of codimension 0 ("elements") allow to visit all intersections with "neighboring" eleme...
Definition: common/intersectioniterator.hh:81
Default Implementations of integrationOuterNormal and unitOuterNormal for IntersectionImp.
Definition: common/intersection.hh:482
FieldVector< ct, dimworld > integrationOuterNormal(const FieldVector< ct, dim-1 > &local) const
Definition: common/intersection.hh:491
FieldVector< ct, dimworld > centerUnitOuterNormal() const
return unit outer normal at center of intersection geometry
Definition: common/intersection.hh:507
FieldVector< ct, dimworld > unitOuterNormal(const FieldVector< ct, dim-1 > &local) const
return unit outer normal
Definition: common/intersection.hh:499
Different resources needed by all grid implementations.