1 #ifndef DUNE_FEM_LOCALMATRIX_HH 2 #define DUNE_FEM_LOCALMATRIX_HH 18 template <
class Traits>
27 template<
class LocalMatrixTraits >
30 typename LocalMatrixTraits::LocalMatrixType >
34 typename LocalMatrixTraits::LocalMatrixType >
57 typedef typename DomainSpaceType :: BasisFunctionSetType
61 typedef typename RangeSpaceType :: BasisFunctionSetType
86 CHECK_AND_CALL_INTERFACE_IMPLEMENTATION
87 (
asImp().
init( domainEntity, rangeEntity ) );
96 void add (
const int localRow,
98 const RangeFieldType &value )
100 CHECK_AND_CALL_INTERFACE_IMPLEMENTATION(
101 asImp().
add(localRow,localCol,value));
110 void set (
const int localRow,
112 const RangeFieldType &value )
114 CHECK_AND_CALL_INTERFACE_IMPLEMENTATION(
115 asImp().
set(localRow,localCol,value));
123 CHECK_AND_CALL_INTERFACE_IMPLEMENTATION(
133 CHECK_AND_CALL_INTERFACE_IMPLEMENTATION(
143 template <
class DomainLocalFunctionType,
144 class RangeLocalFunctionType>
146 RangeLocalFunctionType& rhs)
const 148 CHECK_AND_CALL_INTERFACE_IMPLEMENTATION(
158 const RangeFieldType
get (
const int localRow,
159 const int localCol )
const 161 CHECK_INTERFACE_IMPLEMENTATION(
162 asImp().
get(localRow,localCol));
163 return asImp().get(localRow,localCol);
169 void scale (
const RangeFieldType& scalar )
171 CHECK_AND_CALL_INTERFACE_IMPLEMENTATION(
178 CHECK_AND_CALL_INTERFACE_IMPLEMENTATION(
asImp().
clear());
184 CHECK_AND_CALL_INTERFACE_IMPLEMENTATION(
asImp().
resort());
190 CHECK_AND_CALL_INTERFACE_IMPLEMENTATION(
asImp().
rows() );
191 return asImp().rows();
197 CHECK_AND_CALL_INTERFACE_IMPLEMENTATION(
asImp().
columns() );
198 return asImp().columns();
205 return asImp().domainSpace();
212 return asImp().rangeSpace();
219 return asImp().domainBasisFunctionSet();
226 return asImp().rangeBasisFunctionSet();
232 return asImp().domainEntity();
238 return asImp().rangeEntity();
247 MatrixColumnType
column(
const unsigned int col )
265 template<
class LocalMatrixTraits >
294 : domainSpace_( domainSpace ),
295 rangeSpace_( rangeSpace ),
300 template<
class DomainEntityType,
class RangeEntityType >
305 : domainSpace_( domainSpace ),
306 rangeSpace_( rangeSpace ),
307 domainBaseSet_( domainSpace.basisFunctionSet( domainEntity ) ),
308 rangeBaseSet_( rangeSpace.basisFunctionSet( rangeEntity ) )
312 : domainSpace_( org.domainSpace_ ),
313 rangeSpace_( org.rangeSpace_ ),
314 domainBaseSet_( org.domainBaseSet_ ),
315 rangeBaseSet_( org.rangeBaseSet_ )
322 domainBaseSet_ = domainSpace_.basisFunctionSet( domainEntity );
323 rangeBaseSet_ = rangeSpace_.basisFunctionSet( rangeEntity );
333 int rows ()
const {
return rangeBaseSet_.size(); }
336 int columns ()
const {
return domainBaseSet_.size(); }
339 const DomainSpaceType &
domainSpace ()
const {
return domainSpace_; }
342 const RangeSpaceType &
rangeSpace ()
const {
return rangeSpace_; }
347 return domainBaseSet_;
353 return rangeBaseSet_;
360 template <
class DomainLocalFunctionType,
361 class RangeLocalFunctionType>
363 RangeLocalFunctionType& rhs)
const 365 const int row = this->
rows();
366 const int col = this->
columns();
367 for(
int i=0; i<row; ++i)
369 for(
int j=0; j<col; ++j)
371 rhs[i] += this->
get(i,j) * lhs[j];
379 const int col = this->
columns();
380 for(
int j = 0; j < col; ++j)
382 this->
set(localRow, j, 0);
389 const int row = this->
rows();
390 for(
int i = 0; i < row; ++i)
392 this->
set(i, localCol, 0);
397 template <
class Traits>
408 typedef typename RangeSpaceType :: RangeType
RangeType ;
422 : localMatrix_( localMatrix ),
444 template <
class RangeVectorType>
445 void axpy(
const RangeVectorType& phi,
446 const RangeType& factor,
449 const unsigned int numBasisFunctions = localMatrix_.rows();
450 assert( phi.size() >= numBasisFunctions );
451 for(
unsigned int row = 0; row < numBasisFunctions; ++ row )
453 RangeFieldType value = factor * phi[ row ];
454 localMatrix_.add( row, column_, weight * value );
470 template <
class JacobianVectorType>
471 void axpy(
const JacobianVectorType& dphi,
472 const JacobianRangeType& jacobianFactor,
475 const unsigned int numBasisFunctions = localMatrix_.rows();
476 assert( dphi.size() >= numBasisFunctions );
477 for(
unsigned int row = 0; row < numBasisFunctions; ++ row )
479 RangeFieldType value = 0;
480 for(
int k = 0; k < jacobianFactor.rows; ++k )
481 value += jacobianFactor[ k ] * dphi[ row ][ k ];
483 localMatrix_.add( row, column_, weight * value );
501 template <
class RangeVectorType,
class JacobianVectorType>
502 void axpy(
const RangeVectorType& phi,
503 const JacobianVectorType& dphi,
504 const RangeType& factor,
505 const JacobianRangeType& jacobianFactor,
508 const unsigned int numBasisFunctions = localMatrix_.rows();
509 assert( phi.size() >= numBasisFunctions );
510 assert( dphi.size() >= numBasisFunctions );
511 for(
unsigned int row = 0; row < numBasisFunctions; ++ row )
513 RangeFieldType value = factor * phi[ row ];
514 for(
int k = 0; k < jacobianFactor.rows; ++k )
515 value += jacobianFactor[ k ] * dphi[ row ][ k ];
517 localMatrix_.add( row, column_, weight * value );
528 #endif // #ifndef DUNE_FEM_LOCALMATRIX_HH Traits::DomainSpaceType DomainSpaceType
type of domain discrete function space
Definition: localmatrix.hh:51
int rows() const
get number of rows within the matrix
Definition: localmatrix.hh:188
const DomainBasisFunctionSetType & domainBasisFunctionSet() const
access to the base function set within the domain space
Definition: localmatrix.hh:345
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:145
Traits::RangeSpaceType RangeSpaceType
type of domain discrete function space
Definition: localmatrix.hh:405
BaseType::DomainEntityType DomainEntityType
Definition: localmatrix.hh:281
LocalMatrixDefault(const DomainSpaceType &domainSpace, const RangeSpaceType &rangeSpace)
Definition: localmatrix.hh:292
void axpy(const RangeVectorType &phi, const JacobianVectorType &dphi, const RangeType &factor, const JacobianRangeType &jacobianFactor, const RangeFieldType &weight=RangeFieldType(1))
axpy operation for local matrices
Definition: localmatrix.hh:502
LocalMatrixInterface()
constructor
Definition: localmatrix.hh:76
RangeSpaceType::EntityType RangeEntityType
Definition: localmatrix.hh:65
Traits::RangeFieldType RangeFieldType
type of range field
Definition: localmatrix.hh:48
MatrixColumnObject(LocalMatrixType &localMatrix, const unsigned int col)
constructor taking local matrix and column number
Definition: localmatrix.hh:421
const DomainSpaceType & domainSpace() const
access to the domain space
Definition: localmatrix.hh:339
void init(const DomainEntityType &domainEntity, const RangeEntityType &rangeEntity)
initialize the local matrix to entities
Definition: localmatrix.hh:320
const RangeEntityType & rangeEntity() const
Definition: localmatrix.hh:357
int columns() const
get number of columns within the matrix
Definition: localmatrix.hh:336
const Implementation & asImp() const
Definition: bartonnackmaninterface.hh:37
void clearCol(const int localCol)
ser column entries to zero
Definition: localmatrix.hh:387
const DomainSpaceType & domainSpace() const
access to the domain space
Definition: localmatrix.hh:202
void clearRow(const int localRow)
set row to zero values
Definition: localmatrix.hh:121
Default implementation for local matrix classes.
Definition: localmatrix.hh:266
const unsigned int column_
Definition: localmatrix.hh:418
Traits::LocalMatrixType LocalMatrixType
type of local matrix implementation
Definition: localmatrix.hh:402
MatrixColumnObject< Traits > MatrixColumnType
Definition: localmatrix.hh:70
DomainSpaceType::BasisFunctionSetType DomainBasisFunctionSetType
type of base function sets within domain function space
Definition: localmatrix.hh:58
ThisType LocalMatrixInterfaceType
type of this interface
Definition: localmatrix.hh:42
Interface for local matrix classes.
Definition: localmatrix.hh:28
const RangeSpaceType & rangeSpace() const
access to the range space
Definition: localmatrix.hh:342
RangeBasisFunctionSetType rangeBaseSet_
Definition: localmatrix.hh:289
LocalMatrixTraits Traits
Definition: localmatrix.hh:273
MatrixColumnType column(const unsigned int col)
return column object for local matrix which contains axpy methods for convenience ...
Definition: localmatrix.hh:247
const DomainEntityType & domainEntity() const
Definition: localmatrix.hh:356
LocalMatrixTraits Traits
type of traits class
Definition: localmatrix.hh:39
RangeSpaceType::BasisFunctionSetType RangeBasisFunctionSetType
type of base function sets within range function space
Definition: localmatrix.hh:62
void resort()
resort ordering in global matrix (if possible)
Definition: localmatrix.hh:327
void axpy(const RangeVectorType &phi, const RangeType &factor, const RangeFieldType &weight=RangeFieldType(1))
axpy operation for local matrices
Definition: localmatrix.hh:445
RangeSpaceType::JacobianRangeType JacobianRangeType
type of jacobian range
Definition: localmatrix.hh:410
Definition: coordinate.hh:4
void resort()
resort ordering in global matrix (if possible)
Definition: localmatrix.hh:182
LocalMatrixType & localMatrix_
Definition: localmatrix.hh:416
void finalize()
finalize local matrix setup and possibly add values to real matrix
Definition: localmatrix.hh:253
BaseType::DomainSpaceType DomainSpaceType
Definition: localmatrix.hh:275
Traits::LittleBlockType LittleBlockType
Definition: localmatrix.hh:68
BaseType::RangeSpaceType RangeSpaceType
Definition: localmatrix.hh:276
Traits::RangeSpaceType RangeSpaceType
type of range discrete function space
Definition: localmatrix.hh:54
RangeSpaceType::RangeFieldType RangeFieldType
type of range field
Definition: localmatrix.hh:412
void scale(const RangeFieldType &scalar)
scale matrix with scalar value
Definition: localmatrix.hh:169
void init(const DomainEntityType &domainEntity, const RangeEntityType &rangeEntity)
initialize the local matrix to entities
Definition: localmatrix.hh:84
LocalMatrixDefault(const LocalMatrixDefault &org)
Definition: localmatrix.hh:311
LocalMatrixDefault(const DomainSpaceType &domainSpace, const RangeSpaceType &rangeSpace, const DomainEntityType &domainEntity, const RangeEntityType &rangeEntity)
Definition: localmatrix.hh:301
int rows() const
get number of rows within the matrix
Definition: localmatrix.hh:333
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:362
BaseType::RangeBasisFunctionSetType RangeBasisFunctionSetType
Definition: localmatrix.hh:279
void finalize()
finalize local matrix setup and possibly add values to real matrix
Definition: localmatrix.hh:330
const DomainSpaceType & domainSpace_
Definition: localmatrix.hh:285
Definition: localmatrix.hh:19
int columns() const
get number of columns within the matrix
Definition: localmatrix.hh:195
Traits::LocalMatrixType LocalMatrixType
type of local matrix implementation
Definition: localmatrix.hh:45
const RangeBasisFunctionSetType & rangeBasisFunctionSet() const
access to the base function set within the range space
Definition: localmatrix.hh:223
RangeSpaceType::RangeType RangeType
type of range
Definition: localmatrix.hh:408
DomainBasisFunctionSetType domainBaseSet_
Definition: localmatrix.hh:288
void clearCol(const int localCol)
ser column entries to zero
Definition: localmatrix.hh:131
const RangeSpaceType & rangeSpace_
Definition: localmatrix.hh:286
BaseType::DomainBasisFunctionSetType DomainBasisFunctionSetType
Definition: localmatrix.hh:278
BaseType::RangeEntityType RangeEntityType
Definition: localmatrix.hh:282
const RangeBasisFunctionSetType & rangeBasisFunctionSet() const
access to the base function set within the range space
Definition: localmatrix.hh:351
const RangeEntityType & rangeEntity() const
Definition: localmatrix.hh:235
const RangeSpaceType & rangeSpace() const
access to the range space
Definition: localmatrix.hh:209
void clearRow(const int localRow)
set row to zero values
Definition: localmatrix.hh:377
void axpy(const JacobianVectorType &dphi, const JacobianRangeType &jacobianFactor, const RangeFieldType &weight=RangeFieldType(1))
axpy operation for local matrices
Definition: localmatrix.hh:471
DomainSpaceType::EntityType DomainEntityType
Definition: localmatrix.hh:64
const DomainEntityType & domainEntity() const
Definition: localmatrix.hh:229
void add(const int localRow, const int localCol, const RangeFieldType &value)
add value to matrix entry (row,col) where row and col are local row and local column ...
Definition: localmatrix.hh:96
Definition: bartonnackmaninterface.hh:15
void clear()
set all entries of local matrix to zero
Definition: localmatrix.hh:176
const DomainBasisFunctionSetType & domainBasisFunctionSet() const
access to the base function set within the domain space
Definition: localmatrix.hh:216