Amesos Package Browser (Single Doxygen Collection) Development
Amesos.cpp
Go to the documentation of this file.
00001 // @HEADER
00002 // ***********************************************************************
00003 // 
00004 //                Amesos: Direct Sparse Solver Package
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 #include "Amesos_config.h"
00030 #include "Amesos.h"
00031 #include "Amesos_Klu.h"
00032 #ifdef HAVE_AMESOS_LAPACK
00033 #include "Amesos_Lapack.h"
00034 #endif
00035 #ifdef HAVE_AMESOS_MUMPS
00036 #include "Amesos_Mumps.h"
00037 #endif
00038 #ifdef HAVE_AMESOS_SCALAPACK
00039 #include "Amesos_Scalapack.h"
00040 #endif
00041 #ifdef HAVE_AMESOS_UMFPACK
00042 #include "Amesos_Umfpack.h"
00043 #endif
00044 #ifdef HAVE_AMESOS_SUPERLUDIST
00045 #include "Amesos_Superludist.h"
00046 #endif
00047 #ifdef HAVE_AMESOS_SUPERLU
00048 #include "Amesos_Superlu.h"
00049 #endif
00050 #ifdef HAVE_AMESOS_DSCPACK
00051 #include "Amesos_Dscpack.h"
00052 #endif
00053 #if defined(HAVE_AMESOS_PARDISO) || defined(HAVE_AMESOS_PARDISO_MKL)
00054 #include "Amesos_Pardiso.h"
00055 #endif
00056 #ifdef HAVE_AMESOS_TAUCS
00057 #include "Amesos_Taucs.h"
00058 #endif
00059 #ifdef HAVE_AMESOS_PARAKLETE
00060 #include "Amesos_Paraklete.h"
00061 #endif
00062 #ifdef HAVE_AMESOS_CSPARSE
00063 #include "Amesos_CSparse.h"
00064 #endif
00065 #include "Epetra_Object.h"
00066 
00067 static bool verbose = false; 
00068 
00069 Amesos_BaseSolver* Amesos::Create(const char* ClassType, 
00070           const Epetra_LinearProblem& LinearProblem ) 
00071 { 
00072   std::string CT = ClassType; 
00073   return(Create(CT,LinearProblem));
00074 }
00075 
00076 Amesos_BaseSolver* Amesos::Create(const std::string CT,
00077           const Epetra_LinearProblem& LinearProblem )
00078 {
00079 
00080   if ((CT == "Amesos_Lapack") || (CT == "Lapack")) { 
00081 #ifdef HAVE_AMESOS_LAPACK
00082     return new Amesos_Lapack(LinearProblem); 
00083 #else
00084     if (verbose) std::cerr << "Amesos_Lapack is not implemented" << std::endl ; 
00085     return(0); 
00086 #endif
00087   } 
00088   
00089   if ((CT == "Amesos_Klu") || (CT == "Klu")) { 
00090 #ifdef HAVE_AMESOS_KLU
00091     return new Amesos_Klu(LinearProblem); 
00092 #else
00093     if (verbose) std::cerr << "Amesos_Klu is not implemented" << std::endl ; 
00094     return(0); 
00095 #endif
00096   } 
00097   
00098   if ((CT == "Amesos_Umfpack") || (CT == "Umfpack")) { 
00099 #ifdef HAVE_AMESOS_UMFPACK
00100     return new Amesos_Umfpack(LinearProblem); 
00101 #else
00102     if (verbose) std::cerr << "Amesos_Umfpack is not implemented" << std::endl ; 
00103     return(0); 
00104 #endif
00105   } 
00106   
00107   if ((CT == "Amesos_Superlu") || (CT == "Superlu")) { 
00108 #ifdef HAVE_AMESOS_SUPERLU
00109     return new Amesos_Superlu(LinearProblem); 
00110 #else
00111     if (verbose) std::cerr << "Amesos_Superlu is not implemented" << std::endl ; 
00112     return(0); 
00113 #endif
00114   } 
00115   
00116   if ((CT == "Amesos_Superludist") || (CT == "Superludist")) { 
00117 #ifdef HAVE_AMESOS_SUPERLUDIST
00118     return new Amesos_Superludist(LinearProblem); 
00119 #else
00120     if (verbose) std::cerr << "Amesos_Superludist is not implemented" << std::endl ; 
00121     return(0); 
00122 #endif
00123   } 
00124   
00125   if ((CT == "Amesos_Mumps") || (CT == "Mumps")) { 
00126 #ifdef HAVE_AMESOS_MUMPS
00127     return new Amesos_Mumps(LinearProblem); 
00128 #else
00129     if (verbose) std::cerr << "Amesos_Mumps is not implemented" << std::endl ; 
00130     return(0); 
00131 #endif
00132   } 
00133   
00134   if ((CT == "Amesos_Scalapack") || (CT == "Scalapack")) { 
00135 #ifdef HAVE_AMESOS_SCALAPACK
00136     return new Amesos_Scalapack(LinearProblem); 
00137 #else
00138     if (verbose) std::cerr << "Amesos_Scalapack is not implemented" << std::endl ; 
00139     return(0); 
00140 #endif
00141   } 
00142   
00143   if ((CT == "Amesos_Dscpack") || (CT == "Dscpack")) { 
00144 #ifdef HAVE_AMESOS_DSCPACK
00145     return new Amesos_Dscpack(LinearProblem); 
00146 #else
00147     if (verbose) std::cerr << "Amesos_Dscpack is not implemented" << std::endl ; 
00148     return(0); 
00149 #endif
00150   } 
00151   
00152   if ((CT == "Amesos_Pardiso") || (CT == "Pardiso")) { 
00153 #if defined(HAVE_AMESOS_PARDISO) || defined(HAVE_AMESOS_PARDISO_MKL)
00154     return new Amesos_Pardiso(LinearProblem); 
00155 #else
00156     if (verbose) std::cerr << "Amesos_Pardiso is not implemented" << std::endl ; 
00157     return(0); 
00158 #endif
00159   } 
00160   
00161   if ((CT == "Amesos_Paraklete") || (CT == "Paraklete")) { 
00162 #ifdef HAVE_AMESOS_PARAKLETE
00163     return new Amesos_Paraklete(LinearProblem); 
00164 #else
00165     if (verbose) std::cerr << "Amesos_Paraklete is not implemented" << std::endl ; 
00166     return(0); 
00167 #endif
00168   }
00169 
00170   if ((CT == "Amesos_Taucs") || (CT == "Taucs")) { 
00171 #ifdef HAVE_AMESOS_TAUCS
00172     return new Amesos_Taucs(LinearProblem); 
00173 #else
00174     if (verbose) std::cerr << "Amesos_Taucs is not implemented" << std::endl ; 
00175     return(0); 
00176 #endif
00177   } 
00178   
00179   if ((CT == "Amesos_CSparse") || (CT == "CSparse")) {
00180 #ifdef HAVE_AMESOS_CSPARSE
00181     return new Amesos_CSparse(LinearProblem);
00182 #else
00183     if (verbose) std::cerr << "Amesos_CSparse is not implemented" << std::endl ;
00184     return(0);
00185 #endif
00186   }
00187 
00188   if (verbose) std::cerr << "Unknown class type:" << CT << std::endl ; 
00189   return(0); 
00190 }
00191 
00192 // ====================================================================
00193 bool Amesos::Query(const char* ClassType)
00194 {
00195   std::string CT = ClassType;
00196   return(Query(CT));
00197 }
00198 
00199 // ====================================================================
00200 bool Amesos::Query(const std::string CT) 
00201 { 
00202 
00203   if ((CT == "Amesos_Lapack") || (CT == "Lapack")) { 
00204 #ifdef HAVE_AMESOS_LAPACK
00205     return true;
00206 #else
00207     return false;
00208 #endif
00209   } 
00210   
00211   if ((CT == "Amesos_Klu") || (CT == "Klu")) { 
00212 #ifdef HAVE_AMESOS_KLU
00213     return true; 
00214 #else
00215     return false;
00216 #endif
00217   } 
00218   
00219   if ((CT == "Amesos_Umfpack") || (CT == "Umfpack")) { 
00220 #ifdef HAVE_AMESOS_UMFPACK
00221     return true;
00222 #else
00223     return false;
00224 #endif
00225   } 
00226   
00227   if ((CT == "Amesos_Superlu") || ( CT == "Superlu")) { 
00228 #ifdef HAVE_AMESOS_SUPERLU
00229     return true; 
00230 #else
00231     return false;
00232 #endif
00233   }
00234 
00235   if ((CT == "Amesos_Superludist") || (CT == "Superludist")) { 
00236 #ifdef HAVE_AMESOS_SUPERLUDIST
00237     return true;
00238 #else
00239     return false;
00240 #endif
00241   } 
00242 
00243   if ((CT == "Amesos_Mumps") || (CT == "Mumps")) { 
00244 #ifdef HAVE_AMESOS_MUMPS
00245     return true;
00246 #else
00247     return false;
00248 #endif
00249   } 
00250 
00251   if ((CT == "Amesos_Scalapack") || (CT == "Scalapack")) { 
00252 #ifdef HAVE_AMESOS_SCALAPACK
00253     return true;
00254 #else
00255     return false;
00256 #endif
00257   } 
00258 
00259   if ((CT == "Amesos_Dscpack") || (CT == "Dscpack")) { 
00260 #ifdef HAVE_AMESOS_DSCPACK
00261     return true;
00262 #else
00263     return false;
00264 #endif
00265   } 
00266   
00267   if ((CT == "Amesos_Pardiso") || (CT == "Pardiso")) { 
00268 #if defined(HAVE_AMESOS_PARDISO) || defined(HAVE_AMESOS_PARDISO_MKL)
00269     return true;
00270 #else
00271     return false;
00272 #endif
00273   } 
00274   
00275   if ((CT == "Amesos_Taucs") || (CT == "Taucs")) { 
00276 #ifdef HAVE_AMESOS_TAUCS
00277     return true;
00278 #else
00279     return false;
00280 #endif
00281   }
00282 
00283   if ((CT == "Amesos_Paraklete") || (CT == "Paraklete")) { 
00284 #ifdef HAVE_AMESOS_PARAKLETE
00285     return true;
00286 #else
00287     return false;
00288 #endif
00289   } 
00290   
00291   if ((CT == "Amesos_CSparse") || (CT == "CSparse")) {
00292 #ifdef HAVE_AMESOS_CSPARSE
00293     return true;
00294 #else
00295     return false;
00296 #endif
00297   }
00298 
00299   return(false);
00300 
00301 }
00302 
00303 Teuchos::ParameterList Amesos::GetValidParameters(){ 
00304   Teuchos::ParameterList ParamList  ;
00305 
00306   //  Status Parameters - see Amesos_Status.cpp 
00307 
00308   ParamList.set("OutputLevel",1 ) ; 
00309   ParamList.set("DebugLevel", 0 ) ; 
00310   ParamList.set("PrintTiming", false ) ; 
00311   ParamList.set("ComputeVectorNorms", false ) ; 
00312   ParamList.set("ComputeTrueResidual", false ) ; 
00313 
00314 
00315   //  Control Parameters - see Amesos_Control.cpp
00316   ParamList.set("AddZeroToDiag", false ) ; 
00317   ParamList.set("AddToDiag", 0.0 ) ; 
00318   ParamList.set("Refactorize", false ) ; 
00319   ParamList.set("RcondThreshold", 1e-12 ) ; 
00320   ParamList.set("MaxProcs", -1 ) ; 
00321   ParamList.set("MatrixProperty","general" ) ; 
00322   ParamList.set("ScaleMethod", 0 ) ; 
00323   ParamList.set("Reindex", false ) ; 
00324 
00325 
00326   //  Klu Parameters
00327   ParamList.set("TrustMe", false ) ;     //  If set, Amesos_Klu trusts that the data can be used in place - see Amesos_Klu.cpp
00328 
00329   //  Superlu Parameters - none 
00330 
00331   //  Dscpack Parameters - none
00332 
00333   //  Superludist Parameters
00334   ParamList.set("Redistribute", false ) ; 
00335   Teuchos::ParameterList SuperludistParams;
00336   { 
00337     SuperludistParams.set("ReuseSymbolic",false);
00338     SuperludistParams.set("Fact","SamePattern");
00339     SuperludistParams.set("Equil",false);
00340     SuperludistParams.set("ColPerm","NOT SET");
00341     SuperludistParams.set("RowPerm","NOT SET");
00342     SuperludistParams.set("perm_c",(int*) 0);
00343     SuperludistParams.set("perm_r",(int*) 0);
00344     SuperludistParams.set("IterRefine","NOT SET");
00345     SuperludistParams.set("ReplaceTinyPivot",true);
00346     SuperludistParams.set("PrintNonzeros",false);
00347   }
00348   ParamList.set("Superludist", SuperludistParams ) ; 
00349   //  MC64 Parameters - none
00350 
00351   //  Lapack Parameters
00352   Teuchos::ParameterList LapackParams;
00353   { 
00354     LapackParams.set("Equilibrate",true);
00355   }
00356   ParamList.set("Lapack", LapackParams ) ; 
00357   //  Mumps Parameters
00358   ParamList.set("NoDestroy",false);
00359   Teuchos::ParameterList MumpsParams;
00360   { 
00361     MumpsParams.set("Equilibrate",true);
00362     // ICNTL0, ICNT1, ..., ICNTL40 
00363     for (int i = 1 ; i <= 40 ; ++i)
00364     {
00365       char what[80];
00366       sprintf(what, "ICNTL(%d)", i);
00367       if (MumpsParams.isParameter(what)) 
00368         MumpsParams.set(what,0);
00369     }
00370 
00371     // CNTL0, CNTL1, ..., CNTL5
00372     for (int i = 1 ; i <= 5 ; ++i)
00373     {
00374       char what[80];
00375       sprintf(what, "CNTL(%d)", i);
00376       if (MumpsParams.isParameter(what)) 
00377   MumpsParams.set(what,0.0);
00378     }
00379     MumpsParams.set("RowScaling",(double *) 0);
00380     MumpsParams.set("ColScaling",(double *) 0);
00381 
00382   }
00383   ParamList.set("Mumps", MumpsParams ) ; 
00384 
00385   //  Paraklete Parameters - same as Klu
00386 
00387   //  Pardiso Parameters
00388   Teuchos::ParameterList PardisoParams;
00389   { 
00390     PardisoParams.set("MSGLVL",0);
00391     PardisoParams.set("IPARM(1)",0);
00392     PardisoParams.set("IPARM(2)",0);
00393     PardisoParams.set("IPARM(3)",0);
00394     PardisoParams.set("IPARM(4)",0);
00395     PardisoParams.set("IPARM(8)",0);
00396     PardisoParams.set("IPARM(10)",0);
00397     PardisoParams.set("IPARM(11)",0);
00398     PardisoParams.set("IPARM(18)",0);
00399     PardisoParams.set("IPARM(19)",0);
00400     PardisoParams.set("IPARM(21)",0);
00401  
00402   }
00403   ParamList.set("Pardiso", PardisoParams ) ; 
00404 
00405   //  Scalapack Parameters
00406   Teuchos::ParameterList ScalapackParams;
00407   { 
00408     ScalapackParams.set("2D distribution",true);
00409     ScalapackParams.set("grid_nb",32);
00410   }
00411   ParamList.set("Scalapack", ScalapackParams ) ; 
00412   //  Taucs Parameters - none
00413 
00414   //  Umfpack Parameters - none
00415 
00416   return ParamList ; 
00417 } 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines