4#include "feddlib/core/FEDDCore.hpp"
5#include "feddlib/core/General/DefaultTypeDefs.hpp"
8#include "MultiVector.hpp"
9#include "BlockMultiVector.hpp"
11#include <Xpetra_MatrixFactory.hpp>
12#include <Xpetra_ThyraUtils.hpp>
13#include <Teuchos_VerboseObject.hpp>
14#include <Xpetra_MatrixMatrix.hpp>
15#include <MatrixMarket_Tpetra.hpp>
16#include <TpetraExt_MatrixMatrix.hpp>
19#include <Tpetra_CrsMatrix.hpp>
21#include <MatrixMarket_Tpetra.hpp>
33template <
class SC = default_sc,
class LO = default_lo,
class GO = default_go,
class NO = default_no>
38 typedef Matrix<SC,LO,GO,NO> Matrix_Type;
39 typedef Teuchos::RCP<Matrix_Type> MatrixPtr_Type;
50 typedef Teuchos::RCP<Map_Type> MapPtr_Type;
51 typedef Teuchos::RCP<const Map_Type> MapConstPtr_Type;
54 typedef Teuchos::RCP<MultiVector_Type> MultiVectorPtr_Type;
55 typedef Teuchos::RCP<const MultiVector_Type> MultiVectorConstPtr_Type;
58 typedef Teuchos::RCP<BlockMultiVector_Type> BlockMultiVectorPtr_Type;
61 typedef Teuchos::Comm<int> Comm_Type;
62 typedef Teuchos::RCP<const Comm_Type> CommConstPtr_Type;
64 typedef Tpetra::Import<LO,GO,NO> TpetraImport_Type;
65 typedef Teuchos::RCP<TpetraImport_Type> TpetraImportPtr_Type;
67 typedef Tpetra::Export<LO,GO,NO> TpetraExport_Type;
68 typedef Teuchos::RCP<TpetraExport_Type> TpetraExportPtr_Type;
72 typedef Tpetra::Map<LO,GO,NO> TpetraMap_Type;
73 typedef Teuchos::RCP<TpetraMap_Type> TpetraMapPtr_Type;
74 typedef Teuchos::RCP<const TpetraMap_Type> TpetraMapConstPtr_Type;
75 typedef const TpetraMapConstPtr_Type TpetraMapConstPtrConst_Type;
77 typedef Tpetra::CrsMatrix<SC,LO,GO,NO> TpetraMatrix_Type;
78 typedef Teuchos::RCP<TpetraMatrix_Type> TpetraMatrixPtr_Type;
79 typedef Teuchos::RCP<const TpetraMatrix_Type> TpetraMatrixConstPtr_Type;
80 typedef const Teuchos::RCP<TpetraMatrixConstPtr_Type> TpetraMatrixConstPtrConst_Type;
82 typedef Tpetra::MultiVector<SC,LO,GO,NO> TpetraMV_Type;
83 typedef Teuchos::RCP<TpetraMV_Type> TpetraMVPtr_Type;
87 Matrix( TpetraMatrixPtr_Type& tpetraMatPtrIn );
89 Matrix( MapConstPtr_Type map , LO numEntries);
91 Matrix( MatrixPtr_Type matrixIn );
95 Matrix& operator+=(
const Matrix& matIn);
101 void insertGlobalValues (GO globalRow,
const Teuchos::ArrayView< const GO > &cols,
const Teuchos::ArrayView< const SC > &vals);
112 MapConstPtr_Type
getMap(std::string map_string=
"");
117 MapConstPtr_Type
getMap(std::string map_string=
"")
const;
137 void print(Teuchos::EVerbosityLevel verbLevel=Teuchos::VERB_EXTREME);
152 void fillComplete(MapConstPtr_Type domainMap, MapConstPtr_Type rangeMap);
157 bool isLocallyIndexed();
170 void getGlobalRowView(GO globalRow, Teuchos::ArrayView< const GO > &indices, Teuchos::ArrayView< const SC > &values)
const;
175 void getLocalRowView(LO localRow, Teuchos::ArrayView< const LO > &indices, Teuchos::ArrayView< const SC > &values)
const;
180 void replaceGlobalValues(GO globalRow,
const Teuchos::ArrayView< const GO > &indices,
const Teuchos::ArrayView< const SC > &values);
185 void replaceLocalValues(LO localRow,
const Teuchos::ArrayView< const LO > &indices,
const Teuchos::ArrayView< const SC > &values);
195 void Multiply(
const MatrixPtr_Type &tpA,
bool transposeA ,
const MatrixPtr_Type &tpB,
bool transposeB,
bool fillComplete=
true);
200 void apply(
const MultiVector_Type& X,
202 Teuchos::ETransp mode = Teuchos::NO_TRANS,
203 SC alpha = Teuchos::ScalarTraits<SC>::one(),
204 SC beta = Teuchos::ScalarTraits<SC>::zero() )
const;
214 void writeMM(std::string fileName=
"matrix.mm")
const;
219 void addMatrix(SC alpha,
const MatrixPtr_Type &B, SC beta);
224 void toMV( MultiVectorPtr_Type& mv );
231 void insertLocalValues (LO localRow,
const Teuchos::ArrayView< const LO > &cols,
const Teuchos::ArrayView< const SC > &vals);
236 void importFromVector( MatrixPtr_Type mvIn,
bool reuseImport =
false, std::string combineMode =
"Insert", std::string type=
"Forward" );
241 void exportFromVector( MatrixPtr_Type mvIn,
bool reuseExport =
false, std::string combineMode =
"Insert", std::string type=
"Forward" );
251 TpetraMatrixPtr_Type matrix_;
252 TpetraImportPtr_Type importer_;
253 TpetraExportPtr_Type exporter_;
Definition Map_decl.hpp:36
void fillComplete(MapConstPtr_Type domainMap, MapConstPtr_Type rangeMap)
Filling of Matrix based on specific domainmap (column map) and rangeMap (rowmap).
Definition Matrix_def.hpp:205
void getLocalRowView(LO localRow, Teuchos::ArrayView< const LO > &indices, Teuchos::ArrayView< const SC > &values) const
Extracting single rows of Matrix with local row ID. Indices returns local indices of entries stored i...
Definition Matrix_def.hpp:321
MatrixPtr_Type buildDiagonalInverse(std::string diagonalType)
Definition Matrix_def.hpp:233
Teuchos::RCP< const Thyra::LinearOpBase< SC > > getThyraLinOp() const
i.e. for NOX
Definition Matrix_def.hpp:154
LO getNodeNumRows() const
Returns the local number of rows.
Definition Matrix_def.hpp:81
void print(Teuchos::EVerbosityLevel verbLevel=Teuchos::VERB_EXTREME)
printing matrix
Definition Matrix_def.hpp:188
void replaceLocalValues(LO localRow, const Teuchos::ArrayView< const LO > &indices, const Teuchos::ArrayView< const SC > &values)
Replacing single rows of Matrix with local row ID. Indices returns local indices of entries stored in...
Definition Matrix_def.hpp:341
void replaceGlobalValues(GO globalRow, const Teuchos::ArrayView< const GO > &indices, const Teuchos::ArrayView< const SC > &values)
Replacing single rows of Matrix with global row ID. Indices returns global indices of entries stored ...
Definition Matrix_def.hpp:336
void exportFromVector(MatrixPtr_Type mvIn, bool reuseExport=false, std::string combineMode="Insert", std::string type="Forward")
Definition Matrix_def.hpp:475
void getGlobalRowView(GO globalRow, Teuchos::ArrayView< const GO > &indices, Teuchos::ArrayView< const SC > &values) const
Extracting single rows of Matrix with global row ID. Indices returns global indices of entries stored...
Definition Matrix_def.hpp:306
void toMV(MultiVectorPtr_Type &mv)
Turning Matrix into MultiVector Format.
Definition Matrix_def.hpp:401
void scale(const SC &alpha)
Scaling this with constant alpha.
Definition Matrix_def.hpp:363
TpetraMapConstPtr_Type getMapTpetra(std::string map_string="")
Return map in Xpetra Format of type " ".
Definition Matrix_def.hpp:134
MapConstPtr_Type getMap(std::string map_string="") const
Returns map of type " ". i.e. row or column map.
Definition Matrix_def.hpp:110
MapConstPtr_Type getMap(std::string map_string="")
Returns map of type " ". i.e. row or column map.
Definition Matrix_def.hpp:87
Teuchos::RCP< Thyra::LinearOpBase< SC > > getThyraLinOpNonConst()
i.e. for NOX
Definition Matrix_def.hpp:172
void insertGlobalValues(GO globalRow, const Teuchos::ArrayView< const GO > &cols, const Teuchos::ArrayView< const SC > &vals)
Intertion of values in global row 'globalRow'. Matrix is distributed nodewise. If values are added to...
Definition Matrix_def.hpp:74
bool isFillComplete()
Check if matrix is already filled complete.
Definition Matrix_def.hpp:210
void writeMM(std::string fileName="matrix.mm") const
Writing Matrix in file.
Definition Matrix_def.hpp:370
void importFromVector(MatrixPtr_Type mvIn, bool reuseImport=false, std::string combineMode="Insert", std::string type="Forward")
Definition Matrix_def.hpp:436
void resumeFill()
Resuming filling process. But only limited options i.e. scaling remain.
Definition Matrix_def.hpp:195
void addMatrix(SC alpha, const MatrixPtr_Type &B, SC beta)
B = alpha*this + beta*B.
Definition Matrix_def.hpp:386
void apply(const MultiVector_Type &X, MultiVector_Type &Y, Teuchos::ETransp mode=Teuchos::NO_TRANS, SC alpha=Teuchos::ScalarTraits< SC >::one(), SC beta=Teuchos::ScalarTraits< SC >::zero()) const
Matrix Vector Operation. Applying MultiVector X to this. Y = alpha * (this)^mode * X + beta * Y....
Definition Matrix_def.hpp:351
void fillComplete()
after inserting global values into matrix. After this step the column map is fixed....
Definition Matrix_def.hpp:200
void Multiply(const MatrixPtr_Type &tpA, bool transposeA, const MatrixPtr_Type &tpB, bool transposeB, bool fillComplete=true)
Definition Matrix_def.hpp:220
LO getGlobalMaxNumRowEntries() const
Maximum number of entries in any row of the matrix, over all processes.
Definition Matrix_def.hpp:423
TpetraMatrixConstPtr_Type getTpetraMatrix() const
Return matrix in Xpetra Format of type " ".
Definition Matrix_def.hpp:346
Definition MultiVector_decl.hpp:36
Adaptive Mesh Refinement.
Definition AdaptiveMeshRefinement_decl.hpp:33