|
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 #include "test_single_amesos_thyra_solver.hpp" 00045 #include "Teuchos_CommandLineProcessor.hpp" 00046 #include "Teuchos_VerboseObject.hpp" 00047 00048 int main(int argc, char* argv[]) 00049 { 00050 00051 using Teuchos::CommandLineProcessor; 00052 00053 bool success = true; 00054 bool verbose = true; 00055 00056 Teuchos::RCP<Teuchos::FancyOStream> 00057 out = Teuchos::VerboseObjectBase::getDefaultOStream(); 00058 00059 try { 00060 00061 // 00062 // Read options from command-line 00063 // 00064 00065 std::string matrixFile = ""; 00066 Thyra::Amesos::ESolverType solverType 00067 #ifdef HAVE_AMESOS_KLU 00068 = Thyra::Amesos::KLU; 00069 #else 00070 = Thyra::Amesos::LAPACK; 00071 #endif 00072 Thyra::Amesos::ERefactorizationPolicy refactorizationPolicy = Thyra::Amesos::REPIVOT_ON_REFACTORIZATION; 00073 bool testTranspose = true; 00074 int numRandomVectors = 1; 00075 double maxFwdError = 1e-14; 00076 double maxError = 1e-10; 00077 double maxResid = 1e-10; 00078 bool showAllTests = false; 00079 bool dumpAll = false; 00080 00081 CommandLineProcessor clp; 00082 clp.throwExceptions(false); 00083 clp.addOutputSetupOptions(true); 00084 clp.setOption( "matrix-file", &matrixFile, "Matrix iput file [Required]." ); 00085 clp.setOption( 00086 "solver-type", &solverType 00087 ,Thyra::Amesos::numSolverTypes, Thyra::Amesos::solverTypeValues, Thyra::Amesos::solverTypeNames 00088 ,"Type of direct solver." 00089 ); 00090 clp.setOption( 00091 "refactorization-policy", &refactorizationPolicy 00092 ,Thyra::Amesos::numRefactorizationPolices, Thyra::Amesos::refactorizationPolicyValues, Thyra::Amesos::refactorizationPolicyNames 00093 ,"Pivoting policy used on refactorizations." 00094 ); 00095 clp.setOption( "test-transpose", "no-test-transpose", &testTranspose, "Test the transpose solve or not." ); 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-error", &maxError, "The maximum relative error in the solution." ); 00099 clp.setOption( "max-resid", &maxResid, "The maximum relative error in the residual." ); 00100 clp.setOption( "verbose", "quiet", &verbose, "Set if output is printed or not." ); 00101 clp.setOption( "show-all-tests", "no-show-all-tests", &showAllTests, "Set if all the tests are shown or not." ); 00102 clp.setOption( "dump-all", "no-dump-all", &dumpAll, "Determines if vectors are printed or not." ); 00103 CommandLineProcessor::EParseCommandLineReturn parse_return = clp.parse(argc,argv); 00104 if( parse_return != CommandLineProcessor::PARSE_SUCCESSFUL ) return parse_return; 00105 00106 TEUCHOS_TEST_FOR_EXCEPT( matrixFile == "" ); 00107 00108 Teuchos::ParameterList amesosLOWSFPL; 00109 amesosLOWSFPL.set("Solver Type",toString(solverType)); 00110 amesosLOWSFPL.set("Refactorization Policy",toString(refactorizationPolicy)); 00111 00112 success 00113 = Thyra::test_single_amesos_thyra_solver( 00114 matrixFile,&amesosLOWSFPL,testTranspose,numRandomVectors 00115 ,maxFwdError,maxError,maxResid,showAllTests,dumpAll,verbose?&*out:0 00116 ); 00117 00118 } 00119 catch( const std::exception &excpt ) { 00120 std::cerr << "*** Caught standard exception : " << excpt.what() << std::endl; 00121 success = false; 00122 } 00123 catch( ... ) { 00124 std::cerr << "*** Caught an unknown exception\n"; 00125 success = false; 00126 } 00127 00128 if (verbose) { 00129 if(success) *out << "\nCongratulations! All of the tests checked out!\n"; 00130 else *out << "\nOh no! At least one of the tests failed!\n"; 00131 } 00132 00133 return ( success ? 0 : 1 ); 00134 }
1.7.6.1