00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include "test_single_aztecoo_thyra_solver.hpp"
00031 #include "Teuchos_CommandLineProcessor.hpp"
00032 #include "Teuchos_ParameterList.hpp"
00033 #include "az_aztec_defs.h"
00034
00035 struct MatrixTestPacket {
00036 MatrixTestPacket(
00037 std::string _matrixFile
00038 ,double _maxFwdError
00039 ,int _maxIters
00040 ,double _maxResid
00041 ,double _maxSolutionError
00042 ,double _maxSlackErrorFrac
00043 ,int _maxPrecIters
00044 ,double _maxPrecResid
00045 ,double _maxPrecSolutionError
00046 ,double _maxPrecSlackErrorFrac
00047 )
00048 :matrixFile(_matrixFile)
00049 ,maxFwdError(_maxFwdError)
00050 ,maxIters(_maxIters)
00051 ,maxResid(_maxResid)
00052 ,maxSolutionError(_maxSolutionError)
00053 ,maxSlackErrorFrac(_maxSlackErrorFrac)
00054 ,maxPrecIters(_maxPrecIters)
00055 ,maxPrecResid(_maxPrecResid)
00056 ,maxPrecSolutionError(_maxPrecSolutionError)
00057 ,maxPrecSlackErrorFrac(_maxPrecSlackErrorFrac)
00058 {}
00059 std::string matrixFile;
00060 double maxFwdError;
00061 int maxIters;
00062 double maxResid;
00063 double maxSolutionError;
00064 double maxSlackErrorFrac;
00065 int maxPrecIters;
00066 double maxPrecResid;
00067 double maxPrecSolutionError;
00068 double maxPrecSlackErrorFrac;
00069 };
00070
00071 int main(int argc, char* argv[])
00072 {
00073
00074 using Teuchos::CommandLineProcessor;
00075
00076 bool result, success = true;
00077 bool verbose = true;
00078
00079 Teuchos::FancyOStream out(Teuchos::rcp(&std::cout,false));
00080
00081 try {
00082
00083
00084
00085
00086
00087 std::string matrixDir = "";
00088 int numRandomVectors = 1;
00089 bool showAllTests = false;
00090 bool showAllTestsDetails = false;
00091 bool dumpAll = false;
00092 std::string aztecOutputLevel = "freq";
00093 int aztecOutputFreq = 0;
00094
00095 CommandLineProcessor clp(false);
00096 clp.setOption( "matrix-dir", &matrixDir, "Base directory for the test matrices" );
00097 clp.setOption( "num-random-vectors", &numRandomVectors, "Number of times a test is performed with different random vectors." );
00098 clp.setOption( "verbose", "quiet", &verbose, "Set if output is printed or not." );
00099 clp.setOption( "show-all-tests", "no-show-all-tests", &showAllTests, "Set if all the tests are shown or not." );
00100 clp.setOption( "show-all-tests-details", "no-show-all-tests-details", &showAllTestsDetails, "Set if all the details of the tests are shown or not." );
00101 clp.setOption( "dump-all", "no-dump-all", &dumpAll, "Determines if vectors are printed or not." );
00102 clp.setOption( "aztec-output-level", &aztecOutputLevel, "Aztec output level (freq,last,summary,warnings,all)" );
00103 clp.setOption( "aztec-output-freq", &aztecOutputFreq, "Aztec output freqency (> 0)" );
00104 CommandLineProcessor::EParseCommandLineReturn parse_return = clp.parse(argc,argv);
00105 if( parse_return != CommandLineProcessor::PARSE_SUCCESSFUL ) return parse_return;
00106
00107 TEST_FOR_EXCEPT( matrixDir == "" );
00108
00109 Teuchos::ParameterList fwdSolveParamList, adjSolveParamList;
00110 if( aztecOutputLevel != "freq" ) {
00111 fwdSolveParamList.set("AZ_output",aztecOutputLevel);
00112 adjSolveParamList.set("AZ_output",aztecOutputLevel);
00113 }
00114 else {
00115 fwdSolveParamList.set("AZ_output",aztecOutputFreq);
00116 adjSolveParamList.set("AZ_output",aztecOutputFreq);
00117 }
00118
00119
00120
00121
00122
00123 const int numTestMatrices = 9;
00124
00125 typedef MatrixTestPacket MTP;
00126
00127
00128
00129 const MTP testMatrices[numTestMatrices] =
00130 {
00131 MTP("bcsstk01.mtx" ,1e-12, 40 , 1e-4, 0.6, 1.0, 20 , 1e-10, 0.5, 1.0)
00132 ,MTP("bcsstk02.mtx" ,1e-12, 40 , 1e-3, 0.5, 1.0, 2 , 1e-10, 0.5, 1.0)
00133 ,MTP("bcsstk04.mtx" ,1e-12, 80 , 1e-4, 0.999990, 1.0, 40 , 1e-10, 0.999990, 1.0)
00134 ,MTP("Diagonal.mtx" ,1e-12, 4 , 1e-6, 1e-14, 1.0, 2 , 1e-10, 1e-14, 1.0)
00135 ,MTP("FourByFour.mtx" ,1e-12, 4 , 1e-6, 1e-14, 1.0, 2 , 1e-10, 1e-14, 1.0)
00136 ,MTP("KheadK.mtx" ,1e-12, 8 , 1e-6, 1e-14, 1.0, 2 , 1e-10, 1e-14, 1.0)
00137 ,MTP("KheadSorted.mtx" ,1e-12, 8 , 1e-6, 1e-14, 1.0, 2 , 1e-10, 1e-14, 1.0)
00138 ,MTP("nos1.mtx" ,1e-11, 200, 1e-4, 0.6, 1.0, 237, 1e-2, 5.0, 1.0)
00139 ,MTP("nos5.mtx" ,1e-12, 468, 1e-5, 0.5, 1.0, 468, 1e-10, 0.5, 1.0)
00140 };
00141
00142
00143
00144 for( int matrix_i = 0; matrix_i < numTestMatrices; ++matrix_i ) {
00145 const MatrixTestPacket
00146 mtp = testMatrices[matrix_i];
00147
00148
00149
00150 for( int prec_i = 0; prec_i < 2; ++prec_i ) {
00151 if(verbose)
00152 out << std::endl<<matrix_i<<":"<<prec_i<<": Testing, matrixFile=\'"<<mtp.matrixFile<<"\', ";
00153 bool testTranspose;
00154 int maxIters;
00155 double maxResid;
00156 double maxSolutionError;
00157 double maxSlackErrorFrac;
00158 if(prec_i==0) {
00159 out << "no aztec preconditioning ... ";
00160 fwdSolveParamList.set("AZ_precond","none");
00161 testTranspose = true;
00162 maxIters = mtp.maxIters;
00163 maxResid = mtp.maxResid;
00164 maxSolutionError = mtp.maxSolutionError;
00165 maxSlackErrorFrac = mtp.maxSlackErrorFrac;
00166 }
00167 else {
00168 out << "using aztec preconditioning ... ";
00169 fwdSolveParamList.set("AZ_precond","dom_decomp");
00170 fwdSolveParamList.set("AZ_subdomain_solve","ilu");
00171 testTranspose = false;
00172 maxIters = mtp.maxPrecIters;
00173 maxResid = mtp.maxPrecResid;
00174 maxSolutionError = mtp.maxPrecSolutionError;
00175 maxSlackErrorFrac = mtp.maxPrecSlackErrorFrac;
00176 }
00177 std::ostringstream oss;
00178 Teuchos::FancyOStream fancy_oss(Teuchos::rcp(&oss,false));
00179 result =
00180 Thyra::test_single_aztecoo_thyra_solver(
00181 matrixDir+"/"+mtp.matrixFile,testTranspose,numRandomVectors
00182 ,mtp.maxFwdError,maxIters,maxResid,maxSolutionError
00183 ,showAllTestsDetails,dumpAll,&fwdSolveParamList,&adjSolveParamList,&fancy_oss
00184 );
00185 if(!result) success = false;
00186 if(verbose) {
00187 if(result) {
00188 if(showAllTests)
00189 out << std::endl << oss.str();
00190 else
00191 out << " : passed!\n";
00192 }
00193 else {
00194 if(showAllTests)
00195 out << std::endl << oss.str();
00196 else
00197 out << " : failed!\n";
00198 }
00199 }
00200 }
00201 }
00202
00203 }
00204 catch( const std::exception &excpt ) {
00205 std::cerr << "*** Caught standard exception : " << excpt.what() << std::endl;
00206 success = false;
00207 }
00208 catch( ... ) {
00209 std::cerr << "*** Caught an unknown exception\n";
00210 success = false;
00211 }
00212
00213 if (verbose) {
00214 if(success) out << "\nCongratulations! All of the tests checked out!\n";
00215 else out << "\nOh no! At least one of the tests failed!\n";
00216 }
00217
00218 return ( success ? 0 : 1 );
00219 }