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>
17#include <Tpetra_CrsMatrix.hpp>
19#include <MatrixMarket_Tpetra.hpp>
31template <
class SC = default_sc,
class LO = default_lo,
class GO = default_go,
class NO = default_no>
36 typedef Matrix<SC,LO,GO,NO> Matrix_Type;
37 typedef Teuchos::RCP<Matrix_Type> MatrixPtr_Type;
48 typedef Teuchos::RCP<Map_Type> MapPtr_Type;
49 typedef Teuchos::RCP<const Map_Type> MapConstPtr_Type;
52 typedef Teuchos::RCP<MultiVector_Type> MultiVectorPtr_Type;
53 typedef Teuchos::RCP<const MultiVector_Type> MultiVectorConstPtr_Type;
56 typedef Teuchos::RCP<BlockMultiVector_Type> BlockMultiVectorPtr_Type;
59 typedef Teuchos::Comm<int> Comm_Type;
60 typedef Teuchos::RCP<const Comm_Type> CommConstPtr_Type;
62 typedef Tpetra::Import<LO,GO,NO> TpetraImport_Type;
63 typedef Teuchos::RCP<TpetraImport_Type> TpetraImportPtr_Type;
65 typedef Tpetra::Export<LO,GO,NO> TpetraExport_Type;
66 typedef Teuchos::RCP<TpetraExport_Type> TpetraExportPtr_Type;
70 typedef Tpetra::Map<LO,GO,NO> TpetraMap_Type;
71 typedef Teuchos::RCP<TpetraMap_Type> TpetraMapPtr_Type;
72 typedef Teuchos::RCP<const TpetraMap_Type> TpetraMapConstPtr_Type;
73 typedef const TpetraMapConstPtr_Type TpetraMapConstPtrConst_Type;
75 typedef Tpetra::CrsMatrix<SC,LO,GO,NO> TpetraMatrix_Type;
76 typedef Teuchos::RCP<TpetraMatrix_Type> TpetraMatrixPtr_Type;
77 typedef Teuchos::RCP<const TpetraMatrix_Type> TpetraMatrixConstPtr_Type;
78 typedef const Teuchos::RCP<TpetraMatrixConstPtr_Type> TpetraMatrixConstPtrConst_Type;
80 typedef Tpetra::MultiVector<SC,LO,GO,NO> TpetraMV_Type;
81 typedef Teuchos::RCP<TpetraMV_Type> TpetraMVPtr_Type;
85 Matrix( TpetraMatrixPtr_Type& tpetraMatPtrIn );
87 Matrix( MapConstPtr_Type map , LO numEntries);
89 Matrix( MatrixPtr_Type matrixIn );
93 Matrix& operator+=(
const Matrix& matIn);
99 void insertGlobalValues (GO globalRow,
const Teuchos::ArrayView< const GO > &cols,
const Teuchos::ArrayView< const SC > &vals);
110 MapConstPtr_Type
getMap(std::string map_string=
"");
115 MapConstPtr_Type
getMap(std::string map_string=
"")
const;
135 void print(Teuchos::EVerbosityLevel verbLevel=Teuchos::VERB_EXTREME);
150 void fillComplete(MapConstPtr_Type domainMap, MapConstPtr_Type rangeMap);
155 bool isLocallyIndexed();
168 void getGlobalRowView(GO globalRow, Teuchos::ArrayView< const GO > &indices, Teuchos::ArrayView< const SC > &values)
const;
173 void getLocalRowView(LO localRow, Teuchos::ArrayView< const LO > &indices, Teuchos::ArrayView< const SC > &values)
const;
178 void replaceGlobalValues(GO globalRow,
const Teuchos::ArrayView< const GO > &indices,
const Teuchos::ArrayView< const SC > &values);
183 void replaceLocalValues(LO localRow,
const Teuchos::ArrayView< const LO > &indices,
const Teuchos::ArrayView< const SC > &values);
193 void apply(
const MultiVector_Type& X,
195 Teuchos::ETransp mode = Teuchos::NO_TRANS,
196 SC alpha = Teuchos::ScalarTraits<SC>::one(),
197 SC beta = Teuchos::ScalarTraits<SC>::zero() )
const;
207 void writeMM(std::string fileName=
"matrix.mm")
const;
212 void addMatrix(SC alpha,
const MatrixPtr_Type &B, SC beta);
217 void toMV( MultiVectorPtr_Type& mv );
224 void insertLocalValues (LO localRow,
const Teuchos::ArrayView< const LO > &cols,
const Teuchos::ArrayView< const SC > &vals);
229 void importFromVector( MatrixPtr_Type mvIn,
bool reuseImport =
false, std::string combineMode =
"Insert", std::string type=
"Forward" );
234 void exportFromVector( MatrixPtr_Type mvIn,
bool reuseExport =
false, std::string combineMode =
"Insert", std::string type=
"Forward" );
239 TpetraMatrixPtr_Type matrix_;
240 TpetraImportPtr_Type importer_;
241 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:240
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:260
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:255
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:225
void toMV(MultiVectorPtr_Type &mv)
Turning Matrix into MultiVector Format.
Definition Matrix_def.hpp:321
void scale(const SC &alpha)
Scaling this with constant alpha.
Definition Matrix_def.hpp:282
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:289
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:306
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:270
void fillComplete()
after inserting global values into matrix. After this step the column map is fixed....
Definition Matrix_def.hpp:200
LO getGlobalMaxNumRowEntries() const
Maximum number of entries in any row of the matrix, over all processes.
Definition Matrix_def.hpp:343
TpetraMatrixConstPtr_Type getTpetraMatrix() const
Return matrix in Xpetra Format of type " ".
Definition Matrix_def.hpp:265
Definition MultiVector_decl.hpp:36
Adaptive Mesh Refinement.
Definition AdaptiveMeshRefinement.cpp:5