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 >
34 namespace __CodimensionMapper
40 template<
class Gr
idPart,
int codim >
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;
51 typedef typename IndexSetType::IndexType SizeType;
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 )
82 explicit DofMapper (
const IndexSetType &indexSet )
83 : indexSet_( indexSet ),
87 for( GeometryType type : types.geomTypes( 0 ) )
88 maxNumDofs_ =
std::max( maxNumDofs_, referenceElement( type ).size( codimension ) );
95 SizeType size ()
const 97 return indexSet().size( codimension );
100 static constexpr
bool contains (
int codim ) noexcept
102 return codim == codimension;
105 static constexpr
bool fixedDataSize (
int codim ) noexcept
110 template<
class Function >
111 void mapEach (
const ElementType &element,
Function function )
const 113 if( codimension == 0 )
114 function( 0, indexSet().index( element ) );
117 const SizeType numDofs = this->numDofs( element );
118 for( SizeType i = 0; i < numDofs; ++i )
119 function( i, indexSet().subIndex( element, i, codimension ) );
123 template<
class Entity,
class Function >
124 void mapEachEntityDof (
const Entity &entity,
Function function )
const 126 assert( Entity::codimension == codimension );
127 function( 0, indexSet().index( entity ) );
130 int maxNumDofs ()
const {
return maxNumDofs_; }
132 SizeType numDofs (
const ElementType &element )
const 134 return element.subEntities( codimension );
137 template<
class Entity >
138 static constexpr SizeType numEntityDofs (
const Entity &entity ) noexcept
140 return contains( Entity::codimension ) ? 1 : 0;
161 static constexpr
bool consecutive () noexcept {
return false; }
163 SizeType numBlocks ()
const 165 DUNE_THROW( NotImplemented,
"Method numBlocks() called on non-adaptive block mapper" );
168 SizeType numberOfHoles (
int )
const 170 DUNE_THROW( NotImplemented,
"Method numberOfHoles() called on non-adaptive block mapper" );
173 GlobalKeyType oldIndex (
int hole,
int )
const 175 DUNE_THROW( NotImplemented,
"Method oldIndex() called on non-adaptive block mapper" );
178 GlobalKeyType newIndex (
int hole,
int )
const 180 DUNE_THROW( NotImplemented,
"Method newIndex() called on non-adaptive block mapper" );
183 SizeType oldOffSet (
int )
const 185 DUNE_THROW( NotImplemented,
"Method oldOffSet() called on non-adaptive block mapper" );
188 SizeType offSet (
int )
const 190 DUNE_THROW( NotImplemented,
"Method offSet() called on non-adaptive block mapper" );
196 const IndexSetType &indexSet ()
const {
return indexSet_; }
199 static const ReferenceElement< typename GridPartType::ctype, GridPartType::dimension > &
200 referenceElement ( GeometryType type )
202 return ReferenceElements< typename GridPartType::ctype, GridPartType::dimension >::general( type );
205 const IndexSetType &indexSet_;
214 template<
class Traits >
216 :
public DofMapper< Traits, Dune::Fem::AdaptiveDofMapper >
221 static const int codimension = BaseType::codimension;
223 typedef typename BaseType::SizeType SizeType;
224 typedef typename BaseType::GlobalKeyType GlobalKeyType;
227 using BaseType::indexSet;
231 : BaseType( gridPart )
235 : BaseType( indexSet )
238 static constexpr
bool consecutive () noexcept {
return true; }
240 static constexpr SizeType numBlocks () noexcept
245 SizeType numberOfHoles (
int )
const 247 return indexSet().numberOfHoles( codimension );
250 GlobalKeyType oldIndex (
int hole,
int )
const 252 return indexSet().oldIndex( hole, codimension );
255 GlobalKeyType newIndex (
int hole,
int )
const 257 return indexSet().newIndex( hole, codimension );
260 static constexpr SizeType oldOffSet (
int ) noexcept
265 static constexpr SizeType offSet (
int ) noexcept
276 template<
class GridPart,
int codim,
280 typedef __CodimensionMapper::Traits< GridPart, codim > Traits;
283 typedef typename std::conditional< adaptive,
291 #endif // #ifndef DOXYGEN 307 template<
class Gr
idPart,
int codim >
309 :
public __CodimensionMapper::template Implementation< GridPart, codim >::Type
311 typedef typename __CodimensionMapper::template Implementation< GridPart, codim >::Type BaseType;
315 : BaseType( gridPart )
319 : BaseType( indexSet )
328 template<
class Gr
idPart,
int codim >
336 Key (
const GridPart &gridPart )
337 : gridPart_( gridPart )
342 return &gridPart_.indexSet() == &rhs.gridPart_.indexSet();
347 return !(*
this == rhs);
350 explicit operator const GridPart & ()
const 356 const GridPart &gridPart_;
361 return new Object( static_cast< const GridPart & >( key ) );
374 namespace Capabilities
379 template<
class Gr
idPart,
int codim >
391 #endif // #ifndef DUNE_FEM_SPACE_MAPPER_CODIMENSIONMAPPER_HH Extended interface for adaptive DoF mappers.
Definition: mapper/dofmapper.hh:204
Definition: codimensionmapper.hh:329
static constexpr T max(T a)
Definition: utility.hh:65
Key(const GridPart &gridPart)
Definition: codimensionmapper.hh:336
Definition: codimensionmapper.hh:334
CodimensionMapper(const typename BaseType::GridPartType &gridPart)
Definition: codimensionmapper.hh:314
static Object * createObject(const Key &key)
Definition: codimensionmapper.hh:359
Interface for calculating the size of a function space for a grid on a specified level. Furthermore the local to global mapping of dof number is done. Also during grid adaptation this mapper knows about old and new indices of entities.
Definition: mapper/dofmapper.hh:40
CodimensionMapper< GridPart, codim > Object
Definition: codimensionmapper.hh:332
mapper allocating one DoF per subentity of a given codimension
Definition: codimensionmapper.hh:28
bool operator!=(const Double &a, const Double &b)
Definition: double.hh:629
bool operator==(const Double &a, const Double &b)
Definition: double.hh:589
Definition: coordinate.hh:4
specialize with true if index set implements the interface for adaptive index sets ...
Definition: common/indexset.hh:69
default implementation uses method geomTypes of given index set. Used in DiscreteFunctionSpaces.
Definition: allgeomtypes.hh:89
Definition: space/mapper/capabilities.hh:21
CodimensionMapper(const typename BaseType::IndexSetType &indexSet)
Definition: codimensionmapper.hh:318
Abstract class representing a function.
Definition: function.hh:43
static void deleteObject(Object *object)
Definition: codimensionmapper.hh:364