Loading...
Searching...
No Matches
referenceelements.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_REFERENCEELEMENTS_HH
#define DUNE_GEOMETRY_REFERENCEELEMENTS_HH
#include <cassert>
#include <algorithm>
#include <limits>
#include <tuple>
#include <utility>
#include <vector>
#include <array>
#include <dune/common/typetraits.hh>
#include <dune/common/std/type_traits.hh>
#include <dune/common/visibility.hh>
#include <dune/geometry/dimension.hh>
#include <dune/geometry/type.hh>
#include <dune/geometry/referenceelement.hh>
#include <dune/geometry/referenceelementimplementation.hh>
namespace Dune
{
namespace Geo
{
#ifndef DOXYGEN
namespace Impl
{
// ReferenceElementContainer
// -------------------------
template< class ctype, int dim >
class ReferenceElementContainer
{
static const unsigned int numTopologies = dim >= 0 ? (1u << dim) : 0;
using Implementation = ReferenceElementImplementation< ctype, dim >;
public:
using ReferenceElement = Dune::Geo::ReferenceElement< Implementation >;
using value_type = ReferenceElement;
using const_iterator = const value_type*;
ReferenceElementContainer ()
{
for( unsigned int topologyId = 0; topologyId < numTopologies; ++topologyId )
{
implementations_[ topologyId ].initialize( topologyId );
reference_elements_[ topologyId ].setImplementation( implementations_[ topologyId ] );
}
}
const ReferenceElement& operator() ( const GeometryType &type ) const
{
assert( type.dim() == dim );
return reference_elements_[ type.id() ];
}
const ReferenceElement& simplex () const
{
return reference_elements_[ Dune::GeometryTypes::simplex(dim).id() ];
}
const ReferenceElement& cube () const
{
return reference_elements_[ Dune::GeometryTypes::cube(dim).id() ];
}
const ReferenceElement& pyramid () const
{
return reference_elements_[ Dune::GeometryTypes::pyramid.id() ];
}
const ReferenceElement& prism () const
{
return reference_elements_[ Dune::GeometryTypes::prism.id() ];
}
const_iterator begin () const
{
return reference_elements_.data();
}
const_iterator end () const
{
return reference_elements_.data() + numTopologies;
}
private:
std::array<Implementation,numTopologies> implementations_;
std::array<ReferenceElement,numTopologies> reference_elements_;
};
} // namespace Impl
#endif // DOXYGEN
// ReferenceElements
// ------------------------
template< class ctype_, int dim >
struct ReferenceElements
{
using ctype = ctype_;
using CoordinateField = ctype;
static constexpr int dimension = dim;
private:
using Container = Impl::ReferenceElementContainer< ctype, dim >;
public:
using ReferenceElement = typename Container::ReferenceElement;
using Iterator = typename Container::const_iterator;
using iterator = Iterator;
static const ReferenceElement&
general ( const GeometryType& type )
{
return container() ( type );
}
static const ReferenceElement& simplex ()
{
return container().simplex();
}
static const ReferenceElement& cube ()
{
return container().cube();
}
static Iterator begin ()
{
return container().begin();
}
static Iterator end ()
{
return container().end();
}
private:
DUNE_EXPORT static const Container& container ()
{
static Container container;
return container;
}
};
} // namespace Geo
using Geo::ReferenceElements;
#ifdef DOXYGEN
template<typename... T>
unspecified-value-type referenceElement(T&&... t);
#endif
template<typename T, int dim>
auto referenceElement(const Dune::GeometryType& gt, Dune::Dim<dim> = {})
{
return ReferenceElements<T,dim>::general(gt);
}
template<typename T, int dim, std::enable_if_t<IsNumber<std::decay_t<T>>::value, int> = 0>
auto referenceElement(const T&, const Dune::GeometryType& gt, Dune::Dim<dim>)
{
return ReferenceElements<T,dim>::general(gt);
}
template<typename... T>
using ReferenceElement = decltype(referenceElement(std::declval<T>()...));
} // namespace Dune
#endif // #ifndef DUNE_GEOMETRY_REFERENCEELEMENTS_HH
dimension.hh
referenceelement.hh
referenceelementimplementation.hh
type.hh
A unique label for each type of element that can occur in a grid.
Dune::GeometryTypes::cube
constexpr GeometryType cube(unsigned int dim)
Returns a GeometryType representing a hypercube of dimension dim.
Definition type.hh:462
Dune::GeometryTypes::prism
constexpr GeometryType prism
GeometryType representing a 3D prism.
Definition type.hh:528
Dune::GeometryTypes::pyramid
constexpr GeometryType pyramid
GeometryType representing a 3D pyramid.
Definition type.hh:522
Dune::GeometryTypes::simplex
constexpr GeometryType simplex(unsigned int dim)
Returns a GeometryType representing a simplex of dimension dim.
Definition type.hh:453
Dune::referenceElement
unspecified value type referenceElement(T &&... t)
Returns a reference element for the objects t....
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::ReferenceElements
Class providing access to the singletons of the reference elements.
Definition referenceelements.hh:128
Dune::Geo::ReferenceElements::begin
static Iterator begin()
Definition referenceelements.hh:173
Dune::Geo::ReferenceElements< ctype, mydimension >::iterator
Iterator iterator
Definition referenceelements.hh:152
Dune::Geo::ReferenceElements< ctype, mydimension >::ReferenceElement
typename Container::ReferenceElement ReferenceElement
Definition referenceelements.hh:146
Dune::Geo::ReferenceElements::cube
static const ReferenceElement & cube()
get hypercube reference elements
Definition referenceelements.hh:168
Dune::Geo::ReferenceElements::end
static Iterator end()
Definition referenceelements.hh:178
Dune::Geo::ReferenceElements< ctype, mydimension >::ctype
ctype ctype
Definition referenceelements.hh:131
Dune::Geo::ReferenceElements::general
static const ReferenceElement & general(const GeometryType &type)
get general reference elements
Definition referenceelements.hh:156
Dune::Geo::ReferenceElements::simplex
static const ReferenceElement & simplex()
get simplex reference elements
Definition referenceelements.hh:162
Dune::Geo::ReferenceElements< ctype, mydimension >::Iterator
typename Container::const_iterator Iterator
Definition referenceelements.hh:149
Dune::Geo::ReferenceElements< ctype, mydimension >::dimension
static constexpr int dimension
Definition referenceelements.hh:137
Dune::Geo::ReferenceElements< ctype, mydimension >::CoordinateField
ctype CoordinateField
Definition referenceelements.hh:134
Dune::Dim
Static tag representing a dimension.
Definition dimension.hh:16
Dune::GeometryType
Unique label for each type of entities that can occur in DUNE grids.
Definition type.hh:114
Dune::GeometryType::id
constexpr unsigned int id() const
Return the topology id of the type.
Definition type.hh:365
Dune::ReferenceElements::general
static const ReferenceElement & general(const GeometryType &type)
get general reference elements
Definition referenceelements.hh:156