Ifpack.cpp

00001 #include "Ifpack_ConfigDefs.h"
00002 #if defined(HAVE_IFPACK_TEUCHOS)
00003 #include "Ifpack.h"
00004 #include "Ifpack_Preconditioner.h"
00005 #include "Ifpack_PointRelaxation.h"
00006 #include "Ifpack_BlockRelaxation.h"
00007 #include "Ifpack_IC.h"
00008 #include "Ifpack_ICT.h"
00009 #include "Ifpack_ILU.h"
00010 #include "Ifpack_ILUT.h"
00011 #include "Ifpack_SPARSKIT.h"
00012 #include "Ifpack_AdditiveSchwarz.h"
00013 #include "Ifpack_DenseContainer.h"
00014 #include "Ifpack_SparseContainer.h"
00015 #include "Teuchos_CommandLineProcessor.hpp"
00016 #ifdef HAVE_IFPACK_AMESOS
00017 #include "Ifpack_Amesos.h"
00018 #endif
00019 #include "Ifpack_Chebyshev.h"
00020 
00021 //==============================================================================
00022 Ifpack_Preconditioner* Ifpack::Create(const string PrecType,
00023                                       Epetra_RowMatrix* Matrix,
00024                                       const int Overlap)
00025 {
00026 
00027   if (PrecType == "point relaxation") {
00028     return(new Ifpack_AdditiveSchwarz<Ifpack_PointRelaxation>(Matrix, Overlap));
00029   }
00030   else if (PrecType == "point relaxation stand-alone") {
00031     return(new Ifpack_PointRelaxation(Matrix));
00032   }
00033   else if (PrecType == "block relaxation") {
00034     return(new Ifpack_AdditiveSchwarz<
00035             Ifpack_BlockRelaxation<Ifpack_DenseContainer> >(Matrix,Overlap));
00036   }
00037   else if (PrecType == "block relaxation stand-alone") {
00038     return(new Ifpack_BlockRelaxation<Ifpack_DenseContainer>(Matrix));
00039   }
00040   else if (PrecType == "block relaxation stand-alone (ILU)") {
00041     return(new Ifpack_BlockRelaxation<Ifpack_SparseContainer<Ifpack_ILU> >(Matrix));
00042   }
00043 #ifdef HAVE_IFPACK_AMESOS
00044   else if (PrecType == "block relaxation stand-alone (Amesos)") {
00045     return(new Ifpack_BlockRelaxation<Ifpack_SparseContainer<Ifpack_Amesos> >(Matrix));
00046   }
00047   else if (PrecType == "block relaxation (Amesos)") {
00048     return(new Ifpack_AdditiveSchwarz<
00049             Ifpack_BlockRelaxation<Ifpack_SparseContainer<Ifpack_Amesos> > >(Matrix,Overlap));
00050   }
00051   else if (PrecType == "Amesos") {
00052     return(new Ifpack_AdditiveSchwarz<Ifpack_Amesos>(Matrix,Overlap));
00053   }
00054   else if (PrecType == "Amesos stand-alone" || PrecType == "LU") {
00055     return(new Ifpack_Amesos(Matrix));
00056   }
00057 #endif
00058   else if (PrecType == "IC") {
00059     return(new Ifpack_AdditiveSchwarz<Ifpack_IC>(Matrix,Overlap));
00060 
00061   } 
00062   else if (PrecType == "IC stand-alone") {
00063     return(new Ifpack_IC(Matrix));
00064 
00065   } 
00066   else if (PrecType == "ICT") {
00067     return(new Ifpack_AdditiveSchwarz<Ifpack_ICT>(Matrix,Overlap));
00068 
00069   } 
00070   else if (PrecType == "ICT stand-alone") {
00071     return(new Ifpack_ICT(Matrix));
00072 
00073   } 
00074   else if (PrecType == "ILU") {
00075     return(new Ifpack_AdditiveSchwarz<Ifpack_ILU>(Matrix,Overlap));
00076   }
00077   else if (PrecType == "ILU stand-alone") {
00078     return(new Ifpack_ILU(Matrix));
00079   }
00080   else if (PrecType == "ILUT") {
00081     return(new Ifpack_AdditiveSchwarz<Ifpack_ILUT>(Matrix,Overlap));
00082   }
00083   else if (PrecType == "ILUT stand-alone") {
00084     return(new Ifpack_ILUT(Matrix));
00085   }
00086 #ifdef HAVE_IFPACK_SPARSKIT
00087   else if (PrecType == "SPARSKIT") {
00088     return(new Ifpack_SPARSKIT(Matrix));
00089   }
00090 #endif
00091   else if (PrecType == "Chebyshev") {
00092     return(new Ifpack_Chebyshev(Matrix));
00093   }
00094   else
00095     // nothing understandable
00096     return(0);
00097 
00098 }
00099 
00100 // ======================================================================
00101 int Ifpack::SetParameters(int argc, char* argv[],
00102                           Teuchos::ParameterList& List, string& PrecType,
00103                           int& Overlap)
00104 {
00105   // THIS FUNCTION IS VERY INCOMPLETE...
00106 
00107   Teuchos::CommandLineProcessor CLP;
00108 
00109   // prec type
00110   string ifp_prec_type = "ILU";
00111   CLP.setOption("ifp-prec-type",&ifp_prec_type,"Preconditioner type");
00112   // overlap among the processors
00113   int ifp_overlap = 0;
00114   CLP.setOption("ifp-overlap",&ifp_overlap,"Overlap among processors");
00115   // relaxation type
00116   string ifp_relax_type = "Jacobi";
00117   CLP.setOption("ifp-relax-type",&ifp_relax_type,"Relaxation type");
00118   // sweeps (for relax only)
00119   int ifp_relax_sweeps = 1;
00120   CLP.setOption("ifp-relax-sweeps",
00121                 &ifp_relax_sweeps,"Number of sweeps for relaxation");
00122   // damping (for relax only)
00123   double ifp_relax_damping = 1.0;
00124   CLP.setOption("ifp-relax-damping",
00125                 &ifp_relax_damping,"Damping for relaxation");
00126   // partitioner type (for block relaxation only)
00127   string ifp_part_type = "greedy";
00128   CLP.setOption("ifp-part-type",&ifp_part_type,"Partitioner type");
00129   // number of local parts (for block relaxation only)
00130   int ifp_part_local = 1;
00131   CLP.setOption("ifp-part-local",&ifp_part_local,"number of local partitions");
00132 
00133   // allow users to specify other options for other packages
00134   CLP.recogniseAllOptions(false);
00135   CLP.throwExceptions(false);
00136   CLP.parse(argc,argv);
00137 
00138   // I cannot really set those in the List, I pass them back to the user
00139   PrecType = ifp_prec_type;
00140   Overlap = ifp_overlap;
00141 
00142   // set the list here
00143   List.set("relaxation: type", ifp_relax_type);
00144   List.set("relaxation: sweeps", ifp_relax_sweeps);
00145   List.set("relaxation: damping factor", ifp_relax_damping);
00146   List.set("partitioner: type", ifp_part_type);
00147   List.set("partitioner: local parts", ifp_part_local);
00148 
00149   return(0);
00150 }
00151 #endif // HAVE_IFPACK_TEUCHOS

Generated on Thu Sep 18 12:37:07 2008 for IFPACK by doxygen 1.3.9.1