|
Stratimikos Package Browser (Single Doxygen Collection)
Version of the Day
|
00001 /* 00002 // @HEADER 00003 // *********************************************************************** 00004 // 00005 // Stratimikos: Thyra-based strategies for linear solvers 00006 // Copyright (2006) 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 // Redistribution and use in source and binary forms, with or without 00012 // modification, are permitted provided that the following conditions are 00013 // met: 00014 // 00015 // 1. Redistributions of source code must retain the above copyright 00016 // notice, this list of conditions and the following disclaimer. 00017 // 00018 // 2. Redistributions in binary form must reproduce the above copyright 00019 // notice, this list of conditions and the following disclaimer in the 00020 // documentation and/or other materials provided with the distribution. 00021 // 00022 // 3. Neither the name of the Corporation nor the names of the 00023 // contributors may be used to endorse or promote products derived from 00024 // this software without specific prior written permission. 00025 // 00026 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY 00027 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00028 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00029 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE 00030 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00031 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00032 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00033 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00034 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00035 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00036 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00037 // 00038 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov) 00039 // 00040 // *********************************************************************** 00041 // @HEADER 00042 */ 00043 00044 00045 #include "test_single_belos_thyra_solver.hpp" 00046 #include "Teuchos_CommandLineProcessor.hpp" 00047 #include "Teuchos_ParameterList.hpp" 00048 #include "Teuchos_VerboseObject.hpp" 00049 #include "Teuchos_GlobalMPISession.hpp" 00050 #include "Teuchos_StandardCatchMacros.hpp" 00051 00052 00053 int main(int argc, char* argv[]) 00054 { 00055 00056 using Teuchos::CommandLineProcessor; 00057 00058 bool success = true; 00059 bool verbose = true; 00060 00061 Teuchos::GlobalMPISession mpiSession(&argc, &argv); 00062 00063 Teuchos::RCP<Teuchos::FancyOStream> 00064 out = Teuchos::VerboseObjectBase::getDefaultOStream(); 00065 00066 try { 00067 00068 // 00069 // Read options from command-line 00070 // 00071 00072 std::string matrixFile = ""; 00073 bool testTranspose = false; 00074 bool usePreconditioner = true; 00075 int numRhs = 1; 00076 int numRandomVectors = 1; 00077 double maxFwdError = 1e-14; 00078 int maxIterations = 400; 00079 int maxRestarts = 25; 00080 int gmresKrylovLength = 25; 00081 int outputFrequency = 10; 00082 bool outputMaxResOnly = true; 00083 int blockSize = 1; 00084 double maxResid = 1e-6; 00085 double maxSolutionError = 1e-6; 00086 bool showAllTests = false; 00087 bool dumpAll = false; 00088 00089 CommandLineProcessor clp; 00090 clp.throwExceptions(false); 00091 clp.addOutputSetupOptions(true); 00092 clp.setOption( "matrix-file", &matrixFile, "Matrix input file [Required]." ); 00093 clp.setOption( "test-transpose", "no-test-transpose", &testTranspose, "Test the transpose solve or not." ); 00094 clp.setOption( "use-preconditioner", "no-use-preconditioner", &usePreconditioner, "Use the preconditioner or not." ); 00095 clp.setOption( "num-rhs", &numRhs, "Number of RHS in linear solve." ); 00096 clp.setOption( "num-random-vectors", &numRandomVectors, "Number of times a test is performed with different random vectors." ); 00097 clp.setOption( "max-fwd-error", &maxFwdError, "The maximum relative error in the forward operator." ); 00098 clp.setOption( "max-iters", &maxIterations, "The maximum number of linear solver iterations to take." ); 00099 clp.setOption( "max-restarts", &maxRestarts, "???." ); 00100 clp.setOption( "gmres-krylov-length", &gmresKrylovLength, "???." ); 00101 clp.setOption( "output-frequency", &outputFrequency, "Number of linear solver iterations between output" ); 00102 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." ); 00103 clp.setOption( "block-size", &blockSize, "???." ); 00104 clp.setOption( "max-resid", &maxResid, "The maximum relative error in the residual." ); 00105 clp.setOption( "max-solution-error", &maxSolutionError, "The maximum relative error in the solution of the linear system." ); 00106 clp.setOption( "verbose", "quiet", &verbose, "Set if output is printed or not." ); 00107 clp.setOption( "show-all-tests", "no-show-all-tests", &showAllTests, "Set if all the tests are shown or not." ); 00108 clp.setOption( "dump-all", "no-dump-all", &dumpAll, "Determines if vectors are printed or not." ); 00109 CommandLineProcessor::EParseCommandLineReturn parse_return = clp.parse(argc,argv); 00110 if( parse_return != CommandLineProcessor::PARSE_SUCCESSFUL ) return parse_return; 00111 00112 TEUCHOS_TEST_FOR_EXCEPT( matrixFile == "" ); 00113 00114 Teuchos::ParameterList belosLOWSFPL; 00115 00116 belosLOWSFPL.set("Solver Type","Block GMRES"); 00117 00118 Teuchos::ParameterList& belosLOWSFPL_solver = 00119 belosLOWSFPL.sublist("Solver Types"); 00120 00121 Teuchos::ParameterList& belosLOWSFPL_gmres = 00122 belosLOWSFPL_solver.sublist("Block GMRES"); 00123 00124 belosLOWSFPL_gmres.set("Maximum Iterations",int(maxIterations)); 00125 belosLOWSFPL_gmres.set("Convergence Tolerance",double(maxResid)); 00126 belosLOWSFPL_gmres.set("Maximum Restarts",int(maxRestarts)); 00127 belosLOWSFPL_gmres.set("Block Size",int(blockSize)); 00128 belosLOWSFPL_gmres.set("Num Blocks",int(gmresKrylovLength)); 00129 belosLOWSFPL_gmres.set("Output Frequency",int(outputFrequency)); 00130 belosLOWSFPL_gmres.set("Show Maximum Residual Norm Only",bool(outputMaxResOnly)); 00131 00132 Teuchos::ParameterList precPL("Ifpack"); 00133 if(usePreconditioner) { 00134 precPL.set("Overlap",int(2)); 00135 precPL.set("Prec Type","ILUT"); 00136 } 00137 00138 success 00139 = Thyra::test_single_belos_thyra_solver( 00140 matrixFile,testTranspose,usePreconditioner,numRhs,numRandomVectors 00141 ,maxFwdError,maxResid,maxSolutionError,showAllTests,dumpAll 00142 ,&belosLOWSFPL,&precPL 00143 ,verbose?&*out:0 00144 ); 00145 00146 } 00147 TEUCHOS_STANDARD_CATCH_STATEMENTS(verbose, std::cerr, success) 00148 00149 if (verbose) { 00150 if(success) *out << "\nCongratulations! All of the tests checked out!\n"; 00151 else *out << "\nOh no! At least one of the tests failed!\n"; 00152 } 00153 00154 return ( success ? 0 : 1 ); 00155 }
1.7.6.1