dune-fem  2.6-git
combineddofstorage.hh
Go to the documentation of this file.
1 #ifndef DUNE_FEM_COMBINEDDOFSTORAGE_HH
2 #define DUNE_FEM_COMBINEDDOFSTORAGE_HH
3 
4 //- local includes
7 
8 namespace Dune
9 {
10 
11  namespace Fem
12  {
13 
16  template< class ContainedMapper, int N, DofStoragePolicy policy >
18 
19 
22  template< class ContainedMapper , int N >
23  class CombinedDofConversionUtility< ContainedMapper, N, PointBased >
24  : public PointBasedDofConversionUtility< N >
25  {
27 
28  public:
29  typedef ContainedMapper ContainedMapperType;
30 
31  CombinedDofConversionUtility ( const ContainedMapperType & mapper, const int numComponents )
32  : BaseType( numComponents )
33  {}
34  };
35 
37  template< class ContainedMapper, int N >
38  class CombinedDofConversionUtility< ContainedMapper, N, VariableBased >
39  {
40  public:
41  typedef ContainedMapper ContainedMapperType;
42 
49  : mapper_( mapper )
50  {}
51 
54  {
55  return VariableBased;
56  }
57 
59  void newSize ( int size )
60  {}
61 
64  int component ( int combinedIndex ) const
65  {
66  return combinedIndex / containedSize();
67  }
68 
70  int containedDof ( int combinedIndex ) const
71  {
72  return combinedIndex % containedSize();
73  }
74 
77  int combinedDof ( int containedIndex, int component ) const
78  {
79  return containedIndex + (component * containedSize());
80  }
81 
82  protected:
84 
85  int containedSize () const
86  {
87  return mapper_.size();
88  }
89  };
90 
91 
92 
93  template< class MapperImp, int N, DofStoragePolicy policy >
95  : public Fem :: IndexMapperInterface< CombinedSubMapper< MapperImp, N, policy > >
96  {
98 
99  public:
100  // original mapper
101  typedef MapperImp ContainedMapperType;
103 
104  CombinedSubMapper ( const ContainedMapperType& mapper, unsigned int component )
105  : mapper_( mapper ),
106  component_( component ),
107  utilGlobal_(mapper_, policy == PointBased ? N : mapper.size() )
108  {
109  assert(component_ < N);
110  }
111 
112  CombinedSubMapper(const ThisType& ) = default;
114  ThisType& operator=(const ThisType& ) = delete;
115  ThisType& operator=(ThisType&& ) = delete;
116 
118  unsigned int size () const
119  {
120  return mapper_.size();
121  }
122 
123  unsigned int range () const
124  {
125  return size() * N;
126  }
127 
128  unsigned int operator[] ( unsigned int index ) const
129  {
130  utilGlobal_.newSize( mapper_.size() );
131  return utilGlobal_.combinedDof(index, component_);
132  }
133 
134  private:
135  const ContainedMapperType& mapper_;
136  const unsigned int component_;
137  mutable DofConversionType utilGlobal_;
138  };
139 
140  } // namespace Fem
141 
142 } // namespace Dune
143 
144 #endif // #ifndef DUNE_FEM_COMBINEDDOFSTORAGE_HH
Definition: bindguard.hh:11
DofStoragePolicy
Definition: dofstorage.hh:16
@ PointBased
Definition: dofstorage.hh:16
@ VariableBased
Definition: dofstorage.hh:16
Definition: combineddofstorage.hh:17
ContainedMapper ContainedMapperType
Definition: combineddofstorage.hh:29
CombinedDofConversionUtility(const ContainedMapperType &mapper, const int numComponents)
Definition: combineddofstorage.hh:31
ContainedMapper ContainedMapperType
Definition: combineddofstorage.hh:41
void newSize(int size)
Set new size after adaptation.
Definition: combineddofstorage.hh:59
int containedSize() const
Definition: combineddofstorage.hh:85
int component(int combinedIndex) const
Definition: combineddofstorage.hh:64
int combinedDof(int containedIndex, int component) const
Definition: combineddofstorage.hh:77
CombinedDofConversionUtility(const ContainedMapperType &mapper, int size)
constructor
Definition: combineddofstorage.hh:48
int containedDof(int combinedIndex) const
Number of the (scalar) base function belonging to base function index.
Definition: combineddofstorage.hh:70
static DofStoragePolicy policy()
Find out what type of policy this is.
Definition: combineddofstorage.hh:53
const ContainedMapperType & mapper_
Definition: combineddofstorage.hh:83
Definition: combineddofstorage.hh:96
CombinedSubMapper(ThisType &&)=default
ThisType & operator=(const ThisType &)=delete
unsigned int range() const
Definition: combineddofstorage.hh:123
ThisType & operator=(ThisType &&)=delete
CombinedDofConversionUtility< ContainedMapperType, N, policy > DofConversionType
Definition: combineddofstorage.hh:102
CombinedSubMapper(const ContainedMapperType &mapper, unsigned int component)
Definition: combineddofstorage.hh:104
unsigned int operator[](unsigned int index) const
Definition: combineddofstorage.hh:128
MapperImp ContainedMapperType
Definition: combineddofstorage.hh:101
CombinedSubMapper(const ThisType &)=default
unsigned int size() const
Total number of degrees of freedom.
Definition: combineddofstorage.hh:118
Specialisation for PointBased approach.
Definition: dofstorage.hh:101
Abstract index mapper interface.
Definition: subvector.hh:45