1#ifndef DUNE_FEM_SPACE_LAGRANGE_LAGRANGEPOINTS_HH 
    2#define DUNE_FEM_SPACE_LAGRANGE_LAGRANGEPOINTS_HH 
    7#include <dune/fem/common/forloop.hh> 
   10#include <dune/geometry/referenceelements.hh> 
   13#include <dune/fem/quadrature/cachingquadrature.hh> 
   14#include <dune/fem/space/mapper/localkey.hh> 
   17#include "genericgeometry.hh" 
   18#include "genericlagrangepoints.hh" 
   35    template< 
unsigned int topologyId, 
unsigned int dim, 
unsigned int polOrder >
 
   37    : 
public GenericLagrangePoint< typename GeometryWrapper< topologyId, dim >::ImplType, polOrder >
 
   40      typedef GenericLagrangePoint< typename GeometryWrapper< topologyId, dim >::ImplType, polOrder > BaseType;
 
   43      static const unsigned int dimension = BaseType::dimension;
 
   45      typedef typename BaseType::DofCoordinateType DofCoordinateType;
 
   47      static const unsigned int polynomialOrder = BaseType::polynomialOrder;
 
   48      static const unsigned int numLagrangePoints = BaseType::numLagrangePoints;
 
   50      template< 
unsigned int codim >
 
   53        static unsigned int maxDofs ()
 
   55          return BaseType::template Codim< codim >::maxDofs();
 
   67      void dofSubEntity ( 
unsigned int &codim, 
unsigned int &subEntity )
 
   69        BaseType::dofSubEntity( codim, subEntity );
 
   72      void dofSubEntity ( 
unsigned int &codim, 
unsigned int &subEntity, 
unsigned int &dofNumber )
 
   74        BaseType::dofSubEntity( codim, subEntity, dofNumber );
 
   78      entityDofNumber ( 
unsigned int codim, 
unsigned int subEntity, 
unsigned int dof )
 
   80        return BaseType::entityDofNumber( codim, subEntity, dof );
 
   84    template< 
unsigned int dim, 
unsigned int maxPolOrder >
 
   85    class LagrangePointInterface
 
   87      typedef LagrangePointInterface< dim, maxPolOrder > ThisType;
 
   89      LagrangePointInterface() = 
default;
 
   92      static const unsigned int dimension = dim;
 
   94      static const unsigned int maxPolynomialOrder = maxPolOrder;
 
   97      virtual ~LagrangePointInterface() = 
default;
 
   99      virtual unsigned int entityDofNumber ( 
unsigned int codim,
 
  100                                             unsigned int subEntity,
 
  101                                             unsigned int dofNumber ) 
const = 0;
 
  111      virtual unsigned int maxDofs ( 
unsigned int codim ) 
const = 0;
 
  113      static int maxOrder ()
 
  115        return maxPolynomialOrder;
 
  125      virtual unsigned int numDofs ( 
unsigned int codim, 
unsigned int subEntity ) 
const = 0;
 
  133      virtual unsigned int numDofs ( 
unsigned int codim ) 
const = 0;
 
  135      virtual int order ()
 const 
  137        return maxPolynomialOrder;
 
  141    template< 
unsigned int topologyId, 
unsigned int dim, 
unsigned int maxPolOrder, 
int polOrder  >
 
  142    class LagrangePointImplementation :
 
  143      public LagrangePointInterface< dim, maxPolOrder >
 
  145      typedef LagrangePoint< topologyId, dim, polOrder > LagrangePointType;
 
  147      LagrangePointImplementation() = 
default;
 
  149      virtual ~LagrangePointImplementation() = 
default;
 
  152      entityDofNumber ( 
unsigned int codim, 
unsigned int subEntity, 
unsigned int dofNumber )
 const 
  154        return LagrangePointType::entityDofNumber( codim, subEntity, dofNumber );
 
  164      virtual unsigned int maxDofs ( 
unsigned int codim )
 const 
  166        return LagrangePointType::maxDofs( codim );
 
  172      numDofs ( 
unsigned int codim, 
unsigned int subEntity )
 const 
  174        return LagrangePointType::numDofs( codim, subEntity );
 
  179      virtual unsigned int numDofs ( 
unsigned int codim )
 const 
  181        return LagrangePointType::numDofs( codim );
 
  184      virtual int order ()
 const { 
return polOrder; }
 
  197    template< 
