1#ifndef DUNE_FEM_LOCALMATRIXWRAPPER_HH
2#define DUNE_FEM_LOCALMATRIXWRAPPER_HH
4#include <dune/fem/operator/common/localmatrix.hh>
15 template<
class LocalMatrixStack >
16 class LocalMatrixWrapper;
23 template<
class LocalMatrixStack >
24 struct LocalMatrixWrapperTraits
26 typedef LocalMatrixStack LocalMatrixStackType;
28 typedef typename LocalMatrixStack::ObjectType WrappedLocalMatrixType;
30 typedef LocalMatrixWrapper< LocalMatrixStackType > LocalMatrixType;
32 typedef typename WrappedLocalMatrixType::RangeFieldType RangeFieldType;
34 typedef typename WrappedLocalMatrixType::DomainSpaceType DomainSpaceType;
35 typedef typename WrappedLocalMatrixType::RangeSpaceType RangeSpaceType;
37 typedef typename WrappedLocalMatrixType::LittleBlockType LittleBlockType;
45 template<
class LocalMatrixStack >
46 class LocalMatrixWrapper
47 :
public LocalMatrixInterface< LocalMatrixWrapperTraits< LocalMatrixStack > >
49 typedef LocalMatrixWrapper< LocalMatrixStack > ThisType;
50 typedef LocalMatrixInterface< LocalMatrixWrapperTraits< LocalMatrixStack > > BaseType;
54 typedef LocalMatrixStack LocalMatrixStackType;
57 typedef LocalMatrixWrapperTraits< LocalMatrixStackType > Traits;
60 typedef typename Traits::WrappedLocalMatrixType WrappedLocalMatrixType;
62 typedef typename Traits::RangeFieldType RangeFieldType;
70 typedef typename BaseType::DomainEntityType DomainEntityType;
71 typedef typename BaseType::RangeEntityType RangeEntityType;
74 typedef typename LocalMatrixStackType::PointerType WrappedLocalMatrixPtrType;
78 WrappedLocalMatrixPtrType localMatrixPtr_;
81 WrappedLocalMatrixType &localMatrix_;
85 explicit LocalMatrixWrapper ( LocalMatrixStackType &stack )
86 : localMatrixPtr_( stack.getObject() ),
87 localMatrix_( *localMatrixPtr_ )
91 template<
class DomainEntityType,
class RangeEntityType >
92 LocalMatrixWrapper( LocalMatrixStackType &stack,
93 const DomainEntityType &domainEntity,
94 const RangeEntityType &rangeEntity )
95 : localMatrixPtr_( stack.getObject() ),
96 localMatrix_( *localMatrixPtr_ )
99 localMatrix().init( domainEntity, rangeEntity );
106 LocalMatrixWrapper (
const ThisType &other )
107 : localMatrixPtr_( other.localMatrixPtr_ ),
108 localMatrix_( *localMatrixPtr_ )
112 ~LocalMatrixWrapper ( )
116 localMatrix().finalize();
119 ThisType& operator= (
const ThisType& ) =
delete;
122 void init (
const DomainEntityType &domainEntity,
const RangeEntityType &rangeEntity )
124 localMatrix().init( domainEntity, rangeEntity );
128 void add (
int localRow,
int localCol,
const RangeFieldType &value )
130 localMatrix().add( localRow, localCol, value );
134 void set (
int localRow,
int localCol,
const RangeFieldType &value )
136 localMatrix().set( localRow, localCol, value );
140 void clearRow (
const int localRow )
142 localMatrix().clearRow( localRow );
146 void clearCol (
const int localCol )
148 localMatrix().clearCol( localCol );
152 const RangeFieldType
get (
const int localRow,
153 const int localCol )
const
155 return localMatrix().get( localRow, localCol );
159 void scale (
const RangeFieldType& scalar )
161 return localMatrix().scale( scalar );
167 return localMatrix().clear();
173 return localMatrix().resort();
179 return localMatrix().rows();
185 return localMatrix().columns();
189 template <
class DomainLocalFunctionImp,
190 class RangeLocalFunctionImp>
191 void multiplyAdd(
const DomainLocalFunctionImp& dLf,
192 RangeLocalFunctionImp& rLf)
194 localMatrix().multiplyAdd( dLf, rLf);
198 const DomainSpaceType &domainSpace ()
const
200 return localMatrix().domainSpace();
204 const RangeSpaceType &rangeSpace ()
const
206 return localMatrix().rangeSpace();
209 const DomainEntityType &domainEntity ()
const {
return localMatrix().domainEntity(); }
210 const RangeEntityType &rangeEntity ()
const {
return localMatrix().rangeEntity(); }
213 const DomainBasisFunctionSetType &domainBasisFunctionSet ()
const
215 return localMatrix().domainBasisFunctionSet();
219 const RangeBasisFunctionSetType &rangeBasisFunctionSet ()
const
221 return localMatrix().rangeBasisFunctionSet();
225 const WrappedLocalMatrixType &localMatrix ()
const {
return localMatrix_; }
226 WrappedLocalMatrixType &localMatrix () {
return localMatrix_; }
Traits::DomainSpaceType DomainSpaceType
type of domain discrete function space
Definition: localmatrix.hh:54
Traits::RangeSpaceType RangeSpaceType
type of range discrete function space
Definition: localmatrix.hh:57
RangeSpaceType::BasisFunctionSetType RangeBasisFunctionSetType
type of base function sets within range function space
Definition: localmatrix.hh:65
DomainSpaceType::BasisFunctionSetType DomainBasisFunctionSetType
type of base function sets within domain function space
Definition: localmatrix.hh:61
void multiplyAdd(const DomainLocalFunctionType &lhs, RangeLocalFunctionType &rhs) const
multiply left hand side with local matrix and add to right hand side rhs += Matrix * lhs
Definition: localmatrix.hh:165
Dune namespace.
Definition: alignedallocator.hh:13
constexpr auto get(std::integer_sequence< T, II... >, std::integral_constant< std::size_t, pos >={})
Return the entry at position pos of the given sequence.
Definition: integersequence.hh:22