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 >
320 template<
class DomainEntityType,
class RangeEntityType >
401 template <
class DomainLocalFunctionType,
402 class RangeLocalFunctionType>
404 RangeLocalFunctionType& rhs)
const
406 const int row = this->
rows();
407 const int col = this->
columns();
408 for(
int i=0; i<row; ++i)
410 for(
int j=0; j<col; ++j)
412 rhs[i] += this->
get(i,j) * lhs[j];
420 const int col = this->
columns();
421 for(
int j = 0; j < col; ++j)
423 this->
set(localRow, j, 0);
430 const int row = this->
rows();
431 for(
int i = 0; i < row; ++i)
433 this->
set(i, localCol, 0);
438 template <
class Traits>
449 typedef typename RangeSpaceType :: RangeType
RangeType ;
485 template <
class RangeVectorType>
486 void axpy(
const RangeVectorType& phi,
490 const unsigned int numBasisFunctions =
localMatrix_.rows();
491 assert( phi.size() >= numBasisFunctions );
492 for(
unsigned int row = 0; row < numBasisFunctions; ++ row )
511 template <
class JacobianVectorType>
512 void axpy(
const JacobianVectorType& dphi,
516 const unsigned int numBasisFunctions =
localMatrix_.rows();
517 assert( dphi.size() >= numBasisFunctions );
518 for(
unsigned int row = 0; row < numBasisFunctions; ++ row )
521 for(
int k = 0; k < jacobianFactor.rows; ++k )
522 value += jacobianFactor[ k ] * dphi[ row ][ k ];
542 template <
class RangeVectorType,
class JacobianVectorType>
543 void axpy(
const RangeVectorType& phi,
544 const JacobianVectorType& dphi,
549 const unsigned int numBasisFunctions =
localMatrix_.rows();
550 assert( phi.size() >= numBasisFunctions );
551 assert( dphi.size() >= numBasisFunctions );
552 for(
unsigned int row = 0; row < numBasisFunctions; ++ row )
555 for(
int k = 0; k < jacobianFactor.rows; ++k )
556 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:440
Traits::LocalMatrixType LocalMatrixType
type of local matrix implementation
Definition: localmatrix.hh:443
Traits::RangeSpaceType RangeSpaceType
type of domain discrete function space
Definition: localmatrix.hh:446
RangeSpaceType::JacobianRangeType JacobianRangeType
type of jacobian range
Definition: localmatrix.hh:451
RangeSpaceType::RangeType RangeType
type of range
Definition: localmatrix.hh:449
LocalMatrixType & localMatrix_
Definition: localmatrix.hh:457
RangeSpaceType::RangeFieldType RangeFieldType
type of range field
Definition: localmatrix.hh:453
void axpy(const RangeVectorType &phi, const Explicit< RangeType > &factor, const RangeFieldType &weight=RangeFieldType(1))
axpy operation for local matrices
Definition: localmatrix.hh:486
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:543
void axpy(const JacobianVectorType &dphi, const JacobianRangeType &jacobianFactor, const RangeFieldType &weight=RangeFieldType(1))
axpy operation for local matrices
Definition: localmatrix.hh:512
const unsigned int column_
Definition: localmatrix.hh:459
Interface for local matrix classes.
Definition: localmatrix.hh:32
void unbind()
clear local matrix from entities
Definition: localmatrix.hh:103
void resort()
resort ordering in global matrix (if possible)
Definition: localmatrix.hh:199
Traits::LittleBlockType LittleBlockType
Definition: localmatrix.hh:69
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::LocalMatrixType LocalMatrixType
type of local matrix implementation
Definition: localmatrix.hh:46
const DomainBasisFunctionSetType & domainBasisFunctionSet() const
access to the base function set within the domain space
Definition: localmatrix.hh:233
LocalMatrixInterface()
constructor
Definition: localmatrix.hh:77
Traits::DomainSpaceType DomainSpaceType
type of domain discrete function space
Definition: localmatrix.hh:52
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 Implementation & asImp() const
Definition: bartonnackmaninterface.hh:37
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 DomainSpaceType & domainSpace() const
access to the domain space
Definition: localmatrix.hh:219
Traits::RangeSpaceType RangeSpaceType
type of range discrete function space
Definition: localmatrix.hh:55
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
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
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
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
Traits::RangeFieldType RangeFieldType
type of range field
Definition: localmatrix.hh:49
void finalize()
finalize local matrix setup and possibly add values to real matrix
Definition: localmatrix.hh:270
MatrixColumnObject< Traits > MatrixColumnType
Definition: localmatrix.hh:71
const RangeSpaceType & rangeSpace() const
access to the range space
Definition: localmatrix.hh:226
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
int columns() const
get number of columns within the matrix
Definition: localmatrix.hh:212
const RangeEntityType & rangeEntity() const
Definition: localmatrix.hh:252
const DomainEntityType & domainEntity() const
Definition: localmatrix.hh:246
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
const RangeBasisFunctionSetType & rangeBasisFunctionSet() const
access to the base function set within the range space
Definition: localmatrix.hh:240
Default implementation for local matrix classes.
Definition: localmatrix.hh:285
void clearRow(const int localRow)
set row to zero values
Definition: localmatrix.hh:418
void bind(const DomainEntityType &domainEntity, const RangeEntityType &rangeEntity)
initialize the local matrix to entities
Definition: localmatrix.hh:350
void resort()
resort ordering in global matrix (if possible)
Definition: localmatrix.hh:368
const RangeEntityType & rangeEntity() const
Definition: localmatrix.hh:398
void init(const DomainEntityType &domainEntity, const RangeEntityType &rangeEntity)
initialize the local matrix to entities
Definition: localmatrix.hh:344
LocalMatrixDefault(const DomainSpaceType &domainSpace, const RangeSpaceType &rangeSpace, const DomainEntityType &domainEntity, const RangeEntityType &rangeEntity)
Definition: localmatrix.hh:321
const DomainSpaceType & domainSpace_
Definition: localmatrix.hh:302
int rows() const
get number of rows within the matrix
Definition: localmatrix.hh:374
const DomainEntityType & domainEntity() const
Definition: localmatrix.hh:397
const RangeBasisFunctionSetType & rangeBasisFunctionSet() const
access to the base function set within the range space
Definition: localmatrix.hh:392
const RangeSpaceType & rangeSpace() const
access to the range space
Definition: localmatrix.hh:383
DomainBasisFunctionSetType domainBaseSet_
Definition: localmatrix.hh:305
int columns() const
get number of columns within the matrix
Definition: localmatrix.hh:377
const RangeSpaceType & rangeSpace_
Definition: localmatrix.hh:303
void clearCol(const int localCol)
ser column entries to zero
Definition: localmatrix.hh:428
std::optional< DomainEntityType > domainEntity_
Definition: localmatrix.hh:308
BaseType::DomainBasisFunctionSetType DomainBasisFunctionSetType
Definition: localmatrix.hh:295
BaseType::RangeBasisFunctionSetType RangeBasisFunctionSetType
Definition: localmatrix.hh:296
BaseType::RangeEntityType RangeEntityType
Definition: localmatrix.hh:299
std::optional< RangeEntityType > rangeEntity_
Definition: localmatrix.hh:309
LocalMatrixTraits Traits
Definition: localmatrix.hh:290
void unbind()
clear local matrix from entities
Definition: localmatrix.hh:359
const DomainSpaceType & domainSpace() const
access to the domain space
Definition: localmatrix.hh:380
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:403
BaseType::DomainSpaceType DomainSpaceType
Definition: localmatrix.hh:292
const DomainBasisFunctionSetType & domainBasisFunctionSet() const
access to the base function set within the domain space
Definition: localmatrix.hh:386
BaseType::RangeSpaceType RangeSpaceType
Definition: localmatrix.hh:293
LocalMatrixDefault(const LocalMatrixDefault &org)
Definition: localmatrix.hh:333
LocalMatrixDefault(const DomainSpaceType &domainSpace, const RangeSpaceType &rangeSpace)
Definition: localmatrix.hh:312
RangeBasisFunctionSetType rangeBaseSet_
Definition: localmatrix.hh:306
void finalize()
finalize local matrix setup and possibly add values to real matrix
Definition: localmatrix.hh:371
Traits::RangeFieldType RangeFieldType
Definition: temporarylocalmatrix.hh:115