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

Generated on Wed May 12 21:59:31 2010 for Amesos Package Browser (Single Doxygen Collection) by  doxygen 1.4.7