1 #ifndef DUNE_FEM_LOCALMATRIX_HH
2 #define DUNE_FEM_LOCALMATRIX_HH
6 #include "../../common/explicitfieldvector.hh"
19 template <
class Traits>
20 class MatrixColumnObject ;
28 template<
class LocalMatrixTraits >
31 typename LocalMatrixTraits::LocalMatrixType >
35 typename LocalMatrixTraits::LocalMatrixType >
58 typedef typename DomainSpaceType :: BasisFunctionSetType
62 typedef typename RangeSpaceType :: BasisFunctionSetType
87 CHECK_AND_CALL_INTERFACE_IMPLEMENTATION
97 CHECK_AND_CALL_INTERFACE_IMPLEMENTATION
105 CHECK_AND_CALL_INTERFACE_IMPLEMENTATION(
asImp().
unbind() );
114 void add (
const int localRow,
118 CHECK_AND_CALL_INTERFACE_IMPLEMENTATION(
119 asImp().
add(localRow,localCol,value));
128 void set (
const int localRow,
132 CHECK_AND_CALL_INTERFACE_IMPLEMENTATION(
133 asImp().
set(localRow,localCol,value));
141 CHECK_AND_CALL_INTERFACE_IMPLEMENTATION(
151 CHECK_AND_CALL_INTERFACE_IMPLEMENTATION(
161 template <
class DomainLocalFunctionType,
162 class RangeLocalFunctionType>
164 RangeLocalFunctionType& rhs)
const
166 CHECK_AND_CALL_INTERFACE_IMPLEMENTATION(
177 const int localCol )
const
179 CHECK_INTERFACE_IMPLEMENTATION(
asImp().
get(localRow,localCol));
180 return asImp().get(localRow,localCol);
188 CHECK_AND_CALL_INTERFACE_IMPLEMENTATION(
195 CHECK_AND_CALL_INTERFACE_IMPLEMENTATION(
asImp().
clear());
201 CHECK_AND_CALL_INTERFACE_IMPLEMENTATION(
asImp().
resort());
207 CHECK_AND_CALL_INTERFACE_IMPLEMENTATION(
asImp().
rows() );
208 return asImp().rows();
214 CHECK_AND_CALL_INTERFACE_IMPLEMENTATION(
asImp().
columns() );
215 return asImp().columns();
222 return asImp().domainSpace();
229 return asImp().rangeSpace();
236 return asImp().domainBasisFunctionSet();
243 return asImp().rangeBasisFunctionSet();
249 return asImp().domainEntity();
255 return asImp().rangeEntity();
282 template<
class LocalMatrixTraits >
317 template<
class DomainEntityType,
class RangeEntityType >
390 template <
class DomainLocalFunctionType,
391 class RangeLocalFunctionType>
393 RangeLocalFunctionType& rhs)
const
395 const int row = this->
rows();
396 const int col = this->
columns();
397 for(
int i=0; i<row; ++i)
399 for(
int j=0; j<col; ++j)
401 rhs[i] += this->
get(i,j) * lhs[j];
409 const int col = this->
columns();
410 for(
int j = 0; j < col; ++j)
412 this->
set(localRow, j, 0);
419 const int row = this->
rows();
420 for(
int i = 0; i < row; ++i)
422 this->
set(i, localCol, 0);
427 template <
class Traits>
438 typedef typename RangeSpaceType :: RangeType
RangeType ;
474 template <
class RangeVectorType>
475 void axpy(
const RangeVectorType& phi,
479 const unsigned int numBasisFunctions =
localMatrix_.rows();
480 assert( phi.size() >= numBasisFunctions );
481 for(
unsigned int row = 0; row < numBasisFunctions; ++ row )
500 template <
class JacobianVectorType>
501 void axpy(
const JacobianVectorType& dphi,
505 const unsigned int numBasisFunctions =
localMatrix_.rows();
506 assert( dphi.size() >= numBasisFunctions );
507 for(
unsigned int row = 0; row < numBasisFunctions; ++ row )
510 for(
int k = 0; k < jacobianFactor.rows; ++k )
511 value += jacobianFactor[ k ] * dphi[ row ][ k ];
531 template <
class RangeVectorType,
class JacobianVectorType>
532 void axpy(
const RangeVectorType& phi,
533 const JacobianVectorType& dphi,
538 const unsigned int numBasisFunctions =
localMatrix_.rows();
539 assert( phi.size() >= numBasisFunctions );
540 assert( dphi.size() >= numBasisFunctions );
541 for(
unsigned int row = 0; row < numBasisFunctions; ++ row )
544 for(
int k = 0; k < jacobianFactor.rows; ++k )
545 value += jacobianFactor[ k ] * dphi[ row ][ k ];
Definition: bindguard.hh:11
typename MakeExplicit< FV >::Type Explicit
Definition: explicitfieldvector.hh:171
Definition: bartonnackmaninterface.hh:17
const Implementation & asImp() const
Definition: bartonnackmaninterface.hh:37
Definition: localmatrix.hh:429
LocalMatrixType & localMatrix_
Definition: localmatrix.hh:446
RangeSpaceType ::JacobianRangeType JacobianRangeType
type of jacobian range
Definition: localmatrix.hh:440
void axpy(const RangeVectorType &phi, const Explicit< RangeType > &factor, const RangeFieldType &weight=RangeFieldType(1))
axpy operation for local matrices
Definition: localmatrix.hh:475
RangeSpaceType ::RangeType RangeType
type of range
Definition: localmatrix.hh:438
Traits ::RangeSpaceType RangeSpaceType
type of domain discrete function space
Definition: localmatrix.hh:435
void axpy(const RangeVectorType &phi, const JacobianVectorType &dphi, const Explicit< RangeType > &factor, const JacobianRangeType &jacobianFactor, const RangeFieldType &weight=RangeFieldType(1))
axpy operation for local matrices
Definition: localmatrix.hh:532
void axpy(const JacobianVectorType &dphi, const JacobianRangeType &jacobianFactor, const RangeFieldType &weight=RangeFieldType(1))
axpy operation for local matrices
Definition: localmatrix.hh:501
MatrixColumnObject(LocalMatrixType &localMatrix, const unsigned int col)
constructor taking local matrix and column number
Definition: localmatrix.hh:451
Traits ::LocalMatrixType LocalMatrixType
type of local matrix implementation
Definition: localmatrix.hh:432
const unsigned int column_
Definition: localmatrix.hh:448
RangeSpaceType ::RangeFieldType RangeFieldType
type of range field
Definition: localmatrix.hh:442
Interface for local matrix classes.
Definition: localmatrix.hh:32
void unbind()
clear local matrix from entities
Definition: localmatrix.hh:103
const RangeBasisFunctionSetType & rangeBasisFunctionSet() const
access to the base function set within the range space
Definition: localmatrix.hh:240
void resort()
resort ordering in global matrix (if possible)
Definition: localmatrix.hh:199
const RangeSpaceType & rangeSpace() const
access to the range space
Definition: localmatrix.hh:226
DomainSpaceType ::BasisFunctionSetType DomainBasisFunctionSetType
type of base function sets within domain function space
Definition: localmatrix.hh:59
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: localmatrix.hh:176
void clear()
set all entries of local matrix to zero
Definition: localmatrix.hh:193
void scale(const RangeFieldType &scalar)
scale matrix with scalar value
Definition: localmatrix.hh:186
Traits ::RangeFieldType RangeFieldType
type of range field
Definition: localmatrix.hh:49
LocalMatrixInterface()
constructor
Definition: localmatrix.hh:77
RangeSpaceType ::BasisFunctionSetType RangeBasisFunctionSetType
type of base function sets within range function space
Definition: localmatrix.hh:63
const RangeEntityType & rangeEntity() const
Definition: localmatrix.hh:252
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:114
const DomainEntityType & domainEntity() const
Definition: localmatrix.hh:246
static const Implementation & asImp(const ThisType &other)
Definition: bartonnackmaninterface.hh:27
Traits ::RangeSpaceType RangeSpaceType
type of range discrete function space
Definition: localmatrix.hh:55
void init(const DomainEntityType &domainEntity, const RangeEntityType &rangeEntity)
initialize the local matrix to entities
Definition: localmatrix.hh:85
int rows() const
get number of rows within the matrix
Definition: localmatrix.hh:205
const DomainBasisFunctionSetType & domainBasisFunctionSet() const
access to the base function set within the domain space
Definition: localmatrix.hh:233
void set(const int localRow, const int localCol, const RangeFieldType &value)
set value of matrix entry (row,col) where row and col are local row and local column
Definition: localmatrix.hh:128
Traits ::DomainSpaceType DomainSpaceType
type of domain discrete function space
Definition: localmatrix.hh:52
RangeSpaceType::EntityType RangeEntityType
Definition: localmatrix.hh:66
void bind(const DomainEntityType &domainEntity, const RangeEntityType &rangeEntity)
initialize the local matrix to entities
Definition: localmatrix.hh:95
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:163
void clearRow(const int localRow)
set row to zero values
Definition: localmatrix.hh:139
void finalize()
finalize local matrix setup and possibly add values to real matrix
Definition: localmatrix.hh:270
MatrixColumnObject< Traits > MatrixColumnType
Definition: localmatrix.hh:71
ThisType LocalMatrixInterfaceType
type of this interface
Definition: localmatrix.hh:43
DomainSpaceType::EntityType DomainEntityType
Definition: localmatrix.hh:65
LocalMatrixTraits Traits
type of traits class
Definition: localmatrix.hh:40
Traits ::LittleBlockType LittleBlockType
Definition: localmatrix.hh:69
int columns() const
get number of columns within the matrix
Definition: localmatrix.hh:212
const DomainSpaceType & domainSpace() const
access to the domain space
Definition: localmatrix.hh:219
Traits ::LocalMatrixType LocalMatrixType
type of local matrix implementation
Definition: localmatrix.hh:46
MatrixColumnType column(const unsigned int col)
return column object for local matrix which contains axpy methods for convenience
Definition: localmatrix.hh:264
void clearCol(const int localCol)
ser column entries to zero
Definition: localmatrix.hh:149
Default implementation for local matrix classes.
Definition: localmatrix.hh:285
void clearRow(const int localRow)
set row to zero values
Definition: localmatrix.hh:407
void bind(const DomainEntityType &domainEntity, const RangeEntityType &rangeEntity)
initialize the local matrix to entities
Definition: localmatrix.hh:343
void resort()
resort ordering in global matrix (if possible)
Definition: localmatrix.hh:357
const DomainSpaceType & domainSpace() const
access to the domain space
Definition: localmatrix.hh:369
void init(const DomainEntityType &domainEntity, const RangeEntityType &rangeEntity)
initialize the local matrix to entities
Definition: localmatrix.hh:337
LocalMatrixDefault(const DomainSpaceType &domainSpace, const RangeSpaceType &rangeSpace, const DomainEntityType &domainEntity, const RangeEntityType &rangeEntity)
Definition: localmatrix.hh:318
const DomainSpaceType & domainSpace_
Definition: localmatrix.hh:302
int rows() const
get number of rows within the matrix
Definition: localmatrix.hh:363
DomainBasisFunctionSetType domainBaseSet_
Definition: localmatrix.hh:305
int columns() const
get number of columns within the matrix
Definition: localmatrix.hh:366
const DomainEntityType & domainEntity() const
Definition: localmatrix.hh:386
const RangeSpaceType & rangeSpace_
Definition: localmatrix.hh:303
void clearCol(const int localCol)
ser column entries to zero
Definition: localmatrix.hh:417
BaseType::DomainBasisFunctionSetType DomainBasisFunctionSetType
Definition: localmatrix.hh:295
BaseType::RangeBasisFunctionSetType RangeBasisFunctionSetType
Definition: localmatrix.hh:296
BaseType::RangeEntityType RangeEntityType
Definition: localmatrix.hh:299
LocalMatrixTraits Traits
Definition: localmatrix.hh:290
const RangeSpaceType & rangeSpace() const
access to the range space
Definition: localmatrix.hh:372
void unbind()
clear local matrix from entities
Definition: localmatrix.hh:350
const DomainBasisFunctionSetType & domainBasisFunctionSet() const
access to the base function set within the domain space
Definition: localmatrix.hh:375
BaseType::DomainEntityType DomainEntityType
Definition: localmatrix.hh:298
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:392
const RangeEntityType & rangeEntity() const
Definition: localmatrix.hh:387
BaseType::DomainSpaceType DomainSpaceType
Definition: localmatrix.hh:292
BaseType::RangeSpaceType RangeSpaceType
Definition: localmatrix.hh:293
LocalMatrixDefault(const LocalMatrixDefault &org)
Definition: localmatrix.hh:328
const RangeBasisFunctionSetType & rangeBasisFunctionSet() const
access to the base function set within the range space
Definition: localmatrix.hh:381
LocalMatrixDefault(const DomainSpaceType &domainSpace, const RangeSpaceType &rangeSpace)
Definition: localmatrix.hh:309
RangeBasisFunctionSetType rangeBaseSet_
Definition: localmatrix.hh:306
void finalize()
finalize local matrix setup and possibly add values to real matrix
Definition: localmatrix.hh:360