class FieldImp, 
int dim, 
unsigned int maxPolOrder >
 
  218      typedef LagrangePointInterface< dim, maxPolynomialOrder >
 
  219        LagrangePointInterfaceType;
 
  221      const LagrangePointInterfaceType &lagrangePointImpl ()
 const 
  223        assert( lagrangePointImpl_ ) ;
 
  224        return *lagrangePointImpl_;
 
  231        lagrangePointImpl_( 0 )
 
  234      ~LagrangePointListInterface ()
 
  236        delete lagrangePointImpl_;
 
  239      LagrangePointListInterface ( 
const ThisType& ) = 
delete;
 
  241      void setLagrangePointImpl ( 
const LagrangePointInterfaceType* lpImpl )
 
  243        assert( lagrangePointImpl_ == 0 );
 
  244        lagrangePointImpl_ = lpImpl ;
 
  247      const LocalKey &dofInfo ( 
unsigned int index )
 const 
  249        return dofInfos_[ index ];
 
  252      void dofSubEntity ( 
unsigned int index,
 
  254                          unsigned int &subEntity,
 
  255                          unsigned int &dofNumber )
 const 
  257        const LocalKey &dofInfo = this->dofInfo( index );
 
  258        codim = dofInfo.codim();
 
  259        subEntity = dofInfo.subEntity();
 
  260        dofNumber = dofInfo.index();
 
  263      unsigned int entityDofNumber ( 
unsigned int codim,
 
  264                                     unsigned int subEntity,
 
  265                                     unsigned int dofNumber )
 const 
  267        return lagrangePointImpl().entityDofNumber( codim, subEntity, dofNumber );
 
  272        return lagrangePointImpl().geometryType();
 
  281      unsigned int maxDofs ( 
unsigned int codim )
 const 
  283        return lagrangePointImpl().maxDofs( codim );
 
  286      static int maxOrder ()
 
  288        return LagrangePointInterfaceType::maxOrder();
 
  298      unsigned int numDofs ( 
unsigned int codim, 
unsigned int subEntity )
 const 
  300        return lagrangePointImpl().numDofs( codim, subEntity );
 
  309      unsigned int numDofs ( 
unsigned int codim )
 const 
  311        return lagrangePointImpl().numDofs( codim );
 
  316        return lagrangePointImpl().order();
 
  320      void addDofInfo ( 
const LocalKey &dofInfo )
 
  322        dofInfos_.push_back( dofInfo );
 
  326      std::vector< LocalKey > dofInfos_;
 
  327      const LagrangePointInterfaceType* lagrangePointImpl_;
 
  331    template< 
class FieldImp, 
unsigned int topologyId, 
unsigned int dim, 
unsigned int maxPolOrder >
 
  332    class LagrangePointListImplementation
 
  333    : 
