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::RefCountPtr<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","GMRES");
00069     belosLOWSFPL.set("Max Iters",int(maxIterations));
00070     belosLOWSFPL.set("Default Rel Res Norm",double(maxResid));
00071     belosLOWSFPL.set("Max Restarts",int(maxRestarts));
00072     belosLOWSFPL.set("Block Size",int(blockSize));
00073     belosLOWSFPL.sublist("GMRES").set("Max Number of Krylov Vectors",int(gmresKrylovLength*blockSize));
00074     belosLOWSFPL.sublist("GMRES").set("Variant","Standard");
00075     Teuchos::ParameterList &outputterSL = belosLOWSFPL.sublist("Outputter");
00076     outputterSL.set("Output Frequency",int(outputFrequency));
00077     outputterSL.set("Output Max Res Only",bool(outputMaxResOnly));
00078     if(usePreconditioner) {
00079       Teuchos::ParameterList &ifpackPFSL = belosLOWSFPL.sublist("Ifpack");
00080       ifpackPFSL.set("Overlap",int(2));
00081       ifpackPFSL.set("Prec Type","ILUT");
00082     }
00083     
00084     success
00085       = Thyra::test_single_belos_thyra_solver(
00086         matrixFile,testTranspose,usePreconditioner,numRhs,numRandomVectors
00087         ,maxFwdError,maxResid,maxSolutionError,showAllTests,dumpAll
00088         ,&belosLOWSFPL
00089         ,verbose?&*out:0
00090         );
00091 
00092   }
00093   catch( const std::exception &excpt ) {
00094     std::cerr << "*** Caught standard exception : " << excpt.what() << std::endl;
00095     success = false;
00096   }
00097   catch( ... ) {
00098     std::cerr << "*** Caught an unknown exception\n";
00099     success = false;
00100   }
00101   
00102   if (verbose) {
00103     if(success)  *out << "\nCongratulations! All of the tests checked out!\n";
00104     else         *out << "\nOh no! At least one of the tests failed!\n";
00105   }
00106 
00107   return ( success ? 0 : 1 );
00108 }

Generated on Thu Sep 18 12:30:21 2008 for Belos Package Browser (Single Doxygen Collection) by doxygen 1.3.9.1