Loading...
Searching...
No Matches
affinegeometry.hh
Go to the documentation of this file.
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
#ifndef DUNE_GEOMETRY_AFFINEGEOMETRY_HH
#define DUNE_GEOMETRY_AFFINEGEOMETRY_HH
#include <cmath>
#include <dune/common/fmatrix.hh>
#include <dune/common/fvector.hh>
#include <dune/geometry/type.hh>
#include <dune/geometry/utility/defaultmatrixhelper.hh>
namespace Dune
{
// External Forward Declarations
// -----------------------------
namespace Geo
{
template< typename Implementation >
class ReferenceElement;
template< class ctype, int dim >
class ReferenceElementImplementation;
template< class ctype, int dim >
struct ReferenceElements;
}
template< class ct, int mydim, int cdim>
class AffineGeometry
{
public:
typedef ct ctype;
static const int mydimension= mydim;
static const int coorddimension = cdim;
typedef FieldVector< ctype, mydimension > LocalCoordinate;
typedef FieldVector< ctype, coorddimension > GlobalCoordinate;
typedef ctype Volume;
typedef FieldMatrix< ctype, mydimension, coorddimension > JacobianTransposed;
typedef FieldMatrix< ctype, coorddimension, mydimension > JacobianInverseTransposed;
typedef FieldMatrix< ctype, coorddimension, mydimension > Jacobian;
typedef FieldMatrix< ctype, mydimension, coorddimension > JacobianInverse;
private:
typedef Geo::ReferenceElement< Geo::ReferenceElementImplementation< ctype, mydimension > > ReferenceElement;
typedef Geo::ReferenceElements< ctype, mydimension > ReferenceElements;
// Helper class to compute a matrix pseudo inverse
typedef Impl::FieldMatrixHelper< ct > MatrixHelper;
public:
AffineGeometry () = default;
AffineGeometry ( const ReferenceElement &refElement, const GlobalCoordinate &origin,
const JacobianTransposed &jt )
: refElement_(refElement), origin_(origin), jacobianTransposed_(jt)
{
integrationElement_ = MatrixHelper::rightInvA( jacobianTransposed_, jacobianInverseTransposed_ );
}
AffineGeometry ( Dune::GeometryType gt, const GlobalCoordinate &origin,
const JacobianTransposed &jt )
: AffineGeometry(ReferenceElements::general( gt ), origin, jt)
{ }
template< class CoordVector >
AffineGeometry ( const ReferenceElement &refElement, const CoordVector &coordVector )
: refElement_(refElement), origin_(coordVector[0])
{
for( int i = 0; i < mydimension; ++i )
jacobianTransposed_[ i ] = coordVector[ i+1 ] - origin_;
integrationElement_ = MatrixHelper::rightInvA( jacobianTransposed_, jacobianInverseTransposed_ );
}
template< class CoordVector >
AffineGeometry ( Dune::GeometryType gt, const CoordVector &coordVector )
: AffineGeometry(ReferenceElements::general( gt ), coordVector)
{ }
bool affine () const { return true; }
Dune::GeometryType type () const { return refElement_.type(); }
int corners () const { return refElement_.size( mydimension ); }
GlobalCoordinate corner ( int i ) const
{
return global( refElement_.position( i, mydimension ) );
}
GlobalCoordinate center () const { return global( refElement_.position( 0, 0 ) ); }
GlobalCoordinate global ( const LocalCoordinate &local ) const
{
GlobalCoordinate global( origin_ );
jacobianTransposed_.umtv( local, global );
return global;
}
LocalCoordinate local ( const GlobalCoordinate &global ) const
{
LocalCoordinate local;
jacobianInverseTransposed_.mtv( global - origin_, local );
return local;
}
ctype integrationElement ([[maybe_unused]] const LocalCoordinate &local) const
{
return integrationElement_;
}
Volume volume () const
{
return integrationElement_ * refElement_.volume();
}
const JacobianTransposed &jacobianTransposed ([[maybe_unused]] const LocalCoordinate &local) const
{
return jacobianTransposed_;
}
const JacobianInverseTransposed &jacobianInverseTransposed ([[maybe_unused]] const LocalCoordinate &local) const
{
return jacobianInverseTransposed_;
}
Jacobian jacobian ([[maybe_unused]] const LocalCoordinate &local) const
{
return jacobianTransposed_.transposed();
}
JacobianInverse jacobianInverse ([[maybe_unused]] const LocalCoordinate &local) const
{
return jacobianInverseTransposed_.transposed();
}
friend ReferenceElement referenceElement ( const AffineGeometry &geometry )
{
return geometry.refElement_;
}
private:
ReferenceElement refElement_;
GlobalCoordinate origin_;
JacobianTransposed jacobianTransposed_;
JacobianInverseTransposed jacobianInverseTransposed_;
ctype integrationElement_;
};
} // namespace Dune
#endif // #ifndef DUNE_GEOMETRY_AFFINEGEOMETRY_HH
defaultmatrixhelper.hh
type.hh
A unique label for each type of element that can occur in a grid.
Dune
Definition affinegeometry.hh:22
Dune::ReferenceElement
decltype(referenceElement(std::declval< T >()...)) ReferenceElement
Definition referenceelements.hh:291
Dune::Geo
Definition affinegeometry.hh:28
Dune::Geo::ReferenceElement
This class provides access to geometric and topological properties of a reference element.
Definition referenceelement.hh:52
Dune::Geo::ReferenceElementImplementation
Definition affinegeometry.hh:34
Dune::Geo::ReferenceElements
Class providing access to the singletons of the reference elements.
Definition referenceelements.hh:128
Dune::AffineGeometry::AffineGeometry
AffineGeometry(const ReferenceElement &refElement, const CoordVector &coordVector)
Create affine geometry from reference element and a vector of vertex coordinates.
Definition affinegeometry.hh:116
Dune::AffineGeometry::AffineGeometry
AffineGeometry()=default
Constructs an empty geometry.
Dune::AffineGeometry::AffineGeometry
AffineGeometry(Dune::GeometryType gt, const GlobalCoordinate &origin, const JacobianTransposed &jt)
Create affine geometry from GeometryType, one vertex, and the Jacobian matrix.
Definition affinegeometry.hh:109
Dune::AffineGeometry::LocalCoordinate
FieldVector< ctype, mydimension > LocalCoordinate
Type for local coordinate vector.
Definition affinegeometry.hh:62
Dune::AffineGeometry::type
Dune::GeometryType type() const
Obtain the type of the reference element.
Definition affinegeometry.hh:134
Dune::AffineGeometry::mydimension
static const int mydimension
Dimension of the geometry.
Definition affinegeometry.hh:56
Dune::AffineGeometry::AffineGeometry
AffineGeometry(const ReferenceElement &refElement, const GlobalCoordinate &origin, const JacobianTransposed &jt)
Create affine geometry from reference element, one vertex, and the Jacobian matrix.
Definition affinegeometry.hh:101
Dune::AffineGeometry::Volume
ctype Volume
Type used for volume.
Definition affinegeometry.hh:68
Dune::AffineGeometry::jacobianInverse
JacobianInverse jacobianInverse(const LocalCoordinate &local) const
Obtain the Jacobian's inverse.
Definition affinegeometry.hh:241
Dune::AffineGeometry::referenceElement
friend ReferenceElement referenceElement(const AffineGeometry &geometry)
Definition affinegeometry.hh:246
Dune::AffineGeometry::AffineGeometry
AffineGeometry(Dune::GeometryType gt, const CoordVector &coordVector)
Create affine geometry from GeometryType and a vector of vertex coordinates.
Definition affinegeometry.hh:126
Dune::AffineGeometry::integrationElement
ctype integrationElement(const LocalCoordinate &local) const
Obtain the integration element.
Definition affinegeometry.hh:191
Dune::AffineGeometry::JacobianInverse
FieldMatrix< ctype, mydimension, coorddimension > JacobianInverse
Type for the inverse Jacobian matrix.
Definition affinegeometry.hh:80
Dune::AffineGeometry::Jacobian
FieldMatrix< ctype, coorddimension, mydimension > Jacobian
Type for the Jacobian matrix.
Definition affinegeometry.hh:77
Dune::AffineGeometry::jacobianInverseTransposed
const JacobianInverseTransposed & jacobianInverseTransposed(const LocalCoordinate &local) const
Obtain the transposed of the Jacobian's inverse.
Definition affinegeometry.hh:219
Dune::AffineGeometry::JacobianTransposed
FieldMatrix< ctype, mydimension, coorddimension > JacobianTransposed
Type for the transposed Jacobian matrix.
Definition affinegeometry.hh:71
Dune::AffineGeometry::corner
GlobalCoordinate corner(int i) const
Obtain coordinates of the i-th corner.
Definition affinegeometry.hh:140
Dune::AffineGeometry::corners
int corners() const
Obtain number of corners of the corresponding reference element.
Definition affinegeometry.hh:137
Dune::AffineGeometry::local
LocalCoordinate local(const GlobalCoordinate &global) const
Evaluate the inverse mapping.
Definition affinegeometry.hh:174
Dune::AffineGeometry::JacobianInverseTransposed
FieldMatrix< ctype, coorddimension, mydimension > JacobianInverseTransposed
Type for the transposed inverse Jacobian matrix.
Definition affinegeometry.hh:74
Dune::AffineGeometry::coorddimension
static const int coorddimension
Dimension of the world space.
Definition affinegeometry.hh:59
Dune::AffineGeometry::global
GlobalCoordinate global(const LocalCoordinate &local) const
Evaluate the mapping.
Definition affinegeometry.hh:154
Dune::AffineGeometry::center
GlobalCoordinate center() const
Obtain the centroid of the mapping's image.
Definition affinegeometry.hh:146
Dune::AffineGeometry::jacobian
Jacobian jacobian(const LocalCoordinate &local) const
Obtain the Jacobian.
Definition affinegeometry.hh:230
Dune::AffineGeometry::ctype
ct ctype
Type used for coordinates.
Definition affinegeometry.hh:53
Dune::AffineGeometry::GlobalCoordinate
FieldVector< ctype, coorddimension > GlobalCoordinate
Type for coordinate vector in world space.
Definition affinegeometry.hh:65
Dune::AffineGeometry::affine
bool affine() const
Always true: this is an affine geometry.
Definition affinegeometry.hh:131
Dune::AffineGeometry::jacobianTransposed
const JacobianTransposed & jacobianTransposed(const LocalCoordinate &local) const
Obtain the transposed of the Jacobian.
Definition affinegeometry.hh:208
Dune::AffineGeometry::volume
Volume volume() const
Obtain the volume of the element.
Definition affinegeometry.hh:197
Dune::GeometryType
Unique label for each type of entities that can occur in DUNE grids.
Definition type.hh:114