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