dune-localfunctions 2.10
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
Dune::LocalFiniteElementVariant< Implementations > Class Template Reference

Type erasure class for wrapping LocalFiniteElement classes. More...

#include <dune/localfunctions/common/localfiniteelementvariant.hh>

Inheritance diagram for Dune::LocalFiniteElementVariant< Implementations >:
Inheritance graph

Public Types

using Traits = typename Dune::LocalFiniteElementTraits< LocalBasis, LocalCoefficients, LocalInterpolation >
 Export LocalFiniteElementTraits.
 

Public Member Functions

 LocalFiniteElementVariant ()=default
 Construct empty LocalFiniteElementVariant.
 
 LocalFiniteElementVariant (const std::monostate &monostate)
 Construct empty LocalFiniteElementVariant.
 
template<class Implementation , std::enable_if_t< std::disjunction< std::is_same< std::decay_t< Implementation >, Implementations >... >::value, int > = 0>
 LocalFiniteElementVariant (Implementation &&impl)
 Construct LocalFiniteElementVariant.
 
 LocalFiniteElementVariant (const LocalFiniteElementVariant &other)
 Copy constructor.
 
 LocalFiniteElementVariant (LocalFiniteElementVariant &&other)
 Move constructor.
 
LocalFiniteElementVariantoperator= (const LocalFiniteElementVariant &other)
 Copy assignment.
 
LocalFiniteElementVariantoperator= (LocalFiniteElementVariant &&other)
 Move assignment.
 
template<class Implementation , std::enable_if_t< std::disjunction< std::is_same< std::decay_t< Implementation >, Implementations >... >::value, int > = 0>
LocalFiniteElementVariantoperator= (Implementation &&impl)
 Assignment from implementation.
 
const Traits::LocalBasisType & localBasis () const
 Provide access to LocalBasis implementation of this LocalFiniteElement.
 
const Traits::LocalCoefficientsType & localCoefficients () const
 Provide access to LocalCoefficients implementation of this LocalFiniteElement.
 
const Traits::LocalInterpolationType & localInterpolation () const
 Provide access to LocalInterpolation implementation of this LocalFiniteElement.
 
unsigned int size () const
 Number of shape functions.
 
constexpr GeometryType type () const
 Number of shape functions.
 
const auto & variant () const
 Provide access to underlying std::variant.
 
 operator bool () const
 Check if LocalFiniteElementVariant stores an implementation.
 

Detailed Description

template<class... Implementations>
class Dune::LocalFiniteElementVariant< Implementations >

Type erasure class for wrapping LocalFiniteElement classes.

This is a type erasure wrapper class for types implementing the LocalFiniteElement interface. The types of the LocalFiniteElement implementations that this class can hold have to be provided as template parameter.

The implementation is based on std::variant. Notice that this prepends std::monostate to the Implementations list for the internally stored std::variant such that LocalFiniteElementVariant can be empty and is default-constructible. As a consequence providing std::monostate manually to LocalFiniteElementVariant is neither necessary nor allowed. Access to the stored implementation is internally implemented using std::visit(). To avoid multiple trivial std::visit() calls, the results of size(), order(), and type() are cached on creation and assignment.

In empty state accessing any method beyond operator bool(), variant(), or assignment leads to undefined behavior.

The LocalBasisTraits are extracted from the implementation provided as first template parameter. The other implementations are required to be compatible with this one.

Template Parameters
ImplementationsList of supported LocalFiniteElement implementations

Member Typedef Documentation

◆ Traits

template<class... Implementations>
using Dune::LocalFiniteElementVariant< Implementations >::Traits = typename Dune::LocalFiniteElementTraits<LocalBasis, LocalCoefficients, LocalInterpolation>

Constructor & Destructor Documentation

◆ LocalFiniteElementVariant() [1/5]

template<class... Implementations>
Dune::LocalFiniteElementVariant< Implementations >::LocalFiniteElementVariant ( )
default

Construct empty LocalFiniteElementVariant.