public LagrangePointListInterface< FieldImp, dim, maxPolOrder >
 
  335      typedef LagrangePointListImplementation< FieldImp, topologyId, dim, maxPolOrder > ThisType;
 
  336      typedef LagrangePointListInterface< FieldImp, dim, maxPolOrder > BaseType;
 
  340      typedef FieldImp FieldType;
 
  343      enum { dimension = dim };
 
  346      static const int maxPolynomialOrder = maxPolOrder ;
 
  349      typedef FieldVector< FieldType, dimension > CoordinateType;
 
  353      struct CreateLagrangePoint
 
  355        typedef LagrangePoint< topologyId, dimension, pOrd > LagrangePointType;
 
  356        enum { numLagrangePoints = LagrangePointType::numLagrangePoints };
 
  358        static void apply( ThisType& lp, 
const int order )
 
  361          if( order != pOrd ) return ;
 
  363          for( 
unsigned int i = 0; i < numLagrangePoints; ++i )
 
  365            LagrangePointType pt( i );
 
  367            CoordinateType local;
 
  369            lp.addIntegrationPoint( local );
 
  371            unsigned int codim, subEntity, dofNumber;
 
  372            pt.dofSubEntity( codim, subEntity, dofNumber );
 
  373            lp.addDofInfo( LocalKey( subEntity, codim, dofNumber ) );
 
  376          typedef LagrangePointImplementation< topologyId, dim, maxPolynomialOrder, pOrd >
 
  377              LagrangePointImplementationType;
 
  378          lp.setLagrangePointImpl( 
new LagrangePointImplementationType() );
 
  382      LagrangePointListImplementation ( 
const size_t id )
 
  385        Fem::ForLoop< CreateLagrangePoint, 1, maxPolynomialOrder > :: apply( *
this, maxPolynomialOrder );
 
  388      LagrangePointListImplementation ( 
const GeometryType &geo, 
const int order, 
const size_t id )
 
  391        Fem::ForLoop< CreateLagrangePoint, 1, maxPolynomialOrder > :: apply( *
this, order );
 
  395        assert( order <= maxPolynomialOrder );
 
  399      LagrangePointListImplementation ( 
const ThisType& ) = 
delete;
 
  403    template< 
class FieldImp, 
unsigned int topologyId, 
unsigned int dim, 
unsigned int maxPolOrder >
 
  404    const int LagrangePointListImplementation< FieldImp, topologyId, dim, maxPolOrder >::maxPolynomialOrder;
 
  409    template< 
class Field, 
int dim, 
unsigned int maxPolOrder >
 
  410    struct LagrangePointSetTraits
 
  413      typedef Field FieldType;
 
  416      static const unsigned int maxPolynomialOrder = maxPolOrder;
 
  419      static const int dimension = dim;
 
  422      static const int codimension = 0;
 
  425      template< 
typename ct, 
int quaddim >
 
  428        typedef LagrangePointListImplementation< ct, 0, 0, maxPolynomialOrder >
 
  431        typedef LagrangePointListImplementation< ct, 0, 1, maxPolynomialOrder >
 
  434        typedef LagrangePointListImplementation< ct, 0, dimension, maxPolynomialOrder >
 
  435          SimplexQuadratureType;
 
  437        typedef LagrangePointListImplementation< ct, (1 << dimension)-1, dimension, maxPolynomialOrder >
 
  440        typedef LagrangePointListImplementation< ct, (1 << (dimension-1)), dimension, maxPolynomialOrder >
 
  443        typedef LagrangePointListImplementation< ct, (1 << (dimension-1))-1, dimension, maxPolynomialOrder >
 
  444          PyramidQuadratureType;
 
  449        typedef int QuadratureKeyType ;
 
  461    template< 
class Gr
idPart, 
unsigned int maxPolOrder >
 
  462    class LagrangePointSet;
 
  469    template< 
