4#include <Teuchos_VerboseObject.hpp>
5#include <MatrixMarket_Tpetra.hpp>
6#include <TpetraExt_MatrixMatrix.hpp>
9#include <Tpetra_CrsMatrix.hpp>
11#include <MatrixMarket_Tpetra.hpp>
13#include "feddlib/core/FEDDCore.hpp"
15#include "MultiVector.hpp"
16#include "BlockMultiVector.hpp"
29template <
class SC = default_sc,
class LO = default_lo,
class GO = default_go,
class NO = default_no>
34 typedef Matrix<SC,LO,GO,NO> Matrix_Type;
35 typedef Teuchos::RCP<Matrix_Type> MatrixPtr_Type;
38 typedef Teuchos::RCP<Map_Type> MapPtr_Type;
39 typedef Teuchos::RCP<const Map_Type> MapConstPtr_Type;
42 typedef Teuchos::RCP<MultiVector_Type> MultiVectorPtr_Type;
43 typedef Teuchos::RCP<const MultiVector_Type> MultiVectorConstPtr_Type;
46 typedef Teuchos::RCP<BlockMultiVector_Type> BlockMultiVectorPtr_Type;
49 typedef Teuchos::Comm<int> Comm_Type;
50 typedef Teuchos::RCP<const Comm_Type> CommConstPtr_Type;
52 typedef Tpetra::Import<LO,GO,NO> TpetraImport_Type;
53 typedef Teuchos::RCP<TpetraImport_Type> TpetraImportPtr_Type;
55 typedef Tpetra::Export<LO,GO,NO> TpetraExport_Type;
56 typedef Teuchos::RCP<TpetraExport_Type> TpetraExportPtr_Type;
59 typedef Tpetra::Map<LO,GO,NO> TpetraMap_Type;
60 typedef Teuchos::RCP<TpetraMap_Type> TpetraMapPtr_Type;
61 typedef Teuchos::RCP<const TpetraMap_Type> TpetraMapConstPtr_Type;
62 typedef const TpetraMapConstPtr_Type TpetraMapConstPtrConst_Type;
64 typedef Tpetra::CrsMatrix<SC,LO,GO,NO> TpetraMatrix_Type;
65 typedef Teuchos::RCP<TpetraMatrix_Type> TpetraMatrixPtr_Type;
66 typedef Teuchos::RCP<const TpetraMatrix_Type> TpetraMatrixConstPtr_Type;
67 typedef const Teuchos::RCP<TpetraMatrixConstPtr_Type> TpetraMatrixConstPtrConst_Type;
69 typedef Tpetra::MultiVector<SC,LO,GO,NO> TpetraMV_Type;
70 typedef Teuchos::RCP<TpetraMV_Type> TpetraMVPtr_Type;
74 Matrix( TpetraMatrixPtr_Type& tpetraMatPtrIn );
76 Matrix( MapConstPtr_Type map , LO numEntries);
78 Matrix( MatrixPtr_Type matrixIn );
82 Matrix& operator+=(
const Matrix& matIn);
88 void insertGlobalValues (GO globalRow,
const Teuchos::ArrayView< const GO > &cols,
const Teuchos::ArrayView< const SC > &vals);
99 MapConstPtr_Type
getMap(std::string map_string=
"");
104 MapConstPtr_Type
getMap(std::string map_string=
"")
const;
124 void print(Teuchos::EVerbosityLevel verbLevel=Teuchos::VERB_EXTREME);
139 void fillComplete(MapConstPtr_Type domainMap, MapConstPtr_Type rangeMap);
144 bool isLocallyIndexed();
157 void getGlobalRowView(GO globalRow, Teuchos::ArrayView< const GO > &indices, Teuchos::ArrayView< const SC > &values)
const;
162 void getLocalRowView(LO localRow, Teuchos::ArrayView< const LO > &indices, Teuchos::ArrayView< const SC > &values)
const;
167 void replaceGlobalValues(GO globalRow,
const Teuchos::ArrayView< const GO > &indices,
const Teuchos::ArrayView< const SC > &values);
172 void replaceLocalValues(LO localRow,
const Teuchos::ArrayView< const LO > &indices,
const Teuchos::ArrayView< const SC > &values);
182 void Multiply(
const MatrixPtr_Type &tpA,
bool transposeA ,
const MatrixPtr_Type &tpB,
bool transposeB,
bool fillComplete=
true);
187 void apply(
const MultiVector_Type& X,
189 Teuchos::ETransp mode = Teuchos::NO_TRANS,
190 SC alpha = Teuchos::ScalarTraits<SC>::one(),
191 SC beta = Teuchos::ScalarTraits<SC>::zero() )
const;
201 void writeMM(std::string fileName=
"matrix.mm")
const;
206 void addMatrix(SC alpha,
const MatrixPtr_Type &B, SC beta);
211 void toMV( MultiVectorPtr_Type& mv );
218 void insertLocalValues (LO localRow,
const Teuchos::ArrayView< const LO > &cols,
const Teuchos::ArrayView< const SC > &vals);
223 void importFromVector( MatrixPtr_Type mvIn,
bool reuseImport =
false, std::string combineMode =
"Insert", std::string type=
"Forward" );
228 void exportFromVector( MatrixPtr_Type mvIn,
bool reuseExport =
false, std::string combineMode =
"Insert", std::string type=
"Forward" );
238 TpetraMatrixPtr_Type matrix_;
239 TpetraImportPtr_Type importer_;
240 TpetraExportPtr_Type exporter_;
Definition Map_decl.hpp:30
void fillComplete(MapConstPtr_Type domainMap, MapConstPtr_Type rangeMap)
Filling of Matrix based on specific domainmap (column map) and rangeMap (rowmap).
Definition Matrix_def.hpp:200
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:316
MatrixPtr_Type buildDiagonalInverse(std::string diagonalType)
Definition Matrix_def.hpp:228
Teuchos::RCP< const Thyra::LinearOpBase< SC > > getThyraLinOp() const
i.e. for NOX
Definition Matrix_def.hpp:153
LO getNodeNumRows() const
Returns the local number of rows.
Definition Matrix_def.hpp:80
void print(Teuchos::EVerbosityLevel verbLevel=Teuchos::VERB_EXTREME)
printing matrix
Definition Matrix_def.hpp:183
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:336
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:331
void exportFromVector(MatrixPtr_Type mvIn, bool reuseExport=false, std::string combineMode="Insert", std::string type="Forward")
Definition Matrix_def.hpp:461
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:301
void toMV(MultiVectorPtr_Type &mv)
Turning Matrix into MultiVector Format.
Definition Matrix_def.hpp:387
void scale(const SC &alpha)
Scaling this with constant alpha.
Definition Matrix_def.hpp:358
TpetraMapConstPtr_Type getMapTpetra(std::string map_string="")
Return map in Tpetra Format of type " ".
Definition Matrix_def.hpp:133
MapConstPtr_Type getMap(std::string map_string="") const
Returns map of type " ". i.e. row or column map.
Definition Matrix_def.hpp:109
MapConstPtr_Type getMap(std::string map_string="")
Returns map of type " ". i.e. row or column map.
Definition Matrix_def.hpp:86
Teuchos::RCP< Thyra::LinearOpBase< SC > > getThyraLinOpNonConst()
i.e. for NOX
Definition Matrix_def.hpp:168
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:73
bool isFillComplete()
Check if matrix is already filled complete.
Definition Matrix_def.hpp:205
void writeMM(std::string fileName="matrix.mm") const
Writing Matrix in file.
Definition Matrix_def.hpp:365
void importFromVector(MatrixPtr_Type mvIn, bool reuseImport=false, std::string combineMode="Insert", std::string type="Forward")
Definition Matrix_def.hpp:422
void resumeFill()
Resuming filling process. But only limited options i.e. scaling remain.
Definition Matrix_def.hpp:190
void addMatrix(SC alpha, const MatrixPtr_Type &B, SC beta)
B = alpha*this + beta*B.
Definition Matrix_def.hpp:376
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:346
void fillComplete()
after inserting global values into matrix. After this step the column map is fixed....
Definition Matrix_def.hpp:195
void Multiply(const MatrixPtr_Type &tpA, bool transposeA, const MatrixPtr_Type &tpB, bool transposeB, bool fillComplete=true)
Definition Matrix_def.hpp:215
LO getGlobalMaxNumRowEntries() const
Maximum number of entries in any row of the matrix, over all processes.
Definition Matrix_def.hpp:409
TpetraMatrixConstPtr_Type getTpetraMatrix() const
Return matrix in Tpetra Format.
Definition Matrix_def.hpp:341
Definition MultiVector_decl.hpp:61
Adaptive Mesh Refinement.
Definition AdaptiveMeshRefinement_decl.hpp:36