5 #ifndef DUNE_GRID_COMMON_GEOMETRY_HH 6 #define DUNE_GRID_COMMON_GEOMETRY_HH 14 #include <dune/common/fmatrix.hh> 15 #include <dune/common/typetraits.hh> 16 #include <dune/common/transpose.hh> 17 #include <dune/common/std/type_traits.hh> 19 #include <dune/geometry/referenceelements.hh> 27 template<
int dim,
int dimworld,
class ct,
class Gr
idFamily >
69 template<
int mydim,
int cdim,
class Gr
idImp,
template<
int,
int,
class >
class GeometryImp >
100 typedef typename GridImp::ctype
ctype;
135 template<class Implementation_T>
136 using JacobianInverseOfImplementation = decltype(typename Implementation_T::
JacobianInverse{std::declval<Implementation_T>().
jacobianInverse(std::declval<LocalCoordinate>())});
138 using JacobianInverseDefault = decltype(transpose(std::declval<JacobianInverseTransposed>()));
140 template<
class Implementation_T>
141 using JacobianOfImplementation = decltype(
typename Implementation_T::Jacobian{std::declval<Implementation_T>().
jacobian(std::declval<LocalCoordinate>())});
143 using JacobianDefault = decltype(transpose(std::declval<JacobianTransposed>()));
150 [[deprecated(
"Geometry implementations are required to provide a jacobian(local) method. The default implementation is deprecated and will be removed after release 2.9")]]
161 [[deprecated(
"Geometry implementations are required to provide a jacobianInverse(local) method. The default implementation is deprecated and will be removed after release 2.9")]]
178 using JacobianInverse = Std::detected_or_t<JacobianInverseDefault, JacobianInverseOfImplementation, Implementation>;
189 using Jacobian = Std::detected_or_t<JacobianDefault, JacobianOfImplementation, Implementation>;
221 return impl().corner( i );
267 return impl().integrationElement(
local );
273 return impl().volume();
288 return impl().center();
304 return impl().jacobianTransposed(
local );
330 return impl().jacobianInverseTransposed(
local);
346 auto implDetected = Std::is_detected<JacobianOfImplementation, Implementation>{};
347 return jacobianImpl(
local, implDetected);
373 auto implDetected = Std::is_detected<JacobianInverseOfImplementation, Implementation>{};
374 return jacobianInverseImpl(
local, implDetected);
404 template<
int mydim,
int cdim,
class Gr
idImp,
template<
int,
int,
class>
class GeometryImp>
412 typedef typename GridImp::ctype
ctype;
430 typedef FieldMatrix< ctype, cdim, mydim >
Jacobian;
438 auto refElement = referenceElement< ctype , mydim >(type);
442 const int corners = refElement.size(0,0,mydim);
443 for(
int i=0; i<corners; ++i) localBaryCenter += refElement.position(i,mydim);
444 localBaryCenter *= (
ctype) (1.0/corners);
447 return refElement.volume() * asImp().integrationElement(localBaryCenter);
456 auto refElement = referenceElement< ctype , mydim >(type);
460 return asImp().global(refElement.position(0,0));
466 return asImp().jacobianTransposed(local).transposed();
472 return asImp().jacobianInverseTransposed(local).transposed();
477 GeometryImp<mydim,cdim,GridImp>& asImp () {
return static_cast<GeometryImp<mydim,cdim,GridImp>&
>(*this);}
478 const GeometryImp<mydim,cdim,GridImp>& asImp ()
const {
return static_cast<const GeometryImp<mydim,cdim,GridImp>&
>(*this);}
481 template<
int cdim,
class Gr
idImp,
template<
int,
int,
class>
class GeometryImp>
485 constexpr
static int mydim = 0;
492 typedef typename GridImp::ctype
ctype;
508 typedef FieldMatrix< ctype, cdim, mydim >
Jacobian;
511 FieldVector<ctype, cdim>
global (
const FieldVector<ctype, mydim>& )
const 513 return asImp().corner(0);
517 FieldVector<ctype, mydim>
local (
const FieldVector<ctype, cdim>& )
const 519 return FieldVector<ctype, mydim>();
531 return asImp().corner(0);
537 return asImp().jacobianTransposed(local).transposed();
543 return asImp().jacobianInverseTransposed(local).transposed();
548 GeometryImp<mydim,cdim,GridImp>& asImp () {
return static_cast<GeometryImp<mydim,cdim,GridImp>&
>(*this);}
549 const GeometryImp<mydim,cdim,GridImp>& asImp ()
const {
return static_cast<const GeometryImp<mydim,cdim,GridImp>&
>(*this);}
557 template<
int mydim,
int cdim,
class Gr
idImp,
template<
int,
int,
class >
class GeometryImp>
580 template<
int mydim,
int cdim,
class Gr
idImp,
template<
int,
int,
class >
class GeometryImp,
typename Impl>
582 -> decltype(referenceElement<typename GridImp::ctype,mydim>(geo.type()))
585 return referenceElement<typename Geo::ctype,Geo::mydimension>(geo.type());
590 #endif // DUNE_GRID_COMMON_GEOMETRY_HH Wrapper class for geometries.
Definition: common/geometry.hh:70
Implementation::JacobianInverseTransposed JacobianInverseTransposed
type of jacobian inverse transposed
Definition: common/geometry.hh:120
int corners() const
Return the number of corners of the reference element.
Definition: common/geometry.hh:205
GridImp::ctype ctype
Definition: common/geometry.hh:412
FieldVector< ctype, mydim > local(const FieldVector< ctype, cdim > &) const
return empty vector
Definition: common/geometry.hh:517
Implementation realGeometry
Definition: common/geometry.hh:392
const Implementation & impl() const
access to the underlying implementation
Definition: common/geometry.hh:91
Volume volume() const
return volume of geometry
Definition: common/geometry.hh:271
Std::detected_or_t< JacobianInverseDefault, JacobianInverseOfImplementation, Implementation > JacobianInverse
type of jacobian inverse
Definition: common/geometry.hh:178
FieldMatrix< ctype, mydim, cdim > JacobianInverse
type of jacobian inverse
Definition: common/geometry.hh:505
FieldVector< ctype, mydim > LocalCoordinate
type of local coordinates
Definition: common/geometry.hh:103
LocalCoordinate local(const GlobalCoordinate &global) const
Evaluate the inverse map .
Definition: common/geometry.hh:237
FieldVector< ctype, cdim > center() const
return center of the geometry
Definition: common/geometry.hh:529
ctype Volume
Number type used for the geometry volume.
Definition: common/geometry.hh:418
static const int coorddimension
Definition: common/geometry.hh:409
Volume volume() const
return volume of the geometry
Definition: common/geometry.hh:523
bool affine() const
Return true if the geometry mapping is affine and false otherwise.
Definition: common/geometry.hh:197
FieldMatrix< ctype, cdim, mydim > Jacobian
type of jacobian
Definition: common/geometry.hh:508
decltype(std::declval< Implementation >().volume()) typedef Volume
Number type used for the geometry volume.
Definition: common/geometry.hh:109
Std::detected_or_t< JacobianDefault, JacobianOfImplementation, Implementation > Jacobian
type of jacobian
Definition: common/geometry.hh:189
JacobianInverse jacobianInverse(const LocalCoordinate &local) const
Return inverse of Jacobian.
Definition: common/geometry.hh:371
Geometry(const Implementation &impl)
copy constructor from implementation
Definition: common/geometry.hh:384
Jacobian jacobian(const LocalCoordinate &local) const
Return the Jacobian.
Definition: common/geometry.hh:344
GlobalCoordinate global(const LocalCoordinate &local) const
Evaluate the map .
Definition: common/geometry.hh:228
FieldVector< ctype, cdim > GlobalCoordinate
Definition: common/geometry.hh:415
GeometryType type() const
Return the type of the reference element. The type can be used to access the Dune::ReferenceElement.
Definition: common/geometry.hh:194
FieldMatrix< ctype, cdim, mydim > JacobianInverseTransposed
type of jacobian inverse transposed
Definition: common/geometry.hh:421
JacobianInverse jacobianInverse(const LocalCoordinate &local) const
Return inverse of Jacobian.
Definition: common/geometry.hh:541
FieldMatrix< ctype, mydim, cdim > JacobianTransposed
type of jacobian transposed
Definition: common/geometry.hh:502
GridImp::ctype ctype
define type used for coordinates in grid module
Definition: common/geometry.hh:100
static constexpr int coorddimension
dimension of embedding coordinate system
Definition: common/geometry.hh:97
FieldVector< ctype, cdim > GlobalCoordinate
Definition: common/geometry.hh:495
FieldVector< ctype, mydim > LocalCoordinate
Definition: common/geometry.hh:414
GeometryImp< mydim, cdim, GridImp > Implementation
type of underlying implementation
Definition: common/geometry.hh:78
Jacobian jacobian(const LocalCoordinate &local) const
Return the Jacobian.
Definition: common/geometry.hh:535
Definition: common/geometry.hh:28
static constexpr int mydimension
geometry dimension
Definition: common/geometry.hh:94
auto referenceElement(const Geometry< mydim, cdim, GridImp, GeometryImp > &geo) -> decltype(referenceElement(geo, geo.impl()))
Definition: common/geometry.hh:558
Include standard header files.
Definition: agrid.hh:59
Volume integrationElement(const LocalCoordinate &local) const
Return the factor appearing in the integral transformation formula.
Definition: common/geometry.hh:265
JacobianInverseTransposed jacobianInverseTransposed(const LocalCoordinate &local) const
Return inverse of transposed of Jacobian.
Definition: common/geometry.hh:328
FieldMatrix< ctype, mydim, cdim > JacobianInverse
type of jacobian inverse
Definition: common/geometry.hh:427
FieldMatrix< ctype, cdim, mydim > Jacobian
type of jacobian
Definition: common/geometry.hh:430
GridImp::ctype ctype
Definition: common/geometry.hh:492
FieldMatrix< ctype, mydim, cdim > JacobianTransposed
type of jacobian transposed
Definition: common/geometry.hh:424
GlobalCoordinate center() const
return center of geometry
Definition: common/geometry.hh:286
Jacobian jacobian(const LocalCoordinate &local) const
Return the Jacobian.
Definition: common/geometry.hh:464
FieldVector< ctype, cdim > global(const FieldVector< ctype, mydim > &) const
return the only coordinate
Definition: common/geometry.hh:511
static const int mydimension
Definition: common/geometry.hh:408
Implementation::JacobianTransposed JacobianTransposed
type of jacobian transposed
Definition: common/geometry.hh:131
FieldMatrix< ctype, cdim, mydim > JacobianInverseTransposed
type of jacobian inverse transposed
Definition: common/geometry.hh:499
GlobalCoordinate corner(int i) const
Obtain a corner of the geometry.
Definition: common/geometry.hh:219
ctype Volume
Definition: common/geometry.hh:496
GlobalCoordinate center() const
return center of the geometry
Definition: common/geometry.hh:451
JacobianTransposed jacobianTransposed(const LocalCoordinate &local) const
Return the transposed of the Jacobian.
Definition: common/geometry.hh:302
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:132
JacobianInverse jacobianInverse(const LocalCoordinate &local) const
Return inverse of Jacobian.
Definition: common/geometry.hh:470
Default implementation for class Geometry.
Definition: common/geometry.hh:405
FieldVector< ctype, cdim > GlobalCoordinate
type of the global coordinates
Definition: common/geometry.hh:106
auto referenceElement(const Geometry< mydim, cdim, GridImp, GeometryImp > &geo, const Impl &) -> decltype(referenceElement< typename GridImp::ctype, mydim >(geo.type()))
Second-level dispatch to select the correct reference element for a grid geometry.
Definition: common/geometry.hh:581
Implementation & impl()
access to the underlying implementation
Definition: common/geometry.hh:85
Volume volume() const
return volume of the geometry
Definition: common/geometry.hh:433
FieldVector< ctype, mydim > LocalCoordinate
Definition: common/geometry.hh:494