9
9
#include "Ifpack_RCMReordering.h"
10
10
#include "Ifpack_METISReordering.h"
11
11
#include "Ifpack_LocalFilter.h"
12
#include "Ifpack_NodeFilter.h"
12
13
#include "Ifpack_SingletonFilter.h"
13
14
#include "Ifpack_ReorderFilter.h"
14
15
#include "Ifpack_Utils.h"
24
25
#include "Teuchos_ParameterList.hpp"
25
26
#include "Teuchos_RefCountPtr.hpp"
28
#ifdef IFPACK_NODE_AWARE_CODE
29
#include "EpetraExt_OperatorOut.h"
30
#include "EpetraExt_RowMatrixOut.h"
31
#include "EpetraExt_BlockMapOut.h"
34
#ifdef HAVE_IFPACK_AMESOS
35
#include "Ifpack_AMDReordering.h"
27
39
//! Ifpack_AdditiveSchwarz: a class to define Additive Schwarz preconditioners of Epetra_RowMatrix's.
334
346
//! Pointers to the overlapping matrix.
335
347
Teuchos::RefCountPtr<Ifpack_OverlappingRowMatrix> OverlappingMatrix_;
336
348
//! Localized version of Matrix_ or OverlappingMatrix_.
350
//TODO if we choose to expose the node aware code, i.e., no ifdefs,
351
//TODO then we should switch to this definition.
352
Teuchos::RefCountPtr<Epetra_RowMatrix> LocalizedMatrix_;
354
# ifdef IFPACK_NODE_AWARE_CODE
355
Teuchos::RefCountPtr<Ifpack_NodeFilter> LocalizedMatrix_;
337
357
Teuchos::RefCountPtr<Ifpack_LocalFilter> LocalizedMatrix_;
338
359
//! Contains the label of \c this object.
340
361
//! If true, the preconditioner has been successfully initialized.
389
410
Teuchos::RefCountPtr<Epetra_Time> Time_;
390
411
//! Pointer to the local solver.
391
412
Teuchos::RefCountPtr<T> Inverse_;
413
//! Vectors used in overlap solve.
414
# ifdef IFPACK_NODE_AWARE_CODE
415
mutable Teuchos::RefCountPtr<Epetra_MultiVector> OverlappingX;
416
mutable Teuchos::RefCountPtr<Epetra_MultiVector> OverlappingY;
393
419
}; // class Ifpack_AdditiveSchwarz<T>
439
469
Epetra_RowMatrix* MatrixPtr;
471
# ifdef IFPACK_NODE_AWARE_CODE
474
if (Comm().MyPID() == 0) cout << "Printing out ovArowmap" << endl;
477
EpetraExt::BlockMapToMatrixMarketFile("ovArowmap",OverlappingMatrix_->RowMatrixRowMap());
478
if (Comm().MyPID() == 0) cout << "Printing out ovAcolmap" << endl;
480
EpetraExt::BlockMapToMatrixMarketFile("ovAcolmap",OverlappingMatrix_->RowMatrixColMap());
484
EpetraExt::RowMatrixToMatlabFile("ovA",*OverlappingMatrix_);
485
fprintf(stderr,"p %d n %d matrix file done\n",Comm().MyPID(),ML_NODE_ID);
489
try{ nodeID = List_.get("ML node id",0);}
490
catch(...){fprintf(stderr,"%s","Ifpack_AdditiveSchwarz<T>::Setup(): no parameter \"ML node id\"\n\n");
491
cout << List_ << endl;}
441
495
if (OverlappingMatrix_ != Teuchos::null)
497
# ifdef IFPACK_NODE_AWARE_CODE
498
Ifpack_NodeFilter *tt = new Ifpack_NodeFilter(OverlappingMatrix_,nodeID); //FIXME
499
LocalizedMatrix_ = Teuchos::rcp(tt);
500
//LocalizedMatrix_ = Teuchos::rcp( new Ifpack_LocalFilter(OverlappingMatrix_) );
442
502
LocalizedMatrix_ = Teuchos::rcp( new Ifpack_LocalFilter(OverlappingMatrix_) );
507
# ifdef IFPACK_NODE_AWARE_CODE
508
Ifpack_NodeFilter *tt = new Ifpack_NodeFilter(Matrix_,nodeID); //FIXME
509
LocalizedMatrix_ = Teuchos::rcp(tt);
510
//LocalizedMatrix_ = Teuchos::rcp( new Ifpack_LocalFilter(Matrix_) );
444
512
LocalizedMatrix_ = Teuchos::rcp( new Ifpack_LocalFilter(Matrix_) );
517
fprintf(stderr,"%s","AdditiveSchwarz Setup: problem creating local filter matrix.\n");
446
520
if (LocalizedMatrix_ == Teuchos::null)
447
521
IFPACK_CHK_ERR(-5);
461
535
Reordering_ = Teuchos::rcp( new Ifpack_RCMReordering() );
462
536
else if (ReorderingType_ == "metis")
463
537
Reordering_ = Teuchos::rcp( new Ifpack_METISReordering() );
538
#ifdef HAVE_IFPACK_AMESOS
539
else if (ReorderingType_ == "amd" )
540
Reordering_ = Teuchos::rcp( new Ifpack_AMDReordering() );
465
543
cerr << "reordering type not correct (" << ReorderingType_ << ")" << endl;
466
544
exit(EXIT_FAILURE);
570
648
// compute the overlapping matrix if necessary
571
649
if (IsOverlapping_) {
573
Teuchos::rcp( new Ifpack_OverlappingRowMatrix(Matrix_, OverlapLevel_) );
574
if (OverlappingMatrix_ == Teuchos::null)
650
# ifdef IFPACK_NODE_AWARE_CODE
652
try{ myNodeID = List_.get("ML node id",-1);}
653
catch(...){fprintf(stderr,"pid %d: no such entry (returned %d)\n",Comm().MyPID(),myNodeID);}
655
cout << "pid " << Comm().MyPID()
656
<< ": calling Ifpack_OverlappingRowMatrix with myNodeID = "
657
<< myNodeID << ", OverlapLevel_ = " << OverlapLevel_ << endl;
659
OverlappingMatrix_ = Teuchos::rcp( new Ifpack_OverlappingRowMatrix(Matrix_, OverlapLevel_, myNodeID) );
662
Teuchos::rcp( new Ifpack_OverlappingRowMatrix(Matrix_, OverlapLevel_) );
665
if (OverlappingMatrix_ == Teuchos::null) {
575
666
IFPACK_CHK_ERR(-5);
670
# ifdef IFPACK_NODE_AWARE_CODE
578
677
IFPACK_CHK_ERR(Setup());
679
# ifdef IFPACK_NODE_AWARE_CODE
580
686
if (Inverse_ == Teuchos::null)
581
687
IFPACK_CHK_ERR(-5);
750
856
// process overlap, may need to create vectors and import data
751
857
if (IsOverlapping()) {
858
# ifdef IFPACK_NODE_AWARE_CODE
859
if (OverlappingX == Teuchos::null) {
860
OverlappingX = Teuchos::rcp( new Epetra_MultiVector(OverlappingMatrix_->RowMatrixRowMap(),
862
if (OverlappingX == Teuchos::null) IFPACK_CHK_ERR(-5);
863
} else assert(OverlappingX->NumVectors() == X.NumVectors());
864
if (OverlappingY == Teuchos::null) {
865
OverlappingY = Teuchos::rcp( new Epetra_MultiVector(OverlappingMatrix_->RowMatrixRowMap(),
867
if (OverlappingY == Teuchos::null) IFPACK_CHK_ERR(-5);
868
} else assert(OverlappingY->NumVectors() == Y.NumVectors());
752
870
OverlappingX = Teuchos::rcp( new Epetra_MultiVector(OverlappingMatrix_->RowMatrixRowMap(),
753
871
X.NumVectors()) );
754
872
OverlappingY = Teuchos::rcp( new Epetra_MultiVector(OverlappingMatrix_->RowMatrixRowMap(),
755
873
Y.NumVectors()) );
756
874
if (OverlappingY == Teuchos::null) IFPACK_CHK_ERR(-5);
758
876
OverlappingY->PutScalar(0.0);
759
877
OverlappingX->PutScalar(0.0);
760
878
IFPACK_CHK_ERR(OverlappingMatrix_->ImportMultiVector(X,*OverlappingX,Insert));