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