dune-fem 2.12-git
Loading...
Searching...
No Matches
subobjects.hh
Go to the documentation of this file.
1#ifndef DUNE_FEM_SUBOBJECTS_HH
2#define DUNE_FEM_SUBOBJECTS_HH
3
4#include <type_traits>
5
8
10
11
12namespace Dune
13{
14
15 namespace Fem
16 {
17
18 template< class T >
19 struct RowType;
20
21 template< class T >
22 struct RowType< const T>
23 {
24 typedef const typename RowType<T> :: Type Type;
25 static const int size = RowType<T> :: size;
26 };
27
28 template< class K, int SIZE >
29 struct RowType< FieldVector< K, SIZE > >
30 {
31 typedef K Type;
32 static const int size = SIZE;
33 };
34
35 template< class K, int SIZE >
36 struct RowType< ExplicitFieldVector< K, SIZE > >
37 {
38 typedef K Type;
39 static const int size = SIZE;
40 };
41
42 template< class K, int ROWS, int COLS >
43 struct RowType< FieldMatrix< K, ROWS, COLS > >
44 {
46 static const int size = ROWS;
47 };
48
49
50
51 template <class DomainObject, class RangeObject, int offset >
53 {
54 typedef DomainObject DomainObjectType;
55 typedef RangeObject RangeObjectType;
56
57 typedef typename RowType< RangeObject > :: Type RowType;
58
59 public:
60 SubObject( DomainObjectType &host )
61 : host_( host )
62 {}
63
64 const RowType &operator[] ( const int i ) const
65 {
66 assert( (i >=0 ) && (i < size()) );
67 return host_[ i + offset ];
68 }
69
70 RowType& operator[] ( const int i )
71 {
72 assert( (i >=0 ) && (i < size()) );
73 return host_[ i + offset ];
74 }
75
76 int size () const
77 {
79 }
80
82 {
84 for( int i = 0; i < size(); ++i )
85 y[ i ] = (*this)[ i ];
86 return y;
87 }
88
89 private:
90 DomainObjectType &host_;
91 };
92
93 } // namespace Fem
94
95
96 // cast into fieldMatrix
97 template< class DomianObj, class RangeObj, int offset >
98 struct DenseMatrixAssigner< typename std::remove_const< RangeObj >::type, Fem::SubObject< DomianObj, RangeObj, offset > >
99 {
101 {
102 for( int i = 0; i < s.size(); ++i )
103 fm[ i ] = s[ i ];
104 }
105 };
106
107} // namespace Dune
108
109#endif // #ifndef DUNE_FEM_SUBOBJECTS_HH
int size() const
STL namespace.
Definition explicitfieldvector.hh:75
Definition subobjects.hh:19
const RowType< T >::Type Type
Definition subobjects.hh:24
FieldVector< K, COLS > Type
Definition subobjects.hh:45
Definition subobjects.hh:53
const RowType & operator[](const int i) const
Definition subobjects.hh:64
int size() const
Definition subobjects.hh:76
SubObject(DomainObjectType &host)
Definition subobjects.hh:60
static void apply(typename std::remove_const< RangeObj >::type &fm, const Fem::SubObject< DomianObj, RangeObj, offset > &s)
Definition subobjects.hh:100