class Gr
idPart, 
int codim, 
unsigned int polOrder >
 
  470    class SubEntityLagrangePointIterator
 
  472      typedef SubEntityLagrangePointIterator< GridPart, codim, polOrder > ThisType;
 
  475      typedef GridPart GridPartType;
 
  477      typedef typename GridPartType::ctype FieldType;
 
  479      static const int dimension = GridPartType::dimension;
 
  480      static const int codimension = codim;
 
  482      static const unsigned int polynomialOrder = polOrder;
 
  486      typedef LagrangePointSet< GridPartType, polynomialOrder > LagrangePointSetType;
 
  491      typedef std::decay_t< decltype( ReferenceElementsType::general( std::declval< const Dune::GeometryType & >() ) ) > ReferenceElementType;
 
  493      SubEntityLagrangePointIterator ( 
const LagrangePointSetType &lagrangePointSet,
 
  494                                       const unsigned int subEntity,
 
  495                                       const bool beginIterator )
 
  496      : lagrangePointSet_( &lagrangePointSet ),
 
  497        refElement_( &ReferenceElementsType::general( lagrangePointSet_->geometryType() ) ),
 
  498        subEntity_( subEntity ),
 
  499        codim_( beginIterator ? codimension : dimension+1 ),
 
  502        subSubEntity_( subEntity_ ),
 
  504        numDofs_( lagrangePointSet_->numDofs( codimension, subSubEntity_ ) )
 
  511      SubEntityLagrangePointIterator ()
 
  512      : lagrangePointSet_( 0 ),
 
  514        codim_( dimension+1 ),
 
  520      unsigned int operator* ()
 const 
  522        assert( lagrangePointSet_ );
 
  523        assert( codim_ <= dimension );
 
  525        return lagrangePointSet_->entityDofNumber( codim_, subSubEntity_, dofNumber_ );
 
  528      ThisType &operator++ ()
 
  530        assert( codim_ <= dimension );
 
  536      bool operator== ( 
const ThisType& other )
 const 
  538        if( (other.codim_ != codim_)
 
  539            || (other.subIndex_ != subIndex_)
 
  540            || (other.dofNumber_ != dofNumber_) )
 
  543        return (other.lagrangePointSet_ == lagrangePointSet_)
 
  544               && (other.subEntity_ == subEntity_);
 
  547      bool operator!= ( 
const ThisType& other )
 const 
  549        return !(*
this == other);
 
  552      static ThisType begin ( 
const LagrangePointSetType &lagrangePointSet,
 
  553                              unsigned int subEntity )
 
  555        return ThisType( lagrangePointSet, subEntity, 
true );
 
  558      static ThisType end ( 
const LagrangePointSetType &lagrangePointSet,
 
  559                            unsigned int subEntity )
 
  561        return ThisType( lagrangePointSet, subEntity, 
false );
 
  567        assert( lagrangePointSet_ );
 
  568        assert( refElement_ );
 
  570        while( dofNumber_ >= numDofs_ )
 
  572          const ReferenceElementType &refElement = *refElement_;
 
  576          while( subIndex_ >= numSubIndices_ )
 
  579            if( ++codim_ > dimension )
 
  581            numSubIndices_ = refElement.size( subEntity_, codimension, codim_ );
 
  583          subSubEntity_ = refElement.subEntity( subEntity_, codimension, subIndex_, codim_ );
 
  584          numDofs_ = lagrangePointSet_->numDofs( codim_, subSubEntity_ );
 
  588      const LagrangePointSetType *lagrangePointSet_;
 
  589      const ReferenceElementType *refElement_;
 
  590      unsigned int subEntity_;
 
  593      unsigned int subIndex_, numSubIndices_;
 
  594      unsigned int subSubEntity_;
 
  595      unsigned int dofNumber_, numDofs_;
 
  603    template< 
class Gr
idPart, 
unsigned int polOrder >
 
  604    class SubEntityLagrangePointIterator< GridPart, 0, polOrder >
 
  606      typedef SubEntityLagrangePointIterator< GridPart, 0, polOrder > ThisType;
 
  609      typedef GridPart GridPartType;
 
  611      typedef typename GridPartType::ctype FieldType;
 
  613      static const int dimension = GridPartType::dimension;
 
  614      static const int codimension = 0;
 
  616      static const unsigned int polynomialOrder = polOrder;
 
  618      typedef FieldVector< FieldType, dimension > pointType;
 
  620      typedef LagrangePointSet< GridPartType, polynomialOrder > LagrangePointSetType;
 
  623      SubEntityLagrangePointIterator ( 
const LagrangePointSetType &lagrangePointSet,
 
  624                                       const unsigned int subEntity,
 
  625                                       const bool beginIterator )
 
  626      : lagrangePointSet_( &lagrangePointSet ),
 
  627        numDofs_( lagrangePointSet_->
size() ),
 
  628        index_( beginIterator ? 0 : numDofs_ )
 
  630        assert( subEntity == 0 );
 
  634      SubEntityLagrangePointIterator ()
 
  635      : lagrangePointSet_( 0 ),
 
  640      unsigned int operator* ()
 const 
  642        assert( lagrangePointSet_ );
 
  643        assert( index_ < numDofs_ );
 
  647      ThisType& operator++ ()
 
  649        assert( index_ < numDofs_ );
 
  654      bool operator== ( 
const ThisType& other )
 const 
  656        return (other.index_ == index_)
 
  657               && (other.lagrangePointSet_ == lagrangePointSet_);
 
  660      bool operator!= ( 
const ThisType& other )
 const 
  662        return !(*
this == other);
 
  666      static ThisType begin ( 
const LagrangePointSetType &lagrangePointSet,
 
  667                              unsigned int subEntity )
 
  669        return ThisType( lagrangePointSet, subEntity, 
true );
 
  672      static ThisType end ( 
const LagrangePointSetType &lagrangePointSet,
 
  673                            unsigned int subEntity )
 
  675        return ThisType( lagrangePointSet, subEntity, 
false );
 
  679      const LagrangePointSetType *lagrangePointSet_;
 
  680      unsigned int numDofs_, index_;
 
  685    template< 
class Gr
idPart, 
unsigned int maxPolOrder >
 
  686    class LagrangePointSet
 
  687    : 
public CachingPointList< GridPart, 0, LagrangePointSetTraits< typename GridPart::ctype, GridPart::dimension, maxPolOrder > >
 
  689      typedef LagrangePointSet< GridPart, maxPolOrder > ThisType;
 
  690      typedef CachingPointList< GridPart, 0, LagrangePointSetTraits< typename GridPart::ctype, GridPart::dimension, maxPolOrder > > BaseType;
 
  693      typedef LagrangePointSetTraits< typename GridPart::ctype, GridPart::dimension, maxPolOrder > Traits;
 
  695      typedef GridPart GridPartType;
 
  697      typedef typename GridPartType::ctype FieldType;
 
  699      static const int dimension = BaseType::dimension;
 
  701      enum { maxPolynomialOrder = Traits::maxPolynomialOrder };
 
  703      typedef typename BaseType::CoordinateType CoordinateType;
 
  704      typedef typename Traits::CoordinateType PointType;
 
  706      template< 
unsigned int codim >
 
  710        typedef SubEntityLagrangePointIterator< GridPartType, codim, maxPolynomialOrder >
 
  711          SubEntityIteratorType;
 
  715      typedef typename BaseType::IntegrationPointListType::IntegrationPointListType
 
  716        LagrangePointListType;
 
  720      LagrangePointSet ( 
const GeometryType &geometry, 
const int polynomialOrder )
 
  721      : BaseType( geometry, polynomialOrder ), lagrangePointList_( this->quadImp().ipList() )
 
  725      LagrangePointSet ( 
const ThisType &other )
 
  726      : BaseType( other ), lagrangePointList_( this->quadImp().ipList() )
 
  729      ThisType& operator=( 
const ThisType& ) = 
delete;
 
  731      const LocalKey &localKey ( 
unsigned int index )
 const 
  733        return lagrangePointList_.dofInfo( index );
 
  736      void dofSubEntity ( 
unsigned int index, 
unsigned int &codim,
 
  737                          unsigned int &subEntity )
 const 
  739        unsigned int dofNumber;
 
  740        lagrangePointList_.dofSubEntity( index, codim, subEntity, dofNumber );
 
  743      void dofSubEntity ( 
unsigned int index, 
unsigned int &codim,
 
  744                          unsigned int &subEntity, 
unsigned int &dofNumber )
 const 
  746        lagrangePointList_.dofSubEntity( index, codim, subEntity, dofNumber );
 
  749      unsigned int entityDofNumber ( 
unsigned int codim, 
unsigned int subEntity,
 
  750                                     unsigned int dofNumber )
 const 
  752        return lagrangePointList_.entityDofNumber( codim, subEntity, dofNumber );
 
  755      unsigned int maxDofs ( 
unsigned int codim )
 const 
  757        return lagrangePointList_.maxDofs( codim );
 
  760      unsigned int numDofs ( 
unsigned int codim, 
unsigned int subEntity )
 const 
  762        return lagrangePointList_.numDofs( codim, subEntity );
 
  765      unsigned int numDofs ( 
unsigned int codim )
 const 
  767        return lagrangePointList_.numDofs( codim );
 
  771      std::size_t 
size ()
 const 
  776      template< 
unsigned int codim >
 
  777      typename Codim< codim >::SubEntityIteratorType
 
  778        beginSubEntity ( 
unsigned int subEntity )
 const 
  780        return Codim< codim >::SubEntityIteratorType::begin( *
this, subEntity );
 
  783      template< 
unsigned int codim >
 
  784      typename Codim< codim >::SubEntityIteratorType
 
  785        endSubEntity ( 
unsigned int subEntity )
 const 
  787        return Codim< codim >::SubEntityIteratorType::end( *
this, subEntity );
 
  791      const LagrangePointListType &lagrangePointList_;
 
Generic implementation of an IntegrationPointList.
Definition: quadratureimp.hh:33
 
size_t id() const
obtain the identifier of the integration point list
Definition: quadratureimp.hh:122
 
actual interface class for integration point lists
Definition: quadrature.hh:158
 
IntegrationPointListType::CoordinateType CoordinateType
type of coordinate
Definition: quadrature.hh:180
 
Set of lagrange points.
Definition: lagrangepoints.hh:200
 
unsigned int maxDofs(unsigned int codim) const
obtain the maximal number of DoFs in one entity of a codimension
Definition: lagrangepoints.hh:281
 
FieldVector< FieldType, dimension > CoordinateType
type of points
Definition: lagrangepoints.hh:215
 
unsigned int numDofs(unsigned int codim, unsigned int subEntity) const
obtain the number of DoFs on one entity
Definition: lagrangepoints.hh:298
 
static const int dimension
dimension of points
Definition: lagrangepoints.hh:209
 
GeometryType geometryType() const
obtain GeometryType for this integration point list
Definition: lagrangepoints.hh:270
 
FieldImp FieldType
field type of points
Definition: lagrangepoints.hh:206
 
static const unsigned int maxPolynomialOrder
polynomial order of corresponding base functions
Definition: lagrangepoints.hh:212
 
int order() const
obtain order of the integration point list
Definition: lagrangepoints.hh:314
 
unsigned int numDofs(unsigned int codim) const
obtain the total number of DoFs in a codimension
Definition: lagrangepoints.hh:309
 
A single lagrange point.
Definition: lagrangepoints.hh:38
 
vector space out of a tensor product of fields.
Definition: fvector.hh:97
 
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:114
 
GeometryType geometryType(const Dune::GeometryType &t)
mapping from GeometryType to VTKGeometryType
Definition: common.hh:151
 
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:132
 
constexpr EnableIfInterOperable< T1, T2, bool >::type operator==(const ForwardIteratorFacade< T1, V1, R1, D > &lhs, const ForwardIteratorFacade< T2, V2, R2, D > &rhs)
Checks for equality.
Definition: iteratorfacades.hh:238
 
constexpr EnableIfInterOperable< T1, T2, bool >::type operator!=(const ForwardIteratorFacade< T1, V1, R1, D > &lhs, const ForwardIteratorFacade< T2, V2, R2, D > &rhs)
Checks for inequality.
Definition: iteratorfacades.hh:260
 
Dune namespace.
Definition: alignedallocator.hh:13
 
constexpr std::integral_constant< std::size_t, sizeof...(II)> size(std::integer_sequence< T, II... >)
Return the size of the sequence.
Definition: integersequence.hh:75
 
default defines for used point lists
Definition: lagrangepoints.hh:427
 
LagrangePointListInterface< ct, quaddim, maxPolynomialOrder > IntegrationPointListType
type of integration point list implemementation
Definition: lagrangepoints.hh:447
 
Class providing access to the singletons of the reference elements.
Definition: referenceelements.hh:128