00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include "Ifpack_ConfigDefs.h"
00031 #include "Ifpack.h"
00032 #include "Ifpack_Preconditioner.h"
00033 #include "Ifpack_PointRelaxation.h"
00034 #include "Ifpack_BlockRelaxation.h"
00035 #include "Ifpack_IC.h"
00036 #include "Ifpack_ICT.h"
00037 #include "Ifpack_ILU.h"
00038 #include "Ifpack_ILUT.h"
00039 #include "Ifpack_SPARSKIT.h"
00040 #include "Ifpack_AdditiveSchwarz.h"
00041 #include "Ifpack_DenseContainer.h"
00042 #include "Ifpack_SparseContainer.h"
00043 #ifdef HAVE_IFPACK_AMESOS
00044 #include "Ifpack_Amesos.h"
00045 #endif
00046 #include "Ifpack_Chebyshev.h"
00047
00048 #include "Teuchos_CommandLineProcessor.hpp"
00049 #include "Teuchos_StringToIntMap.hpp"
00050
00051 namespace {
00052
00053 const Teuchos::StringToIntMap
00054 precTypeNameToIntMap(
00055 "parameter \"Prec Type\"", Ifpack::numPrecTypes, Ifpack::precTypeNames
00056 );
00057
00058 }
00059
00060
00061 const Ifpack::EPrecType Ifpack::precTypeValues[Ifpack::numPrecTypes] =
00062 {
00063 POINT_RELAXATION
00064 ,POINT_RELAXATION_STAND_ALONE
00065 ,BLOCK_RELAXATION
00066 ,BLOCK_RELAXATION_STAND_ALONE
00067 ,BLOCK_RELAXATION_STAND_ALONE_ILU
00068 #ifdef HAVE_IFPACK_AMESOS
00069 ,BLOCK_RELAXATION_STAND_ALONE_AMESOS
00070 ,BLOCK_RELAXATION_AMESOS
00071 ,AMESOS
00072 ,AMESOS_STAND_ALONE
00073 #endif // HAVE_IFPACK_AMESOS
00074 ,IC
00075 ,IC_STAND_ALONE
00076 ,ICT
00077 ,ICT_STAND_ALONE
00078 ,ILU
00079 ,ILU_STAND_ALONE
00080 ,ILUT
00081 ,ILUT_STAND_ALONE
00082 #ifdef HAVE_IFPACK_SPARSKIT
00083 ,SPARSKIT
00084 #endif // HAVE_IFPACK_SPARSKIT
00085 ,CHEBYSHEV
00086 };
00087
00088
00089 const char* Ifpack::precTypeNames[Ifpack::numPrecTypes] =
00090 {
00091 "point relaxation"
00092 ,"point relaxation stand-alone"
00093 ,"block relaxation"
00094 ,"block relaxation stand-alone"
00095 ,"block relaxation stand-alone (ILU)"
00096 #ifdef HAVE_IFPACK_AMESOS
00097 ,"block relaxation stand-alone (Amesos)"
00098 ,"block relaxation (Amesos)"
00099 ,"Amesos"
00100 ,"Amesos stand-alone"
00101 #endif
00102 ,"IC"
00103 ,"IC stand-alone"
00104 ,"ICT"
00105 ,"ICT stand-alone"
00106 ,"ILU"
00107 ,"ILU stand-alone"
00108 ,"ILUT"
00109 ,"ILUT stand-alone"
00110 #ifdef HAVE_IFPACK_SPARSKIT
00111 ,"SPARSKIT"
00112 #endif
00113 ,"Chebyshev"
00114 };
00115
00116
00117 const bool Ifpack::supportsUnsymmetric[Ifpack::numPrecTypes] =
00118 {
00119 true
00120 ,true
00121 ,true
00122 ,true
00123 ,true
00124 #ifdef HAVE_IFPACK_AMESOS
00125 ,true
00126 ,true
00127 ,true
00128 ,true
00129 #endif
00130 ,false
00131 ,false
00132 ,false
00133 ,false
00134 ,true
00135 ,true
00136 ,true
00137 ,true
00138 #ifdef HAVE_IFPACK_SPARSKIT
00139 ,true
00140 #endif
00141 ,false
00142 };
00143
00144
00145 Ifpack_Preconditioner* Ifpack::Create(EPrecType PrecType,
00146 Epetra_RowMatrix* Matrix,
00147 const int Overlap)
00148 {
00149 switch(PrecType) {
00150 case POINT_RELAXATION:
00151 return(new Ifpack_AdditiveSchwarz<Ifpack_PointRelaxation>(Matrix, Overlap));
00152 case POINT_RELAXATION_STAND_ALONE:
00153 return(new Ifpack_PointRelaxation(Matrix));
00154 case BLOCK_RELAXATION:
00155 return(new Ifpack_AdditiveSchwarz<
00156 Ifpack_BlockRelaxation<Ifpack_DenseContainer> >(Matrix,Overlap));
00157 case BLOCK_RELAXATION_STAND_ALONE:
00158 return(new Ifpack_BlockRelaxation<Ifpack_DenseContainer>(Matrix));
00159 case BLOCK_RELAXATION_STAND_ALONE_ILU:
00160 return(new Ifpack_BlockRelaxation<Ifpack_SparseContainer<Ifpack_ILU> >(Matrix));
00161 #ifdef HAVE_IFPACK_AMESOS
00162 case BLOCK_RELAXATION_STAND_ALONE_AMESOS:
00163 return(new Ifpack_BlockRelaxation<Ifpack_SparseContainer<Ifpack_Amesos> >(Matrix));
00164 case BLOCK_RELAXATION_AMESOS:
00165 return(new Ifpack_AdditiveSchwarz<
00166 Ifpack_BlockRelaxation<Ifpack_SparseContainer<Ifpack_Amesos> > >(Matrix,Overlap));
00167 case AMESOS:
00168 return(new Ifpack_AdditiveSchwarz<Ifpack_Amesos>(Matrix,Overlap));
00169 case AMESOS_STAND_ALONE:
00170 return(new Ifpack_Amesos(Matrix));
00171 #endif
00172 case IC:
00173 return(new Ifpack_AdditiveSchwarz<Ifpack_IC>(Matrix,Overlap));
00174 case IC_STAND_ALONE:
00175 return(new Ifpack_IC(Matrix));
00176 case ICT:
00177 return(new Ifpack_AdditiveSchwarz<Ifpack_ICT>(Matrix,Overlap));
00178 case ICT_STAND_ALONE:
00179 return(new Ifpack_ICT(Matrix));
00180 case ILU:
00181 return(new Ifpack_AdditiveSchwarz<Ifpack_ILU>(Matrix,Overlap));
00182 case ILU_STAND_ALONE:
00183 return(new Ifpack_ILU(Matrix));
00184 case ILUT:
00185 return(new Ifpack_AdditiveSchwarz<Ifpack_ILUT>(Matrix,Overlap));
00186 case ILUT_STAND_ALONE:
00187 return(new Ifpack_ILUT(Matrix));
00188 #ifdef HAVE_IFPACK_SPARSKIT
00189 case SPARSKIT:
00190 return(new Ifpack_SPARSKIT(Matrix));
00191 #endif
00192 case CHEBYSHEV:
00193 return(new Ifpack_Chebyshev(Matrix));
00194 default:
00195 TEST_FOR_EXCEPT(true);
00196
00197
00198
00199 }
00200 return 0;
00201 }
00202
00203
00204 Ifpack_Preconditioner* Ifpack::Create(const string PrecType,
00205 Epetra_RowMatrix* Matrix,
00206 const int Overlap)
00207 {
00208 try {
00209 return Ifpack::Create(Teuchos::get<EPrecType>(::precTypeNameToIntMap,PrecType),Matrix,Overlap);
00210 }
00211 catch( const Teuchos::StringToIntMap::DoesNotExist &excpt ) {
00212
00213
00214
00215
00216
00217
00218 }
00219 return 0;
00220 }
00221
00222
00223 int Ifpack::SetParameters(int argc, char* argv[],
00224 Teuchos::ParameterList& List, string& PrecType,
00225 int& Overlap)
00226 {
00227
00228
00229 Teuchos::CommandLineProcessor CLP;
00230
00231
00232 string ifp_prec_type = "ILU";
00233 CLP.setOption("ifp-prec-type",&ifp_prec_type,"Preconditioner type");
00234
00235 int ifp_overlap = 0;
00236 CLP.setOption("ifp-overlap",&ifp_overlap,"Overlap among processors");
00237
00238 string ifp_relax_type = "Jacobi";
00239 CLP.setOption("ifp-relax-type",&ifp_relax_type,"Relaxation type");
00240
00241 int ifp_relax_sweeps = 1;
00242 CLP.setOption("ifp-relax-sweeps",
00243 &ifp_relax_sweeps,"Number of sweeps for relaxation");
00244
00245 double ifp_relax_damping = 1.0;
00246 CLP.setOption("ifp-relax-damping",
00247 &ifp_relax_damping,"Damping for relaxation");
00248
00249 string ifp_part_type = "greedy";
00250 CLP.setOption("ifp-part-type",&ifp_part_type,"Partitioner type");
00251
00252 int ifp_part_local = 1;
00253 CLP.setOption("ifp-part-local",&ifp_part_local,"number of local partitions");
00254
00255
00256 CLP.recogniseAllOptions(false);
00257 CLP.throwExceptions(false);
00258 CLP.parse(argc,argv);
00259
00260
00261 PrecType = ifp_prec_type;
00262 Overlap = ifp_overlap;
00263
00264
00265 List.set("relaxation: type", ifp_relax_type);
00266 List.set("relaxation: sweeps", ifp_relax_sweeps);
00267 List.set("relaxation: damping factor", ifp_relax_damping);
00268 List.set("partitioner: type", ifp_part_type);
00269 List.set("partitioner: local parts", ifp_part_local);
00270
00271 return(0);
00272 }