Finite Element Domain Decomposition Library
FEDDLib
Loading...
Searching...
No Matches
Matrix_def.hpp
1#ifndef MATRIX_DEF_hpp
2#define MATRIX_DEF_hpp
3#include "Matrix_decl.hpp"
4
13
14namespace FEDD {
15//using namespace Teuchos;
16template <class SC, class LO, class GO, class NO>
17Matrix<SC,LO,GO,NO>::Matrix():
18 matrix_()
19{
20
21}
22
23template <class SC, class LO, class GO, class NO>
24Matrix<SC,LO,GO,NO>::Matrix( TpetraMatrixPtr_Type& tpetraMatPtrIn ):
25matrix_( tpetraMatPtrIn )
26{
27
28}
29
30template <class SC, class LO, class GO, class NO>
31Matrix<SC,LO,GO,NO>::Matrix( MapConstPtr_Type map , LO numEntries):
32matrix_( )
33{
34 matrix_ = Teuchos::RCP( new TpetraMatrix_Type(map->getTpetraMap(), numEntries)); //, plist) );
35
36}
37
38
39template <class SC, class LO, class GO, class NO>
40Matrix<SC,LO,GO,NO>::Matrix( MatrixPtr_Type matrixIn ):
41matrix_( )
42{
43 matrix_ =Teuchos::RCP( new TpetraMatrix_Type( matrixIn->getMap()->getTpetraMap(), matrixIn->getGlobalMaxNumRowEntries() ));
44 if(matrixIn->isLocallyIndexed())
45 {
46 Teuchos::ArrayView<const SC> values;
47 Teuchos::ArrayView<const LO> indices;
48
49 MapConstPtr_Type colMap = matrixIn->getMap("col");
50 MapConstPtr_Type rowMap = matrixIn->getMap("row");
51
52 for (UN i=0; i<matrixIn->getNodeNumRows(); i++)
53 {
54 matrixIn->getLocalRowView( i, indices, values );
55 Teuchos::Array<GO> indicesGlobal( indices.size() );
56 for (UN j=0; j<indices.size(); j++)
57 {
58 indicesGlobal[j] = colMap->getGlobalElement( indices[j] );
59
60 }
61 matrix_->insertGlobalValues( rowMap->getGlobalElement( i ), indicesGlobal(), values );
62 }
63 }
64
65 matrix_->fillComplete( matrixIn->getMap("domain")->getTpetraMap(), matrixIn->getMap("range")->getTpetraMap() );
66}
67
68template <class SC, class LO, class GO, class NO>
69Matrix<SC,LO,GO,NO>::~Matrix(){
70
71}
72
73template <class SC, class LO, class GO, class NO>
74void Matrix<SC,LO,GO,NO>::insertGlobalValues(GO globalRow, const Teuchos::ArrayView< const GO > &cols, const Teuchos::ArrayView< const SC > &vals){
75
76 TEUCHOS_TEST_FOR_EXCEPTION(matrix_.is_null(),std::runtime_error,"");
77 matrix_->insertGlobalValues( globalRow, cols, vals );
78}
79
80template <class SC, class LO, class GO, class NO>
82 return matrix_->getLocalNumRows();
83}
84
85
86template <class SC, class LO, class GO, class NO>
87typename Matrix<SC,LO,GO,NO>::MapConstPtr_Type Matrix<SC,LO,GO,NO>::getMap(std::string map_string){
88
89 TEUCHOS_TEST_FOR_EXCEPTION(matrix_.is_null(),std::runtime_error,"RCP<Matrix> is null.");
90 TpetraMapConstPtr_Type tpetraMap;
91 if (!map_string.compare("row")) {
92 tpetraMap = matrix_->getRowMap();
93 }
94 else if (!map_string.compare("col")) {
95 tpetraMap = matrix_->getColMap();
96 }
97 else if (!map_string.compare("domain")) {
98 tpetraMap = matrix_->getDomainMap();
99 }
100 else if (!map_string.compare("range")) {
101 tpetraMap = matrix_->getRangeMap();
102 }
103 else
104 tpetraMap = matrix_->getMap();
106 return Teuchos::rcp( new Map_Type(tpetraMap) );
107}
108
109template <class SC, class LO, class GO, class NO>
110typename Matrix<SC,LO,GO,NO>::MapConstPtr_Type Matrix<SC,LO,GO,NO>::getMap(std::string map_string) const{
111
112 TEUCHOS_TEST_FOR_EXCEPTION(matrix_.is_null(),std::runtime_error,"RCP<Matrix> is null.");
113 TpetraMapConstPtr_Type tpetraMap;
114 if (!map_string.compare("row")) {
115 tpetraMap = matrix_->getRowMap();
116 }
117 else if (!map_string.compare("col")) {
118 tpetraMap = matrix_->getColMap();
119 }
120 else if (!map_string.compare("domain")) {
121 tpetraMap = matrix_->getDomainMap();
122 }
123 else if (!map_string.compare("range")) {
124 tpetraMap = matrix_->getRangeMap();
126 else
127 tpetraMap = matrix_->getMap();
128
129 return Teuchos::rcp( new Map_Type(tpetraMap) );
131
132
133template <class SC, class LO, class GO, class NO>
134typename Matrix<SC,LO,GO,NO>::TpetraMapConstPtr_Type Matrix<SC,LO,GO,NO>::getMapTpetra(std::string map_string){
136 TEUCHOS_TEST_FOR_EXCEPTION(matrix_.is_null(),std::runtime_error,"RCP<Matrix> is null.");
137
138 if (!map_string.compare("row")) {
139 return matrix_->getRowMap();
141 else if (!map_string.compare("col")) {
142 return matrix_->getColMap();
143 }
144 else if (!map_string.compare("domain")) {
145 return matrix_->getDomainMap();
146 }
147 else if (!map_string.compare("range")) {
148 return matrix_->getRangeMap();
149 }
150 return matrix_->getMap();
151}
152
153template <class SC, class LO, class GO, class NO>
154Teuchos::RCP<const Thyra::LinearOpBase<SC> > Matrix<SC,LO,GO,NO>::getThyraLinOp() const{
155 //Xpetra::CrsMatrixWrap<SC,LO,GO,NO>& crsWrapMatrix = dynamic_cast<Xpetra::CrsMatrixWrap<SC,LO,GO,NO>&>(*matrix_);
156 //return Xpetra::ThyraUtils<SC,LO,GO,NO>::toThyra(crsWrapMatrix.getCrsMatrix());
157
158 Teuchos::RCP<Thyra::LinearOpBase<SC> > thyraOp = Teuchos::null;
159
160 Teuchos::RCP<Tpetra::CrsMatrix<SC,LO,GO,NO> > tpCrsMat = matrix_; // = xTpCrsMat->getTpetra_CrsMatrixNonConst();
161 TEUCHOS_TEST_FOR_EXCEPT(Teuchos::is_null(tpCrsMat));
162 Teuchos::RCP<Tpetra::RowMatrix<SC,LO,GO,NO> > tpRowMat = Teuchos::rcp_dynamic_cast<Tpetra::RowMatrix<SC,LO,GO,NO> >(tpCrsMat, true);
163 Teuchos::RCP<Tpetra::Operator <SC,LO,GO,NO> > tpOperator = Teuchos::rcp_dynamic_cast<Tpetra::Operator<SC,LO,GO,NO> >(tpRowMat, true);
164
165 thyraOp = Thyra::createLinearOp(tpOperator);
166
167 return thyraOp;
169}
170
171template <class SC, class LO, class GO, class NO>
172Teuchos::RCP<Thyra::LinearOpBase<SC> > Matrix<SC,LO,GO,NO>::getThyraLinOpNonConst() {
173 //Xpetra::CrsMatrixWrap<SC,LO,GO,NO>& crsWrapMatrix = dynamic_cast<Xpetra::CrsMatrixWrap<SC,LO,GO,NO>&>(*matrix_);
174 //return Teuchos::rcp_const_cast<Thyra::LinearOpBase<SC> > (Xpetra::ThyraUtils<SC,LO,GO,NO>::toThyra(crsWrapMatrix.getCrsMatrix()) );
175 Teuchos::RCP<Thyra::LinearOpBase<SC> > thyraOp = Teuchos::null;
176
177 Teuchos::RCP<Tpetra::CrsMatrix<SC,LO,GO,NO> > tpCrsMat = matrix_; // = xTpCrsMat->getTpetra_CrsMatrixNonConst();
178 TEUCHOS_TEST_FOR_EXCEPT(Teuchos::is_null(tpCrsMat));
179 Teuchos::RCP<Tpetra::RowMatrix<SC,LO,GO,NO> > tpRowMat = Teuchos::rcp_dynamic_cast<Tpetra::RowMatrix<SC,LO,GO,NO> >(tpCrsMat, true);
180 Teuchos::RCP<Tpetra::Operator <SC,LO,GO,NO> > tpOperator = Teuchos::rcp_dynamic_cast<Tpetra::Operator<SC,LO,GO,NO> >(tpRowMat, true);
181
182 thyraOp = Thyra::createLinearOp(tpOperator);
184 return Teuchos::rcp_const_cast<Thyra::LinearOpBase<SC> > (thyraOp); // is this now const or not??
185}
186
187template <class SC, class LO, class GO, class NO>
188void Matrix<SC,LO,GO,NO>::print(Teuchos::EVerbosityLevel verbLevel){
189
190 Teuchos::RCP<Teuchos::FancyOStream> out = Teuchos::VerboseObjectBase::getDefaultOStream();
191 matrix_->describe(*out,verbLevel);
192}
194template <class SC, class LO, class GO, class NO>
196 matrix_->resumeFill();
197}
198
199template <class SC, class LO, class GO, class NO>
201 matrix_->fillComplete();
203
204template <class SC, class LO, class GO, class NO>
205void Matrix<SC,LO,GO,NO>::fillComplete(MapConstPtr_Type domainMap, MapConstPtr_Type rangeMap){
206 matrix_->fillComplete( domainMap->getTpetraMap(), rangeMap->getTpetraMap() );
208
209template <class SC, class LO, class GO, class NO>
211 return matrix_->isFillComplete();
213
214template <class SC, class LO, class GO, class NO>
215bool Matrix<SC,LO,GO,NO>::isLocallyIndexed(){
216 return matrix_->isLocallyIndexed();
218
219//typename Matrix<SC,LO,GO,NO>::ThyraLinOpPtr_Type Matrix<SC,LO,GO,NO>::getThyraLinOp(){
220//
221// return ;
222//}
223
224template <class SC, class LO, class GO, class NO>
225void Matrix<SC,LO,GO,NO>::getGlobalRowView(GO globalRow, Teuchos::ArrayView< const GO > &indices, Teuchos::ArrayView< const SC > &values) const{
226 TEUCHOS_TEST_FOR_EXCEPTION(matrix_->isLocallyIndexed(),std::logic_error,"Underlying matrix is locally indexed and we can not use a global row view. Global row copy is valid here and can be implemented.");
227
228 typename Tpetra::CrsMatrix<SC,LO,GO,NO>::global_inds_host_view_type Indices; //ArrayView< const LO > indices
229 typename Tpetra::CrsMatrix<SC,LO,GO,NO>::values_host_view_type Values;
230 //typename Tpetra::CrsGraph<LocalOrdinal,GlobalOrdinal,Node>::local_inds_host_view_type indices;
231 //typename Tpetra::CrsMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node>::values_host_view_type values;
232
233 matrix_->getGlobalRowView(globalRow, Indices, Values);
234 indices = Teuchos::ArrayView<const GO> (Indices.data(), Indices.extent(0));
235 values = Teuchos::ArrayView<const SC> (reinterpret_cast<const SC*>(Values.data()), Values.extent(0));
236
237}
238
239template <class SC, class LO, class GO, class NO>
240void Matrix<SC,LO,GO,NO>::getLocalRowView(LO localRow, Teuchos::ArrayView< const LO > &indices, Teuchos::ArrayView< const SC > &values) const{
241 TEUCHOS_TEST_FOR_EXCEPTION(matrix_->isGloballyIndexed(),std::logic_error,"Underlying matrix is globally indexed and we can not use a local row view.");
242 typename Tpetra::CrsMatrix<SC,LO,GO,NO>::local_inds_host_view_type Indices; //ArrayView< const LO > indices
243 typename Tpetra::CrsMatrix<SC,LO,GO,NO>::values_host_view_type Values;
244 //typename Tpetra::CrsGraph<LocalOrdinal,GlobalOrdinal,Node>::local_inds_host_view_type indices;
245 //typename Tpetra::CrsMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node>::values_host_view_type values;
246
247 matrix_->getLocalRowView(localRow, Indices, Values);
248 indices = Teuchos::ArrayView<const LO> (Indices.data(), Indices.extent(0));
249 values = Teuchos::ArrayView<const SC> (reinterpret_cast<const SC*>(Values.data()), Values.extent(0));
250
251}
252
253
254template <class SC, class LO, class GO, class NO>
255void Matrix<SC,LO,GO,NO>::replaceGlobalValues(GO globalRow, const Teuchos::ArrayView< const GO > &indices, const Teuchos::ArrayView< const SC > &values){
256 matrix_->replaceGlobalValues(globalRow, indices, values);
257}
258
259template <class SC, class LO, class GO, class NO>
260void Matrix<SC,LO,GO,NO>::replaceLocalValues(LO localRow, const Teuchos::ArrayView< const LO > &indices, const Teuchos::ArrayView< const SC > &values){
261 matrix_->replaceLocalValues(localRow, indices, values);
262}
263
264template <class SC, class LO, class GO, class NO>
265typename Matrix<SC,LO,GO,NO>::TpetraMatrixConstPtr_Type Matrix<SC,LO,GO,NO>::getTpetraMatrix() const{
266 return matrix_;
267}
268
269template <class SC, class LO, class GO, class NO>
270void Matrix<SC,LO,GO,NO>::apply(const MultiVector_Type& X,
271 MultiVector_Type& Y,
272 Teuchos::ETransp mode,
273 SC alpha,
274 SC beta) const{
275
276 TpetraMVPtr_Type yTpetra = Y.getTpetraMultiVectorNonConst();
277
278 matrix_->apply( *X.getTpetraMultiVector(), *yTpetra, mode, alpha, beta );
279}
280
281template <class SC, class LO, class GO, class NO>
282void Matrix<SC,LO,GO,NO>::scale(const SC& alpha) {
283
284 matrix_->scale( alpha );
285
286}
287
288template <class SC, class LO, class GO, class NO>
289void Matrix<SC,LO,GO,NO>::writeMM(std::string fileName) const{
290 TEUCHOS_TEST_FOR_EXCEPTION( matrix_.is_null(), std::runtime_error,"Matrix in writeMM is null.");
291 // TEUCHOS_TEST_FOR_EXCEPTION( !(matrix_->getMap()->lib()==Xpetra::UseTpetra), std::logic_error,"Only available for Tpetra underlying lib.");
292 //typedef Tpetra::CrsMatrix<SC,LO,GO,NO> TpetraCrsMatrix;
293 //typedef Teuchos::RCP<TpetraCrsMatrix> TpetraCrsMatrixPtr;
294
295 //Xpetra::CrsMatrixWrap<SC,LO,GO,NO>& crsOp = dynamic_cast<Xpetra::CrsMatrixWrap<SC,LO,GO,NO>&>(*matrix_);
296 //Xpetra::TpetraCrsMatrix<SC,LO,GO,NO>& xTpetraMat = dynamic_cast<Xpetra::TpetraCrsMatrix<SC,LO,GO,NO>&>(*crsOp.getCrsMatrix());
297
298 TpetraMatrixPtr_Type tpetraMat = matrix_;
299
300 Tpetra::MatrixMarket::Writer< TpetraMatrix_Type > tpetraWriter;
301
302 tpetraWriter.writeSparseFile(fileName, tpetraMat, "matrix", "");
303}
304
305template <class SC, class LO, class GO, class NO>
306void Matrix<SC,LO,GO,NO>::addMatrix(SC alpha, const MatrixPtr_Type &B, SC beta){
307 //B = alpha*A + beta*B.
308 if (B->isFillComplete())
309 B->resumeFill();
310 TEUCHOS_TEST_FOR_EXCEPTION( B->isLocallyIndexed(), std::runtime_error,"Matrix in is locally index but Trilinos Epetra/Tpetra can not add to a matrix at this stage.");
311
312 //const Tpetra::CrsMatrix<SC,LO,GO,NO>& tpA = Xpetra::Helpers<SC,LO,GO,NO>::Op2TpetraCrs(A);
313 //Tpetra::CrsMatrix<SC,LO,GO,NO>& tpB = Xpetra::Helpers<SC,LO,GO,NO>::Op2NonConstTpetraCrs(B);
314
315 Tpetra::MatrixMatrix::Add(*matrix_, false, alpha, *B->matrix_, beta);
316
317 //Xpetra::MatrixMatrix<SC,LO,GO,NO>::TwoMatrixAdd( *matrix_, false, alpha, *B->matrix_, beta );
318}
319
320template <class SC, class LO, class GO, class NO>
321void Matrix<SC,LO,GO,NO>::toMV( MultiVectorPtr_Type& mv ){
322
323 MapConstPtr_Type map = this->getMap("row");
324 MapConstPtr_Type mapCol = this->getMap("col");
325 // number of matrix columns will be the number of multivectors
326 int numMV = mapCol->getMaxAllGlobalIndex() + 1;
327
328 mv = Teuchos::rcp( new MultiVector_Type ( map, numMV ) );
329 Teuchos::ArrayView< const LO > indices;
330 Teuchos::ArrayView< const SC > values;
331 Teuchos::ArrayRCP< SC > valuesMV;
332 GO globalCol = -1;
333 for (int i=0; i<this->getNodeNumRows(); i++) {
334 this->getLocalRowView( i, indices, values );
335 for (int j=0; j<indices.size(); j++) {
336 globalCol = mapCol->getGlobalElement( indices[j] );
337 valuesMV = mv->getDataNonConst( globalCol );
338 valuesMV[ i ] = values[ j ];
339 }
340 }
341}
342template <class SC, class LO, class GO, class NO>
344 return matrix_->getGlobalMaxNumRowEntries();
345}
346
347template <class SC, class LO, class GO, class NO>
348void Matrix<SC,LO,GO,NO>::insertLocalValues(LO localRow, const Teuchos::ArrayView< const LO > &cols, const Teuchos::ArrayView< const SC > &vals){
349
350 TEUCHOS_TEST_FOR_EXCEPTION(matrix_.is_null(),std::runtime_error,"");
351 matrix_->insertLocalValues( localRow, cols, vals );
352}
353
354
355template <class SC, class LO, class GO, class NO>
356void Matrix<SC,LO,GO,NO>::importFromVector( MatrixPtr_Type mvIn, bool reuseImport, std::string combineMode, std::string type) {
357
358 //TEUCHOS_TEST_FOR_EXCEPTION( getNodeNumCols() != mvIn->getNodeNumCols(), std::logic_error,"MultiVectors for fillFromVector have different number of vectors.");
359
360 if ( importer_.is_null() || !reuseImport) {
361 if (type=="Forward")
362 importer_ = Teuchos::RCP(new Tpetra::Import<LO, GO, NO>( mvIn->getMapTpetra(), this->getMapTpetra() ));
363 else if(type=="Reverse")
364 importer_ = Teuchos::RCP(new Tpetra::Import<LO, GO, NO>( this->getMapTpetra(), mvIn->getMapTpetra() ));
365 else
366 TEUCHOS_TEST_FOR_EXCEPTION( true, std::logic_error,"Unknown type for import. Choose Forward or Reverse");
367 }
368 else{
369 TEUCHOS_TEST_FOR_EXCEPTION( !importer_->getSourceMap()->isSameAs( *mvIn->getMap()->getTpetraMap() ), std::logic_error,"Source maps of Importer and Matrix are not the same.");
370 TEUCHOS_TEST_FOR_EXCEPTION( !importer_->getTargetMap()->isSameAs( *this->getMap()->getTpetraMap() ), std::logic_error,"Target maps of Importer and Matrix are not the same.");
371 }
372
373
374 if (type=="Forward") {
375 if ( !combineMode.compare("Insert") )
376 matrix_->doImport ( *mvIn->getTpetraMatrix(), *importer_, Tpetra::INSERT);
377 else if ( !combineMode.compare("Add") )
378 matrix_->doImport ( *mvIn->getTpetraMatrix(), *importer_, Tpetra::ADD);
379 else
380 TEUCHOS_TEST_FOR_EXCEPTION( true, std::logic_error,"Unknown combine mode.");
381 }
382 else if(type=="Reverse"){
383 if ( !combineMode.compare("Insert") )
384 matrix_->doExport ( *mvIn->getTpetraMatrix(), *importer_, Tpetra::INSERT);
385 else if ( !combineMode.compare("Add") )
386 matrix_->doExport ( *mvIn->getTpetraMatrix(), *importer_, Tpetra::ADD);
387 else
388 TEUCHOS_TEST_FOR_EXCEPTION( true, std::logic_error,"Unknown combine mode.");
389 }
390 else
391 TEUCHOS_TEST_FOR_EXCEPTION( true, std::logic_error,"Unknown type for import. Choose Forward or Reverse");
392}
393
394template <class SC, class LO, class GO, class NO>
395void Matrix<SC,LO,GO,NO>::exportFromVector( MatrixPtr_Type mvIn, bool reuseExport, std::string combineMode, std::string type) {
396
397 //TEUCHOS_TEST_FOR_EXCEPTION( getNodeNumCols() != mvIn->getNodeNumCols(), std::logic_error,"MultiVectors for fillFromVector have different number of vectors.");
398
399 if ( exporter_.is_null() || !reuseExport) {
400 if (type=="Forward")
401 exporter_ = Teuchos::RCP(new Tpetra::Export<LO, GO, NO>( mvIn->getMapTpetra(), this->getMapTpetra() ));
402 else if(type=="Reverse")
403 exporter_ = Teuchos::RCP(new Tpetra::Export<LO, GO, NO>( this->getMapTpetra(), mvIn->getMapTpetra() ));
404 else
405 TEUCHOS_TEST_FOR_EXCEPTION( true, std::logic_error,"Unknown type for import. Choose Forward or Reverse");
406 }
407 else{
408 TEUCHOS_TEST_FOR_EXCEPTION( !exporter_->getSourceMap()->isSameAs( *this->getMap()->getTpetraMap() ), std::logic_error,"Source maps of Exporter and Multivector are not the same.");
409 TEUCHOS_TEST_FOR_EXCEPTION( !exporter_->getTargetMap()->isSameAs( *mvIn->getMap()->getTpetraMap() ), std::logic_error,"Target maps of Exporter and Multivector are not the same.");
410 }
411
412
413 if (type=="Forward") {
414 if ( !combineMode.compare("Insert") )
415 matrix_->doExport ( *mvIn->getTpetraMatrix(), *exporter_, Tpetra::INSERT);
416 else if ( !combineMode.compare("Add") )
417 matrix_->doExport ( *mvIn->getTpetraMatrix(), *exporter_, Tpetra::ADD);
418 else
419 TEUCHOS_TEST_FOR_EXCEPTION( true, std::logic_error,"Unknown combine mode.");
420 }
421 else if(type=="Reverse"){
422 if ( !combineMode.compare("Insert") )
423 matrix_->doImport ( *mvIn->getTpetraMatrix(), *exporter_, Tpetra::INSERT);
424 else if ( !combineMode.compare("Add") )
425 matrix_->doImport ( *mvIn->getTpetraMatrix(), *exporter_, Tpetra::ADD);
426 else
427 TEUCHOS_TEST_FOR_EXCEPTION( true, std::logic_error,"Unknown combine mode.");
428 }
429 else
430 TEUCHOS_TEST_FOR_EXCEPTION( true, std::logic_error,"Unknown type for import. Choose Forward or Reverse");
431}
432
433}
434#endif
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="")
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
Adaptive Mesh Refinement.
Definition AdaptiveMeshRefinement.cpp:5