1 #ifndef DUNE_FEM_SPACE_MAPPER_CODIMENSIONMAPPER_HH
2 #define DUNE_FEM_SPACE_MAPPER_CODIMENSIONMAPPER_HH
9 #include <dune/common/exceptions.hh>
11 #include <dune/geometry/referenceelements.hh>
12 #include <dune/geometry/type.hh>
27 template<
class Gr
idPart,
int codim >
28 class CodimensionMapper;
34 namespace __CodimensionMapper
40 template<
class Gr
idPart,
int codim >
43 typedef CodimensionMapper< GridPart, codim > DofMapperType;
45 static const int codimension = codim;
47 typedef GridPart GridPartType;
48 typedef typename GridPartType::IndexSetType IndexSetType;
50 typedef typename GridPartType::template Codim< 0 >::EntityType ElementType;
52 typedef SizeType GlobalKeyType;
64 typedef Base< T > BaseType;
67 typedef typename BaseType::Traits Traits;
69 static const int codimension = Traits::codimension;
71 typedef typename Traits::GridPartType GridPartType;
72 typedef typename Traits::IndexSetType IndexSetType;
74 typedef typename BaseType::ElementType ElementType;
75 typedef typename BaseType::SizeType SizeType;
76 typedef typename Traits::GlobalKeyType GlobalKeyType;
78 explicit DofMapper (
const GridPartType &gridPart )
79 : DofMapper( gridPart.indexSet() )
82 explicit DofMapper (
const IndexSetType &indexSet )
83 : indexSet_( indexSet ),
86 AllGeomTypes< IndexSetType, typename GridPartType::GridType > types( indexSet );
87 for( GeometryType type : types.geomTypes( 0 ) )
88 maxNumDofs_ =
std::max( maxNumDofs_, referenceElement( type ).size( codimension ) );
91 std::vector< int > codimensions( 1,
int(Traits::codimension) );
92 indexSet_.requestCodimensions( codimensions );
99 SizeType size ()
const
101 return indexSet().size( codimension );
104 static constexpr
bool contains (
int codim ) noexcept
106 return codim == codimension;
109 static constexpr
bool fixedDataSize (
int codim ) noexcept
114 template<
class Function >
115 void mapEach (
const ElementType &element, Function
function )
const
117 if( codimension == 0 )
118 function( 0, indexSet().index( element ) );
121 const SizeType numDofs = this->numDofs( element );
122 for( SizeType i = 0; i < numDofs; ++i )
123 function( i, indexSet().subIndex( element, i, codimension ) );
127 template<
class Entity,
class Function >
128 void mapEachEntityDof (
const Entity &entity, Function
function )
const
130 assert( Entity::codimension == codimension );
131 function( 0, indexSet().index( entity ) );
134 int maxNumDofs ()
const {
return maxNumDofs_; }
136 SizeType numDofs (
const ElementType &element )
const
138 return element.subEntities( codimension );
141 template<
class Entity >
142 static constexpr SizeType numEntityDofs (
const Entity &entity ) noexcept
144 return contains( Entity::codimension ) ? 1 : 0;
167 static constexpr
bool consecutive () noexcept {
return false; }
169 SizeType numBlocks ()
const
171 DUNE_THROW( NotImplemented,
"Method numBlocks() called on non-adaptive block mapper" );
174 SizeType numberOfHoles (
int )
const
176 DUNE_THROW( NotImplemented,
"Method numberOfHoles() called on non-adaptive block mapper" );
179 GlobalKeyType oldIndex (
int hole,
int )
const
181 DUNE_THROW( NotImplemented,
"Method oldIndex() called on non-adaptive block mapper" );
184 GlobalKeyType newIndex (
int hole,
int )
const
186 DUNE_THROW( NotImplemented,
"Method newIndex() called on non-adaptive block mapper" );
189 SizeType oldOffSet (
int )
const
191 DUNE_THROW( NotImplemented,
"Method oldOffSet() called on non-adaptive block mapper" );
194 SizeType offSet (
int )
const
196 DUNE_THROW( NotImplemented,
"Method offSet() called on non-adaptive block mapper" );
202 const IndexSetType &indexSet ()
const {
return indexSet_; }
205 static auto referenceElement ( GeometryType type )
206 -> decltype( ReferenceElements< typename GridPartType::ctype, GridPartType::dimension >::general( type ) )
208 return ReferenceElements< typename GridPartType::ctype, GridPartType::dimension >::general( type );
211 const IndexSetType &indexSet_;
220 template<
class Traits >
221 class AdaptiveDofMapper
222 :
public DofMapper< Traits, Dune::Fem::AdaptiveDofMapper >
224 typedef DofMapper< Traits, Dune::Fem::AdaptiveDofMapper > BaseType;
227 static const int codimension = BaseType::codimension;
229 typedef typename BaseType::SizeType SizeType;
230 typedef typename BaseType::GlobalKeyType GlobalKeyType;
233 using BaseType::indexSet;
236 explicit AdaptiveDofMapper (
const typename BaseType::GridPartType &gridPart )
237 : BaseType( gridPart )
240 explicit AdaptiveDofMapper (
const typename BaseType::IndexSetType &indexSet )
241 : BaseType( indexSet )
244 static constexpr
bool consecutive () noexcept {
return true; }
246 static constexpr SizeType numBlocks () noexcept
251 SizeType numberOfHoles (
int )
const
253 return indexSet().numberOfHoles( codimension );
256 GlobalKeyType oldIndex (
int hole,
int )
const
258 return indexSet().oldIndex( hole, codimension );
261 GlobalKeyType newIndex (
int hole,
int )
const
263 return indexSet().newIndex( hole, codimension );
266 static constexpr SizeType oldOffSet (
int ) noexcept
271 static constexpr SizeType offSet (
int ) noexcept
282 template<
class GridPart,
int codim,
286 typedef __CodimensionMapper::Traits< GridPart, codim > Traits;
289 typedef typename std::conditional< adaptive,
290 AdaptiveDofMapper< Traits >,
313 template<
class Gr
idPart,
int codim >
315 :
public __CodimensionMapper::template Implementation< GridPart, codim >::Type
317 typedef typename __CodimensionMapper::template Implementation< GridPart, codim >::Type BaseType;
321 : BaseType( gridPart )
325 : BaseType( indexSet )
334 template<
class Gr
idPart,
int codim >
342 Key (
const GridPart &gridPart )
343 : gridPart_( gridPart )
348 return &gridPart_.indexSet() == &rhs.gridPart_.indexSet();
353 return !(*
this == rhs);
356 explicit operator const GridPart & ()
const
362 const GridPart &gridPart_;
367 return new Object(
static_cast< const GridPart &
>( key ) );
380 namespace Capabilities
385 template<
class Gr
idPart,
int codim >
395 template<
class Gr
idPart,
int codim >
398 static const bool v =
true;
Definition: bindguard.hh:11
typename Impl::Index< Range >::Type IndexType
Definition: hybrid.hh:69
static constexpr T max(T a)
Definition: utility.hh:77
specialize with true if index set implements the interface for consecutive index sets
Definition: common/indexset.hh:42
static const bool v
Definition: common/indexset.hh:49
specialize with true if index set implements the interface for adaptive index sets
Definition: common/indexset.hh:64
static const bool v
Definition: common/indexset.hh:71
Definition: space/mapper/capabilities.hh:22
static const bool v
Definition: space/mapper/capabilities.hh:23
mapper allocating one DoF per subentity of a given codimension
Definition: codimensionmapper.hh:316
CodimensionMapper(const typename BaseType::IndexSetType &indexSet)
Definition: codimensionmapper.hh:324
CodimensionMapper(const typename BaseType::GridPartType &gridPart)
Definition: codimensionmapper.hh:320
Definition: codimensionmapper.hh:336
static Object * createObject(const Key &key)
Definition: codimensionmapper.hh:365
static void deleteObject(Object *object)
Definition: codimensionmapper.hh:370
CodimensionMapper< GridPart, codim > Object
Definition: codimensionmapper.hh:338
Definition: codimensionmapper.hh:341
bool operator==(const Key &rhs)
Definition: codimensionmapper.hh:346
Key(const GridPart &gridPart)
Definition: codimensionmapper.hh:342
bool operator!=(const Key &rhs)
Definition: codimensionmapper.hh:351
Interface for calculating the size of a function space for a grid on a specified level....
Definition: mapper/dofmapper.hh:43
Extended interface for adaptive DoF mappers.
Definition: mapper/dofmapper.hh:219