Finite Element Domain Decomposition Library
FEDDLib
Loading...
Searching...
No Matches
BlockMultiVector_decl.hpp
1#ifndef BlockMultiVector_DECL_hpp
2#define BlockMultiVector_DECL_hpp
3
4#include "feddlib/core/FEDDCore.hpp"
5#include "feddlib/core/General/DefaultTypeDefs.hpp"
6#include "BlockMap.hpp"
7#include "MultiVector.hpp"
8#include <Thyra_ProductVectorSpaceBase.hpp>
9#include <Thyra_DefaultProductMultiVector_decl.hpp>
18
19namespace FEDD {
20template <class SC, class LO, class GO, class NO>
21class MultiVector;
22template <class LO, class GO, class NO>
23class BlockMap;
24template <class SC = default_sc, class LO = default_lo, class GO = default_go, class NO = default_no>
25class BlockMultiVector {
26
27public:
28
29 typedef BlockMultiVector<SC,LO,GO,NO> BlockMultiVector_Type;
30 typedef Teuchos::RCP<BlockMultiVector_Type> BlockMultiVectorPtr_Type;
31 typedef Teuchos::RCP<const BlockMultiVector_Type> BlockMultiVectorConstPtr_Type;
32
33 typedef MultiVector<SC,LO,GO,NO> MultiVector_Type;
34 typedef Teuchos::RCP<MultiVector_Type> MultiVectorPtr_Type;
35 typedef Teuchos::RCP<const MultiVector_Type> MultiVectorConstPtr_Type;
36
37 typedef typename MultiVector_Type::Map_Type Map_Type;
38 typedef typename MultiVector_Type::MapPtr_Type MapPtr_Type;
39 typedef typename MultiVector_Type::MapConstPtr_Type MapConstPtr_Type;
40
41 typedef typename MultiVector_Type::Comm_Type Comm_Type;
42 typedef typename MultiVector_Type::CommConstPtr_Type CommConstPtr_Type;
43
44 typedef BlockMap<LO,GO,NO> BlockMap_Type;
45 typedef Teuchos::RCP<BlockMap_Type> BlockMapPtr_Type;
46 typedef Teuchos::RCP<const BlockMap_Type> BlockMapConstPtr_Type;
47
48 BlockMultiVector();
49
50 BlockMultiVector(UN size);
51
52 BlockMultiVector( BlockMultiVectorPtr_Type bMVIn);
53
54 BlockMultiVector( std::vector<MapConstPtr_Type>& maps, int numMV = 1 );
55
56 BlockMultiVector( BlockMapConstPtr_Type blockMap, int numMV = 1 );
57
58 ~BlockMultiVector();
59
60 BlockMultiVector_Type& operator= (const BlockMultiVector_Type& rhs) {
61 TEUCHOS_TEST_FOR_EXCEPTION( size() != rhs.size(), std::logic_error,"BlockMultiVector sizes are not equal for deep copy.");
62 for (int i=0; i<size(); i++) {
63 *blockMultiVector_[i] = *rhs[i];
64 }
65 return *this;
66 }
67
68 MultiVectorPtr_Type operator[] (int i) const{
69 TEUCHOS_TEST_FOR_EXCEPTION( i > size()-1, std::logic_error,"The requested MultiVector does not exist in BlockMultiVector.");
70 return blockMultiVector_[i];
71 }
72
73 void resize( UN size );
74
75 void buildFromMaps( std::vector<MapConstPtr_Type>& maps, int numMV );
76
77 void buildFromBlockMap( BlockMapConstPtr_Type blockMap, int numMV );
78
79 void merge();
80
81 void mergeBlock(UN block);
82
83 void split();
84
85 void splitBlock(UN block);
86
87 void determineLocalOffsets();
88
89 void determineGlobalOffsets();
90
91 void setMergedVector( MultiVectorPtr_Type& mv );
92
93 int size() const;
94
95 UN getNumVectors() const;
96
97 void addBlock(const MultiVectorPtr_Type& multiVector, int i);
98
99 MultiVectorConstPtr_Type getBlock(int i) const;
100
101 MultiVectorPtr_Type getBlockNonConst(int i);
102
103 Teuchos::RCP< Thyra::MultiVectorBase<SC> > getThyraMultiVector( );
104
105 Teuchos::RCP<const Thyra::MultiVectorBase<SC> > getThyraMultiVectorConst( );
106
107 Teuchos::RCP< Thyra::ProductMultiVectorBase<SC> > getProdThyraMultiVector( );
108
109 Teuchos::RCP<const Thyra::ProductMultiVectorBase<SC> > getThyraProdMultiVectorConst( ) const;
110
111 void fromThyraMultiVector( Teuchos::RCP< Thyra::MultiVectorBase<SC> > thyraMV);
112
113 void fromThyraProdMultiVector( Teuchos::RCP< Thyra::ProductMultiVectorBase<SC> > thyraMV);
114
115 void norm2(const Teuchos::ArrayView<typename Teuchos::ScalarTraits<SC>::magnitudeType> &norms) const;
116
117 void normInf(const Teuchos::ArrayView<typename Teuchos::ScalarTraits<SC>::magnitudeType> &norms) const;
118
119 void dot(BlockMultiVectorConstPtr_Type a, const Teuchos::ArrayView<typename Teuchos::ScalarTraits<SC>::magnitudeType> &dots) ;
120
121 void update( const SC& alpha, const BlockMultiVector_Type& A, const SC& beta );
122
123 void update( const SC& alpha, const BlockMultiVector_Type& A, const SC& beta , const BlockMultiVector_Type& B, const SC& gamma);
124
125 BlockMultiVectorPtr_Type sumColumns() const;
126
127 // Matrix-matrix multiplication: this = beta*this + alpha*op(A)*op(B).
128 void multiply(Teuchos::ETransp transA, Teuchos::ETransp transB, const SC &alpha, BlockMultiVectorConstPtr_Type &A, BlockMultiVectorConstPtr_Type &B, const SC &beta);
129
130 void putScalar( const SC& alpha );
131
132 void scale( const SC& alpha );
133
134 void writeMM(std::string fN = "blockMV") const;
135
136 void print(Teuchos::EVerbosityLevel verbLevel=Teuchos::VERB_EXTREME);
137
138 BlockMapConstPtr_Type getMap() const;
139
140 MultiVectorConstPtr_Type getMergedVector();
141
142private:
143
144 Teuchos::Array<MultiVectorPtr_Type> blockMultiVector_;
145 BlockMapPtr_Type blockMap_;
146 MultiVectorPtr_Type mergedMultiVector_;
147 MapPtr_Type mergedMap_;
148 Teuchos::ArrayRCP<LO> localBlockOffsets_;
149 Teuchos::ArrayRCP<GO> globalBlockOffsets_;
150};
151}
152
153#endif
Block Variant of Map class.
Definition BlockMap_decl.hpp:38
Definition MultiVector_decl.hpp:36
Adaptive Mesh Refinement.
Definition AdaptiveMeshRefinement.cpp:5