◆ LocalFiniteElementVariant() [2/5]

template<class... Implementations>
Dune::LocalFiniteElementVariant< Implementations >::LocalFiniteElementVariant ( const std::monostate &  monostate)
inline

Construct empty LocalFiniteElementVariant.

◆ LocalFiniteElementVariant() [3/5]

template<class... Implementations>
template<class Implementation , std::enable_if_t< std::disjunction< std::is_same< std::decay_t< Implementation >, Implementations >... >::value, int > = 0>
Dune::LocalFiniteElementVariant< Implementations >::LocalFiniteElementVariant ( Implementation &&  impl)
inline

Construct LocalFiniteElementVariant.

The created LocalFiniteElementVariant will store a copy of the provided implementation.

◆ LocalFiniteElementVariant() [4/5]

template<class... Implementations>
Dune::LocalFiniteElementVariant< Implementations >::LocalFiniteElementVariant ( const LocalFiniteElementVariant< Implementations > &  other)
inline

Copy constructor.

◆ LocalFiniteElementVariant() [5/5]

template<class... Implementations>
Dune::LocalFiniteElementVariant< Implementations >::LocalFiniteElementVariant ( LocalFiniteElementVariant< Implementations > &&  other)
inline

Move constructor.

Member Function Documentation

◆ localBasis()

template<class... Implementations>
const Traits::LocalBasisType & Dune::LocalFiniteElementVariant< Implementations >::localBasis ( ) const
inline

Provide access to LocalBasis implementation of this LocalFiniteElement.

◆ localCoefficients()

template<class... Implementations>
const Traits::LocalCoefficientsType & Dune::LocalFiniteElementVariant< Implementations >::localCoefficients ( ) const
inline

Provide access to LocalCoefficients implementation of this LocalFiniteElement.

◆ localInterpolation()

template<class... Implementations>
const Traits::LocalInterpolationType & Dune::LocalFiniteElementVariant< Implementations >::localInterpolation ( ) const
inline

Provide access to LocalInterpolation implementation of this LocalFiniteElement.

◆ operator bool()

template<class... Implementations>
Dune::LocalFiniteElementVariant< Implementations >::operator bool ( ) const
inline

Check if LocalFiniteElementVariant stores an implementation.

This returns true iff variant() does not store a monostate.

◆ operator=() [1/3]

template<class... Implementations>
LocalFiniteElementVariant & Dune::LocalFiniteElementVariant< Implementations >::operator= ( const LocalFiniteElementVariant< Implementations > &  other)
inline

Copy assignment.

◆ operator=() [2/3]

template<class... Implementations>
template<class Implementation , std::enable_if_t< std::disjunction< std::is_same< std::decay_t< Implementation >, Implementations >... >::value, int > = 0>
LocalFiniteElementVariant & Dune::LocalFiniteElementVariant< Implementations >::operator= ( Implementation &&  impl)
inline

Assignment from implementation.

◆ operator=() [3/3]

template<class... Implementations>
LocalFiniteElementVariant & Dune::LocalFiniteElementVariant< Implementations >::operator= ( LocalFiniteElementVariant< Implementations > &&  other)
inline

Move assignment.

◆ size()

template<class... Implementations>
unsigned int Dune::LocalFiniteElementVariant< Implementations >::size ( ) const
inline

Number of shape functions.

◆ type()

template<class... Implementations>
constexpr GeometryType Dune::LocalFiniteElementVariant< Implementations >::type ( ) const
inlineconstexpr

Number of shape functions.

◆ variant()

template<class... Implementations>
const auto & Dune::LocalFiniteElementVariant< Implementations >::variant ( ) const
inline

Provide access to underlying std::variant.

This allows to use std::visit on a higher level which allows to avoid the indirection of the std::variant - polymorphism inside the visitor code. Notice that the provided std::variant contains std::monostate in its type list. Hence any visitor used to access the variant has to be std::monostate-aware.


The documentation for this class was generated from the following file: