1#ifndef DUNE_FEM_SPACE_MAPPER_CODIMENSIONMAPPER_HH 
    2#define DUNE_FEM_SPACE_MAPPER_CODIMENSIONMAPPER_HH 
   11#include <dune/geometry/referenceelements.hh> 
   14#include <dune/fem/gridpart/common/indexset.hh> 
   15#include <dune/fem/misc/functor.hh> 
   16#include <dune/fem/space/common/allgeomtypes.hh> 
   17#include <dune/fem/space/mapper/dofmapper.hh> 
   28    template< 
class Gr
idPart, 
int codim >
 
   29    class CodimensionMapper;
 
   35    namespace __CodimensionMapper
 
   41      template< 
class Gr
idPart, 
int codim >
 
   44        typedef CodimensionMapper< GridPart, codim > DofMapperType;
 
   46        static const int codimension = codim;
 
   48        typedef GridPart GridPartType;
 
   51        typedef typename GridPartType::template Codim< 0 >::EntityType ElementType;
 
   53        typedef std::size_t SizeType;
 
   54        typedef SizeType GlobalKeyType;
 
   66        typedef Base< T > BaseType;
 
   69        typedef typename BaseType::Traits Traits;
 
   71        static const int codimension = Traits::codimension;
 
   73        typedef typename Traits::GridPartType GridPartType;
 
   74        typedef typename Traits::IndexSetType IndexSetType;
 
   76        typedef typename BaseType::ElementType ElementType;
 
   77        typedef typename BaseType::SizeType SizeType;
 
   78        typedef typename Traits::GlobalKeyType GlobalKeyType;
 
   80        explicit DofMapper ( 
const GridPartType &gridPart )
 
   81          : DofMapper( gridPart.indexSet() )
 
   84        explicit DofMapper ( 
const IndexSetType &indexSet )
 
   85          : indexSet_( indexSet ),
 
   89          AllGeomTypes< IndexSetType, typename GridPartType::GridType > types( indexSet );
 
   90          for( GeometryType type : types.geomTypes( 0 ) )
 
   93          if constexpr ( Capabilities::isDuneFemIndexSet< IndexSetType >:: v )
 
   96            std::vector< int > codimensions( 1, 
int(Traits::codimension) );
 
   97            indexSet_.requestCodimensions( codimensions );
 
  105        SizeType 
size ()
 const 
  107          return indexSet().size( codimension ) + extension_;
 
  110        static constexpr bool contains ( 
int codim ) 
noexcept 
  112          return codim == codimension;
 
  115        static constexpr bool fixedDataSize ( 
int codim ) 
noexcept 
  120        template< 
class Function >
 
  121        void mapEach ( 
const ElementType &element, Function function )
 const 
  123          if( codimension == 0 )
 
  124            function( 0, indexSet().index( element ) );
 
  127            const SizeType numDofs = this->numDofs( element );
 
  128            for( SizeType i = 0; i < numDofs; ++i )
 
  129              function( i, indexSet().subIndex( element, i, codimension ) );
 
  133        void map ( 
const ElementType &element, std::vector< GlobalKeyType > &indices )
 const 
  135          indices.resize( numDofs( element ) );
 
  136          mapEach( element, [ &indices ] ( 
int local, GlobalKeyType global ) { indices[ local ] = global; } );
 
  139        template< 
class Entity >
 
  140        void mapEntityDofs ( 
const Entity &entity, std::vector< GlobalKeyType > &indices )
 const 
  142          indices.resize( numEntityDofs( entity ) );
 
  143          mapEachEntityDof( entity, AssignFunctor< std::vector< GlobalKeyType > >( indices ) );
 
  146        template< 
class Entity, 
class Function >
 
  147        void mapEachEntityDof ( 
const Entity &entity, Function function )
 const 
  150          function( 0, indexSet().index( entity ) );
 
  153        int maxNumDofs ()
 const { 
return maxNumDofs_; }
 
  155        SizeType numDofs ( 
const ElementType &element )
 const 
  157          return element.subEntities( codimension );
 
  160        template< 
class Entity >
 
  161        static constexpr SizeType numEntityDofs ( 
const Entity &entity ) 
noexcept 
  168        void extendSize( 
const SizeType extension )
 
  170          extension_ = extension;
 
  173        [[deprecated(
"Use onSubEntity method with char vector instead")]]
 
  174        void onSubEntity ( 
const ElementType &element, 
int i, 
int c, std::vector< bool > &indices )
 const 
  176          std::vector< char > _idx;
 
  177          onSubEntity(element, i, c, _idx);
 
  178          indices.resize( _idx.size() );
 
  179          for (std::size_t i=0; i<_idx.size();++i)
 
  180            _idx[i] = indices[i] > 0;
 
  182        void onSubEntity ( 
const ElementType &element, 
int i, 
int c, std::vector< char > &indices )
 const 
  184          indices.resize( numDofs(element) );
 
  185          std::fill(indices.begin(),indices.end(),0);
 
  207        static constexpr bool consecutive () noexcept { 
return false; }
 
  209        SizeType numBlocks ()
 const 
  211          DUNE_THROW( NotImplemented, 
"Method numBlocks() called on non-adaptive block mapper" );
 
  214        SizeType numberOfHoles ( 
int )
 const 
  216          DUNE_THROW( NotImplemented, 
"Method numberOfHoles() called on non-adaptive block mapper" );
 
  219        GlobalKeyType oldIndex ( 
int hole, 
int )
 const 
  221          DUNE_THROW( NotImplemented, 
"Method oldIndex() called on non-adaptive block mapper" );
 
  224        GlobalKeyType newIndex ( 
int hole, 
int )
 const 
  226          DUNE_THROW( NotImplemented, 
"Method newIndex() called on non-adaptive block mapper" );
 
  229        SizeType oldOffSet ( 
int )
 const 
  231          DUNE_THROW( NotImplemented, 
"Method oldOffSet() called on non-adaptive block mapper" );
 
  234        SizeType offSet ( 
int )
 const 
  236          DUNE_THROW( NotImplemented, 
"Method offSet() called on non-adaptive block mapper" );
 
  242        const IndexSetType &indexSet ()
 const { 
return indexSet_; }
 
  251        const IndexSetType &indexSet_;
 
  261      template< 
class Traits >
 
  262      class AdaptiveDofMapper
 
  263        : 
public DofMapper< Traits, Dune::Fem::AdaptiveDofMapper >
 
  265        typedef DofMapper< Traits, Dune::Fem::AdaptiveDofMapper > BaseType;
 
  268        static const int codimension = BaseType::codimension;
 
  270        typedef typename BaseType::SizeType SizeType;
 
  271        typedef typename BaseType::GlobalKeyType GlobalKeyType;
 
  274        using BaseType::indexSet;
 
  277        explicit AdaptiveDofMapper ( 
const typename BaseType::GridPartType &gridPart )
 
  278          : BaseType( gridPart )
 
  281        explicit AdaptiveDofMapper ( 
const typename BaseType::IndexSetType &indexSet )
 
  282          : BaseType( indexSet )
 
  285        static constexpr bool consecutive () noexcept { 
return true; }
 
  287        static constexpr SizeType numBlocks () noexcept
 
  292        SizeType numberOfHoles ( 
int )
 const 
  294          return indexSet().numberOfHoles( codimension );
 
  297        GlobalKeyType oldIndex ( 
int hole, 
int )
 const 
  299          return indexSet().oldIndex( hole, codimension );
 
  302        GlobalKeyType newIndex ( 
int hole, 
int )
 const 
  304          return indexSet().newIndex( hole, codimension );
 
  307        static constexpr SizeType oldOffSet ( 
int ) 
noexcept 
  312        static constexpr SizeType offSet ( 
int ) 
noexcept 
  323      template< 
class GridPart, 
int codim,
 
  324                bool adaptive = Capabilities::isAdaptiveIndexSet< typename GridPart::IndexSetType >::v >
 
  327        typedef __CodimensionMapper::Traits< GridPart, codim > Traits;
 
  330        typedef typename std::conditional< adaptive,
 
  331            AdaptiveDofMapper< Traits >,
 
  354    template< 
class Gr
idPart, 
int codim >
 
  356      : 
public __CodimensionMapper::template Implementation< GridPart, codim >::Type
 
  358      typedef typename __CodimensionMapper::template Implementation< GridPart, codim >::Type BaseType;
 
  362        : BaseType( gridPart )
 
  366        : BaseType( *indexSet )
 
  370        : BaseType( indexSet )
 
  378    namespace Capabilities
 
  383      template< 
class Gr
idPart, 
int codim >
 
  393      template< 
class Gr
idPart, 
int codim >
 
  394      struct isConsecutiveIndexSet< __CodimensionMapper::AdaptiveDofMapper< __CodimensionMapper::Traits< GridPart, codim > > >
 
  396        static const bool v = 
true;
 
static constexpr int codimension
Know your own codimension.
Definition: entity.hh:106
 
consecutive, persistent index set for the leaf level based on the grid's hierarchy index set
Definition: adaptiveleafindexset.hh:1351
 
specialize with true if index set implements the interface for adaptive index sets
Definition: indexset.hh:83
 
mapper allocating one DoF per subentity of a given codimension
Definition: codimensionmapper.hh:357
 
Interface for calculating the size of a function space for a grid on a specified level....
Definition: dofmapper.hh:43
 
A few common exception classes.
 
#define DUNE_THROW(E,...)
Definition: exceptions.hh:314
 
unspecified value type referenceElement(T &&... t)
Returns a reference element for the objects t....
 
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
 
constexpr std::bool_constant<((II==value)||...)> contains(std::integer_sequence< T, II... >, std::integral_constant< T, value >)
Checks whether or not a given sequence contains a value.
Definition: integersequence.hh:137
 
static const ReferenceElement & general(const GeometryType &type)
get general reference elements
Definition: referenceelements.hh:156
 
A unique label for each type of element that can occur in a grid.