DUNE-FEM (unstable)

localmatrixcolumn.hh
1#ifndef DUNE_FEM_OPERATOR_COMMON_LOCALMATRIXCOLUMN_HH
2#define DUNE_FEM_OPERATOR_COMMON_LOCALMATRIXCOLUMN_HH
3
4#include <utility>
5
6#include <dune/fem/operator/common/temporarylocalmatrix.hh>
7
8namespace Dune
9{
10
11 namespace Fem
12 {
13
14 // LocalMatrixEntry
15 // ----------------
16
17 template< class LocalMatrix >
18 class LocalMatrixEntry
19 {
20 typedef LocalMatrixEntry< LocalMatrix > ThisType;
21
22 public:
23 typedef LocalMatrix LocalMatrixType;
24
25 typedef typename LocalMatrixType::RangeFieldType RangeFieldType;
26
27 LocalMatrixEntry ( LocalMatrixType &localMatrix, unsigned int row, unsigned int col )
28 : localMatrix_( localMatrix ), row_( row ), col_( col )
29 {}
30
31 operator RangeFieldType () const { return localMatrix_.get( row_, col_ ); }
32
33 ThisType &operator= ( const RangeFieldType &value ) { localMatrix_.set( row_, col_, value ); return *this; }
34
35 ThisType &operator+= ( const RangeFieldType &value ) { localMatrix_.add( row_, col_, value ); return *this; }
36 ThisType &operator-= ( const RangeFieldType &value ) { localMatrix_.add( row_, col_, -value ); return *this; }
37
38 ThisType &operator*= ( const RangeFieldType &value ) { localMatrix_.set( row_, col_, localMatrix_.get( row_, col_ ) * value ); return *this; }
39 ThisType &operator/= ( const RangeFieldType &value ) { localMatrix_.set( row_, col_, localMatrix_.get( row_, col_ ) / value ); return *this; }
40
41 private:
42 LocalMatrixType &localMatrix_;
43 unsigned int row_, col_;
44 };
45
46
47
48 // LocalMatrixColumn
49 // -----------------
50
51 template< class LocalMatrix >
52 class LocalMatrixColumn
53 {
54 typedef LocalMatrixColumn< LocalMatrix > ThisType;
55
56 public:
57 typedef LocalMatrix LocalMatrixType;
58
59 typedef typename LocalMatrixType::RangeFieldType RangeFieldType;
60 typedef typename LocalMatrixType::RangeBasisFunctionSetType BasisFunctionSetType;
61
62 typedef typename BasisFunctionSetType::RangeType RangeType;
63 typedef typename BasisFunctionSetType::JacobianRangeType JacobianRangeType;
64 typedef typename BasisFunctionSetType::HessianRangeType HessianRangeType;
65
66 typedef RangeFieldType value_type;
67 typedef unsigned int size_type;
68
69 LocalMatrixColumn ( LocalMatrixType &localMatrix, unsigned int col )
70 : localMatrix_( localMatrix ), col_( col )
71 {}
72
73 RangeFieldType operator[] ( size_type row ) const { return localMatrix_.get( row, col_ ); }
74
75 LocalMatrixEntry< LocalMatrixType > operator[] ( size_type row ) { return LocalMatrixEntry< LocalMatrixType >( localMatrix_, row, col_ ); }
76
77 template< class Point, class... Factor >
78 void axpy ( const Point &x, Factor &&... factor )
79 {
80 basisFunctionSet().axpy( x, std::forward< Factor >( factor )..., *this );
81 }
82
83 template< class Quadrature, class... Factor >
84 void axpyQuadrature ( const Quadrature &quadrature, Factor &&... factor )
85 {
86 basisFunctionSet().axpy( quadrature, std::forward< Factor >( factor )..., *this );
87 }
88
89 const BasisFunctionSetType &basisFunctionSet () const { return localMatrix_.rangeBasisFunctionSet(); }
90
91 auto size() const { return basisFunctionSet().size(); }
92
93 private:
94 LocalMatrixType &localMatrix_;
95 unsigned int col_;
96 };
97
98
99
100 // LocalMatrixColumn for TemporaryLocalMatrix
101 // ------------------------------------------
102
103 template< class DomainSpace, class RangeSpace >
104 class LocalMatrixColumn< TemporaryLocalMatrix< DomainSpace, RangeSpace > >
105 {
106 typedef LocalMatrixColumn< TemporaryLocalMatrix< DomainSpace, RangeSpace > > ThisType;
107
108 public:
109 typedef TemporaryLocalMatrix< DomainSpace, RangeSpace > LocalMatrixType;
110
111 typedef typename LocalMatrixType::RangeFieldType RangeFieldType;
112 typedef typename LocalMatrixType::RangeBasisFunctionSetType BasisFunctionSetType;
113
114 typedef typename BasisFunctionSetType::RangeType RangeType;
115 typedef typename BasisFunctionSetType::JacobianRangeType JacobianRangeType;
116 typedef typename BasisFunctionSetType::HessianRangeType HessianRangeType;
117
118 typedef RangeFieldType value_type;
119 typedef unsigned int size_type;
120
121 LocalMatrixColumn ( LocalMatrixType &localMatrix, unsigned int col )
122 : localMatrix_( localMatrix ), col_( col )
123 {}
124
125 const value_type &operator[] ( size_type row ) const { return localMatrix_[ row ][ col_ ]; }
126 value_type &operator[] ( size_type row ) { return localMatrix_[ row ][ col_ ]; }
127
128 template< class Point, class... Factor >
129 void axpy ( const Point &x, Factor &&... factor )
130 {
131 basisFunctionSet().axpy( x, std::forward< Factor >( factor )..., *this );
132 }
133
134 template< class Quadrature, class... Factor >
135 void axpyQuadrature ( const Quadrature &quadrature, Factor &&... factor )
136 {
137 basisFunctionSet().axpy( quadrature, std::forward< Factor >( factor )..., *this );
138 }
139
140 const BasisFunctionSetType &basisFunctionSet () const { return localMatrix_.rangeBasisFunctionSet(); }
141
142 auto size() const { return basisFunctionSet().size(); }
143
144 private:
145 LocalMatrixType &localMatrix_;
146 unsigned int col_;
147 };
148
149 } // namespace Fem
150
151} // namespace Dune
152
153#endif // #ifndef DUNE_FEM_OPERATOR_COMMON_LOCALMATRIXCOLUMN_HH
actual interface class for quadratures
Dune namespace.
Definition: alignedallocator.hh:13
constexpr std::integral_constant< std::size_t, sizeof...(II)> size(std::integer_sequence< T, II... >)
Return the size of the sequence.
Definition: integersequence.hh:75
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 21, 23:30, 2024)