44 #include "Teuchos_GlobalMPISession.hpp" 45 #include "Teuchos_CommandLineProcessor.hpp" 46 #include "Teuchos_ParameterList.hpp" 47 #include "az_aztec_defs.h" 51 std::string _matrixFile
55 ,
double _maxSolutionError
56 ,
double _maxSlackErrorFrac
59 ,
double _maxPrecSolutionError
60 ,
double _maxPrecSlackErrorFrac
85 int main(
int argc,
char* argv[])
88 Teuchos::GlobalMPISession mpiSession(&argc,&argv);
90 using Teuchos::CommandLineProcessor;
92 bool result, success =
true;
95 Teuchos::FancyOStream out(Teuchos::rcp(&std::cout,
false));
103 std::string matrixDir =
"";
104 int numRandomVectors = 1;
105 bool showAllTests =
false;
106 bool showAllTestsDetails =
false;
107 bool dumpAll =
false;
108 std::string aztecOutputLevel =
"freq";
109 int aztecOutputFreq = 0;
111 CommandLineProcessor clp(
false);
112 clp.setOption(
"matrix-dir", &matrixDir,
"Base directory for the test matrices" );
113 clp.setOption(
"num-random-vectors", &numRandomVectors,
"Number of times a test is performed with different random vectors." );
114 clp.setOption(
"verbose",
"quiet", &verbose,
"Set if output is printed or not." );
115 clp.setOption(
"show-all-tests",
"no-show-all-tests", &showAllTests,
"Set if all the tests are shown or not." );
116 clp.setOption(
"show-all-tests-details",
"no-show-all-tests-details", &showAllTestsDetails,
"Set if all the details of the tests are shown or not." );
117 clp.setOption(
"dump-all",
"no-dump-all", &dumpAll,
"Determines if vectors are printed or not." );
118 clp.setOption(
"aztec-output-level", &aztecOutputLevel,
"Aztec output level (freq,last,summary,warnings,all)" );
119 clp.setOption(
"aztec-output-freq", &aztecOutputFreq,
"Aztec output freqency (> 0)" );
120 CommandLineProcessor::EParseCommandLineReturn parse_return = clp.parse(argc,argv);
121 if( parse_return != CommandLineProcessor::PARSE_SUCCESSFUL )
return parse_return;
123 TEUCHOS_TEST_FOR_EXCEPT( matrixDir ==
"" );
129 const int numTestMatrices = 9;
135 const MTP testMatrices[numTestMatrices] =
137 MTP(
"bcsstk01.mtx" ,1e-12, 40 , 1e-4, 0.6, 1.0, 20 , 1e-10, 0.5, 1.0)
138 ,MTP(
"bcsstk02.mtx" ,1e-12, 40 , 1e-3, 0.5, 1.0, 2 , 1e-10, 0.5, 1.0)
139 ,MTP(
"bcsstk04.mtx" ,1e-12, 80 , 1e-4, 0.999990, 1.0, 40 , 1e-10, 0.999990, 1.0)
140 ,MTP(
"Diagonal.mtx" ,1e-12, 4 , 1e-6, 1e-14, 1.0, 2 , 1e-10, 1e-14, 1.0)
141 ,MTP(
"FourByFour.mtx" ,1e-12, 4 , 1e-6, 1e-14, 1.0, 2 , 1e-10, 1e-14, 1.0)
142 ,MTP(
"KheadK.mtx" ,1e-12, 8 , 1e-6, 1e-14, 1.0, 2 , 1e-10, 1e-14, 1.0)
143 ,MTP(
"KheadSorted.mtx" ,1e-12, 8 , 1e-6, 1e-14, 1.0, 2 , 1e-10, 1e-14, 1.0)
144 ,MTP(
"nos1.mtx" ,1e-11, 200, 1e-4, 0.6, 1.0, 237, 1e-2, 5.0, 1.0)
145 ,MTP(
"nos5.mtx" ,1e-12, 468, 1e-5, 0.5, 1.0, 468, 1e-10, 0.5, 1.0)
150 for(
int matrix_i = 0; matrix_i < numTestMatrices; ++matrix_i ) {
152 mtp = testMatrices[matrix_i];
156 for(
int prec_i = 0; prec_i < 2; ++prec_i ) {
158 out << std::endl<<matrix_i<<
":"<<prec_i<<
": Testing, matrixFile=\'"<<mtp.
matrixFile<<
"\', ";
161 double maxSolutionError;
162 double maxSlackErrorFrac;
163 Teuchos::ParameterList
164 paramList(
"AztecOOLinearOpWithSolveFactory");
165 Teuchos::ParameterList
166 &fwdSolvePL = paramList.sublist(
"Forward Solve"),
167 &adjSolvePL = paramList.sublist(
"Adjoint Solve");
168 Teuchos::ParameterList
169 &fwdAztecOOPL = fwdSolvePL.sublist(
"AztecOO"),
170 &adjAztecOOPL = adjSolvePL.sublist(
"AztecOO");
171 if( aztecOutputLevel !=
"freq" ) {
172 fwdAztecOOPL.set(
"Output Frequency",aztecOutputLevel);
173 adjAztecOOPL.set(
"Output Frequency",aztecOutputLevel);
176 fwdAztecOOPL.set(
"Output Frequency",aztecOutputFreq);
177 adjAztecOOPL.set(
"Output Frequency",aztecOutputFreq);
180 out <<
"no aztec preconditioning ... ";
181 fwdAztecOOPL.set(
"Aztec Preconditioner",
"none");
182 testTranspose =
true;
183 fwdSolvePL.set(
"Max Iterations",mtp.
maxIters);
184 adjSolvePL.set(
"Max Iterations",mtp.
maxIters);
190 out <<
"using aztec preconditioning ... ";
191 fwdAztecOOPL.set(
"Aztec Preconditioner",
"ilu");
192 testTranspose =
false;
199 std::ostringstream oss;
200 Teuchos::FancyOStream fancy_oss(Teuchos::rcp(&oss,
false));
203 matrixDir+
"/"+mtp.
matrixFile,testTranspose,numRandomVectors
205 ,showAllTestsDetails,dumpAll,¶mList,&fancy_oss
207 if(!result) success =
false;
211 out << std::endl << oss.str();
213 out <<
" : passed!\n";
217 out << std::endl << oss.str();
219 out <<
" : failed!\n";
226 catch(
const std::exception &excpt ) {
227 std::cerr <<
"*** Caught standard exception : " << excpt.what() << std::endl;
231 std::cerr <<
"*** Caught an unknown exception\n";
236 if(success) out <<
"\nCongratulations! All of the tests checked out!\n";
237 else out <<
"\nOh no! At least one of the tests failed!\n";
240 return ( success ? 0 : 1 );
int main(int argc, char *argv[])
double maxPrecSolutionError
bool test_single_aztecoo_thyra_solver(const std::string matrixFile, const bool testTranspose, const int numRandomVectors, const double maxFwdError, const double maxResid, const double maxSolutionError, const bool showAllTests, const bool dumpAll, Teuchos::ParameterList *paramList, Teuchos::FancyOStream *out)
Testing function for a single aztecoo solver with a single matrix.
double maxPrecSlackErrorFrac
MatrixTestPacket(std::string _matrixFile, double _maxFwdError, int _maxIters, double _maxResid, double _maxSolutionError, double _maxSlackErrorFrac, int _maxPrecIters, double _maxPrecResid, double _maxPrecSolutionError, double _maxPrecSlackErrorFrac)