|
Stratimikos Package Browser (Single Doxygen Collection)
Version of the Day
|
00001 /* 00002 // @HEADER 00003 // *********************************************************************** 00004 // 00005 // Amesos: Direct Sparse Solver Package 00006 // Copyright (2004) 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 // This library is free software; you can redistribute it and/or modify 00012 // it under the terms of the GNU Lesser General Public License as 00013 // published by the Free Software Foundation; either version 2.1 of the 00014 // License, or (at your option) any later version. 00015 // 00016 // This library is distributed in the hope that it will be useful, but 00017 // WITHOUT ANY WARRANTY; without even the implied warranty of 00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00019 // Lesser General Public License for more details. 00020 // 00021 // You should have received a copy of the GNU Lesser General Public 00022 // License along with this library; if not, write to the Free Software 00023 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00024 // USA 00025 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 00026 // 00027 // *********************************************************************** 00028 // @HEADER 00029 */ 00030 00031 #include "test_single_amesos_thyra_solver.hpp" 00032 #include "Teuchos_CommandLineProcessor.hpp" 00033 #include "Teuchos_GlobalMPISession.hpp" 00034 #include "Teuchos_VerboseObject.hpp" 00035 00036 struct MatrixTestPacket { 00037 MatrixTestPacket(std::string _matrixFile, bool _unsymmetric, double _maxFwdError, double _maxError, double _maxResid) 00038 :matrixFile(_matrixFile),unsymmetric(_unsymmetric),maxFwdError(_maxFwdError),maxError(_maxError),maxResid(_maxResid) {} 00039 std::string matrixFile; 00040 bool unsymmetric; 00041 double maxFwdError; 00042 double maxError; 00043 double maxResid; 00044 }; 00045 00046 int main(int argc, char* argv[]) 00047 { 00048 00049 Teuchos::GlobalMPISession mpiSession(&argc, &argv); 00050 00051 using Teuchos::CommandLineProcessor; 00052 using Teuchos::OSTab; 00053 00054 bool result, success = true; 00055 bool verbose = true; 00056 00057 00058 Teuchos::RCP<Teuchos::FancyOStream> 00059 out = Teuchos::VerboseObjectBase::getDefaultOStream(); 00060 00061 try { 00062 00063 // 00064 // Read options from command-line 00065 // 00066 00067 std::string matrixDir = "."; 00068 bool testTranspose = true; 00069 int numRandomVectors = 1; 00070 bool showAllTests = false; 00071 bool showAllTestsDetails = false; 00072 bool dumpAll = false; 00073 00074 CommandLineProcessor clp; 00075 clp.throwExceptions(false); 00076 clp.addOutputSetupOptions(true); 00077 clp.setOption( "matrix-dir", &matrixDir, "Base directory for the test matrices" ); 00078 clp.setOption( "test-transpose", "no-test-transpose", &testTranspose, "Test the transpose solve or not." ); 00079 clp.setOption( "num-random-vectors", &numRandomVectors, "Number of times a test is performed with different random vectors." ); 00080 clp.setOption( "verbose", "quiet", &verbose, "Set if output is printed or not." ); 00081 clp.setOption( "show-all-tests", "no-show-all-tests", &showAllTests, "Set if all the tests are shown or not." ); 00082 clp.setOption( "show-all-tests-details", "no-show-all-tests-details", &showAllTestsDetails, "Set if all the details of the tests are shown or not." ); 00083 clp.setOption( "dump-all", "no-dump-all", &dumpAll, "Determines if vectors are printed or not." ); 00084 CommandLineProcessor::EParseCommandLineReturn parse_return = clp.parse(argc,argv); 00085 if( parse_return != CommandLineProcessor::PARSE_SUCCESSFUL ) return parse_return; 00086 00087 TEUCHOS_TEST_FOR_EXCEPT( matrixDir == "" ); 00088 00089 // 00090 // Define the test matrices 00091 // 00092 00093 const int numTestMatrices = 9; 00094 00095 typedef MatrixTestPacket MTP; 00096 00097 // Set up the matices and the tolerances. 00098 // Note, we may need to adjust these for bad platforms ... 00099 const MTP testMatrices[numTestMatrices] = 00100 { 00101 MTP("bcsstk01.mtx",false,1e-12,1e-12,1e-12) 00102 ,MTP("bcsstk02.mtx",false,1e-12,1e-12,1e-12) 00103 ,MTP("bcsstk04.mtx",false,1e-12,1e-10,1e-12) 00104 ,MTP("Diagonal.mtx",false,1e-12,1e-12,1e-12) 00105 ,MTP("FourByFour.mtx",true,1e-12,1e-12,1e-12) 00106 ,MTP("KheadK.mtx",false,1e-12,1e-12,1e-12) 00107 ,MTP("KheadSorted.mtx",false,1e-12,1e-12,1e-12) 00108 ,MTP("nos1.mtx",false,1e-11,1e-10,1e-12) 00109 ,MTP("nos5.mtx",false,1e-12,1e-12,1e-12) 00110 }; 00111 // 00112 // Loop through all of the test matrices 00113 // 00114 for( int matrix_i = 0; matrix_i < numTestMatrices; ++matrix_i ) { 00115 const MatrixTestPacket 00116 mtp = testMatrices[matrix_i]; 00117 // 00118 // Loop through all of the solvers 00119 // 00120 for( int solver_i = 0; solver_i < Thyra::Amesos::numSolverTypes; ++solver_i ) { 00121 const Thyra::Amesos::ESolverType 00122 solverType = Thyra::Amesos::solverTypeValues[solver_i]; 00123 00124 // bug 1902 - Amesos_Superlu fails on bcsstk01.mtx 00125 // bug 1903 - Amesos_Superlu fails on four matrices, 00126 // when called from the thyra test 00127 // 00128 bool BadMatrixForSuperlu = 00129 mtp.matrixFile == "bcsstk01.mtx" // bug 1902 00130 || mtp.matrixFile == "bcsstk04.mtx" // bug 1903 00131 || mtp.matrixFile == "KheadK.mtx" // bug 1903 00132 || mtp.matrixFile == "KheadSorted.mtx" // bug 1903 00133 || mtp.matrixFile == "nos1.mtx" ; // bug 1903 00134 // 00135 // Toggle the refactorization options 00136 // 00137 for( int factorizationPolicy_i = 0; factorizationPolicy_i < Thyra::Amesos::numRefactorizationPolices; ++factorizationPolicy_i ) { 00138 const Thyra::Amesos::ERefactorizationPolicy 00139 refactorizationPolicy = Thyra::Amesos::refactorizationPolicyValues[factorizationPolicy_i]; 00140 if(verbose) 00141 *out 00142 << std::endl<<matrix_i<<"."<<solver_i<<"."<<factorizationPolicy_i<<": " 00143 << "Testing, matrixFile=\'"<<mtp.matrixFile<<"\', solverType=\'"<<toString(solverType)<<"\', refactorizationPolicy=\'"<<toString(refactorizationPolicy)<<"\' ..."; 00144 if( mtp.unsymmetric && !Thyra::Amesos::supportsUnsymmetric[solver_i] ) { 00145 *out << " : Skipping since unsymmetric and not supported!\n"; 00146 } 00147 else { 00148 // bug 1902 and bug 1903 00149 string StrSolverType = toString(solverType) ; 00150 string StrSuperlu = "Superlu"; 00151 if ( StrSolverType==StrSuperlu && BadMatrixForSuperlu ) { 00152 *out << " : Skipping since Superlu fails on this matrix!\n"; 00153 } 00154 else { 00155 std::ostringstream ossStore; 00156 Teuchos::RCP<Teuchos::FancyOStream> 00157 oss = Teuchos::rcp(new Teuchos::FancyOStream(Teuchos::rcp(&ossStore,false))); 00158 Teuchos::ParameterList amesosLOWSFPL; 00159 amesosLOWSFPL.set("Solver Type",toString(solverType)); 00160 amesosLOWSFPL.set("Refactorization Policy",toString(refactorizationPolicy)); 00161 result = 00162 Thyra::test_single_amesos_thyra_solver( 00163 matrixDir+"/"+mtp.matrixFile,&amesosLOWSFPL,testTranspose,numRandomVectors 00164 ,mtp.maxFwdError,mtp.maxError,mtp.maxResid,showAllTestsDetails,dumpAll,OSTab(oss).get() 00165 ); 00166 if(!result) success = false; 00167 if(verbose) { 00168 if(result) { 00169 if(showAllTests) 00170 *out << std::endl << ossStore.str(); 00171 else 00172 *out << " : passed!\n"; 00173 } 00174 else { 00175 if(showAllTests) 00176 *out << std::endl << ossStore.str(); 00177 else 00178 *out << " : failed!\n"; 00179 } 00180 } 00181 } 00182 } 00183 } 00184 } 00185 } 00186 00187 } 00188 catch( const std::exception &excpt ) { 00189 std::cerr << "*** Caught standard exception : " << excpt.what() << std::endl; 00190 success = false; 00191 } 00192 catch( ... ) { 00193 std::cerr << "*** Caught an unknown exception\n"; 00194 success = false; 00195 } 00196 00197 if (verbose) { 00198 if(success) *out << "\nCongratulations! All of the tests checked out!\n"; 00199 else *out << "\nOh no! At least one of the tests failed!\n"; 00200 } 00201 00202 return ( success ? 0 : 1 ); 00203 }
1.7.6.1