dune-grid 2.11
Loading...
Searching...
No Matches
common/intersection.hh
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright © 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
11namespace 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
251 {
252 return this->real.inside();
253 }
254
262 {
263 return this->real.outside();
264 }
265
273 bool conforming () const
274 {
275 return this->real.conforming();
276 }
277
292 {
293 return this->real.geometryInInside();
294 }
295
310 {
311 return this->real.geometryInOutside();
312 }
313
329 {
330 return this->real.geometry();
331 }
332
334 GeometryType type () const
335 {
336 return this->real.type();
337 }
338
351 int indexInInside () const
352 {
353 return this->real.indexInInside();
354 }
355
368 int indexInOutside () const
369 {
370 return this->real.indexInOutside();
371 }
372
378 {
379 return this->real.outerNormal(local);
380 }
381
391 {
392 return this->real.integrationOuterNormal(local);
393 }
394
401 {
402 return this->real.unitOuterNormal(local);
403 }
404
412 {
413 return this->real.centerUnitOuterNormal();
414 }
415
417 bool operator==(const Intersection& other) const
418 {
419 return real.equals(other.real);
420 }
421
423 bool operator!=(const Intersection& other) const
424 {
425 return !real.equals(other.real);
426 }
427
430 {}
431
434 : real(other.real)
435 {}
436
439 : real(std::move(other.real))
440 {}
441
444 {
445 real = other.real;
446 return *this;
447 }
448
451 {
452 real = std::move(other.real);
453 return *this;
454 }
455
456 //===========================================================
460 //===========================================================
461
464 : real( impl )
465 {}
466
469 : real( std::move(impl) )
470 {}
471
473
474 protected:
477 friend class IntersectionIterator<GridImp, IntersectionImp, IntersectionImp>;
478
479 };
480
481 //**********************************************************************
487 template< class GridImp, class IntersectionImp >
489 {
490 constexpr static int dim = GridImp::dimension;
491 constexpr static int dimworld = GridImp::dimensionworld;
492 typedef typename GridImp::ctype ct;
493 public:
494
498 FieldVector<ct, dimworld> integrationOuterNormal (const FieldVector<ct, dim-1>& local) const
499 {
500 FieldVector<ct, dimworld> n = asImp().unitOuterNormal(local);
501 n *= asImp().geometry().integrationElement(local);
502 return n;
503 }
504
506 FieldVector<ct, dimworld> unitOuterNormal (const FieldVector<ct, dim-1>& local) const
507 {
508 FieldVector<ct, dimworld> n = asImp().outerNormal(local);
509 n /= n.two_norm();
510 return n;
511 }
512
514 FieldVector<ct, dimworld> centerUnitOuterNormal () const
515 {
516 // For now, we do this...
517 GeometryType type = asImp().geometry().type();
518 auto refElement = referenceElement<ct, dim-1>(type);
519 return asImp().unitOuterNormal(refElement.position(0,0));
520 // But later, if we change the meaning of center(),
521 // we may have to change to this...
522 // return asImp().unitOuterNormal(asImp().local(asImp().center()));
523 }
524
525 private:
526 // CRTP (curiously recurring template pattern)
527 IntersectionImp &asImp () { return static_cast< IntersectionImp & >( *this ); }
528 const IntersectionImp &asImp () const { return static_cast< const IntersectionImp & >( *this ); }
529 };
530
531} // namespace Dune
532
533#endif // DUNE_GRID_COMMON_INTERSECTION_HH
STL namespace.
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
Intersection & operator=(const Intersection &other)
Copy assignment operator from an existing intersection.
Definition common/intersection.hh:443
Geometry geometry() const
geometrical information about the intersection in global coordinates.
Definition common/intersection.hh:328
bool conforming() const
Return true if intersection is conforming.
Definition common/intersection.hh:273
Entity outside() const
return Entity on the outside of this intersection. That is the neighboring Entity.
Definition common/intersection.hh:261
int indexInOutside() const
Local index of codim 1 entity in outside() entity where intersection is contained in.
Definition common/intersection.hh:368
static constexpr int mydimension
Definition common/intersection.hh:207
bool neighbor() const
return true if intersection is shared with another element.
Definition common/intersection.hh:242
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:351
Intersection(Implementation &&impl)
Definition common/intersection.hh:468
Intersection & operator=(Intersection &&other)
Move assignment operator from an existing intersection.
Definition common/intersection.hh:450
Geometry::GlobalCoordinate GlobalCoordinate
Definition common/intersection.hh:201
GridImp::template Codim< 1 >::LocalGeometry LocalGeometry
Definition common/intersection.hh:204
GlobalCoordinate unitOuterNormal(const LocalCoordinate &local) const
Return unit outer normal (length == 1).
Definition common/intersection.hh:400
bool operator!=(const Intersection &other) const
Compares two intersections for inequality.
Definition common/intersection.hh:423
GeometryType type() const
obtain the type of reference element for this intersection
Definition common/intersection.hh:334
Intersection(Intersection &&other)
Move constructor from an existing intersection.
Definition common/intersection.hh:438
LocalGeometry geometryInOutside() const
geometrical information about this intersection in local coordinates of the outside() entity.
Definition common/intersection.hh:309
LocalGeometry geometryInInside() const
geometrical information about this intersection in local coordinates of the inside() entity.
Definition common/intersection.hh:291
size_t boundarySegmentIndex() const
index of the boundary segment within the macro grid
Definition common/intersection.hh:236
static constexpr int dimensionworld
Definition common/intersection.hh:210
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
Definition common/intersection.hh:198
GlobalCoordinate centerUnitOuterNormal() const
Return unit outer normal (length == 1).
Definition common/intersection.hh:411
GridImp::template Codim< 1 >::Geometry Geometry
Definition common/intersection.hh:195
Implementation & impl()
access to the underlying implementation
Definition common/intersection.hh:178
GridImp::template Codim< 0 >::Entity Entity
Definition common/intersection.hh:192
const Implementation & impl() const
access to the underlying implementation
Definition common/intersection.hh:185
GlobalCoordinate outerNormal(const LocalCoordinate &local) const
Return an outer normal (length not necessarily 1).
Definition common/intersection.hh:377
Intersection()
Default constructor.
Definition common/intersection.hh:429
Intersection(const Implementation &impl)
Definition common/intersection.hh:463
AlbertaGridLeafIntersection< const GridImp > 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:390
bool operator==(const Intersection &other) const
Compares two intersections for equality.
Definition common/intersection.hh:417
Intersection(const Intersection &other)
Copy constructor from an existing intersection.
Definition common/intersection.hh:433
LocalGeometry geometryInOutside() const
Definition intersection.cc:402
GridImp::template Codim< 0 >::Entity outside() const
Definition intersection.cc:365
int indexInOutside() const
Definition intersection.cc:426
LocalGeometry geometryInInside() const
Definition intersection.cc:391
Geometry geometry() const
Definition intersection.cc:417
bool neighbor() const
Definition intersection.cc:382
bool conforming() const
Definition albertagrid/intersection.hh:166
NormalVector integrationOuterNormal(const LocalCoordType &local) const
Definition intersection.cc:189
NormalVector centerUnitOuterNormal() const
Definition intersection.cc:179
int indexInInside() const
Definition intersection.cc:74
NormalVector unitOuterNormal(const LocalCoordType &local) const
Definition intersection.cc:205
bool boundary() const
Definition intersection.cc:43
size_t boundarySegmentIndex() const
Definition intersection.cc:64
GeometryType type() const
Definition intersection.cc:82
NormalVector outerNormal(const LocalCoordType &local) const
Definition intersection.cc:197
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:489
FieldVector< ct, dimworld > integrationOuterNormal(const FieldVector< ct, dim-1 > &local) const
Definition common/intersection.hh:498
FieldVector< ct, dimworld > unitOuterNormal(const FieldVector< ct, dim-1 > &local) const
return unit outer normal
Definition common/intersection.hh:506
FieldVector< ct, dimworld > centerUnitOuterNormal() const
return unit outer normal at center of intersection geometry
Definition common/intersection.hh:514
Different resources needed by all grid implementations.