Stratimikos Package Browser (Single Doxygen Collection) Version of the Day
test_single_amesos_thyra_solver_driver.cpp
Go to the documentation of this file.
00001 /*
00002 // @HEADER
00003 // ***********************************************************************
00004 // 
00005 //                Amesos: Direct Sparse Solver Package
00006 //                 Copyright (2004) Sandia Corporation
00007 // 
00008 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00009 // license for use of this work by or on behalf of the U.S. Government.
00010 // 
00011 // This library is free software; you can redistribute it and/or modify
00012 // it under the terms of the GNU Lesser General Public License as
00013 // published by the Free Software Foundation; either version 2.1 of the
00014 // License, or (at your option) any later version.
00015 //  
00016 // This library is distributed in the hope that it will be useful, but
00017 // WITHOUT ANY WARRANTY; without even the implied warranty of
00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019 // Lesser General Public License for more details.
00020 //  
00021 // You should have received a copy of the GNU Lesser General Public
00022 // License along with this library; if not, write to the Free Software
00023 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00024 // USA
00025 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 
00026 // 
00027 // ***********************************************************************
00028 // @HEADER
00029 */
00030 
00031 #include "test_single_amesos_thyra_solver.hpp"
00032 #include "Teuchos_CommandLineProcessor.hpp"
00033 #include "Teuchos_VerboseObject.hpp"
00034 
00035 int main(int argc, char* argv[])
00036 {
00037   
00038   using Teuchos::CommandLineProcessor;
00039 
00040   bool success = true;
00041   bool verbose = true;
00042 
00043   Teuchos::RCP<Teuchos::FancyOStream>
00044     out = Teuchos::VerboseObjectBase::getDefaultOStream();
00045 
00046   try {
00047 
00048     //
00049     // Read options from command-line
00050     //
00051     
00052     std::string                             matrixFile             = "";
00053     Thyra::Amesos::ESolverType              solverType
00054 #ifdef HAVE_AMESOS_KLU
00055                                                                    = Thyra::Amesos::KLU;
00056 #else
00057                                                                    = Thyra::Amesos::LAPACK;
00058 #endif
00059     Thyra::Amesos::ERefactorizationPolicy   refactorizationPolicy  = Thyra::Amesos::REPIVOT_ON_REFACTORIZATION;
00060     bool                                    testTranspose          = true;
00061     int                                     numRandomVectors       = 1;
00062     double                                  maxFwdError            = 1e-14;
00063     double                                  maxError               = 1e-10;
00064     double                                  maxResid               = 1e-10;
00065     bool                                    showAllTests           = false;
00066     bool                                    dumpAll                = false;
00067 
00068     CommandLineProcessor  clp;
00069     clp.throwExceptions(false);
00070     clp.addOutputSetupOptions(true);
00071     clp.setOption( "matrix-file", &matrixFile, "Matrix iput file [Required]." );
00072     clp.setOption(
00073       "solver-type", &solverType
00074       ,Thyra::Amesos::numSolverTypes, Thyra::Amesos::solverTypeValues, Thyra::Amesos::solverTypeNames
00075       ,"Type of direct solver."
00076       );
00077     clp.setOption(
00078       "refactorization-policy", &refactorizationPolicy
00079       ,Thyra::Amesos::numRefactorizationPolices, Thyra::Amesos::refactorizationPolicyValues, Thyra::Amesos::refactorizationPolicyNames
00080       ,"Pivoting policy used on refactorizations."
00081       );
00082     clp.setOption( "test-transpose", "no-test-transpose", &testTranspose, "Test the transpose solve or not." );
00083     clp.setOption( "num-random-vectors", &numRandomVectors, "Number of times a test is performed with different random vectors." );
00084     clp.setOption( "max-fwd-error", &maxFwdError, "The maximum relative error in the forward operator." );
00085     clp.setOption( "max-error", &maxError, "The maximum relative error in the solution." );
00086     clp.setOption( "max-resid", &maxResid, "The maximum relative error in the residual." );
00087     clp.setOption( "verbose", "quiet", &verbose, "Set if output is printed or not." );
00088     clp.setOption( "show-all-tests", "no-show-all-tests", &showAllTests, "Set if all the tests are shown or not." );
00089     clp.setOption( "dump-all", "no-dump-all", &dumpAll, "Determines if vectors are printed or not." );
00090     CommandLineProcessor::EParseCommandLineReturn parse_return = clp.parse(argc,argv);
00091     if( parse_return != CommandLineProcessor::PARSE_SUCCESSFUL ) return parse_return;
00092 
00093     TEUCHOS_TEST_FOR_EXCEPT( matrixFile == "" );
00094 
00095     Teuchos::ParameterList amesosLOWSFPL;
00096     amesosLOWSFPL.set("Solver Type",toString(solverType));
00097     amesosLOWSFPL.set("Refactorization Policy",toString(refactorizationPolicy));
00098 
00099     success
00100       = Thyra::test_single_amesos_thyra_solver(
00101         matrixFile,&amesosLOWSFPL,testTranspose,numRandomVectors
00102         ,maxFwdError,maxError,maxResid,showAllTests,dumpAll,verbose?&*out:0
00103         );
00104 
00105   }
00106   catch( const std::exception &excpt ) {
00107     std::cerr << "*** Caught standard exception : " << excpt.what() << std::endl;
00108     success = false;
00109   }
00110   catch( ... ) {
00111     std::cerr << "*** Caught an unknown exception\n";
00112     success = false;
00113   }
00114   
00115   if (verbose) {
00116     if(success)  *out << "\nCongratulations! All of the tests checked out!\n";
00117     else         *out << "\nOh no! At least one of the tests failed!\n";
00118   }
00119 
00120   return ( success ? 0 : 1 );
00121 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines