3#ifndef DUNE_GRID_COMMON_GEOMETRY_HH
4#define DUNE_GRID_COMMON_GEOMETRY_HH
12#include <dune/common/fmatrix.hh>
13#include <dune/common/typetraits.hh>
15#include <dune/geometry/referenceelements.hh>
23 template<
int dim,
int dimworld,
class ct,
class Gr
idFamily >
24 class GridDefaultImplementation;
65 template<
int mydim,
int cdim,
class Gr
idImp,
template<
int,
int,
class >
class GeometryImp >
95 typedef typename GridImp::ctype
ctype;
104 typedef decltype(std::declval<Implementation>().volume())
Volume;
131 GeometryType
type ()
const {
return impl().type(); }
158 return impl().corner( i );
167 return impl().global( local );
204 return impl().integrationElement( local );
210 return impl().volume();
225 return impl().center();
241 return impl().jacobianTransposed( local );
267 return impl().jacobianInverseTransposed(local);
299 template<
int mydim,
int cdim,
class Gr
idImp,
template<
int,
int,
class>
class GeometryImp>
307 typedef typename GridImp::ctype
ctype;
324 GeometryType type = asImp().type();
327 auto refElement = referenceElement< ctype , mydim >(type);
331 const int corners = refElement.size(0,0,mydim);
332 for(
int i=0; i<corners; ++i) localBaryCenter += refElement.position(i,mydim);
333 localBaryCenter *= (
ctype) (1.0/corners);
336 return refElement.volume() * asImp().integrationElement(localBaryCenter);
342 GeometryType type = asImp().type();
345 auto refElement = referenceElement< ctype , mydim >(type);
349 return asImp().global(refElement.position(0,0));
354 GeometryImp<mydim,cdim,GridImp>& asImp () {
return static_cast<GeometryImp<mydim,cdim,GridImp>&
>(*this);}
355 const GeometryImp<mydim,cdim,GridImp>& asImp ()
const {
return static_cast<const GeometryImp<mydim,cdim,GridImp>&
>(*this);}
358 template<
int cdim,
class Gr
idImp,
template<
int,
int,
class>
class GeometryImp>
369 typedef typename GridImp::ctype
ctype;
382 FieldVector<ctype, cdim> global (
const FieldVector<ctype, mydim>& local)
const
384 return asImp().corner(0);
388 FieldVector<ctype, mydim> local (
const FieldVector<ctype, cdim>& )
const
390 return FieldVector<ctype, mydim>();
402 return asImp().corner(0);
407 GeometryImp<mydim,cdim,GridImp>& asImp () {
return static_cast<GeometryImp<mydim,cdim,GridImp>&
>(*this);}
408 const GeometryImp<mydim,cdim,GridImp>& asImp ()
const {
return static_cast<const GeometryImp<mydim,cdim,GridImp>&
>(*this);}
416 template<
int mydim,
int cdim,
class Gr
idImp,
template<
int,
int,
class >
class GeometryImp>
439 template<
int mydim,
int cdim,
class Gr
idImp,
template<
int,
int,
class >
class GeometryImp,
typename Impl>
441 ->
decltype(referenceElement<typename GridImp::ctype,mydim>(geo.type()))
444 return referenceElement<typename Geo::ctype,Geo::mydimension>(geo.type());
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
Wrapper class for geometries.
Definition: common/geometry.hh:67
FieldVector< ctype, cdim > GlobalCoordinate
type of the global coordinates
Definition: common/geometry.hh:101
JacobianTransposed jacobianTransposed(const LocalCoordinate &local) const
Return the transposed of the Jacobian.
Definition: common/geometry.hh:239
Implementation & impl()
access to the underlying implementation
Definition: common/geometry.hh:81
GeometryType type() const
Return the type of the reference element. The type can be used to access the Dune::ReferenceElement.
Definition: common/geometry.hh:131
GlobalCoordinate global(const LocalCoordinate &local) const
Evaluate the map .
Definition: common/geometry.hh:165
Geometry(const Implementation &impl)
copy constructor from implementation
Definition: common/geometry.hh:276
@ mydimension
Definition: common/geometry.hh:90
Implementation::JacobianTransposed JacobianTransposed
type of jacobian transposed
Definition: common/geometry.hh:126
Implementation::JacobianInverseTransposed JacobianInverseTransposed
type of jacobian inverse transposed
Definition: common/geometry.hh:115
GlobalCoordinate corner(int i) const
Obtain a corner of the geometry.
Definition: common/geometry.hh:156
int corners() const
Return the number of corners of the reference element.
Definition: common/geometry.hh:142
Volume volume() const
return volume of geometry
Definition: common/geometry.hh:208
decltype(std::declval< Implementation >().volume()) Volume
Number type used for the geometry volume.
Definition: common/geometry.hh:104
GridImp::ctype ctype
define type used for coordinates in grid module
Definition: common/geometry.hh:95
ctype integrationElement(const LocalCoordinate &local) const
Return the factor appearing in the integral transformation formula.
Definition: common/geometry.hh:202
const Implementation & impl() const
access to the underlying implementation
Definition: common/geometry.hh:87
FieldVector< ctype, mydim > LocalCoordinate
type of local coordinates
Definition: common/geometry.hh:98
Implementation realGeometry
Definition: common/geometry.hh:287
GlobalCoordinate center() const
return center of geometry
Definition: common/geometry.hh:223
bool affine() const
Return true if the geometry mapping is affine and false otherwise.
Definition: common/geometry.hh:134
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:440
const Geometry & operator=(const Geometry &rhs)=delete
@ coorddimension
Definition: common/geometry.hh:92
GeometryImp< mydim, cdim, GridImp > Implementation
type of underlying implementation
Definition: common/geometry.hh:74
JacobianInverseTransposed jacobianInverseTransposed(const LocalCoordinate &local) const
Return inverse of transposed of Jacobian.
Definition: common/geometry.hh:265
Default implementation for class Geometry.
Definition: common/geometry.hh:301
FieldVector< ctype, cdim > GlobalCoordinate
Definition: common/geometry.hh:310
static const int mydimension
Definition: common/geometry.hh:303
Volume volume() const
return volume of the geometry
Definition: common/geometry.hh:322
FieldVector< ctype, mydim > LocalCoordinate
Definition: common/geometry.hh:309
GlobalCoordinate center() const
return center of the geometry
Definition: common/geometry.hh:340
FieldMatrix< ctype, mydim, cdim > JacobianTransposed
type of jacobian transposed
Definition: common/geometry.hh:319
GridImp::ctype ctype
Definition: common/geometry.hh:307
FieldMatrix< ctype, cdim, mydim > JacobianInverseTransposed
type of jacobian inverse transposed
Definition: common/geometry.hh:316
static const int coorddimension
Definition: common/geometry.hh:304
ctype Volume
Number type used for the geometry volume.
Definition: common/geometry.hh:313
GridImp::ctype ctype
Definition: common/geometry.hh:369
FieldVector< ctype, cdim > GlobalCoordinate
Definition: common/geometry.hh:372
FieldMatrix< ctype, cdim, mydim > JacobianInverseTransposed
type of jacobian inverse transposed
Definition: common/geometry.hh:376
ctype Volume
Definition: common/geometry.hh:373
FieldVector< ctype, cdim > center() const
return center of the geometry
Definition: common/geometry.hh:400
FieldVector< ctype, mydim > LocalCoordinate
Definition: common/geometry.hh:371
FieldMatrix< ctype, mydim, cdim > JacobianTransposed
type of jacobian transposed
Definition: common/geometry.hh:379
Volume volume() const
return volume of the geometry
Definition: common/geometry.hh:394