test/PreconditionerFactory/cxx_main.cpp

Go to the documentation of this file.
00001 // @HEADER
00002 // ***********************************************************************
00003 // 
00004 //                IFPACK
00005 //                 Copyright (2004) Sandia Corporation
00006 // 
00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00008 // license for use of this work by or on behalf of the U.S. Government.
00009 // 
00010 // This library is free software; you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as
00012 // published by the Free Software Foundation; either version 2.1 of the
00013 // License, or (at your option) any later version.
00014 //  
00015 // This library is distributed in the hope that it will be useful, but
00016 // WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 // Lesser General Public License for more details.
00019 //  
00020 // You should have received a copy of the GNU Lesser General Public
00021 // License along with this library; if not, write to the Free Software
00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00023 // USA
00024 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 
00025 // 
00026 // ***********************************************************************
00027 // @HEADER
00028 
00029 #ifdef NDEBUG
00030 #undef NDEBUG
00031 #endif
00032 
00033 #include "Ifpack_ConfigDefs.h"
00034 
00035 #ifdef HAVE_MPI
00036 #include "Epetra_MpiComm.h"
00037 #else
00038 #include "Epetra_SerialComm.h"
00039 #endif
00040 #include "Epetra_CrsMatrix.h"
00041 #include "Epetra_Vector.h"
00042 #include "Epetra_LinearProblem.h"
00043 #include "Epetra_Map.h"
00044 #include "Galeri_Maps.h"
00045 #include "Galeri_CrsMatrices.h"
00046 #include "Teuchos_ParameterList.hpp"
00047 #include "Teuchos_RefCountPtr.hpp"
00048 #include "Ifpack_Preconditioner.h"
00049 #include "Ifpack.h"
00050 #include "AztecOO.h"
00051 #ifdef HAVE_IFPACK_AMESOS
00052 #include "Amesos_TestRowMatrix.h"
00053 #endif
00054 
00055 // =======================================================================
00056 // GOAL: test that the names in the factory do not change. This test
00057 //       will not solve any linear system.
00058 //
00059 int main(int argc, char *argv[])
00060 {
00061 #ifdef HAVE_MPI
00062   MPI_Init(&argc,&argv);
00063   Epetra_MpiComm Comm( MPI_COMM_WORLD );
00064 #else
00065   Epetra_SerialComm Comm;
00066 #endif
00067 
00068   Teuchos::ParameterList GaleriList;
00069   const int n = 9; 
00070   GaleriList.set("n", n);
00071   Teuchos::RefCountPtr<Epetra_Map> Map = Teuchos::rcp( Galeri::CreateMap("Linear", Comm, GaleriList) );
00072   Teuchos::RefCountPtr<Epetra_CrsMatrix> A = Teuchos::rcp( Galeri::CreateCrsMatrix("Minij", &*Map, GaleriList) );
00073   
00074   Ifpack Factory;
00075   Teuchos::RefCountPtr<Ifpack_Preconditioner> Prec;
00076 
00077   Prec = Teuchos::rcp( Factory.Create("point relaxation", &*A) );
00078   assert (Prec != Teuchos::null);
00079   IFPACK_CHK_ERR(Prec->Initialize());
00080   IFPACK_CHK_ERR(Prec->Compute());
00081   cout << *Prec;
00082 
00083   Prec = Teuchos::rcp( Factory.Create("point relaxation stand-alone", &*A) );
00084   assert (Prec != Teuchos::null);
00085   IFPACK_CHK_ERR(Prec->Initialize());
00086   IFPACK_CHK_ERR(Prec->Compute());
00087   cout << *Prec;
00088 
00089   Prec = Teuchos::rcp( Factory.Create("block relaxation", &*A) );
00090   assert (Prec != Teuchos::null);
00091   IFPACK_CHK_ERR(Prec->Initialize());
00092   IFPACK_CHK_ERR(Prec->Compute());
00093   cout << *Prec;
00094 
00095   Prec = Teuchos::rcp( Factory.Create("block relaxation stand-alone", &*A) );
00096   assert (Prec != Teuchos::null);
00097   IFPACK_CHK_ERR(Prec->Initialize());
00098   IFPACK_CHK_ERR(Prec->Compute());
00099   cout << *Prec;
00100 
00101   Prec = Teuchos::rcp( Factory.Create("IC", &*A) );
00102   assert (Prec != Teuchos::null);
00103   IFPACK_CHK_ERR(Prec->Initialize());
00104   IFPACK_CHK_ERR(Prec->Compute());
00105   cout << *Prec;
00106 
00107   Prec = Teuchos::rcp( Factory.Create("ICT", &*A) );
00108   assert (Prec != Teuchos::null);
00109   IFPACK_CHK_ERR(Prec->Initialize());
00110   IFPACK_CHK_ERR(Prec->Compute());
00111   cout << *Prec;
00112 
00113   Prec = Teuchos::rcp( Factory.Create("ILU", &*A) );
00114   assert (Prec != Teuchos::null);
00115   IFPACK_CHK_ERR(Prec->Initialize());
00116   IFPACK_CHK_ERR(Prec->Compute());
00117   cout << *Prec;
00118 
00119   Prec = Teuchos::rcp( Factory.Create("ILUT", &*A) );
00120   assert (Prec != Teuchos::null);
00121   IFPACK_CHK_ERR(Prec->Initialize());
00122   IFPACK_CHK_ERR(Prec->Compute());
00123   cout << *Prec;
00124 
00125   Prec = Teuchos::rcp( Factory.Create("IC stand-alone", &*A) );
00126   assert (Prec != Teuchos::null);
00127   IFPACK_CHK_ERR(Prec->Initialize());
00128   IFPACK_CHK_ERR(Prec->Compute());
00129   cout << *Prec;
00130 
00131   Prec = Teuchos::rcp( Factory.Create("ICT stand-alone", &*A) );
00132   assert (Prec != Teuchos::null);
00133   IFPACK_CHK_ERR(Prec->Initialize());
00134   IFPACK_CHK_ERR(Prec->Compute());
00135   cout << *Prec;
00136 
00137   Prec = Teuchos::rcp( Factory.Create("ILU stand-alone", &*A) );
00138   assert (Prec != Teuchos::null);
00139   IFPACK_CHK_ERR(Prec->Initialize());
00140   IFPACK_CHK_ERR(Prec->Compute());
00141   cout << *Prec;
00142 
00143   Prec = Teuchos::rcp( Factory.Create("ILUT stand-alone", &*A) );
00144   assert (Prec != Teuchos::null);
00145   IFPACK_CHK_ERR(Prec->Initialize());
00146   IFPACK_CHK_ERR(Prec->Compute());
00147   cout << *Prec;
00148 
00149 #ifdef HAVE_IFPACK_AMESOS
00150   Prec = Teuchos::rcp( Factory.Create("Amesos", &*A) );
00151   assert (Prec != Teuchos::null);
00152   IFPACK_CHK_ERR(Prec->Initialize());
00153   IFPACK_CHK_ERR(Prec->Compute());
00154   cout << *Prec;
00155 
00156   Prec = Teuchos::rcp( Factory.Create("Amesos stand-alone", &*A) );
00157   assert (Prec != Teuchos::null);
00158   IFPACK_CHK_ERR(Prec->Initialize());
00159   IFPACK_CHK_ERR(Prec->Compute());
00160   cout << *Prec;
00161 #endif
00162   
00163   Prec = Teuchos::rcp( Factory.Create("Chebyshev", &*A) );
00164   assert (Prec != Teuchos::null);
00165   IFPACK_CHK_ERR(Prec->Initialize());
00166   IFPACK_CHK_ERR(Prec->Compute());
00167   cout << *Prec;
00168 
00169   if (Comm.MyPID() == 0)
00170     cout << "Test `PrecondititonerFactory.exe' passed!" << endl;
00171 
00172 #ifdef HAVE_MPI
00173   MPI_Finalize() ; 
00174 #endif
00175 
00176   return(EXIT_SUCCESS);
00177 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Generated on Wed Apr 13 10:05:33 2011 for Ifpack Package Browser (Single Doxygen Collection) by  doxygen 1.6.3