dune-fem  2.4.1-rc
dofblock.hh
Go to the documentation of this file.
1 #ifndef DUNE_FEM_DOFBLOCK_HH
2 #define DUNE_FEM_DOFBLOCK_HH
3 
4 #include <utility>
5 #include <type_traits>
6 
8 
9 namespace Dune
10 {
11 
12  namespace Fem
13  {
14 
36  template< class DiscreteFunction, class Dof, unsigned int Size >
38  {
40 
41  friend class Fem :: Envelope< ThisType >;
42 
43  typedef DofBlockProxy< const DiscreteFunction, const Dof, Size > ConstDofBlockProxy;
44  typedef DofBlockProxy< typename std::remove_const< DiscreteFunction >::type, typename std::remove_const< Dof >::type, Size > NonConstDofBlockProxy;
45 
46  public:
47  typedef DiscreteFunction DiscreteFunctionType;
48 
49  typedef Dof DofType;
50 
51  static const unsigned int size = Size;
52 
53  typedef unsigned int size_type;
54 
55  typedef std::pair< DiscreteFunctionType *, size_type > KeyType;
56 
57  protected:
58  DofBlockProxy ( const KeyType &key )
59  : discreteFunction_( *(key.first) ),
60  first_( size * key.second )
61  {}
62 
65  first_( other.first_ )
66  {}
67 
70  first_( other.first_ )
71  {}
72 
73  public:
74  const ThisType &operator= ( const ConstDofBlockProxy &other )
75  {
76  for( size_type i = 0; i < size; ++i )
77  (*this)[ i ] = other[ i ];
78  return *this;
79  }
80 
81  const ThisType &operator= ( const NonConstDofBlockProxy &other )
82  {
83  for( size_type i = 0; i < size; ++i )
84  (*this)[ i ] = other[ i ];
85  return *this;
86  }
87 
88  const DofType &operator[] ( size_type index ) const
89  {
90  return discreteFunction_.dof( first_ + index );
91  }
92 
94  {
95  return discreteFunction_.dof( first_ + index );
96  }
97 
98  size_type dim () const
99  {
100  return size;
101  }
102 
103  protected:
106  };
107 
108  } // namespace Fem
109 
110 } // namespace Dune
111 
112 #endif // #ifndef DUNE_FEM_DOFBLOCK_HH
size_type dim() const
Definition: dofblock.hh:98
unsigned int size_type
Definition: dofblock.hh:53
Definition: envelope.hh:10
Dof DofType
Definition: dofblock.hh:49
DoF block proxy for discrete functions with random access to DoFs.
Definition: dofblock.hh:37
DofBlockProxy(const ConstDofBlockProxy &other)
Definition: dofblock.hh:63
DofBlockProxy(const NonConstDofBlockProxy &other)
Definition: dofblock.hh:68
std::pair< DiscreteFunctionType *, size_type > KeyType
Definition: dofblock.hh:55
DiscreteFunction DiscreteFunctionType
Definition: dofblock.hh:47
Definition: coordinate.hh:4
const ThisType & operator=(const ConstDofBlockProxy &other)
Definition: dofblock.hh:74
const DofType & operator[](size_type index) const
Definition: dofblock.hh:88
const size_type first_
Definition: dofblock.hh:105
DiscreteFunctionType & discreteFunction_
Definition: dofblock.hh:104
static const unsigned int size
Definition: dofblock.hh:51