44 #ifdef HAVE_IFPACK_AZTECOO  
   46 #include "Epetra_MpiComm.h" 
   48 #include "Epetra_SerialComm.h" 
   50 #include "Epetra_CrsMatrix.h" 
   51 #include "Epetra_Vector.h" 
   52 #include "Epetra_LinearProblem.h" 
   53 #include "Trilinos_Util_CrsMatrixGallery.h" 
   54 #include "Teuchos_ParameterList.hpp" 
   61 using namespace Trilinos_Util;
 
   64 static bool Solver = AZ_gmres;
 
   78   List.
set(
"relaxation: damping factor", 1.0);
 
   79   List.
set(
"relaxation: type", 
"Jacobi");
 
   80   List.
set(
"relaxation: sweeps",1);
 
   81   List.
set(
"partitioner: overlap", Overlap);
 
   82   List.
set(
"partitioner: type", 
"greedy");
 
   83   List.
set(
"partitioner: local parts", 16);
 
   89   Prec.SetParameters(List);
 
   93   AztecOO AztecOOSolver(*Problem);
 
   94   AztecOOSolver.SetAztecOption(AZ_solver,
Solver);
 
   96     AztecOOSolver.SetAztecOption(AZ_output,32);
 
   98     AztecOOSolver.SetAztecOption(AZ_output,AZ_none);
 
   99   AztecOOSolver.SetPrecOperator(&Prec);
 
  101   AztecOOSolver.Iterate(1550,1e-8);
 
  103   return(AztecOOSolver.NumIters());
 
  108                       CrsMatrixGallery& Gallery, 
int NumParts)
 
  118   List.
set(
"relaxation: damping factor", 1.0);
 
  119   List.
set(
"relaxation: type", PrecType);
 
  120   List.
set(
"relaxation: sweeps",1);
 
  121   List.
set(
"partitioner: type", 
"greedy");
 
  122   List.
set(
"partitioner: local parts", NumParts);
 
  128   Prec.SetParameters(List);
 
  132   AztecOO AztecOOSolver(*Problem);
 
  133   AztecOOSolver.SetAztecOption(AZ_solver,
Solver);
 
  135     AztecOOSolver.SetAztecOption(AZ_output,32);
 
  137     AztecOOSolver.SetAztecOption(AZ_output,AZ_none);
 
  138   AztecOOSolver.SetPrecOperator(&Prec);
 
  140   AztecOOSolver.Iterate(1550,1e-8);
 
  142   return(AztecOOSolver.NumIters());
 
  147                           CrsMatrixGallery& Gallery, 
int sweeps)
 
  158   List.
set(
"relaxation: damping factor", 1.0);
 
  159   List.
set(
"relaxation: type", PrecType);
 
  160   List.
set(
"relaxation: sweeps",sweeps);
 
  161   List.
set(
"partitioner: type", 
"linear");
 
  164   int ItersPoint, ItersBlock;
 
  175     Point.SetParameters(List);
 
  179     AztecOO AztecOOSolver(*Problem);
 
  180     AztecOOSolver.SetAztecOption(AZ_solver,
Solver);
 
  182       AztecOOSolver.SetAztecOption(AZ_output,32);
 
  184       AztecOOSolver.SetAztecOption(AZ_output,AZ_none);
 
  185     AztecOOSolver.SetPrecOperator(&Point);
 
  187     AztecOOSolver.Iterate(1550,1e-8);
 
  189     double TrueResidual = AztecOOSolver.TrueResidual();
 
  190     ItersPoint = AztecOOSolver.NumIters();
 
  193       cout << 
"Iterations  = " << ItersPoint << endl;
 
  194       cout << 
"Norm of the true residual = " << TrueResidual << endl;
 
  207     Block.SetParameters(List);
 
  211     AztecOO AztecOOSolver(*Problem);
 
  212     AztecOOSolver.SetAztecOption(AZ_solver,
Solver);
 
  214       AztecOOSolver.SetAztecOption(AZ_output,32);
 
  216       AztecOOSolver.SetAztecOption(AZ_output,AZ_none);
 
  217     AztecOOSolver.SetPrecOperator(&Block);
 
  219     AztecOOSolver.Iterate(1550,1e-8);
 
  221     double TrueResidual = AztecOOSolver.TrueResidual();
 
  222     ItersBlock = AztecOOSolver.NumIters();
 
  225       cout << 
"Iterations " << ItersBlock << endl;
 
  226       cout << 
"Norm of the true residual = " << TrueResidual << endl;
 
  230   if (ItersPoint != ItersBlock) {
 
  232       cout << 
"TEST FAILED!" << endl;
 
  237       cout << 
"TEST PASSED" << endl;
 
  244                 CrsMatrixGallery& Gallery)
 
  257   List.
set(
"relaxation: damping factor", 1.0);
 
  258   List.
set(
"relaxation: type", PrecType);
 
  267     List.
set(
"relaxation: sweeps",1);
 
  269     Point.SetParameters(List);
 
  273     AztecOO AztecOOSolver(*Problem);
 
  274     AztecOOSolver.SetAztecOption(AZ_solver,
Solver);
 
  275     AztecOOSolver.SetAztecOption(AZ_output,AZ_none);
 
  276     AztecOOSolver.SetPrecOperator(&Point);
 
  278     AztecOOSolver.Iterate(1550,1e-8);
 
  280     double TrueResidual = AztecOOSolver.TrueResidual();
 
  283       cout << 
