~chaffra/+junk/trilinos

« back to all changes in this revision

Viewing changes to packages/ifpack/src/Ifpack_AdditiveSchwarz.h

  • Committer: Bazaar Package Importer
  • Author(s): Christophe Prud'homme, Christophe Prud'homme, Johannes Ring
  • Date: 2009-12-13 12:53:22 UTC
  • mfrom: (5.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20091213125322-in0nrdjc55deqsw9
Tags: 10.0.3.dfsg-1
[Christophe Prud'homme]
* New upstream release

[Johannes Ring]
* debian/patches/libname.patch: Add prefix 'libtrilinos_' to all
  libraries. 
* debian/patches/soname.patch: Add soversion to libraries.
* debian/watch: Update download URL.
* debian/control:
  - Remove python-numeric from Build-Depends (virtual package).
  - Remove automake and autotools from Build-Depends and add cmake to
    reflect switch to CMake.
  - Add python-support to Build-Depends.
* debian/rules: 
  - Cleanup and updates for switch to CMake.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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"
26
27
 
 
28
#ifdef IFPACK_NODE_AWARE_CODE
 
29
#include "EpetraExt_OperatorOut.h"
 
30
#include "EpetraExt_RowMatrixOut.h"
 
31
#include "EpetraExt_BlockMapOut.h"
 
32
#endif
 
33
 
 
34
#ifdef HAVE_IFPACK_AMESOS
 
35
  #include "Ifpack_AMDReordering.h"
 
36
#endif
 
37
 
 
38
 
27
39
//! Ifpack_AdditiveSchwarz: a class to define Additive Schwarz preconditioners of Epetra_RowMatrix's.
28
40
 
29
41
/*!
334
346
  //! Pointers to the overlapping matrix.
335
347
  Teuchos::RefCountPtr<Ifpack_OverlappingRowMatrix> OverlappingMatrix_;
336
348
  //! Localized version of Matrix_ or OverlappingMatrix_.
 
349
/*
 
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_;
 
353
*/
 
354
# ifdef IFPACK_NODE_AWARE_CODE
 
355
  Teuchos::RefCountPtr<Ifpack_NodeFilter> LocalizedMatrix_;
 
356
# else
337
357
  Teuchos::RefCountPtr<Ifpack_LocalFilter> LocalizedMatrix_;
 
358
# endif
338
359
  //! Contains the label of \c this object.
339
360
  string Label_;
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;
 
417
#endif
392
418
 
393
419
}; // class Ifpack_AdditiveSchwarz<T>
394
420
 
431
457
  SetParameters(List_in);
432
458
}
433
459
 
 
460
#ifdef IFPACK_NODE_AWARE_CODE
 
461
extern int ML_NODE_ID;
 
462
#endif
 
463
 
434
464
//==============================================================================
435
465
template<typename T>
436
466
int Ifpack_AdditiveSchwarz<T>::Setup()
438
468
 
439
469
  Epetra_RowMatrix* MatrixPtr;
440
470
 
 
471
# ifdef IFPACK_NODE_AWARE_CODE
 
472
/*
 
473
  sleep(3);
 
474
  if (Comm().MyPID() == 0) cout << "Printing out ovArowmap" << endl;
 
475
  Comm().Barrier();
 
476
 
 
477
  EpetraExt::BlockMapToMatrixMarketFile("ovArowmap",OverlappingMatrix_->RowMatrixRowMap());
 
478
  if (Comm().MyPID() == 0) cout << "Printing out ovAcolmap" << endl;
 
479
  Comm().Barrier();
 
480
  EpetraExt::BlockMapToMatrixMarketFile("ovAcolmap",OverlappingMatrix_->RowMatrixColMap());
 
481
  Comm().Barrier();
 
482
*/
 
483
/*
 
484
  EpetraExt::RowMatrixToMatlabFile("ovA",*OverlappingMatrix_);
 
485
  fprintf(stderr,"p %d n %d matrix file done\n",Comm().MyPID(),ML_NODE_ID);
 
486
  Comm().Barrier();
 
487
*/
 
488
  int nodeID;
 
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;}
 
