dune-fem 2.8.0
Loading...
Searching...
No Matches
localmatrixwrapper.hh
Go to the documentation of this file.
1#ifndef DUNE_FEM_LOCALMATRIXWRAPPER_HH
2#define DUNE_FEM_LOCALMATRIXWRAPPER_HH
3
5
6namespace Dune
7{
8
9 namespace Fem
10 {
11
12 // Internal Forward Declarations
13 // -----------------------------
14
15 template< class LocalMatrixStack >
16 class LocalMatrixWrapper;
17
18
19
20 // LocalMatrixWrapperTraits
21 // ------------------------
22
23 template< class LocalMatrixStack >
25 {
26 typedef LocalMatrixStack LocalMatrixStackType;
27
28 typedef typename LocalMatrixStack::ObjectType WrappedLocalMatrixType;
29
31
32 typedef typename WrappedLocalMatrixType::RangeFieldType RangeFieldType;
33
34 typedef typename WrappedLocalMatrixType::DomainSpaceType DomainSpaceType;
35 typedef typename WrappedLocalMatrixType::RangeSpaceType RangeSpaceType;
36
37 typedef typename WrappedLocalMatrixType::LittleBlockType LittleBlockType;
38 };
39
40
41
42 // LocalMatrixWrapper
43 // ------------------
44
45 template< class LocalMatrixStack >
47 : public LocalMatrixInterface< LocalMatrixWrapperTraits< LocalMatrixStack > >
48 {
51
52 public:
54 typedef LocalMatrixStack LocalMatrixStackType;
55
58
61
63
66
69
72
73 private:
74 typedef typename LocalMatrixStackType::PointerType WrappedLocalMatrixPtrType;
75
76 // ObjectPointer to the actual local matrix
77 // (the pointer is required to keep the reference alive)
78 WrappedLocalMatrixPtrType localMatrixPtr_;
79
80 // reference to the actual local matrix
81 WrappedLocalMatrixType &localMatrix_;
82
83 public:
86 : localMatrixPtr_( stack.getObject() ),
87 localMatrix_( *localMatrixPtr_ )
88 {}
89
91 template< class DomainEntityType, class RangeEntityType >
95 : localMatrixPtr_( stack.getObject() ),
96 localMatrix_( *localMatrixPtr_ )
97 {
98 // initialize the wrapped local matrix with the entities
100 }
101
107 : localMatrixPtr_( other.localMatrixPtr_ ),
108 localMatrix_( *localMatrixPtr_ )
109 {}
110
113 {
114 // call finalize on local matrix implementation
115 // (e.g. needed for PETSc to add values to the real matrix)
116 localMatrix().finalize();
117 }
118
119 ThisType& operator= ( const ThisType& ) = delete;
120
123 {
125 }
126
128 void add ( int localRow, int localCol, const RangeFieldType &value )
129 {
130 localMatrix().add( localRow, localCol, value );
131 }
132
134 void set ( int localRow, int localCol, const RangeFieldType &value )
135 {
136 localMatrix().set( localRow, localCol, value );
137 }
138
140 void clearRow ( const int localRow )
141 {
142 localMatrix().clearRow( localRow );
143 }
144
146 void clearCol ( const int localCol )
147 {
148 localMatrix().clearCol( localCol );
149 }
150
152 const RangeFieldType get ( const int localRow,
153 const int localCol ) const
154 {
155 return localMatrix().get( localRow, localCol );
156 }
157
159 void scale ( const RangeFieldType& scalar )
160 {
161 return localMatrix().scale( scalar );
162 }
163
165 void clear ()
166 {
167 return localMatrix().clear();
168 }
169
171 void resort ()
172 {
173 return localMatrix().resort();
174 }
175
177 int rows () const
178 {
179 return localMatrix().rows();
180 }
181
183 int columns () const
184 {
185 return localMatrix().columns();
186 }
187
189 template <class DomainLocalFunctionImp,
190 class RangeLocalFunctionImp>
191 void multiplyAdd(const DomainLocalFunctionImp& dLf,
192 RangeLocalFunctionImp& rLf)
193 {
194 localMatrix().multiplyAdd( dLf, rLf);
195 }
196
199 {
200 return localMatrix().domainSpace();
201 }
202
205 {
206 return localMatrix().rangeSpace();
207 }
208
209 const DomainEntityType &domainEntity () const { return localMatrix().domainEntity(); }
210 const RangeEntityType &rangeEntity () const { return localMatrix().rangeEntity(); }
211
214 {
215 return localMatrix().domainBasisFunctionSet();
216 }
217
220 {
221 return localMatrix().rangeBasisFunctionSet();
222 }
223
224 protected:
225 const WrappedLocalMatrixType &localMatrix () const { return localMatrix_; }
226 WrappedLocalMatrixType &localMatrix () { return localMatrix_; }
227 };
228
229 } // namespace Fem
230
231} // namespace Dune
232
233#endif // #ifndef DUNE_FEM_LOCALMATRIXWRAPPER_HH
Definition: bindguard.hh:11
Interface for local matrix classes.
Definition: localmatrix.hh:32
Traits::DomainSpaceType DomainSpaceType
type of domain discrete function space
Definition: localmatrix.hh:52
Traits::RangeSpaceType RangeSpaceType
type of range discrete function space
Definition: localmatrix.hh:55
RangeSpaceType::EntityType RangeEntityType
Definition: localmatrix.hh:66
RangeSpaceType::BasisFunctionSetType RangeBasisFunctionSetType
type of base function sets within range function space
Definition: localmatrix.hh:63
DomainSpaceType::BasisFunctionSetType DomainBasisFunctionSetType
type of base function sets within domain function space
Definition: localmatrix.hh:59
DomainSpaceType::EntityType DomainEntityType
Definition: localmatrix.hh:65
Definition: localmatrixwrapper.hh:48
void add(int localRow, int localCol, const RangeFieldType &value)
add value to matrix entry (row,col) where row and col are local row and local column
Definition: localmatrixwrapper.hh:128
void multiplyAdd(const DomainLocalFunctionImp &dLf, RangeLocalFunctionImp &rLf)
multiply left hand side with local matrix and add to right hand side rhs += Matrix * lhs
Definition: localmatrixwrapper.hh:191
const RangeSpaceType & rangeSpace() const
access to the range space
Definition: localmatrixwrapper.hh:204
BaseType::DomainSpaceType DomainSpaceType
Definition: localmatrixwrapper.hh:64
LocalMatrixWrapperTraits< LocalMatrixStackType > Traits
type of the traits
Definition: localmatrixwrapper.hh:57
void clearCol(const int localCol)
set row to zero values
Definition: localmatrixwrapper.hh:146
const DomainEntityType & domainEntity() const
Definition: localmatrixwrapper.hh:209
const DomainBasisFunctionSetType & domainBasisFunctionSet() const
access to the base function set within the domain space
Definition: localmatrixwrapper.hh:213
const RangeBasisFunctionSetType & rangeBasisFunctionSet() const
access to the base function set within the range space
Definition: localmatrixwrapper.hh:219
void clearRow(const int localRow)
set row to zero values
Definition: localmatrixwrapper.hh:140
const RangeFieldType get(const int localRow, const int localCol) const
get value of matrix entry (row,col) where row and col are local row and local column
Definition: localmatrixwrapper.hh:152
const RangeEntityType & rangeEntity() const
Definition: localmatrixwrapper.hh:210
void scale(const RangeFieldType &scalar)
scale matrix with scalar value
Definition: localmatrixwrapper.hh:159
LocalMatrixWrapper(LocalMatrixStackType &stack)
constructor creating an uninitialized local matrix
Definition: localmatrixwrapper.hh:85
LocalMatrixWrapper(const ThisType &other)
copy constructor
Definition: localmatrixwrapper.hh:106
void clear()
set all entries of local matrix to zero
Definition: localmatrixwrapper.hh:165
WrappedLocalMatrixType & localMatrix()
Definition: localmatrixwrapper.hh:226
BaseType::RangeEntityType RangeEntityType
Definition: localmatrixwrapper.hh:71
Traits::RangeFieldType RangeFieldType
Definition: localmatrixwrapper.hh:62
~LocalMatrixWrapper()
destructor
Definition: localmatrixwrapper.hh:112
int columns() const
get number of columns within the matrix
Definition: localmatrixwrapper.hh:183
void init(const DomainEntityType &domainEntity, const RangeEntityType &rangeEntity)
initialize the local matrix to entities
Definition: localmatrixwrapper.hh:122
BaseType::DomainBasisFunctionSetType DomainBasisFunctionSetType
Definition: localmatrixwrapper.hh:67
const DomainSpaceType & domainSpace() const
access to the domain space
Definition: localmatrixwrapper.hh:198
int rows() const
get number of rows within the matrix
Definition: localmatrixwrapper.hh:177
void resort()
resort ordering in global matrix (if possible)
Definition: localmatrixwrapper.hh:171
void set(int localRow, int localCol, const RangeFieldType &value)
set value of matrix entry (row,col) where row and col are local row and local column
Definition: localmatrixwrapper.hh:134
BaseType::RangeSpaceType RangeSpaceType
Definition: localmatrixwrapper.hh:65
LocalMatrixStack LocalMatrixStackType
type of the local matrix stack
Definition: localmatrixwrapper.hh:54
BaseType::DomainEntityType DomainEntityType
Definition: localmatrixwrapper.hh:70
ThisType & operator=(const ThisType &)=delete
Traits::WrappedLocalMatrixType WrappedLocalMatrixType
type of the wrapped local matrix
Definition: localmatrixwrapper.hh:60
LocalMatrixWrapper(LocalMatrixStackType &stack, const DomainEntityType &domainEntity, const RangeEntityType &rangeEntity)
constructor initializing the wrapped local matrix
Definition: localmatrixwrapper.hh:92
const WrappedLocalMatrixType & localMatrix() const
Definition: localmatrixwrapper.hh:225
BaseType::RangeBasisFunctionSetType RangeBasisFunctionSetType
Definition: localmatrixwrapper.hh:68
Definition: localmatrixwrapper.hh:25
LocalMatrixStack::ObjectType WrappedLocalMatrixType
Definition: localmatrixwrapper.hh:28
LocalMatrixWrapper< LocalMatrixStackType > LocalMatrixType
Definition: localmatrixwrapper.hh:30
WrappedLocalMatrixType::DomainSpaceType DomainSpaceType
Definition: localmatrixwrapper.hh:34
LocalMatrixStack LocalMatrixStackType
Definition: localmatrixwrapper.hh:26
WrappedLocalMatrixType::RangeFieldType RangeFieldType
Definition: localmatrixwrapper.hh:32
WrappedLocalMatrixType::RangeSpaceType RangeSpaceType
Definition: localmatrixwrapper.hh:35
WrappedLocalMatrixType::LittleBlockType LittleBlockType
Definition: localmatrixwrapper.hh:37