DUNE-FEM (unstable)

dofblock.hh
1#ifndef DUNE_FEM_DOFBLOCK_HH
2#define DUNE_FEM_DOFBLOCK_HH
3
4#include <utility>
5#include <type_traits>
6
7#include <dune/fem/storage/envelope.hh>
8
9namespace 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
63 DofBlockProxy ( const ConstDofBlockProxy &other )
64 : discreteFunction_( other.discreteFunction_ ),
65 first_( other.first_ )
66 {}
67
69 : discreteFunction_( other.discreteFunction_ ),
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
93 DofType &operator[] ( size_type index )
94 {
95 return discreteFunction_.dof( first_ + index );
96 }
97
98 size_type dim () const
99 {
100 return size;
101 }
102
103 protected:
104 DiscreteFunctionType &discreteFunction_;
105 const size_type first_;
106 };
107
108 } // namespace Fem
109
110} // namespace Dune
111
112#endif // #ifndef DUNE_FEM_DOFBLOCK_HH
DoF block proxy for discrete functions with random access to DoFs.
Definition: dofblock.hh:38
Dune namespace.
Definition: alignedallocator.hh:13
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 13, 23:29, 2024)