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 "Ifpack_Preconditioner.h"
00048 #include "Ifpack.h"
00049 #include "AztecOO.h"
00050 #ifdef HAVE_IFPACK_AMESOS
00051 #include "Amesos_TestRowMatrix.h"
00052 #endif
00053 
00054 // =======================================================================
00055 // GOAL: test that the names in the factory do not change. This test
00056 //       will not solve any linear system.
00057 //
00058 int main(int argc, char *argv[])
00059 {
00060 #ifdef HAVE_MPI
00061   MPI_Init(&argc,&argv);
00062   Epetra_MpiComm Comm( MPI_COMM_WORLD );
00063 #else
00064   Epetra_SerialComm Comm;
00065 #endif
00066 
00067   Teuchos::ParameterList GaleriList;
00068   const int n = 9; 
00069   GaleriList.set("n", n);
00070   Epetra_Map* Map = Galeri::CreateMap("Linear", Comm, GaleriList);
00071   Epetra_CrsMatrix* A = Galeri::CreateCrsMatrix("Minij", Map, GaleriList);
00072   
00073   Ifpack Factory;
00074   Ifpack_Preconditioner* Prec;
00075 
00076   Prec = Factory.Create("point relaxation", A);
00077   assert (Prec != 0);
00078   IFPACK_CHK_ERR(Prec->Initialize());
00079   IFPACK_CHK_ERR(Prec->Compute());
00080   cout << *Prec;
00081   delete Prec;
00082 
00083   Prec = Factory.Create("point relaxation stand-alone", A);
00084   assert (Prec != 0);
00085   IFPACK_CHK_ERR(Prec->Initialize());
00086   IFPACK_CHK_ERR(Prec->Compute());
00087   cout << *Prec;
00088   delete Prec;
00089 
00090   Prec = Factory.Create("block relaxation", A);
00091   assert (Prec != 0);
00092   IFPACK_CHK_ERR(Prec->Initialize());
00093   IFPACK_CHK_ERR(Prec->Compute());
00094   cout << *Prec;
00095   delete Prec;
00096 
00097   Prec = Factory.Create("block relaxation stand-alone", A);
00098   assert (Prec != 0);
00099   IFPACK_CHK_ERR(Prec->Initialize());
00100   IFPACK_CHK_ERR(Prec->Compute());
00101   cout << *Prec;
00102   delete Prec;
00103 
00104   Prec = Factory.Create("IC", A);
00105   assert (Prec != 0);
00106   IFPACK_CHK_ERR(Prec->Initialize());
00107   IFPACK_CHK_ERR(Prec->Compute());
00108   cout << *Prec;
00109   delete Prec;
00110 
00111   Prec = Factory.Create("ICT", A);
00112   assert (Prec != 0);
00113   IFPACK_CHK_ERR(Prec->Initialize());
00114   IFPACK_CHK_ERR(Prec->Compute());
00115   cout << *Prec;
00116   delete Prec;
00117 
00118   Prec = Factory.Create("ILU", A);
00119   assert (Prec != 0);
00120   IFPACK_CHK_ERR(Prec->Initialize());
00121   IFPACK_CHK_ERR(Prec->Compute());
00122   cout << *Prec;
00123   delete Prec;
00124 
00125   Prec = Factory.Create("ILUT", A);
00126   assert (Prec != 0);
00127   IFPACK_CHK_ERR(Prec->Initialize());
00128   IFPACK_CHK_ERR(Prec->Compute());
00129   cout << *Prec;
00130   delete Prec;
00131 
00132   Prec = Factory.Create("IC stand-alone", A);
00133   assert (Prec != 0);
00134   IFPACK_CHK_ERR(Prec->Initialize());
00135   IFPACK_CHK_ERR(Prec->Compute());
00136   cout << *Prec;
00137   delete Prec;
00138 
00139   Prec = Factory.Create("ICT stand-alone", A);
00140   assert (Prec != 0);
00141   IFPACK_CHK_ERR(Prec->Initialize());
00142   IFPACK_CHK_ERR(Prec->Compute());
00143   cout << *Prec;
00144   delete Prec;
00145 
00146   Prec = Factory.Create("ILU stand-alone", A);
00147   assert (Prec != 0);
00148   IFPACK_CHK_ERR(Prec->Initialize());
00149   IFPACK_CHK_ERR(Prec->Compute());
00150   cout << *Prec;
00151   delete Prec;
00152 
00153   Prec = Factory.Create("ILUT stand-alone", A);
00154   assert (Prec != 0);
00155   IFPACK_CHK_ERR(Prec->Initialize());
00156   IFPACK_CHK_ERR(Prec->Compute());
00157   cout << *Prec;
00158   delete Prec;
00159 
00160 #ifdef HAVE_IFPACK_AMESOS
00161   Prec = Factory.Create("Amesos", A);
00162   assert (Prec != 0);
00163   IFPACK_CHK_ERR(Prec->Initialize());
00164   IFPACK_CHK_ERR(Prec->Compute());
00165   cout << *Prec;
00166   delete Prec;
00167 
00168   Prec = Factory.Create("Amesos stand-alone", A);
00169   assert (Prec != 0);
00170   IFPACK_CHK_ERR(Prec->Initialize());
00171   IFPACK_CHK_ERR(Prec->Compute());
00172   cout << *Prec;
00173   delete Prec;
00174 #endif
00175   
00176   Prec = Factory.Create("Chebyshev", A);
00177   assert (Prec != 0);
00178   IFPACK_CHK_ERR(Prec->Initialize());
00179   IFPACK_CHK_ERR(Prec->Compute());
00180   cout << *Prec;
00181 
00182   delete Prec;
00183   delete A;
00184   delete Map;
00185 
00186   if (Comm.MyPID() == 0)
00187     cout << "Test `PrecondititonerFactory.exe' passed!" << endl;
00188 
00189 #ifdef HAVE_MPI
00190   MPI_Finalize() ; 
00191 #endif
00192 
00193   return(EXIT_SUCCESS);
00194 }

Generated on Thu Sep 18 12:37:21 2008 for Ifpack Package Browser (Single Doxygen Collection) by doxygen 1.3.9.1