test_single_belos_thyra_solver_driver.cpp

Go to the documentation of this file.
00001 
00002 #include "test_single_belos_thyra_solver.hpp"
00003 #include "Teuchos_CommandLineProcessor.hpp"
00004 #include "Teuchos_ParameterList.hpp"
00005 #include "Teuchos_VerboseObject.hpp"
00006 
00007 int main(int argc, char* argv[])
00008 {
00009   
00010   using Teuchos::CommandLineProcessor;
00011 
00012   bool success = true;
00013   bool verbose = true;
00014 
00015   Teuchos::RCP<Teuchos::FancyOStream>
00016     out = Teuchos::VerboseObjectBase::getDefaultOStream();
00017 
00018   try {
00019 
00020     //
00021     // Read options from command-line
00022     //
00023     
00024     std::string     matrixFile             = "";
00025     bool            testTranspose          = false;
00026     bool            usePreconditioner      = true;
00027     int             numRhs                 = 1;
00028     int             numRandomVectors       = 1;
00029     double          maxFwdError            = 1e-14;
00030     int             maxIterations          = 400;
00031     int             maxRestarts            = 25;
00032     int             gmresKrylovLength      = 25;
00033     int             outputFrequency        = 10;
00034     bool            outputMaxResOnly       = true;
00035     int             blockSize              = 1;
00036     double          maxResid               = 1e-6;
00037     double          maxSolutionError       = 1e-6;
00038     bool            showAllTests           = false;
00039     bool            dumpAll                = false;
00040 
00041     CommandLineProcessor  clp;
00042     clp.throwExceptions(false);
00043     clp.addOutputSetupOptions(true);
00044     clp.setOption( "matrix-file", &matrixFile, "Matrix input file [Required]." );
00045     clp.setOption( "test-transpose", "no-test-transpose", &testTranspose, "Test the transpose solve or not." );
00046     clp.setOption( "use-preconditioner", "no-use-preconditioner", &usePreconditioner, "Use the preconditioner or not." );
00047     clp.setOption( "num-rhs", &numRhs, "Number of RHS in linear solve." );
00048     clp.setOption( "num-random-vectors", &numRandomVectors, "Number of times a test is performed with different random vectors." );
00049     clp.setOption( "max-fwd-error", &maxFwdError, "The maximum relative error in the forward operator." );
00050     clp.setOption( "max-iters", &maxIterations, "The maximum number of linear solver iterations to take." );
00051     clp.setOption( "max-restarts", &maxRestarts, "???." );
00052     clp.setOption( "gmres-krylov-length", &gmresKrylovLength, "???." );
00053     clp.setOption( "output-frequency", &outputFrequency, "Number of linear solver iterations between output" );
00054     clp.setOption( "output-max-res-only", "output-all-res", &outputMaxResOnly, "Determines if only the max residual is printed or if all residuals are printed per iteration." );
00055     clp.setOption( "block-size", &blockSize, "???." );
00056     clp.setOption( "max-resid", &maxResid, "The maximum relative error in the residual." );
00057     clp.setOption( "max-solution-error", &maxSolutionError, "The maximum relative error in the solution of the linear system." );
00058     clp.setOption( "verbose", "quiet", &verbose, "Set if output is printed or not." );
00059     clp.setOption( "show-all-tests", "no-show-all-tests", &showAllTests, "Set if all the tests are shown or not." );
00060     clp.setOption( "dump-all", "no-dump-all", &dumpAll, "Determines if vectors are printed or not." );
00061     CommandLineProcessor::EParseCommandLineReturn parse_return = clp.parse(argc,argv);
00062     if( parse_return != CommandLineProcessor::PARSE_SUCCESSFUL ) return parse_return;
00063 
00064     TEST_FOR_EXCEPT( matrixFile == "" );
00065 
00066     Teuchos::ParameterList belosLOWSFPL;
00067 
00068     belosLOWSFPL.set("Solver Type","Block GMRES");
00069 
00070     Teuchos::ParameterList& belosLOWSFPL_solver =
00071       belosLOWSFPL.sublist("Solver Types");
00072 
00073     Teuchos::ParameterList& belosLOWSFPL_gmres =
00074       belosLOWSFPL_solver.sublist("Block GMRES");
00075 
00076     belosLOWSFPL_gmres.set("Maximum Iterations",int(maxIterations));
00077     belosLOWSFPL_gmres.set("Convergence Tolerance",double(maxResid));
00078     belosLOWSFPL_gmres.set("Maximum Restarts",int(maxRestarts));
00079     belosLOWSFPL_gmres.set("Block Size",int(blockSize));
00080     belosLOWSFPL_gmres.set("Num Blocks",int(gmresKrylovLength));
00081     belosLOWSFPL_gmres.set("Output Frequency",int(outputFrequency));
00082     belosLOWSFPL_gmres.set("Show Maximum Residual Norm Only",bool(outputMaxResOnly));
00083 
00084     Teuchos::ParameterList precPL("Ifpack");
00085     if(usePreconditioner) {
00086       precPL.set("Overlap",int(2));
00087       precPL.set("Prec Type","ILUT");
00088     }
00089     
00090     success
00091       = Thyra::test_single_belos_thyra_solver(
00092         matrixFile,testTranspose,usePreconditioner,numRhs,numRandomVectors
00093         ,maxFwdError,maxResid,maxSolutionError,showAllTests,dumpAll
00094         ,&belosLOWSFPL,&precPL
00095         ,verbose?&*out:0
00096         );
00097 
00098   }
00099   catch( const std::exception &excpt ) {
00100     std::cerr << "*** Caught standard exception : " << excpt.what() << std::endl;
00101     success = false;
00102   }
00103   catch( ... ) {
00104     std::cerr << "*** Caught an unknown exception\n";
00105     success = false;
00106   }
00107   
00108   if (verbose) {
00109     if(success)  *out << "\nCongratulations! All of the tests checked out!\n";
00110     else         *out << "\nOh no! At least one of the tests failed!\n";
00111   }
00112 
00113   return ( success ? 0 : 1 );
00114 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends
Generated on Wed Apr 13 10:19:51 2011 for Stratimikos Package Browser (Single Doxygen Collection) by  doxygen 1.6.3