Finite Element Domain Decomposition Library
FEDDLib
Loading...
Searching...
No Matches
BlockMatrix_decl.hpp
1#ifndef BLOCKMATRIX_DECL_hpp
2#define BLOCKMATRIX_DECL_hpp
3
4#include "feddlib/core/General/DefaultTypeDefs.hpp"
5#include "feddlib/core/General/SmallMatrix.hpp"
6#include "BlockMap.hpp"
7#include "BlockMultiVector.hpp"
8#include "Matrix.hpp"
9#include <Teuchos_Tuple.hpp>
10#include <Thyra_BlockedLinearOpBase.hpp>
11#include <Thyra_DefaultBlockedLinearOp_decl.hpp>
20
21namespace FEDD {
22template <class SC = default_sc, class LO = default_lo, class GO = default_go, class NO = default_no>
23class BlockMatrix {
24
25public:
26
27 typedef Matrix<SC,LO,GO,NO> Matrix_Type;
28 typedef Teuchos::RCP<Matrix_Type> MatrixPtr_Type;
29 typedef Teuchos::RCP<const Matrix_Type> MatrixConstPtr_Type;
30
31 typedef typename Matrix_Type::Map_Type Map_Type;
32 typedef typename Matrix_Type::MapPtr_Type MapPtr_Type;
33 typedef typename Matrix_Type::MapConstPtr_Type MapConstPtr_Type;
34
35 typedef typename Matrix_Type::MultiVector_Type MultiVector_Type;
36 typedef typename Matrix_Type::MultiVectorPtr_Type MultiVectorPtr_Type;
37 typedef typename Matrix_Type::MultiVectorConstPtr_Type MultiVectorConstPtr_Type;
38
39 typedef BlockMultiVector<SC,LO,GO,NO> BlockMultiVector_Type;
40 typedef Teuchos::RCP<BlockMultiVector_Type> BlockMultiVectorPtr_Type;
41
42 typedef BlockMatrix<SC,LO,GO,NO> BlockMatrix_Type;
43 typedef Teuchos::RCP<BlockMatrix_Type> BlockMatrixPtr_Type;
44
45 typedef BlockMap<LO,GO,NO> BlockMap_Type;
46 typedef Teuchos::RCP<BlockMap_Type> BlockMapPtr_Type;
47
48 typedef Teuchos::Tuple<GO, 2> GOTuple_Type;
49 typedef Teuchos::Tuple<LO, 2> LOTuple_Type;
50
51 BlockMatrix();
52
53 BlockMatrix(UN size);
54
55 // TODO
56 BlockMatrix(BlockMatrixPtr_Type bMatrixIn);
57
58 ~BlockMatrix();
59
60 int size() const;
61
62 void resize(UN size);
63
64 MatrixPtr_Type getBlock(int i, int j);
65
66 MatrixConstPtr_Type getBlockConst(int i, int j) const;
67
68 bool blockExists(int i, int j) const;
69
70 void addBlock(const MatrixPtr_Type& matrix, int i, int j);
71
72 void merge();
73
74 void mergeBlockNew(UN blockRow, UN blockCol);
75
76 void determineLocalOffsets();
77
78 void determineGlobalOffsets();
79
80 void print(Teuchos::EVerbosityLevel verbLevel=Teuchos::VERB_EXTREME);
81
82 void printMerge(Teuchos::EVerbosityLevel verbLevel=Teuchos::VERB_EXTREME);
83
84 void writeMM(std::string fN="blockMat") const;
85
86 Teuchos::RCP<const Thyra::LinearOpBase<SC> > getThyraLinOp();
87
88 Teuchos::RCP<const Thyra::BlockedLinearOpBase<SC> > getThyraLinBlockOp() const;
89
90 void apply(const BlockMultiVector_Type& X,
91 BlockMultiVector_Type& Y ) const;
92
93 void apply(const BlockMultiVector_Type& X,
94 BlockMultiVector_Type& Y,
95 const SmallMatrix<SC>& coeff) const;
96
97 void addMatrix( const SmallMatrix<SC>& coeffAlpha, const BlockMatrixPtr_Type& matrix, const SmallMatrix<SC>& coeffbeta );
98
99 MatrixPtr_Type getMergedMatrix();
100
101 BlockMapPtr_Type getMap();
102protected:
103
104 SmallMatrix<MatrixPtr_Type> blockMatrix_;
105 BlockMapPtr_Type blockMap_;
106 MatrixPtr_Type mergedMatrix_;
107 MapPtr_Type mergedMap_;
108 Teuchos::RCP<SmallMatrix<GOTuple_Type> > globalBlockOffsets_;
109 Teuchos::RCP<SmallMatrix<LOTuple_Type> > localBlockOffsets_;
110};
111
112}
113#endif
Block Variant of Map class.
Definition BlockMap_decl.hpp:38
Definition BlockMultiVector_decl.hpp:25
Definition Matrix_decl.hpp:32
This class represents a templated small Matrix of type T. Primarily created for 2x2 and 3x3 matrices....
Definition SmallMatrix.hpp:22
Adaptive Mesh Refinement.
Definition AdaptiveMeshRefinement.cpp:5