492
# endif
 
493
 
 
494
  try{
441
495
  if (OverlappingMatrix_ != Teuchos::null)
 
496
  {
 
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_) );
 
501
#   else
442
502
    LocalizedMatrix_ = Teuchos::rcp( new Ifpack_LocalFilter(OverlappingMatrix_) );
 
503
#   endif
 
504
  }
443
505
  else
 
506
  {
 
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_) );
 
511
#   else
444
512
    LocalizedMatrix_ = Teuchos::rcp( new Ifpack_LocalFilter(Matrix_) );
 
513
#   endif
 
514
  }
 
515
  }
 
516
  catch(...) {
 
517
     fprintf(stderr,"%s","AdditiveSchwarz Setup: problem creating local filter matrix.\n");
 
518
  }
445
519
 
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() );
 
541
#endif
464
542
    else {
465
543
      cerr << "reordering type not correct (" << ReorderingType_ << ")" << endl;
466
544
      exit(EXIT_FAILURE);
569
647
 
570
648
  // compute the overlapping matrix if necessary
571
649
  if (IsOverlapping_) {
572
 
    OverlappingMatrix_ = 
573
 
      Teuchos::rcp( new Ifpack_OverlappingRowMatrix(Matrix_, OverlapLevel_) );
574
 
    if (OverlappingMatrix_ == Teuchos::null)
 
650
#     ifdef IFPACK_NODE_AWARE_CODE
 
651
      int myNodeID;
 
652
      try{ myNodeID = List_.get("ML node id",-1);}
 
653
      catch(...){fprintf(stderr,"pid %d: no such entry (returned %d)\n",Comm().MyPID(),myNodeID);}
 
654
/*
 
655
      cout << "pid " << Comm().MyPID()
 
656
           << ": calling Ifpack_OverlappingRowMatrix with myNodeID = "
 
657
           << myNodeID << ", OverlapLevel_ = " << OverlapLevel_ << endl;
 
658
*/
 
659
      OverlappingMatrix_ = Teuchos::rcp( new Ifpack_OverlappingRowMatrix(Matrix_, OverlapLevel_, myNodeID) );
 
660
#   else
 
661
      OverlappingMatrix_ =
 
662
        Teuchos::rcp( new Ifpack_OverlappingRowMatrix(Matrix_, OverlapLevel_) );
 
663
#   endif
 
664
 
 
665
    if (OverlappingMatrix_ == Teuchos::null) {
575
666
      IFPACK_CHK_ERR(-5);
 
667
    } 
576
668
  }
577
669
 
 
670
# ifdef IFPACK_NODE_AWARE_CODE
 
671
/*
 
672
  sleep(1);
 
673
  Comm().Barrier();
 
674
*/
 
675
# endif
 
676
 
578
677
  IFPACK_CHK_ERR(Setup());
579
678
 
 
679
# ifdef IFPACK_NODE_AWARE_CODE
 
680
/*
 
681
  sleep(1);
 
682
  Comm().Barrier();
 
683
*/
 
684
#endif
 
685
 
580
686
  if (Inverse_ == Teuchos::null)
581
687
    IFPACK_CHK_ERR(-5);
582
688
 
730
836
  // compute the preconditioner is not done by the user
731
837
  if (!IsComputed())
732
838
    IFPACK_CHK_ERR(-3);
733
 
  
 
839
 
734
840
  int NumVectors = X.NumVectors();
735
841
 
736
842
  if (NumVectors != Y.NumVectors())
749
855
 
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(),
 
861
                                   X.NumVectors()) );
 
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(),
 
866
                                     Y.NumVectors()) );
 
867
      if (OverlappingY == Teuchos::null) IFPACK_CHK_ERR(-5);
 
868
    } else assert(OverlappingY->NumVectors() == Y.NumVectors());
 
869
#else
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);
757
 
 
 
875
#   endif
758
876
    OverlappingY->PutScalar(0.0);
759
877
    OverlappingX->PutScalar(0.0);
760
878
    IFPACK_CHK_ERR(OverlappingMatrix_->ImportMultiVector(X,*OverlappingX,Insert));