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 #ifdef HAVE_IFPACK_HIPS
00047 #include "Ifpack_HIPS.h"
00048 #endif
00049 #ifdef HAVE_IFPACK_SUPERLU
00050 #include "Ifpack_SILU.h"
00051 #endif
00052
00053 #include "Ifpack_Chebyshev.h"
00054 #include "Ifpack_IHSS.h"
00055 #include "Ifpack_SORa.h"
00056
00057 #include "Teuchos_CommandLineProcessor.hpp"
00058 #include "Teuchos_StringToIntMap.hpp"
00059 #include "Epetra_CrsMatrix.h"
00060
00061
00062 namespace {
00063
00064 const Teuchos::StringToIntMap
00065 precTypeNameToIntMap(
00066 "parameter \"Prec Type\"", Ifpack::numPrecTypes, Ifpack::precTypeNames
00067 );
00068
00069 }
00070
00071
00072 const Ifpack::EPrecType Ifpack::precTypeValues[Ifpack::numPrecTypes] =
00073 {
00074 POINT_RELAXATION
00075 ,POINT_RELAXATION_STAND_ALONE
00076 ,BLOCK_RELAXATION
00077 ,BLOCK_RELAXATION_STAND_ALONE
00078 ,BLOCK_RELAXATION_STAND_ALONE_ILU
00079 #ifdef HAVE_IFPACK_AMESOS
00080 ,BLOCK_RELAXATION_STAND_ALONE_AMESOS
00081 ,BLOCK_RELAXATION_AMESOS
00082 ,AMESOS
00083 ,AMESOS_STAND_ALONE
00084 #endif // HAVE_IFPACK_AMESOS
00085 ,IC
00086 ,IC_STAND_ALONE
00087 ,ICT
00088 ,ICT_STAND_ALONE
00089 ,ILU
00090 ,ILU_STAND_ALONE
00091 ,ILUT
00092 ,ILUT_STAND_ALONE
00093 #ifdef HAVE_IFPACK_SPARSKIT
00094 ,SPARSKIT
00095 #endif // HAVE_IFPACK_SPARSKIT
00096 #ifdef HAVE_IFPACK_HIPS
00097 ,HIPS
00098 #endif
00099 #ifdef HAVE_HYPRE
00100 ,HYPRE
00101 #endif
00102 #ifdef HAVE_IFPACK_SUPERLU
00103 ,SILU
00104 #endif
00105 ,CHEBYSHEV
00106 ,IHSS
00107 ,SORA
00108 };
00109
00110
00111 const char* Ifpack::precTypeNames[Ifpack::numPrecTypes] =
00112 {
00113 "point relaxation"
00114 ,"point relaxation stand-alone"
00115 ,"block relaxation"
00116 ,"block relaxation stand-alone"
00117 ,"block relaxation stand-alone (ILU)"
00118 #ifdef HAVE_IFPACK_AMESOS
00119 ,"block relaxation stand-alone (Amesos)"
00120 ,"block relaxation (Amesos)"
00121 ,"Amesos"
00122 ,"Amesos stand-alone"
00123 #endif
00124 ,"IC"
00125 ,"IC stand-alone"
00126 ,"ICT"
00127 ,"ICT stand-alone"
00128 ,"ILU"
00129 ,"ILU stand-alone"
00130 ,"ILUT"
00131 ,"ILUT stand-alone"
00132 #ifdef HAVE_IFPACK_SPARSKIT
00133 ,"SPARSKIT"
00134 #endif
00135 #ifdef HAVE_IFPACK_HIPS
00136 ,"HIPS"
00137 #endif
00138 #ifdef HAVE_HYPRE
00139 ,"Hypre"
00140 #endif
00141 #ifdef HAVE_IFPACK_SUPERLU
00142 ,"SILU"
00143 #endif
00144 ,"Chebyshev"
00145 ,"IHSS"
00146 ,"SORa"
00147 };
00148
00149
00150 const bool Ifpack::supportsUnsymmetric[Ifpack::numPrecTypes] =
00151 {
00152 true
00153 ,true
00154 ,true
00155 ,true
00156 ,true
00157 #ifdef HAVE_IFPACK_AMESOS
00158 ,true
00159 ,true
00160 ,true
00161 ,true
00162 #endif
00163 ,false
00164 ,false
00165 ,false
00166 ,false
00167 ,true
00168 ,true
00169 ,true
00170 ,true
00171 #ifdef HAVE_IFPACK_SPARSKIT
00172 ,true
00173 #endif
00174 #ifdef HAVE_IFPACK_HIPS
00175 ,true
00176 #endif
00177 #ifdef HAVE_HYPRE
00178 ,true
00179 #endif
00180 #ifdef HAVE_IFPACK_SUPERLU
00181 ,true
00182 #endif
00183 ,false
00184 ,true
00185 ,true
00186 };
00187
00188
00189 Ifpack_Preconditioner* Ifpack::Create(EPrecType PrecType,
00190 Epetra_RowMatrix* Matrix,
00191 const int Overlap)
00192 {
00193 switch(PrecType) {
00194 case POINT_RELAXATION:
00195 return(new Ifpack_AdditiveSchwarz<Ifpack_PointRelaxation>(Matrix, Overlap));
00196 case POINT_RELAXATION_STAND_ALONE:
00197 return(new Ifpack_PointRelaxation(Matrix));
00198 case BLOCK_RELAXATION:
00199 return(new Ifpack_AdditiveSchwarz<
00200 Ifpack_BlockRelaxation<Ifpack_DenseContainer> >(Matrix,Overlap));
00201 case BLOCK_RELAXATION_STAND_ALONE:
00202 return(new Ifpack_BlockRelaxation<Ifpack_DenseContainer>(Matrix));
00203 case BLOCK_RELAXATION_STAND_ALONE_ILU:
00204 return(new Ifpack_BlockRelaxation<Ifpack_SparseContainer<Ifpack_ILU> >(Matrix));
00205 #ifdef HAVE_IFPACK_AMESOS
00206 case BLOCK_RELAXATION_STAND_ALONE_AMESOS:
00207 return(new Ifpack_BlockRelaxation<Ifpack_SparseContainer<Ifpack_Amesos> >(Matrix));
00208 case BLOCK_RELAXATION_AMESOS:
00209 return(new Ifpack_AdditiveSchwarz<
00210 Ifpack_BlockRelaxation<Ifpack_SparseContainer<Ifpack_Amesos> > >(Matrix,Overlap));
00211 case AMESOS:
00212 return(new Ifpack_AdditiveSchwarz<Ifpack_Amesos>(Matrix,Overlap));
00213 case AMESOS_STAND_ALONE:
00214 return(new Ifpack_Amesos(Matrix));
00215 #endif
00216 case IC:
00217 return(new Ifpack_AdditiveSchwarz<Ifpack_IC>(Matrix,Overlap));
00218 case IC_STAND_ALONE:
00219 return(new Ifpack_IC(Matrix));
00220 case ICT:
00221 return(new Ifpack_AdditiveSchwarz<Ifpack_ICT>(Matrix,Overlap));
00222 case ICT_STAND_ALONE:
00223 return(new Ifpack_ICT(Matrix));
00224 case ILU:
00225 return(new Ifpack_AdditiveSchwarz<Ifpack_ILU>(Matrix,Overlap));
00226 case ILU_STAND_ALONE:
00227 return(new Ifpack_ILU(Matrix));
00228 case ILUT:
00229 return(new Ifpack_AdditiveSchwarz<Ifpack_ILUT>(Matrix,Overlap));
00230 case ILUT_STAND_ALONE:
00231 return(new Ifpack_ILUT(Matrix));
00232 #ifdef HAVE_IFPACK_SPARSKIT
00233 case SPARSKIT:
00234 return(new Ifpack_SPARSKIT(Matrix));
00235 #endif
00236 #ifdef HAVE_IFPACK_HIPS
00237 case HIPS:
00238 return(new Ifpack_HIPS(Matrix));
00239 #endif
00240 #ifdef HAVE_HYPRE
00241 case HYPRE:
00242 return(new Ifpack_Hypre(Matrix));
00243 #endif
00244 #ifdef HAVE_IFPACK_SUPERLU
00245 case SILU:
00246 return(new Ifpack_SILU(Matrix));
00247 #endif
00248 case CHEBYSHEV:
00249 return(new Ifpack_Chebyshev(Matrix));
00250 #ifdef HAVE_IFPACK_EPETRAEXT
00251 case IHSS:
00252 return(new Ifpack_IHSS(Matrix));
00253 case SORA:
00254 return(new Ifpack_SORa(Matrix));
00255 #endif
00256 default:
00257 TEUCHOS_TEST_FOR_EXCEPT(true);
00258
00259
00260
00261 }
00262 return 0;
00263 }
00264
00265
00266 Ifpack_Preconditioner* Ifpack::Create(const string PrecType,
00267 Epetra_RowMatrix* Matrix,
00268 const int Overlap)
00269 {
00270 try {
00271 return Ifpack::Create(Teuchos::get<EPrecType>(::precTypeNameToIntMap,PrecType),Matrix,Overlap);
00272 }
00273 catch( const Teuchos::StringToIntMap::DoesNotExist &excpt ) {
00274
00275
00276
00277
00278
00279
00280 }
00281 return 0;
00282 }
00283
00284
00285 int Ifpack::SetParameters(int argc, char* argv[],
00286 Teuchos::ParameterList& List, string& PrecType,
00287 int& Overlap)
00288 {
00289
00290
00291 Teuchos::CommandLineProcessor CLP;
00292
00293
00294 string ifp_prec_type = "ILU";
00295 CLP.setOption("ifp-prec-type",&ifp_prec_type,"Preconditioner type");
00296
00297 int ifp_overlap = 0;
00298 CLP.setOption("ifp-overlap",&ifp_overlap,"Overlap among processors");
00299
00300 string ifp_relax_type = "Jacobi";
00301 CLP.setOption("ifp-relax-type",&ifp_relax_type,"Relaxation type");
00302
00303 int ifp_relax_sweeps = 1;
00304 CLP.setOption("ifp-relax-sweeps",
00305 &ifp_relax_sweeps,"Number of sweeps for relaxation");
00306
00307 double ifp_relax_damping = 1.0;
00308 CLP.setOption("ifp-relax-damping",
00309 &ifp_relax_damping,"Damping for relaxation");
00310
00311 string ifp_part_type = "greedy";
00312 CLP.setOption("ifp-part-type",&ifp_part_type,"Partitioner type");
00313
00314 int ifp_part_local = 1;
00315 CLP.setOption("ifp-part-local",&ifp_part_local,"number of local partitions");
00316
00317
00318 CLP.recogniseAllOptions(false);
00319 CLP.throwExceptions(false);
00320 CLP.parse(argc,argv);
00321
00322
00323 PrecType = ifp_prec_type;
00324 Overlap = ifp_overlap;
00325
00326
00327 List.set("relaxation: type", ifp_relax_type);
00328 List.set("relaxation: sweeps", ifp_relax_sweeps);
00329 List.set("relaxation: damping factor", ifp_relax_damping);
00330 List.set("partitioner: type", ifp_part_type);
00331 List.set("partitioner: local parts", ifp_part_local);
00332
00333 return(0);
00334 }