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 ),
87 AllGeomTypes< IndexSetType, typename GridPartType::GridType > types( indexSet );
88 for( GeometryType type : types.geomTypes( 0 ) )
89 maxNumDofs_ =
std::max( maxNumDofs_, referenceElement( type ).size( codimension ) );
92 std::vector< int > codimensions( 1,
int(Traits::codimension) );
93 indexSet_.requestCodimensions( codimensions );
100 SizeType size ()
const
102 return indexSet().size( codimension ) + extension_;
105 static constexpr bool contains (
int codim )
noexcept
107 return codim == codimension;
110 static constexpr bool fixedDataSize (
int codim )
noexcept
115 template<
class Function >
116 void mapEach (
const ElementType &element, Function function )
const
118 if( codimension == 0 )
119 function( 0, indexSet().index( element ) );
122 const SizeType numDofs = this->numDofs( element );
123 for( SizeType i = 0; i < numDofs; ++i )
124 function( i, indexSet().subIndex( element, i, codimension ) );
128 template<
class Entity,
class Function >
129 void mapEachEntityDof (
const Entity &entity, Function function )
const
131 assert( Entity::codimension == codimension );
132 function( 0, indexSet().index( entity ) );
135 int maxNumDofs ()
const {
return maxNumDofs_; }
137 SizeType numDofs (
const ElementType &element )
const
139 return element.subEntities( codimension );
142 template<
class Entity >
143 static constexpr SizeType numEntityDofs (
const Entity &entity )
noexcept
145 return contains( Entity::codimension ) ? 1 : 0;
150 void extendSize(
const SizeType extension )
152 extension_ = extension;
155 void onSubEntity (
const ElementType &element,
int i,
int c, std::vector< bool > &indices )
const
157 indices.resize( numDofs(element) );
158 std::fill(indices.begin(),indices.end(),
false);
180 static constexpr bool consecutive () noexcept {
return false; }
182 SizeType numBlocks ()
const
184 DUNE_THROW( NotImplemented,
"Method numBlocks() called on non-adaptive block mapper" );
187 SizeType numberOfHoles (
int )
const
189 DUNE_THROW( NotImplemented,
"Method numberOfHoles() called on non-adaptive block mapper" );
192 GlobalKeyType oldIndex (
int hole,
int )
const
194 DUNE_THROW( NotImplemented,
"Method oldIndex() called on non-adaptive block mapper" );
197 GlobalKeyType newIndex (
int hole,
int )
const
199 DUNE_THROW( NotImplemented,
"Method newIndex() called on non-adaptive block mapper" );
202 SizeType oldOffSet (
int )
const
204 DUNE_THROW( NotImplemented,
"Method oldOffSet() called on non-adaptive block mapper" );
207 SizeType offSet (
int )
const
209 DUNE_THROW( NotImplemented,
"Method offSet() called on non-adaptive block mapper" );
215 const IndexSetType &indexSet ()
const {
return indexSet_; }
218 static auto referenceElement ( GeometryType type )
219 ->
decltype( ReferenceElements< typename GridPartType::ctype, GridPartType::dimension >::general( type ) )
221 return ReferenceElements< typename GridPartType::ctype, GridPartType::dimension >::general( type );
224 const IndexSetType &indexSet_;
234 template<
class Traits >
235 class AdaptiveDofMapper
236 :
public DofMapper< Traits, Dune::Fem::AdaptiveDofMapper >
238 typedef DofMapper< Traits, Dune::Fem::AdaptiveDofMapper > BaseType;
241 static const int codimension = BaseType::codimension;
243 typedef typename BaseType::SizeType SizeType;
244 typedef typename BaseType::GlobalKeyType GlobalKeyType;
247 using BaseType::indexSet;
250 explicit AdaptiveDofMapper (
const typename BaseType::GridPartType &gridPart )
251 : BaseType( gridPart )
254 explicit AdaptiveDofMapper (
const typename BaseType::IndexSetType &indexSet )
255 : BaseType( indexSet )
258 static constexpr bool consecutive () noexcept {
return true; }
260 static constexpr SizeType numBlocks () noexcept
265 SizeType numberOfHoles (
int )
const
267 return indexSet().numberOfHoles( codimension );
270 GlobalKeyType oldIndex (
int hole,
int )
const
272 return indexSet().oldIndex( hole, codimension );
275 GlobalKeyType newIndex (
int hole,
int )
const
277 return indexSet().newIndex( hole, codimension );
280 static constexpr SizeType oldOffSet (
int )
noexcept
285 static constexpr SizeType offSet (
int )
noexcept
296 template<
class GridPart,
int codim,
300 typedef __CodimensionMapper::Traits< GridPart, codim > Traits;
303 typedef typename std::conditional< adaptive,
304 AdaptiveDofMapper< Traits >,
327 template<
class Gr
idPart,
int codim >
329 :
public __CodimensionMapper::template Implementation< GridPart, codim >::Type
331 typedef typename __CodimensionMapper::template Implementation< GridPart, codim >::Type BaseType;
335 : BaseType( gridPart )
339 : BaseType( *indexSet )
343 : BaseType( indexSet )
351 namespace Capabilities
356 template<
class Gr
idPart,
int codim >
366 template<
class Gr
idPart,
int codim >
369 static const bool v =
true;
double max(const Dune::Fem::Double &v, const double p)
Definition: double.hh:965
Definition: bindguard.hh:11
typename Impl::Index< Range >::Type IndexType
Definition: hybrid.hh:69
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:330
CodimensionMapper(const typename BaseType::IndexSetType &indexSet)
Definition: codimensionmapper.hh:342
CodimensionMapper(const typename BaseType::IndexSetType *indexSet)
Definition: codimensionmapper.hh:338
CodimensionMapper(const typename BaseType::GridPartType &gridPart)
Definition: codimensionmapper.hh:334
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