"Norm of the true residual = " << TrueResidual << endl;
 
  285     Iters1 = AztecOOSolver.NumIters();
 
  292     List.
set(
"relaxation: sweeps",10);
 
  294     Point.SetParameters(List);
 
  299     AztecOO AztecOOSolver(*Problem);
 
  300     AztecOOSolver.SetAztecOption(AZ_solver,
Solver);
 
  301     AztecOOSolver.SetAztecOption(AZ_output,AZ_none);
 
  302     AztecOOSolver.SetPrecOperator(&Point);
 
  303     AztecOOSolver.Iterate(1550,1e-8);
 
  305     double TrueResidual = AztecOOSolver.TrueResidual();
 
  308       cout << 
"Norm of the true residual = " << TrueResidual << endl;
 
  310     Iters10 = AztecOOSolver.NumIters();
 
  314     cout << 
"Iters_1 = " << Iters1 << 
", Iters_10 = " << Iters10 << endl;
 
  315     cout << 
"(second number should be smaller than first one)" << endl;
 
  318   if (Iters10 > Iters1) {
 
  320       cout << 
"TEST FAILED!" << endl;
 
  325       cout << 
"TEST PASSED" << endl;
 
  332                CrsMatrixGallery& Gallery)
 
  347   List.
set(
"relaxation: damping factor", 1.0);
 
  348   List.
set(
"relaxation: sweeps",1550);
 
  349   List.
set(
"relaxation: type", PrecType);
 
  353   Point.SetParameters(List);
 
  356   Point.ApplyInverse(RHS,LHS);
 
  360   double residual, diff;
 
  361   Gallery.ComputeResidual(&residual);
 
  362   Gallery.ComputeDiffBetweenStartingAndExactSolutions(&diff);
 
  365     cout << 
"||b-Ax||_2 = " << residual << endl;
 
  366     cout << 
"||x_exact - x||_2 = " << diff << endl;
 
  370   if (residual < 1e-2) {
 
  372       cout << 
"Test passed" << endl;
 
  377       cout << 
"Test failed!" << endl;
 
  383 int main(
int argc, 
char *argv[])
 
  387   MPI_Init(&argc,&argv);
 
  395   for (
int i = 1 ; i < argc ; ++i) {
 
  396     if (strcmp(argv[i],
"-s") == 0) {
 
  403   const int NumPoints = 900;
 
  405   CrsMatrixGallery Gallery(
"", Comm);
 
  406   Gallery.Set(
"problem_size", NumPoints);
 
  407   Gallery.Set(
"map_type", 
"linear");
 
  409     Gallery.Set(
"problem_type", 
"laplace_2d");
 
  411     Gallery.Set(
"problem_type", 
"recirc_2d");
 
  414   int TestPassed = 
true;
 
  423   if(!
BasicTest(
"symmetric Gauss-Seidel",Gallery))
 
  435   if(!
KrylovTest(
"symmetric Gauss-Seidel",Gallery))
 
  447   TestPassed = TestPassed && 
 
  450   TestPassed = TestPassed && 
 
  453   TestPassed = TestPassed && 
 
  456   TestPassed = TestPassed && 
 
  460     TestPassed = TestPassed && 
 
  463     TestPassed = TestPassed && 
 
  472     int Iters4, Iters8, Iters16;
 
  476     if ((Iters16 > Iters8) && (Iters8 > Iters4)) {
 
  478         cout << 
"Test passed" << endl;
 
  482         cout << 
"TEST FAILED!" << endl;
 
  483       TestPassed = TestPassed && 
false;
 
  492     int Iters0, Iters2, Iters4;
 
  496     if ((Iters4 < Iters2) && (Iters2 < Iters0)) {
 
  498         cout << 
"Test passed" << endl;
 
  502         cout << 
"TEST FAILED!" << endl;
 
  503       TestPassed = TestPassed && 
false;
 
  512     cout << 
"Test `PointPreconditioner.exe' FAILED!" << endl;
 
  520   cout << 
"Test `PointPreconditioner.exe' passed!" << endl;
 
  527 #include "Epetra_MpiComm.h" 
  529 #include "Epetra_SerialComm.h" 
  532 int main(
int argc, 
char *argv[])
 
  536   MPI_Init(&argc,&argv);
 
  542   puts(
"please configure IFPACK with --eanble-aztecoo --enable-teuchos");
 
  543   puts(
"to run this test");
 
  548   return(EXIT_SUCCESS);
 
Epetra_MultiVector * GetLHS() const 
Epetra_MultiVector * GetRHS() const 
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
bool BasicTest(std::string PrecType, const Teuchos::RefCountPtr< Epetra_RowMatrix > &A, bool backward, bool reorder=false)
bool KrylovTest(std::string PrecType, const Teuchos::RefCountPtr< Epetra_RowMatrix > &A, bool backward, bool reorder=false)
virtual int MyPID() const =0
virtual const Epetra_Comm & Comm() const =0
Ifpack_AdditiveSchwarz: a class to define Additive Schwarz preconditioners of Epetra_RowMatrix's. 
Ifpack_PointRelaxation: a class to define point relaxation preconditioners of for Epetra_RowMatrix's...
virtual int NumMyRows() const =0
int main(int argc, char *argv[])
Epetra_RowMatrix * GetMatrix() const 
int CompareBlockOverlap(const Teuchos::RefCountPtr< Epetra_RowMatrix > &A, int Overlap)
int CompareBlockSizes(std::string PrecType, const Teuchos::RefCountPtr< Epetra_RowMatrix > &A, int NumParts)