Loading...
Searching...
No Matches
referenceelement.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_REFERENCEELEMENT_HH
#define DUNE_GEOMETRY_REFERENCEELEMENT_HH
#include <dune/geometry/type.hh>
namespace Dune {
namespace Geo {
namespace Impl {
// forward declaration for friend declaration
template<typename ctype, int dim>
class ReferenceElementContainer;
}
// forward declaration for constructing default reference element type
template<typename ctype, int dim>
class ReferenceElementImplementation;
// forward declaration for backwards compatibility conversion
template<typename ctype, int dim>
struct ReferenceElements;
// ReferenceElement
// ----------------
template<typename Implementation>
class ReferenceElement
{
public:
#ifndef DOXYGEN
template<int codim>
using Codim = typename Implementation::template Codim<codim>;
#else
template< int codim >
struct Codim
{
using Geometry = implementation-defined;
};
#endif // DOXYGEN
using ctype = typename Implementation::ctype;
using CoordinateField = ctype;
using Coordinate = typename Implementation::Coordinate;
typedef ctype Volume;
static constexpr int dimension = Implementation::dimension;
int size(int c) const
{
return _impl->size(c);
}
int size(int i, int c, int cc) const
{
return _impl->size(i,c,cc);
}
int subEntity(int i, int c, int ii, int cc) const
{
return _impl->subEntity(i,c,ii,cc);
}
auto subEntities ( int i, int c, int cc ) const
{
return _impl->subEntities(i,c,cc);
}
GeometryType type(int i, int c) const
{
return _impl->type(i,c);
}
GeometryType type() const
{
return _impl->type();
}
Coordinate position(int i, int c) const
{
return _impl->position(i,c);
}
bool checkInside(const Coordinate& local) const
{
return _impl->checkInside(local);
}
template<int codim>
typename Codim<codim>::Geometry geometry(int i) const
{
return _impl->template geometry<codim>(i);
}
CoordinateField volume() const
{
return _impl->volume();
}
Coordinate integrationOuterNormal(int face) const
{
return _impl->integrationOuterNormal(face);
}
ReferenceElement()
: _impl(nullptr)
{}
const Implementation& impl() const
{
return *_impl;
}
bool operator==(const ReferenceElement& r) const
{
return _impl == r._impl;
}
bool operator!=(const ReferenceElement& r) const
{
return not (*this == r);
}
friend std::size_t hash_value(const ReferenceElement& r)
{
return reinterpret_cast<std::size_t>(r._impl);
}
private:
// The implementation must be a friend to construct a wrapper around itself.
friend Implementation;
// The reference container is a friend to be able to call setImplementation.
friend class Impl::ReferenceElementContainer<ctype,dimension>;
// Constructor for wrapping an implementation reference (required internally by the default implementation)
ReferenceElement(const Implementation& impl)
: _impl(&impl)
{}
void setImplementation(const Implementation& impl)
{
_impl = &impl;
}
const Implementation* _impl;
};
}
}
#endif // DUNE_GEOMETRY_REFERENCEELEMENT_HH
type.hh
A unique label for each type of element that can occur in a grid.
Dune
Definition affinegeometry.hh:22
Dune::Geo
Definition affinegeometry.hh:28
Dune::Geo::ReferenceElement::volume
CoordinateField volume() const
obtain the volume of the reference element
Definition referenceelement.hh:228
Dune::Geo::ReferenceElement::type
GeometryType type(int i, int c) const
obtain the type of subentity (i,c)
Definition referenceelement.hh:167
Dune::Geo::ReferenceElement::ReferenceElement
ReferenceElement()
Constructs an empty reference element.
Definition referenceelement.hh:254
Dune::Geo::ReferenceElement::operator!=
bool operator!=(const ReferenceElement &r) const
Compares for inequality with another reference element.
Definition referenceelement.hh:275
Dune::Geo::ReferenceElement::position
Coordinate position(int i, int c) const
position of the barycenter of entity (i,c)
Definition referenceelement.hh:190
Dune::Geo::ReferenceElement< Geo::ReferenceElementImplementation< ctype, mydimension > >::Coordinate
typename Geo::ReferenceElementImplementation< ctype, mydimension >::Coordinate Coordinate
Definition referenceelement.hh:81
Dune::Geo::ReferenceElement::geometry
Codim< codim >::Geometry geometry(int i) const
obtain the embedding of subentity (i,codim) into the reference element
Definition referenceelement.hh:221
Dune::Geo::ReferenceElement< Geo::ReferenceElementImplementation< ctype, mydimension > >::dimension
static constexpr int dimension
Definition referenceelement.hh:87
Dune::Geo::ReferenceElement::size
int size(int i, int c, int cc) const
number of subentities of codimension cc of subentity (i,c)
Definition referenceelement.hh:111
Dune::Geo::ReferenceElement::subEntity
int subEntity(int i, int c, int ii, int cc) const
obtain number of ii-th subentity with codim cc of (i,c)
Definition referenceelement.hh:130
Dune::Geo::ReferenceElement< Geo::ReferenceElementImplementation< ctype, mydimension > >::ctype
typename Geo::ReferenceElementImplementation< ctype, mydimension >::ctype ctype
Definition referenceelement.hh:75
Dune::Geo::ReferenceElement::size
int size(int c) const
number of subentities of codimension c
Definition referenceelement.hh:94
Dune::Geo::ReferenceElement::type
GeometryType type() const
obtain the type of this reference element
Definition referenceelement.hh:175
Dune::Geo::ReferenceElement::impl
const Implementation & impl() const
Returns a reference to the internal implementation object.
Definition referenceelement.hh:263
Dune::Geo::ReferenceElement::checkInside
bool checkInside(const Coordinate &local) const
check if a coordinate is in the reference element
Definition referenceelement.hh:203
Dune::Geo::ReferenceElement::integrationOuterNormal
Coordinate integrationOuterNormal(int face) const
obtain the integration outer normal of the reference element
Definition referenceelement.hh:241
Dune::Geo::ReferenceElement< Geo::ReferenceElementImplementation< ctype, mydimension > >::CoordinateField
ctype CoordinateField
Definition referenceelement.hh:78
Dune::Geo::ReferenceElement::operator==
bool operator==(const ReferenceElement &r) const
Compares for equality with another reference element.
Definition referenceelement.hh:269
Dune::Geo::ReferenceElement::hash_value
friend std::size_t hash_value(const ReferenceElement &r)
Yields a hash value suitable for storing the reference element a in hash table.
Definition referenceelement.hh:281
Dune::Geo::ReferenceElement::subEntities
auto subEntities(int i, int c, int cc) const
Obtain the range of numbers of subentities with codim cc of (i,c).
Definition referenceelement.hh:153
Dune::Geo::ReferenceElement< Geo::ReferenceElementImplementation< ctype, mydimension > >::Volume
ctype Volume
Definition referenceelement.hh:84
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::Geo::ReferenceElement::Codim
Collection of types depending on the codimension.
Definition referenceelement.hh:67
Dune::Geo::ReferenceElement::Codim::Geometry
implementation-defined Geometry
type of geometry embedding a subentity into the reference element
Definition referenceelement.hh:69
Dune::GeometryType
Unique label for each type of entities that can occur in DUNE grids.
Definition type.hh:114