dune-grid  2.9.0
common/intersection.hh
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (C) DUNE Project contributors, see file LICENSE.md in module root
2 // SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
3 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
4 // vi: set et ts=4 sw=2 sts=2:
5 
6 #ifndef DUNE_GRID_COMMON_INTERSECTION_HH
7 #define DUNE_GRID_COMMON_INTERSECTION_HH
8 
10 
11 namespace Dune
12 {
13 
162  template< class GridImp, class IntersectionImp >
164  {
165  public:
171  typedef IntersectionImp Implementation;
172 
178  Implementation &impl () { return real; }
179 
185  const Implementation &impl () const { return real; }
186 
187  protected:
189 
190  public:
192  typedef typename GridImp::template Codim<0>::Entity Entity;
193 
195  typedef typename GridImp::template Codim<1>::Geometry Geometry;
196 
199 
202 
204  typedef typename GridImp::template Codim<1>::LocalGeometry LocalGeometry;
205 
207  constexpr static int mydimension = GridImp::dimension - 1;
208 
210  constexpr static int dimensionworld = GridImp::dimensionworld;
211 
213  typedef typename GridImp::ctype ctype;
214 
216  bool boundary () const
217  {
218  return this->real.boundary();
219  }
220 
236  size_t boundarySegmentIndex () const
237  {
238  return this->real.boundarySegmentIndex();
239  }
240 
242  bool neighbor () const
243  {
244  return this->real.neighbor();
245  }
246 
250  Entity inside() const
251  {
252  return this->real.inside();
253  }
254 
261  Entity outside() const
262  {
263  return this->real.outside();
264  }
265 
268  bool conforming () const
269  {
270  return this->real.conforming();
271  }
272 
287  {
288  return this->real.geometryInInside();
289  }
290 
305  {
306  return this->real.geometryInOutside();
307  }
308 
324  {
325  return this->real.geometry();
326  }
327 
330  {
331  return this->real.type();
332  }
333 
346  int indexInInside () const
347  {
348  return this->real.indexInInside();
349  }
350 
363  int indexInOutside () const
364  {
365  return this->real.indexInOutside();
366  }
367 
373  {
374  return this->real.outerNormal(local);
375  }
376 
386  {
387  return this->real.integrationOuterNormal(local);
388  }
389 
396  {
397  return this->real.unitOuterNormal(local);
398  }
399 
407  {
408  return this->real.centerUnitOuterNormal();
409  }
410 
412  bool operator==(const Intersection& other) const
413  {
414  return real.equals(other.real);
415  }
416 
418  bool operator!=(const Intersection& other) const
419  {
420  return !real.equals(other.real);
421  }
422 
425  {}
426 
429  : real(other.real)
430  {}
431 
434  : real(std::move(other.real))
435  {}
436 
439  {
440  real = other.real;
441  return *this;
442  }
443 
446  {
447  real = std::move(other.real);
448  return *this;
449  }
450 
451  //===========================================================
455  //===========================================================
456 
459  : real( impl )
460  {}
461 
464  : real( std::move(impl) )
465  {}
466 
468 
469  protected:
472  friend class IntersectionIterator<GridImp, IntersectionImp, IntersectionImp>;
473 
474  };
475 
476  //**********************************************************************
482  template< class GridImp, class IntersectionImp >
484  {
485  constexpr static int dim = GridImp::dimension;
486  constexpr static int dimworld = GridImp::dimensionworld;
487  typedef typename GridImp::ctype ct;
488  public:
489 
493  FieldVector<ct, dimworld> integrationOuterNormal (const FieldVector<ct, dim-1>& local) const
494  {
495  FieldVector<ct, dimworld> n = asImp().unitOuterNormal(local);
496  n *= asImp().geometry().integrationElement(local);
497  return n;
498  }
499 
501  FieldVector<ct, dimworld> unitOuterNormal (const FieldVector<ct, dim-1>& local) const
502  {
503  FieldVector<ct, dimworld> n = asImp().outerNormal(local);
504  n /= n.two_norm();
505  return n;
506  }
507 
509  FieldVector<ct, dimworld> centerUnitOuterNormal () const
510  {
511  // For now, we do this...
512  GeometryType type = asImp().geometry().type();
513  auto refElement = referenceElement<ct, dim-1>(type);
514  return asImp().unitOuterNormal(refElement.position(0,0));
515  // But later, if we change the meaning of center(),
516  // we may have to change to this...
517  // return asImp().unitOuterNormal(asImp().local(asImp().center()));
518  }
519 
520  private:
521  // CRTP (curiously recurring template pattern)
522  IntersectionImp &asImp () { return static_cast< IntersectionImp & >( *this ); }
523  const IntersectionImp &asImp () const { return static_cast< const IntersectionImp & >( *this ); }
524  };
525 
526 } // namespace Dune
527 
528 #endif // DUNE_GRID_COMMON_INTERSECTION_HH
Include standard header files.
Definition: agrid.hh:60
auto referenceElement(const Geometry< mydim, cdim, GridImp, GeometryImp > &geo) -> decltype(referenceElement(geo, geo.impl()))
Definition: common/geometry.hh:558
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:132
Intersection of a mesh entity of codimension 0 ("element") with a "neighboring" element or with the d...
Definition: common/intersection.hh:164
Geometry geometry() const
geometrical information about the intersection in global coordinates.
Definition: common/intersection.hh:323
constexpr static int mydimension
dimension of the intersection
Definition: common/intersection.hh:207
bool conforming() const
Return true if intersection is conforming.
Definition: common/intersection.hh:268
Entity outside() const
return Entity on the outside of this intersection. That is the neighboring Entity.
Definition: common/intersection.hh:261
Intersection & operator=(const Intersection &other)
Copy assignment operator from an existing intersection.
Definition: common/intersection.hh:438
int indexInOutside() const
Local index of codim 1 entity in outside() entity where intersection is contained in.
Definition: common/intersection.hh:363
Intersection & operator=(Intersection &&other)
Move assignment operator from an existing intersection.
Definition: common/intersection.hh:445
bool neighbor() const
return true if intersection is shared with another element.
Definition: common/intersection.hh:242
const Implementation & impl() const
access to the underlying implementation
Definition: common/intersection.hh:185
bool boundary() const
Return true if intersection is with interior or exterior boundary (see the cases above)
Definition: common/intersection.hh:216
int indexInInside() const
Local index of codim 1 entity in the inside() entity where intersection is contained in.
Definition: common/intersection.hh:346
Intersection(Implementation &&impl)
Definition: common/intersection.hh:463
Geometry::GlobalCoordinate GlobalCoordinate
Type for normal vectors.
Definition: common/intersection.hh:201
constexpr static int dimensionworld
dimension of world
Definition: common/intersection.hh:210
GridImp::template Codim< 1 >::LocalGeometry LocalGeometry
Codim 1 geometry returned by geometryInInside() and geometryInOutside()
Definition: common/intersection.hh:204
GlobalCoordinate unitOuterNormal(const LocalCoordinate &local) const
Return unit outer normal (length == 1)
Definition: common/intersection.hh:395
bool operator!=(const Intersection &other) const
Compares two intersections for inequality.
Definition: common/intersection.hh:418
GeometryType type() const
obtain the type of reference element for this intersection
Definition: common/intersection.hh:329
Intersection(Intersection &&other)
Move constructor from an existing intersection.
Definition: common/intersection.hh:433
LocalGeometry geometryInOutside() const
geometrical information about this intersection in local coordinates of the outside() entity.
Definition: common/intersection.hh:304
LocalGeometry geometryInInside() const
geometrical information about this intersection in local coordinates of the inside() entity.
Definition: common/intersection.hh:286
size_t boundarySegmentIndex() const
index of the boundary segment within the macro grid
Definition: common/intersection.hh:236
Entity inside() const
return Entity on the inside of this intersection. That is the Entity where we started this.
Definition: common/intersection.hh:250
Geometry::LocalCoordinate LocalCoordinate
Type for vectors of coordinates on the intersection.
Definition: common/intersection.hh:198
Implementation real
Definition: common/intersection.hh:188
GlobalCoordinate centerUnitOuterNormal() const
Return unit outer normal (length == 1)
Definition: common/intersection.hh:406
GridImp::template Codim< 1 >::Geometry Geometry
Codim 1 geometry returned by geometry()
Definition: common/intersection.hh:195
GridImp::template Codim< 0 >::Entity Entity
Type of entity that this Intersection belongs to.
Definition: common/intersection.hh:192
GlobalCoordinate outerNormal(const LocalCoordinate &local) const
Return an outer normal (length not necessarily 1)
Definition: common/intersection.hh:372
Implementation & impl()
access to the underlying implementation
Definition: common/intersection.hh:178
Intersection()
Default constructor.
Definition: common/intersection.hh:424
GridImp::ctype ctype
Type of individual coefficients of coordinate vectors.
Definition: common/intersection.hh:213
Intersection(const Implementation &impl)
Definition: common/intersection.hh:458
IntersectionImp Implementation
type of underlying implementation
Definition: common/intersection.hh:171
GlobalCoordinate integrationOuterNormal(const LocalCoordinate &local) const
return unit outer normal scaled with the integration element
Definition: common/intersection.hh:385
bool operator==(const Intersection &other) const
Compares two intersections for equality.
Definition: common/intersection.hh:412
Intersection(const Intersection &other)
Copy constructor from an existing intersection.
Definition: common/intersection.hh:428
FieldVector< ctype, cdim > GlobalCoordinate
type of the global coordinates
Definition: common/geometry.hh:106
FieldVector< ctype, mydim > LocalCoordinate
type of local coordinates
Definition: common/geometry.hh:103
Mesh entities of codimension 0 ("elements") allow to visit all intersections with "neighboring" eleme...
Definition: common/intersectioniterator.hh:83
Default Implementations of integrationOuterNormal and unitOuterNormal for IntersectionImp.
Definition: common/intersection.hh:484
FieldVector< ct, dimworld > integrationOuterNormal(const FieldVector< ct, dim-1 > &local) const
Definition: common/intersection.hh:493
FieldVector< ct, dimworld > centerUnitOuterNormal() const
return unit outer normal at center of intersection geometry
Definition: common/intersection.hh:509
FieldVector< ct, dimworld > unitOuterNormal(const FieldVector< ct, dim-1 > &local) const
return unit outer normal
Definition: common/intersection.hh:501
Different resources needed by all grid implementations.